Basic testing
After successful login to Red Pitaya's OS a set of simple programs was provided for testing of basic functionalities. By default all these programs were installed to /root/gwyhwserver_gwyscope
directory. Change to this directory and open e.g. test_spi.c
using e.g. nano
or vim
text editors.
The programs are written in plain C programming language and are quite self explanatory. The documentation of functions can be found on Gwyscope websites.
Analog inputs and outputs can be easily tested with the mentioned test_spi
utility. Important variables are listed here:
- hrdac1, hrdac2, hrdac3 - values that are to be set on the 20-bit DACs
- lrdac[i] - field with values for 16-bit DACs. Note that i variable goes from 0 to 15. Values stored in lrdac[0], lrdac[1],… correspond to AO1, AO2,… on the Gwyscope box.
- adc[] - field with values for 18-bit ADCs. Values stored in adc[0], adc[1],… correspond to AI1, AI2,… on the Gwyscope box.
- read_adc1, read_adc2 - boolean variables that control whether first or second 8-channel 18-bit ADC should be read. Value of 1 means yes, we should read it.
- muxA, muxB - setting of multiplexers, for instance muxA = 1 means that first analog input (adc[0] or AI1) is connected to first (fast) Red Pitaya's analog input; muxB = 4 connects adc[3] (or AI4) to RP's second input.
- adc1, adc2 - store values for Red Pitaya's (fast) analog inputs
Important functions are the following ones:
- librp_SetHRDAC1() - sets voltage on the first (most left) 20-bit DAC; Note that the SPI communication is implemented on the FPGA, so this is hardware specific and it won't work on PCB V4 and older; similar functions exist for the other two DACs
- librp_SetDAC() - sets voltage on Red Pitaya's fast analog outputs (RP FO1 & RP FO2 on Gwyscope box); note that LIBRP_CH_1 corresponds to the first output, LIBRP_CH_2 to the second
- librp_SPICycle() - SPI communication between CPU and other devices. Up to PCB V4 this is used for communication with all ADCs and DACs. Since version V5 the 20-bit DACs are controlled by dedicated functions, see above.
- librp_ReadADC() - reads voltages from RP's fast analog inputs.
If vim
was used for editing, note that i
has to be pressed to switch to insert mode. After the changes have been made, switch back to command mode by pressing Escape
and write changes to disk using :wq
. Now create new binary by calling make
and execute the updated program by ./test_spi
as shown below.
To test the functionality of the SPI communication, simply connect different DACs to ADCs and see, if the values match.