Front-end calibration

There was a small DC offset (~4-5mV) in the Red Pitaya analog front-end inputs. According to the User Guide it should be possible to compensate the offset by adjusting some EEPROM registers.

http://wiki.redpitaya.com/index.php?title=User_Manual#Calibration

The User Guide also shows a simple shell script that measures the offset from the captured input samples. If we denote the input samples with xn and capture N samples then the average value y is:

equation2

Then we just need to program -y to the EEPROM register that compensates the offset. The EEPROM is accessed with a RP command line tool called calib. To use the tool we must first login to RP e.g. using the console connection or SSH. As I have a Linux Mint box available I’ll just use the builtin ssh command to login to RP (using the IP address obtained earlier). The default password for the ‘root’ user is ‘root’.

calib-01

The calibration shell script for channel 1 is shown below:


#!/bin/sh

N=1000

echo "- acquiring ${N} ADC samples"

# Offset is the negative mean of ADC samples
OFFSET=`acquire ${N} | awk '{print $1}' |
awk '{ total += $NF } END { printf("%0.f\n", -total/NR) }'`

echo "- updating EEPROM with the new calibration value"

calib -r | awk -v offset=${OFFSET} '{$5=offset}1' | calib -w

The acquire command captures N=1000 samples from the A/D converter and passes the sample values to a small AWK script that calculates the average from the captured values. Finally the negative average is passed to the calib command for writing to the EEPROM. Nice.

Let’s copy the script to RP and let’s run it.

redpitaya> ./calib1.sh
- acquiring 1000 ADC samples
- updating EEPROM with the new calibration value
redpitaya>

And let’s check the oscilloscope display again.

RedPitaya-11

Looks like I have eliminated the DC offset from channel 1. For channel 2 the script just needs a couple of small changes: 1) capture samples  from channel 2,  2) write the correction value to channel 2 register. Here is the updated script calib2.sh:

#!/bin/sh

N=1000

echo "- acquiring ${N} ADC samples from channel 2"

# Offset is the negative mean of ADC samples
OFFSET=`acquire ${N} | awk '{print $2}' |
awk '{ total += $NF } END { printf("%0.f\n", -total/NR) }'`

echo "- updating EEPROM with the new calibration value"

calib -r | awk -v offset=${OFFSET} '{$6=offset}1' | calib -w

Let’s run the script and check the result (I have to restart the oscilloscope to see the change).

RedPitaya-12

Front-end calibration done!

RedPitaya-13