ADC – Analog data acquisition
Table of Contents
The ADC block is used to retrieve the measurements from an analog input of the B-Box or B-Board.
This help documentation deals with the software part of the analog data acquisition. To set-up the hardware part, please refer to the following documents:
- Analog front-end configuration on B-Box RCP (PN105)
- B-Box RCP datasheet (PDF)
- B-Board PRO datasheet (PDF)
Simulink block
Signal specification
- The output signal returns a single-precision floating-point value representing the measured quantity in its physical unit (e.g. Volts, Amperes). When
use ADC history
is selected, it returns a vector of the N last values, as documented in Oversampling (PN154). - The
sim
input signal is used in simulation and documented in Simulation essentials with Simulink (PN135). - The
>
input signal needs to be connected to the CONFIG block in order to account for the exact sampling instant in simulation.

Standard parameters
Device ID
selects which B-Box/B-Board to address when used in a multi-device configuration.Input channel
selects which physical input channel to read from (e.g. 0 to 15 on B-Box RCP).Quick configuration
loads the parameters of an imperix sensor.Sensor sensitivity
is the sensor sensitivity in Volts per measured unit (e.g. V/V for a voltage sensor and V/A for a current sensor).Sensor output offset
compensates for the sensor offset. It is expressed in Volts at the output of the sensor.Programmable gain value
must match the configuration set on the frontpanel of the B-Box.Match B-Board input full-scale
must be checked if the device is a B-Board PRO. It forces the programmable analog gain to x2, to account for the +/- 5V input full-scale of the B-Board PRO (as opposed to +/- 10V on the B-Box RCP).
Advanced parameters
Use ADC history
enables the possibility the retrieve the N last sampled values.History depth (samples)
is the number N of values to retrieve.


PLECS block
Signal specification
- The output signal returns a single-precision floating-point value representing the measured quantity in its physical unit (e.g. Volts, Amperes). When
ADC history
is enabled, it returns a vector of the N last values, as documented in Oversampling (PN154). - The target inport (only visible at the atomic subsystem level) is used in simulation and documented in Simulation essentials with PLECS (PN137).
- The
>
input signal needs to be connected to the CONFIG block to account for the exact sampling instant in simulation.

Standard parameters
Device ID
selects which B-Box/B-Board to address when used in a multi-device configuration.Input channel
(vectorizable) selects which physical input channel to read from (e.g. 0 to 15 on B-Box RCP).Use/load sensor parameters
loads the parameters of an imperix sensor.Sensor sensitivity
(vectorizable) is the sensor sensitivity in Volts per measured unit (e.g. V/V for a voltage sensor and V/A for a current sensor).Sensor output offset
(vectorizable) compensates for the sensor offset. It is expressed in Volts at the output of the sensor.Programmable gain value
must match the configuration set on the frontpanel of the B-Box RCP. If the device is a B-Board PRO, it must be set to x2, to account for the +/- 5V input full-scale of the B-Board PRO (as opposed to +/- 10V on the B-Box RCP).
Advanced parameters
Use ADC history
enables the possibility the retrieve the N last sampled values.History depth (samples)
is the number N of values to retrieve.


C++ functions
ConfigureMainInterrupt
function as explained in the related note: Interrupt configuration.Standard functions
Advanced functions for oversampling
These functions are used to perform oversampling, read Oversampling (PN154) to learn more.
Example of use
sensors.h
This example considers the current sensor of a PEB8024 module. Its sensitivity is \(S=50.0\,[\text{mV/A}]\). As recommended in the datasheet, the chosen front-end gain is selected as \(G= 2\). Considering that the ADC offers 16 bits over the ±10V input range, this results in a total sensitivity \(\alpha = S\cdot G\cdot 32768/10=327.68\,[\text{bit/A}]\).
In this example, gain
must therefore be equal to \(\mathtt{gain}=1/\alpha=3.052\,[\text{mA/bit}]\). The offset
value can be adjusted empirically to cancel the measured value when no current is flowing through the sensor (static offset).
#define ADCONV (32768.0/10.0) // +/- 10V input range, 16-bit ADC
#define SENSITIVITY (0.05*2*ADCONV) // total sensitivity
#define I_GAIN (1.0/SENSITIVITY )
float I_meas = 0;
tUserSafe UserInit(void)
{
Adc_ConfigureInput(0, I_GAIN, 0.0);
return SAFE;
}
tUserSafe UserInterrupt(void)
{
I_meas = Adc_GetValue(0);
return SAFE;
}
Code language: C++ (cpp)