> For the complete documentation index, see [llms.txt](https://arpes-1-2.gitbook.io/arpes-1-2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://arpes-1-2.gitbook.io/arpes-1-2/manuals-arpes-1-2/starting-the-experiment/auto-beam-position-control.md).

# Auto beam position control

Automated procedure that steers the beam to the optimal position.

{% hint style="info" %}
The beam position monitoring device, it's electronics and software were all designed by Dr. Emile Rienks.
{% endhint %}

In our beamline the beam moves away from the optimal path when the photon energy is changed. To compensate for this effect one can move one of the SMU mirrors to bring the beam back.&#x20;

<mark style="background-color:red;">**Now there is an automated procedure that runs in the background and keeps the beam on the optimal trajectory!**</mark>

<mark style="background-color:red;">**As long as fully automatic procedure works, the rest of this page can be ignored!**</mark>

***

<details>

<summary><strong>Semi-automatic control (ONLY if automatic mode doesn't work!)</strong></summary>

To start it (for example after PC was rebooted) you will need to do the following:

1. Open powershell (or open a new tab in the existing one, e.g. the one used for beamline control).
2. Type in `ssh melmak2` and press enter to execute (this is to connect to the Raspberry Pi)
3. Execute `caMonitor vxi-11/psdutil/pvNames.txt` (to monitor mono status)
4. Open another tab in powershell and also execute `ssh melmak2`&#x20;
5. Execute `psdControl bruecke13,1,4 lcmAB` (this will start the main script that does the adjustment)
6. If you want to stop it, type in `q` and press Enter. The error message "Error opening /dev/ttyUSB0: No such file or directory" will appear, this is normal.

{% hint style="info" %}
Most probably all these commands have been executed recently, so after you ssh to melmak2 instead of typing you can simply press arrow up several times and you will find the correct commands.&#x20;

But please check that they are indeed the same!
{% endhint %}

</details>

<details>

<summary>General info about how it works + outdated information</summary>

There is a special device inside the beamline located at the position of one of the slits (the one monitored by a camera). The device has two plates that are illuminated by the beam and one can measure photocurrent from each of them, in the past this has been done by two Keithley ampermeters located on top of the rack of 1^3 beamline (see photo below). These two currents change monotonously as a function of beam position (one increases and another one decreases) and the optimal position is calibrated to be at the point where the currents are equal. To avoid electrons excited from one plate to reach the other one (which would lead to erroneous measurements) there is a bias voltage of 100 V applied between the plates.

The current signals from Keithleys are passed to a Raspberry Pi which (if current is large enough) will move the SMU M3 in decreasing steps until the currents are equal.

<figure><img src="https://1019940988-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4xyQ1EYH71vPc02yXQ%2Fuploads%2FYPFXX5xkKWvXSukX0cGL%2FKeithleys1-2.jpg?alt=media&amp;token=87b2cd18-c03b-48eb-9923-1699db2c18b0" alt="" width="303"><figcaption><p>The bottom Keithley is #1, the top one is #2, note the LED and "Vsource:+100.000"</p></figcaption></figure>

{% hint style="warning" %}
The procedure waits for the mono and undulator to reach their destinations before it starts any adjustments.
{% endhint %}

There are two beamline branches using the same technique, and at the moment (May 2025) users need to switch a pair of cables manually to change the controlled branch from 1-Squared to 1-Cubed. One pair of cables is labeled with roman numerals (I, II) and another with arabic (1, 2). **Arabic one is for 1-squared**, roman — for 1-cubed. They should go to corresponding Keithleys (currently 1 is on the left-bottom, 2 is on the left-top, but if the configuration has changed you can just swap 1<->I and 2<->II cables). Always switch both cables and make sure that the connected cables belong to the same pair.

<figure><img src="https://1019940988-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4xyQ1EYH71vPc02yXQ%2Fuploads%2FWavlLQoqMGMOzXtrPIQ4%2FCables_I_II.jpg?alt=media&amp;token=3cc7d441-eb24-42fb-a1f8-f2f3550066a9" alt="" width="303"><figcaption><p>Cables I and II are connected (for 1-cubed), the pair (1, 2) is lying on the rack </p></figcaption></figure>

## Troubleshooting

If the terminal was closed without quitting the beam control procedure correctly by `q` it could happen that the procedure will not do anything next time. In this case try to quit the procedure with `q`, then switch two Keithley devices off and on again, then start the procedure again.

If beam positioning script doesn't work, shows errors, doesn't close with `q` , kill it with ctrl-C and then reboot Keithleys and restart the procedure.

After restarting Keithleys you will need to press TRIG button on the Keithley #2 (on top) and then OPER button, it will activate bias voltage of 100V between the plates. LED should light up and there should be "Vsource:+100.000V" on the screen. If it shows zero, enter 100 manually using the arrows under "voltage source".

In the worst case, you can switch the script off and [correct the beam position manually](/arpes-1-2/manuals-arpes-1-2/starting-the-experiment/changing-light-parameters.md#adjusting-smu-for-different-photon-energies-now-its-done-automatically).

</details>
