In this part we will explain the format of the received data (SPA>PC), and how to decode it.
The returned packet of data from the SPA100 is always a 16 byte packet and also contains a checksum. This data is transmitted at either 2Hz or 10Hz (dependent on the sample rate of the SPA100).
Data is formatted like this:
Data returned:
2 bytes – STATUS (only 2 bits used, 14 bits reserved for future use)
2 bytes – USB voltage (12 bits) / Calibration Data (16 bits)
3 bytes – 1x 24bit current value of ADC’s
8 bytes – reserved for future use
1 byte – Checksum
Total of 16 bytes
Byte | Function |
0 | Device Status (MSB) |
1 | Device Status (LSB) |
2 | USB voltage (MSB) / Calibration Data (MSB) |
3 | USB voltage (LSB) / Calibration Data (LSB) |
4 | Reserved for future use |
5 | Reserved for future use |
6 | ADC raw current (MSB, b23-b16) |
7 | ADC raw current (CSB, b15-b8) |
8 | ADC raw current (LSB, b7-b0) |
9 | Reserved for future use |
10 | Reserved for future use |
11 | Reserved for future use |
12 | Reserved for future use |
13 | Reserved for future use |
14 | Reserved for future use |
15 | Checksum |
Checksum calculation
Add the values of bytes 0 to 14 together, apply an 8 bit mask ($00FF) and compare with the value of byte 15.
Device Status word
bits 0 to 11=unused
bit 12=USB/CAL status (0=USB voltage, 1=calibration DATA)
bit 13=CAL data start packet marker (0=no marker, 1=initial byte)
bits 14,15=unused
USB voltage is not implemented on the SPA100, and ADC raw current is a signed value.
Calibration data is sent as a sequence of two bytes (word) when bit 12=1, when bit12=0 the data will be the USB voltage (not implemented in the SPA100).
Word 0 is identified when bit12=1 and bit13=1, each subsequent packet (when b12=1) from the SPA100 contains the next word of calibration data.
Calibration Data word
Word 0= DAC value at +40V source output
Word 1= DAC value at -40V source output
Word 2,3= unused
Word 4,5= Range 1+ ADC raw value (32 bit signed [long]), known as “adcpos”
Word 6,7= Range 1- ADC raw value (32 bit signed [long]), known as “adcneg”
Word 8-11= Range 1+ Calibration current value (64 bit float [double]), known as “ipos”
Word 12-15= Range 1- Calibration current value (64 bit float [double]), known as “ineg”
….
Word 88,89= Range 8+ ADC raw value (32 bit signed [long]), known as “adcpos”
Word 90,91= Range 8- ADC raw value (32 bit signed [long]), known as “adcneg”
Word 92-95= Range 8+ Calibration current value (64 bit float [double]), known as “ipos”
Word 96-99= Range 8- Calibration current value (64 bit float [double]), known as “ineg”
Scale and Offset for each range is calculated in EPIC using the ADC raw value and calibration values contained in this calibration data:
Scale= (ipos – ineg) / (adcpos – adcneg)
Offset= ineg – (adcneg * Scale)
So to calculate the actual current (for a given range):
Current= (ADCraw* Scale) + Offset
EPIC will slowly (depending on sample rate of SPA100) load this calibration data in the background, when it has double checked this data (essentially it downloads it twice), it will compare it with the contents of “SPA_cal.txt”, if there is a discrepancy it will overwrite SPA_cal.txt. This typically occurs once after a calibration or an SPA100 is connected to a fresh or different install of EPIC. This typically takes 5-10 minutes.
EPIC carries out further processing/filtering of the SPA100 data (such as applying a rolling average and/or temporary nulling).
In part #3 we will discuss the Source (DAC), how it’s calibrated and the output circuitry.