Analog I/O configuration on B-Box 4

This page covers the configuration of the analog I/O channels located on the front-end of the B-Box 4. The B-Box 4 has 24 analog I/O channels, all of which can be configured as either an input or an output, depending on the user code running on the controller. The following text documents the various configuration options of analog channels in input mode, supplemented by information on the operating principles of the B-Box 4 analog front-end.

What constitutes an analog input channel from the user perspective, is actually a chain of hardware parts and fast software routines which produce the data that is available in the user’s control algorithm:

  • The hardware section of the chain consists of a sensor, external to the B-Box 4, connected to the analog I/O port. Inside of the B-Box 4 the input signal is captured by an analog-to-digital converter (ADC). The data are then forwarded through the FPGA to the hardware protection mechanism and for further processing.
  • In the software section, the FPGA finishes the processing of the data by downsampling it to the CPU clock rate, rescaling it into a meaningful quantity (by dividing with the sensitivity of the whole chain, from the sensor to the converted value) and transferring this data to the CPU memory in the shortest time possible.

Parts of this chain can be configured to fit the user’s setup:

  • In terms of hardware configuration, sensor calibration options for auto-detection-compatible imperix sensors and the hardware protection mechanism safety limits and reaction time can be configured either through Cockpit or directly through the front panel screen menus of the B-Box 4.
  • The software section is configured based on the settings declared by the user in their controller code. This includes setting the direction of analog channels (input vs output), as well as configuring different downsampling techniques, the cut-off frequency of the low-pass filter (if active) and rescaling factors.

How to configure analog front-end hardware

To access the analog I/O configuration of the B-Box 4 from Cockpit:

  1. Navigate over to the Cockpit Targets perspective by clicking on the corresponding button in the left bar
  2. From the left bar, choose your device and select the Analog I/Os tab in the central area
  3. Read/modify the configuration of a given channel by selecting it in the virtual representation of the B-Box 4 front panel or by finding it in the table at in the bottom half of the tab.

If an auto-detection-compatible sensor was detected, its sensitivity and offset can be edited through the menu accessible by clicking on the EDIT button in the sensor area of the analog channel diagram.

The same settings are accessible directly on the B-Box 4 front-end using its LCD screen and rotary-push button:

  1. Press the button, select the “Analog I/O” menu and enter it by pressing the button again
  2. Select the desired input channel and enter its menu
  3. Browse the available options, enter, rotate the button and enter again to confirm your changes

The hardware configuration options available on the B-Box 4 are:

  • If a compatible imperix sensor was detected:
    • Calibrated sensitivity [V/sensor unit] – compensates for the differences in real and nominal sensitivity
    • Calibrated offset [sensor unit] – compensates any slight offset that might be present in the channel
    • Use calibration data – toggles applying the above compensation
  • For the hardware protection mechanism:
    • Safety limit high – sets the limit in the range of [-10, +10]V
    • Safety limit low – sets the limit in the range of [-10, +10]V
    • Reaction time – sets the mechanism activation time to Ultra fast (\(0.8\mu s\)) or Fast and (\(1.6\mu s\))

How the analog front-end works

This section covers the principles of operation of the analog input/output channels of the B-Box 4.

Analog channel input mode

Configuring an analog channel as an input, done by assigning an ADC block to the corresponding channel number in the user code, activates a fast analog-to-digital converter (ADC) chip that feeds into several advanced, configurable mechanisms.

For a given control rate \(F_{\text{CPU}}\), each ADC acquires as many samples as possible such that \(k\cdot F_{\text{CPU}} \leq 20 MSps\), where \(k\in \mathbb{N}\) is called the oversampling ratio. The acquired samples are then fed into the:

  1. Hardware protection mechanism
  2. Downsampler for the user-configurable FPGA and the CPU
  3. Oversample datalogger

The data are processed in parallel on all three paths. With the hardware protection mechanism explained in more detail below, this subsection will focus on explaining how the acquired samples are made available to the user in the controller FPGA and CPU and how this process is configurable from the user code.

Analog input signals in the FPGA and CPU

The samples acquired by the ADC are forwarded to be downsampled to \(F_{\text{FPGA}}\). The relationship between \(F_{\text{FPGA}}\), \(F_{\text{CPU}}\), and the B-Box 4 CLOCK_0 is defined in the user code during the Control task configuration, through the Postscaler and Multiplier parameters.

The resulting \(F_{\text{FPGA}}\) and \(F_{\text{CPU}}\) after setting the CLOCK_0 frequency, Postscaler and Multiplier in the Simulink CONFIG block

Forming the analog input signal at the FPGA sampling frequency can be done in three ways, configurable for each analog input channel individually through the ADC block in the user code:

  1. Synchronous sampling (marked simply as “Downsampling” in the analog input channel diagram)
  2. Synchronous averaging (“Sync. average”)
  3. Low-pass filtering + down-sampling (“Low-pass filter”)

Synchronous sampling works by taking the first sample out of all of the data points captured by the ADC, within one period of CLOCK_0. This approach results in the smallest possible sampling delay but less robustness to noise and non-linearities.
Synchronous averaging, on the other hand, is a technique that takes all of the points captured within one or two periods of CLOCK_0 and averages them. This results in an improved signal-to-noise ratio at the cost of a slightly higher sampling delay.
In both cases, within one period of CLOCK_0, multiple, equidistant points can be taken based on the Multiplier. In addition to that, the clock signal can be shifted based on the Sampling phase, which is also set during the Control task configuration. A more detailed comparison between these procedures can be found in our article on Synchronous averaging.

Synchronous sampling (left) and Synchronous averaging over one period of SCLK (right) with SCLK=1 x CLOCK_0

If a more aggressive attenuation in the high-frequency range is required, B-Box 4 also offers the option to apply a digital low-pass filter on the data captured by the ADC and then apply synchronous sampling on the resulting, smoothed waveform. The chosen filter cut-off frequency introduces a non-negligible group delay, which should be accounted for in the control algorithm. For more information on the characteristics of the low-pass filter, please consult the B-Box 4 datasheet.

The resulting signal, formed at the sampling rate of \(F_{\text{FPGA}}\), is available in the user-programmable part of the B-Box 4 FPGA and can be used to configure fast control schemes unbounded by the CPU. To learn more about using the ADC signals available in the FPGA, check out Getting started with FPGA control development.

Finally, before being made available to the CPU, the analog input signal is rescaled and then downsampled again, according to the configured Multiplier and Postscaler factors.
The rescaling is done to transform the acquired signal, output by sensors in the [-10, +10]V range in order to be compatible with the analog input port of the B-Box 4, to meaningful physical quantities. To do this, its values are divided by the sensitivity and shifted back by the offset declared in the corresponding ADC block.

Oversampled signals

The Oversample datalogger saves the samples acquired by the ADC directly into the external RAM of the B-Box 4. The data are then made accessible in the Cockpit Scope Module through the Linux instance running on the controller’s supervisor CPU core. Unlike analog input signals in the CPU, oversampled signals are rescaled from the [-10, +10]V range on the PC side, in Cockpit.
This allows the user to visualize data points that would otherwise not have been visible at the control sample rate and analyze phenomena like ripple currents and aliasing effects.

Oversampled data overlayed with the corresponding CPU samples after sync. averaging

Analog channel output mode

To set an analog channel to output mode, add a DAC block with the corresponding channel number to the user code. This activates the operational amplifiers that drive the I/O pins of that port. The amplifiers are controlled by the DAC chip and the DAC is updated with new values by the CPU as soon as possible after the end of the CPU control task. All DACs latch their values synchronously with a delay of up to one control task period.

Hardware protection mechanism (safety limits)

The B-Box 4 offers over-value protection for each channel. The protection mechanism was made software-independent since it was implemented in a non-editable FPGA section of the controller. However, the mechanism is user-programmable through its safety limits and two reaction time presets. As mentioned in the first section of this article, these can be set either through Cockpit or through the B-Box 4 front panel screen.

Safety limit faults

Values acquired by the ADC that are higher than the designated HIGH threshold or lower than the LOW threshold of a given analog channel, trigger a safety limit fault. How quickly, depends on the reaction time setting, which can be:

  • Ultra fast, equating to 4 samples or a total delay of at most \(0.8\mu s\)
  • Fast, equating to 20 samples, or a total delay of at most \(1.6\mu s\)

Once a fault is declared:

  • Output of PWM signals is immediately blocked
  • The orange LED of the corresponding channel port lights up
  • The fault is forwarded through BBOS to Cockpit
Safety limit fault indicator in the Cockpit target view triggered by an over-value on channel 1

To unblock the PWMs and exit the fault state, the user must acknowledge the safety limit fault. This can be done either on the B-Box 4 front panel or though Cockpit. Acknowledging only works if the conditions that created the fault were removed.

When the hardware protection triggers, it is strongly recommended to use whatever information is at disposal to fully identify and understand why. Cockpit and the B-Box 4 front-panel provide information on which channel triggered the fault and whether the HIGH or LOW threshold was exceeded. This, along with whatever data was potentially acquired by Cockpit when the fault happened and the user’s knowledge of their setup should be a good starting point to understand whether it’s safe to readjust their safety limits or to alter their testing procedure (e.g. voltage and current references) so they stay within the safe operating area of their devices.

Sensor calibration

The newest generation of imperix sensors come with the capability to store information about themselves. This enables them to be identified automatically by the B-Box 4 at startup. The sensor information can be observed through Cockpit and the front panel screen of the B-Box 4. The communication with the sensor is performed through the 1-Wire protocol, via pin 3 on the RJ45 connector. The information itself is stored on an EEPROM chip on the sensor.

A part of the information saved on the sensor is user-configurable. To correct any small deviations between the real sensor sensitivity and the factory configured one, as well as any slight offset the sensor may introduce into its readings, the user can input their own calibrated sensitivity and offset.

How to calibrate imperix sensors

To configure sensor parameters from Cockpit, select the channel it is connected to in the Analog I/Os tab of the corresponding B-Box 4 and click on the EDIT button. In case a sensor was not found, or was added later, you can hit the REFRESH button to re-scan all of the analog inputs through 1-Wire.

Clicking on the EDIT button opens up a Sensor info configuration window. The input Calibrated sensitivity and Calibrated offset will be saved on the sensor’s EEPROM upon clicking write. The calibration will be applied as long as the “Use calibration data” option is checked. A similar procedure can be followed in the “Analog I/O” menu on the B-Box 4 front panel screen.

Sensor configuration in Cockpit comes with the additional capability to automatically detect the offset that needs to be compensated for. To perform the procedure correctly, follow these steps

  1. Connect your sensor to an analog channel and let it measure 0V or 0A
  2. Build a code with a probe connected directly to the ADC coressponding to sensor’s analog channel
  3. In Cockpit, link your project to your B-Box 4 and make sure that it’s connected with code running
  4. Click on ‘Detect’ in the Sensor configuration window of the corresponding analog channel
  5. After 2s, the procedure will be done and the Calibrated offset field will be auto-populated with the result
  6. If the result is according to expectations, hit ‘Write’ to save the offset compensation factor on your sensor

Overview of all front-end configuration options

The following table provides a complete overview of all front-end related configuration options, where they can be configured from and to which values:

Configuration
option
Configurable fromPossible valuesComment
Calibrated sensor sensitivityCockpit Analog I/Os tab and B-Box 4 front-panelReal values with precision of up to 6 decimal places Values interpreted in [V/sensor unit]
Calibrated sensor offsetCockpit Analog I/Os tab and B-Box 4 front-panelReal values with precision of up to 6 decimal places Values interpreted in [sensor unit]
Use sensor calibration dataCockpit Analog I/Os tab and B-Box 4 front-panelTrue, FalseOption only available for auto-detection-compatible imperix sensors.
Safety limit highCockpit Analog I/Os tab and B-Box 4 front-panel[-10, 10]V with 0.1V precisionAccuracy ± 1 % m.v. ± 10 mV
Safety limit lowCockpit Analog I/Os tab and B-Box 4 front-panel[-10, 10]V with 0.1V precisionAccuracy ± 1 % m.v. ± 10 mV
Protection mechanism
reaction time
Cockpit Analog I/Os tab and B-Box 4 front-panelUltra fast, FastMax delay \(0.8\mu s\) and \(1.6\mu s\), respectively
Analog channel directionThe ADC and DAC block in the user codeIn, Out
Analog input acquisition modeThe ADC block in the user codeSync. sampling,
Sync. averaging
Sync. averaging can be set to work over 1 and 2 periods of CLOCK_0
Analog input Low-pass filterThe ADC block in the user codeOff, 0.5kHz, 1kHz, 1.6kHz, 2.5kHz, 4kHz, 6.4kHz, 8kHz, 10kHz, 16kHz, 20kHz, 32kHz, 40kHzLow-pass filtering is always paired with Sync. sampling