Stimulator Thermometer Agent

This is an OCS agent to acquire temperature data of the stimulator.

usage: agent.py [-h] --paths-spinode [PATHS_SPINODE ...]

Agent Options

--paths-spinode

Path to the spi nodes.

Configuration File Examples

Below are useful configurations examples for the relevant OCS files and for running the agent.

OCS Site Config

To configure the stimulator thermometer agent we need to add a StimThermometerAgent block to our ocs configuration file. Here is an example configuration block using all of the available arguments:

{'agent-class': 'StimThermometerAgent',
 'instance-id': 'stim_thermo',
 'arguments': [['--paths-spinode', [
   '/sys/bus/spi/devices/spi3.0/',
   '/sys/bus/spi/devices/spi3.1/',
   '/sys/bus/spi/devices/spi3.2/',
   '/sys/bus/spi/devices/spi3.3/']]]}

Description

The stimulator utilizes the MAX31856 and MAX31865 devices to read thermocouple and PT1000 sensors, respectively. These devices are connected to the KR260 board within the stimulator readout box via a Raspberry Pi-compatible pin header using a 4-wire SPI configuration. The programmable logic (PL) of the KR260 is configured with an AXI SPI IP core to facilitate SPI communication between the CPU and these devices.

The operating system on the KR260 CPU recognizes these devices through a device tree overlay, as shown below:

&axi_quad_spi{
 temperature-sensor@0 {
     compatible = "maxim,max31856";
     spi-max-frequency = <5000000>;
     reg = <0x0>;
     spi-cpha;
     thermocouple-type = <0x05>;
   };
};

The compatible property is set to the corresponding device to load the appropriate driver. After applying the device tree overlay, the devices can be accessed via the Industrial I/O (IIO) subsystem. Temperature readings can then be obtained by accessing the corresponding files, such as: /sys/bus/iio/devices/iio:device2/in_temp_raw.

The agent reads these files and publishes the acquired data to the feed.

Agent API

class socs.agents.stimulator_thermometer.agent.StimThermometerAgent(agent, paths_spinode)[source]

OCS agent class for stimulator thermometer.

Parameters:

paths_spinode (list of str or pathlib.Path) – List of path to SPI nodes of temperature devices.

acq()[source]

Process - Fetch temperatures from the thermometer readers.

Parameters:

sampling_frequency (float, optional) – Sampling frequency in Hz, default to 1 Hz.

Notes

An example of the session data:

>>> response.session['data']

{"Channel_0": {"T":15.092116135817285},
 "Channel_1": {"T":15.092116135817285},
 "Channel_2": {"T":15.40625,"T_cj":16.796875},
 "Channel_3": {"T":15.4921875,"T_cj":16.453125}},
 ...
 "timestamp": 1738827824.2523127
}

Supporting APIs

class socs.agents.stimulator_thermometer.drivers.StimThermoError[source]

Exception raised by stimulator thermometer.

class socs.agents.stimulator_thermometer.drivers.Iio(path)[source]

Generic IIO driver.

Parameters:

path (str or pathlib.Path) – Path to the iio device directory.

read(name)[source]

Read the file in the iio directory.

Parameters:

name (str) – File name in IIO directory.

Returns:

data – Contents of the file.

Return type:

str

property name

Read name of the iio device.

Returns:

name – Name of the device.

Return type:

str

class socs.agents.stimulator_thermometer.drivers.Max31856(path)[source]

Class to read MAX31856 via IIO interface.

Parameters:

path (str or pathlib.Path) – Path to the iio device directory.

property thermocouple_type

Get thermocouple type.

Returns:

type – Thermocouple type in string.

Return type:

str

get_temp_raw()[source]

Get raw temperature.

Returns:

temp_raw – Raw temperature.

Return type:

int

get_temp()[source]

Get temperature in degrees Celsius.

Returns:

temp – Temperature in degrees Celsius.

Return type:

float

get_temp_ambient_raw()[source]

Get raw ambient temperature.

Returns:

temp_ambient_raw – Raw ambient temperature.

Return type:

int

get_temp_ambient()[source]

Get ambient temperature in degrees Celsius.

Returns:

temp_ambient – Ambient temperature in degrees Celsius.

Return type:

float

class socs.agents.stimulator_thermometer.drivers.Max31865(path)[source]

Class to read MAX31865 via IIO interface.

Parameters:

path (str or pathlib.Path) – Path to the iio device directory.

get_temp_raw()[source]

Get raw temperature.

Returns:

temp_raw – Raw temperature.

Return type:

int

get_temp()[source]

Get temperature in degrees Celsius.

Returns:

temp – Temperature in degrees Celsius.

Return type:

float