Magnet Control Software

From HaicuWiki
Revision as of 22:06, 5 November 2026 by Lmartin (talk | contribs) (Created page with "== Requirements == The ramps produced by the pi must be as regular as possible, and react to the trigger signal with minimal, reproducible, delay. While a delay of up to a few milliseconds can be compensated for, this is only true if the delay is at least predictable to within less than 100 microseconds. The pi should also be able to log readback values both during ramp and steady-state, but this must not impact the timing of the ramps. As a standard linux system, the r...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Requirements

The ramps produced by the pi must be as regular as possible, and react to the trigger signal with minimal, reproducible, delay. While a delay of up to a few milliseconds can be compensated for, this is only true if the delay is at least predictable to within less than 100 microseconds. The pi should also be able to log readback values both during ramp and steady-state, but this must not impact the timing of the ramps. As a standard linux system, the raspberry pi is not ideal for this task, first and foremost because background processes can occupy the CPU at any given time, delaying the execution of other operations. The raspberry pi was chosen anyway because of its ease of use and customization.

Approach

The main approach to achieving these requirements is multithreading. The pi4 has 4 CPU cores, so can run 4 independent threads in parallel without impacting each threads function. The magnet control frontend runs several threads itself, but most of those are not extremely time critical and can share a core with each other or the linux system itself.

In addition to the MIDAS frontend itself, the code is organized mostly into two classes:

GpioHandler

This object handles one TRIGGER pin, one READY pin, and one FINISHED pin. It can be attached to one or two #MagPs objects.

MagPs

This abstract class has two implementations: AeTech and Sgx. During construction it can be set up to operate in different modes, independently for control and for monitoring. Not all modes are available for both sub-classes. The modes are:

SCPI

Use the SCPI text interface (Sgx only).

ADDA

Use the WaveShare AD/DA board (not fully tested for control, only used for readback)

CAIO

Use the CAIO hat. (Would need hardware change to use for readback.)

Specifically for readback, it's possible to read back SCPI values, even if the general mode is set to ADDA.

  1. MIDAS frontend interface: communicates with MIDAS and does all the housekeeping and logging. It runs all the time, but can be preempted by operating system calls etc.
  2. ReadValues: regularly (e.g. every 100ms) reads power supply readback values and DCCT voltages into running buffers. It too runs all the time, non-exclusive.
  3. ArmedLoop: