Analog board¶
Description¶
The AnalogManager
handles the acquisition of data from the photodiodes, SiPMs and thermistors. Data is acquired using AnalogManager::GetLightLevel()
member function. This function uses the AnalogManager::SerialReadOut()
to handle the analog inputs on a separate board that is directly connected to the CPU board. This function is called in a separate joinable thread via the AnalogManager by both OperationMode daughter classes when they are operating to update the measurements periodically. Functions like RunInstrument::PollLightLevel()
make use of the AnalogManager::ReadLightLevel()
to read out the current stored LightLevel in the AnalogManager object in a thread safe way. The AnalogManager::CompareLightLevel()
handles the comparison of the average photodiode reading with set thresholds in order to set the mode to day/night. These thresholds are stored in AnalogManager.h
as ``LIGHT_THRESHOLD``s and must be updated as the instrument calibration is carried out. The pinout of the analog board connected is described in the hardware interfaces section of the documentation.
Reading photodiodes/SiPMs¶
The analog channels are read out via a serial interface to the analog board. A stream of data is sent constantly, so the software looks for packets by identifying the header tag. The details of the packet structure are still under development but will be updated here once settled.
The analog channels are always read out, it is not necessary to add a flag to the main mecontrol
executable. If no sensors are connected, the values on all channels should be -5
. If sensors are connected, some positive value should be read out. The exact value and its units will depend on the eventual calibration and light level.
Connection of the photodiodes/SiPMs/Thermistors¶
Please refer to the hardware interfaces/analog_ports section for the connector pinout.
AnalogManager¶
-
class AnalogManager¶
class to handle the analog data acquisition (photodiodes, SiPMs, thermistors) uses a simple Arduino to replace the AnalogManager module due to issues with power comsumption.
Public Types
Public Functions
-
AnalogManager()¶
constructor
compare light level to threshold value LIGHT_THRESHOLD from configuration file @TODO check if more sophisticated tests needed in lab
get the current light level. preforms an analog acquisition using AnalogManager::AnalogDataCollect() and converts the output to the easily readable LightLevel format
-
int AnalogDataCollect()¶
analog board read out uses the Arduino to collect data on the analog ports, as defined in AnalogManager.h
-
int Notify()¶
notify the object of an instrument mode switch used by OperationMode::Notify
-
int Reset()¶
reset the mode switching after an instrument mode change used by OperationMode::Reset()
Private Functions
-
int SetInterfaceAttribs(int fd, int speed)¶
Set up interface attributes for the interface with the Arduino device.
-
int SerialReadOut(int fd)¶
Read serial output from a file descriptor. returns -1 if failed.
- Parameters:
fd – file descriptor
-
float ConvertToTemp(char data[9])¶
Convert the data to actual temperature because the result is a 16 bit signed integer, it should be stored to an “int16_t” type, which is always 16 bits even when compiled on a 32 bit processor.
-
AnalogManager()¶