Commit 217e1b7d authored by Matthieu Cattin's avatar Matthieu Cattin

Modifications for box v2. Only one channel is connected to AWG at a time. The…

Modifications for box v2. Only one channel is connected to AWG at a time. The others have Vref for the selected range.
parent 243cc399
......@@ -24,21 +24,41 @@ calibr_box: Access to calibration box via USB-UART bridge CP2103
class CCalibr_box:
def __init__(self, device):
self.cp210x = cp210x_gpio.CCP210x(device)
# Select AWG as default output
self.cp210x.gpio_set(0x0)
self.cp210x = cp210x_gpio.CCP210x(device)
# Select AWG as default output
self.cp210x.gpio_set(0x0)
def select_output(self, out):
if('10V' == out):
self.cp210x.gpio_set(0xF)
elif('1V' == out):
self.cp210x.gpio_set(0xD)
elif('100mV' == out):
self.cp210x.gpio_set(0xC)
elif('AWG' == out):
self.cp210x.gpio_set(0x0)
else:
raise Exception('Invalid output selection!')
if('10V' == out):
self.cp210x.gpio_set(0xF)
elif('1V' == out):
self.cp210x.gpio_set(0xD)
elif('100mV' == out):
self.cp210x.gpio_set(0xC)
elif('AWG' == out):
self.cp210x.gpio_set(0x0)
else:
raise Exception('Invalid output selection!')
# Select which channel is connected to AWG
# others are set to Vref for the selected range
# !! ONLY FOR BOX V2 !!
def select_output_ch(self, out, channel):
if channel >= 1 and channel <= 4:
value = ((channel-1)<<2)
else:
raise Exception('Invalid channel number, must be [1..4]!')
print hex(value)
if('10V' == out):
value += 0x3
elif('1V' == out):
value += 0x1
elif('100mV' == out):
value += 0x0
else:
raise Exception('Invalid output selection!')
print hex(value)
self.cp210x.gpio_set(value)
def get_config(self):
return self.cp210x.gpio_get()
return self.cp210x.gpio_get()
......@@ -100,12 +100,12 @@ def set_awg_freq(gen, sine, freq):
def main (default_directory = '.'):
# Load firmware to FPGA
load_firmware(default_directory)
#load_firmware(default_directory)
# Objects declaration
spec = rr.Gennum() # bind to the SPEC board
spec_fmc = spec_fmc_adc.CSpecFmcAdc100Ms(spec)
fmc = fmc_adc.CFmcAdc100Ms(spec)
#spec = rr.Gennum() # bind to the SPEC board
#spec_fmc = spec_fmc_adc.CSpecFmcAdc100Ms(spec)
#fmc = fmc_adc.CFmcAdc100Ms(spec)
usb_tty = find_usb_tty.CttyUSB()
awg_tty = usb_tty.find_usb_tty(AWG_USB_VENDOR_ID, AWG_USB_DEVICE_ID)
box_tty = usb_tty.find_usb_tty(BOX_USB_VENDOR_ID, BOX_USB_DEVICE_ID)
......@@ -114,15 +114,35 @@ def main (default_directory = '.'):
box = calibr_box.CCalibr_box(box_tty[0])
# Enable "DMA finished" IRQ
spec_fmc.set_irq_en_mask(0x1)
#spec_fmc.set_irq_en_mask(0x1)
# Initialise fmc adc
fmc_adc_init(spec, fmc)
#fmc_adc_init(spec, fmc)
# Disconnect all inputs
disconnect_channels(fmc)
#disconnect_channels(fmc)
# Calibration box version 2
for i in range(NB_CHANNELS):
box.select_output_ch('10V', i+1)
print "Channel %d = AWG, others = 10V Vref"%(i+1)
raw_input('Press ENTER to continue...')
for i in range(NB_CHANNELS):
box.select_output_ch('1V', i+1)
print "Channel %d = AWG, others = 1V Vref"%(i+1)
raw_input('Press ENTER to continue...')
for i in range(NB_CHANNELS):
box.select_output_ch('100mV', i+1)
print "Channel %d = AWG, others = 100mV Vref"%(i+1)
raw_input('Press ENTER to continue...')
sys.exit()
# Test calibration box ranges
# Calibration box version 1
print('\n=== 10V range ===')
box.select_output('10V')
print('Box gpio: %X')%box.get_config()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment