Calibration
Description of the ADALM2000 calibration API in libm2k.
Standard calibration
Danger
Always disconnect analog inputs/outputs before calibration.
The libm2k API offers three methods for calibrating the board:
calibrateADC(): calibrate ADC
calibrateDAC(): calibrate DAC
isCalibrated(): true if at least one calibration procedure was performed on the current session (firmware version < v0.26) or on the board since was plugged in (firmware version >= v0.26). The function’s output does not imply that the last calibration is still valid.
Python example:
import libm2k
ctx = libm2k.m2kOpen()
if ctx is None:
print("Connection Error: No ADALM2000 device available/connected to your PC.")
exit(1)
ctx.calibrateADC()
ctx.calibrateDAC()
# signal processing
libm2k.contextClose(ctx)
Temperature calibration
Important
Only available from firmware version v0.26.
Libm2k offers a way to use prerecorded calibration values that are stored in a context attribute. Using this approach, there is no need to disconnect the analog inputs/outputs at every run because the calibration parameters are stored on the device. Since calibration values are dependent on temperature, a script will record the values at different temperatures and eventually create a file that is compatible with libm2k and the context attribute format.
Generating the file
The calibration values are written to the context attribute from a file on the ADALM2000 partition. The values will be stored on the device until they are overwritten.
Important
There is a known limitation: The maximum temperature file size is 4 kb. This will change in a future release.
This file must be called ‘m2k-calib-temp-lut.ini’ and it should contain only a row having the following format:
cal,temp_lut=[<temperature>,<adc_offset1>,<adc_offset2>,<adc_gain1> <adc_gain2>, <dac_offset1>,<dac_offset2>,<dac_gain1>,<dac_gain2> [...]]
Example of file:
cal,temp_lut=49.0,3038,2056,0.769531,1.07428,474,2026,0.597656,0.68335,49.2,3038,2056,0.769531,1.07428,474,2026,0.597656,0.68335,49.4,3038,2057,0.769531,1.073547,474,2024,0.597656,0.683777,49.6,3038,2057,0.769531,1.073547,474,2024,0.597656,0.683777
Caution
The values differ from board to board.
The file can be generated by using the following script. For better result, please consider exposing ADALM2000 to wider temperature variations, while the file is generated - will generate calibration values for more diverse points.
synopsis
generate_temperature_calib_lut <uri>
[-h | --help]
[-t | --temperature max_temp]
[-T | --timeout min]
[-v | --values nb_values]
[-f | --file path]
[-a | --append]
description
Generate the temperature calibration lookup table.
temperature The maximum temperature to stop at (default 75 °C).
timeout The number of minutes after timeout will occur (default 30 minutes).
values The maximum number of values to extract at the end.
file The path to the generated file (default ‘m2k-calib-temp-lut.ini’).
append Append the new computed values to the existent file.
examples
Create the ini file ‘m2k-calib-temp-lut.ini’. The process can be stopped by pressing ‘CTRL + C’, otherwise the process will stop when the temperature of the board rises up to 75 °C or after 30 minutes
~$
python3 generate_temperature_calib_lut.py ip:192.168.2.1
Create the ini file ‘example.ini’. The process can be stopped by pressing ‘CTRL + C’, otherwise the process will stop when the temperature of the board rises up to 54 °C or after 15 minutes. Extract 5 values from all computed calibration parameters. If the file is already created, the new computed values will be appended.
~$
python3 generate_temperature_calib_lut.py auto -v 5 -t 54 -T 15 -f "example.ini" -a
Calibrating using the ini file
The purpose of this calibration type is to automate and to make the calibration process faster. Please make sure to have the following minimum requirements:
A valid calibration file. The file can be generated using the script mentioned above.
Firmware v0.26 on your board
libm2k v0.3.1
After the board booted, copy the ini file inside the m2k drive. Then eject the drive (do not unplug!) and wait for ADALM2000 to boot. Once booted, the temperature calibration lookup table will be usable from libm2k.
If you are using the -f or –file option you should rename the file to ‘m2k-calib-temp-lut.ini’ before copying it to the device.
In order to perform a fast calibration call the fallowing context method: calibrateFromContext(). The method hasContextCalibration() will validate if the temperature calibration can be performed on the current board. There are some reasons why the calibration can be performed:
the values are not loaded onto the device
the values are incorrect (not numerical values)
some values are missing
Python example:
import libm2k
ctx = libm2k.m2kOpen()
if ctx is None:
print("Connection Error: No ADALM2000 device available/connected to your PC.")
exit(1)
if ctx.hasContextCalibration():
ctx.calibrateFromContext()
else:
ctx.calibrateADC()
ctx.calibrateDAC()
# signal processing
libm2k.contextClose(ctx)