Commit f8a810ba authored by Matthieu Cattin's avatar Matthieu Cattin

test09 working, test to be trimmed

parent 8c77befe
......@@ -42,8 +42,47 @@ NB_SHOTS = 1
DMA_LENGTH = 4096 # DMA length in bytes
FREQ_POINTS = [1E6, 10E6, 15E6, 16E6, 17E6, 18E6, 19E6, 20E6, 21E6, 22E6, 23E6, 24E6, 25E6, 30E6, 40E6, 60E6, 80E6]
# col 0: freq
# col 1: expected amplitude (ADC raw data)
# col 2: tolerance on the amplitude
points = [[1E6, 33300, 4000],
[10E6, 21000, 4000],
[15E6, 16500, 4000],
[16E6, 15700, 4000],
[17E6, 15000, 4000],
[18E6, 14500, 4000],
[19E6, 14000, 4000],
[20E6, 12500, 4000],
[21E6, 12500, 4000],
[22E6, 12500, 4000],
[23E6, 12000, 4000],
[24E6, 11500, 4000],
[25E6, 10000, 4000],
[30E6, 9000, 4000],
[40E6, 4500, 4000],
[60E6, 1000, 700],
[80E6, 400, 300]]
# The following table is used to test the test
"""
points = [[1E6, 36300, 1000],
[10E6, 24000, 1000],
[15E6, 19500, 1000],
[16E6, 18700, 1000],
[17E6, 18000, 1000],
[18E6, 17500, 1000],
[19E6, 17000, 1000],
[20E6, 15500, 1000],
[21E6, 15500, 1000],
[22E6, 15500, 1000],
[23E6, 15000, 1000],
[24E6, 14500, 1000],
[25E6, 14000, 2000],
[30E6, 12000, 1000],
[40E6, 7500, 1000],
[60E6, 4000, 500],
[80E6, 3400, 200]]
"""
def open_all_channels(fmc):
for i in range(1,NB_CHANNELS+1):
......@@ -131,48 +170,33 @@ def main (default_directory='.'):
fmc.set_shots(NB_SHOTS)
ch_diff = []
for j in range(len(FREQ_POINTS)):
set_awg_freq(gen, sine, FREQ_POINTS[j])
for j in range(len(points)):
set_awg_freq(gen, sine, points[j][0])
for i in range(1,NB_CHANNELS+1):
fmc.set_input_range(i, '1V')
time.sleep(SSR_SET_SLEEP)
channel = acquisition(gnum, pages, fmc, i)
ch_diff.append(max(channel)-min(channel))
diff = max(channel)-min(channel)
print('CH%d diff:%d')%(i, diff)
ch_diff.append(diff)
fmc.set_input_range(i, 'OPEN')
npoints = arange(0,len(ch_diff)/4,1)
loglog(FREQ_POINTS, ch_diff[0::4], 'b', FREQ_POINTS, ch_diff[1::4], 'g', FREQ_POINTS, ch_diff[2::4], 'r', FREQ_POINTS, ch_diff[3::4], 'c')
if((diff < points[j][1]-points[j][2]) | (diff > points[j][1]+points[j][2])):
print('Channel %d frequency response is out of range at freq:%2.3fMHz')%(i, points[j][0]/1E6)
print('Current amplitude:%d, expected:%d +/-%d')%(diff, points[j][1], points[j][2])
raise PtsError('Channel %d frequency response is out of range at freq:%2.3fMHz'%(i, points[j][0]/1E6))
pt = array(points)
freq = pt[:,0]
a_min = pt[:,1] - pt[:,2]
a_max = pt[:,1] + pt[:,2]
semilogx(freq, ch_diff[0::4], 'b', label='Channel 1')
semilogx(freq, ch_diff[1::4], 'g', label='Channel 2')
semilogx(freq, ch_diff[2::4], 'r', label='Channel 3')
semilogx(freq, ch_diff[3::4], 'c', label='Channel 4')
semilogx(freq, a_min, 'r:', label='Lower limit')
semilogx(freq, a_max, 'r:', label='Upper limit')
legend()
show()
raw_input('Press ENTER')
"""
# Start acquisition
fmc.stop_acq()
print('Acquisition FSM state : %s') % fmc.get_acq_fsm_state()
fmc.start_acq()
# Wait end of acquisition
while('IDLE' != fmc.get_acq_fsm_state()):
print fmc.get_acq_fsm_state()
time.sleep(1)
# Retrieve data trough DMA
gnum.add_dma_item(0*DMA_LENGTH, pages[1]+0*DMA_LENGTH, DMA_LENGTH, 0, 0)
gnum.start_dma()
gnum.wait_irq()
page1_data = gnum.get_memory_page(1)
channels = []
for i in range(len(page1_data)):
channels.append(page1_data[i] & 0xFFFF)
channels.append(page1_data[i]>>16)
channel = [[],[],[],[]]
for i in range(NB_CHANNELS):
channel[i] = (channels[i::4])
print('ch%d min:%d max:%d diff:%d')%(i+1, min(channel[i]), max(channel[i]), max(channel[i])-min(channel[i]))
"""
#for i in range(40):
# print("channels:%.4X ch1:%.4X ch2:%.4X ch3:%.4X ch4:%.4X") % (channels[i], channel[0][i/4], channel[1][i/4], channel[2][i/4], channel[3][i/4])
# Make sure all switches are OFF
open_all_channels(fmc)
......
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