Firmware  0.5.1
Loading...
Searching...
No Matches
Analog

This module takes over all analog functions of the firmware. This includes measuring track voltage and current, measuring temperature, and monitoring all of those measurements.

Initialization

Initialization takes place in init(). This function performs the following operations:

  • Creates queues for raw voltage and current vales as well as temperatures in Si units
  • Initializes the ADC in continuous mode and applies a curve fitting calibration
  • Initializes the internal temperature sensor
  • Creates an ADC and temperature task

ADC task

Once started, the ADC task runs continuously. It measures voltages and currents at a frequency of 8kHz. A total of 160 samples are recorded within one conversion frame meaning one frame lasts exactly 20ms. All measurements are written to the corresponding voltages or currents queue.

If the measured currents indicate a short circuit, the bug LED is switched on, state is set to short circuit and a ROCO track short circuit message is broadcast.

Suspend/resume ADC task

Since the ADC task holds a mutex on the continuous mode driver, the only way to stop and start the ADC is to send a task notification. This is done using adc_task_notify_suspend() or adc_task_notify_resume(). The conversion frame then starts again from the beginning and this method can be used to synchronize the ADC.

Temperature task

Once started, the temperature task runs continuously. The internal temperature sensor is read once per second and the result is converted into degrees Celsius. The result is written to the corresponding queue.

Conversions

The convert.hpp header provides some conversion functions to convert between raw ADC values ​​and Si units. The following functions are defined:

Previous Next
Drivers LED