Commit 768724ee authored by Matthieu Cattin's avatar Matthieu Cattin

test19: add ploting feature for debug.

parent 391f4a18
......@@ -136,6 +136,40 @@ def volt2digital_without_offset(value, full_scale, nb_bit):
#print('volt2digital: %2.9f > %2.9f')%(value,digital)
return int(digital)
# Plot data from all channels
def plot_all(data, mean, ylimit):
sample = arange(len(data)/4)
clf()
plot(sample, data[0::4], 'b', label='Channel 1')
plot(sample, data[1::4], 'g', label='Channel 2')
plot(sample, data[2::4], 'c', label='Channel 3')
plot(sample, data[3::4], 'm', label='Channel 4')
plot(sample, [mean[0]]*len(sample), 'r')
plot(sample, [mean[1]]*len(sample), 'r')
plot(sample, [mean[2]]*len(sample), 'r')
plot(sample, [mean[3]]*len(sample), 'r')
ylim(-ylimit-(ylimit/10.0), ylimit+(ylimit/10.0))
grid(which='both')
legend()
draw()
show()
return 0
# Plot data from all channels
def plot_channel(ch, data, mean, ylimit):
print("nb of samples to plot: %d"%len(data))
sample = arange(len(data))
lbl = "Channel %d"%ch
clf()
plot(sample, data, 'b', label=lbl)
plot(sample, [mean]*len(sample), 'r')
ylim(-ylimit-(ylimit/10.0), ylimit+(ylimit/10.0))
grid(which='both')
legend()
draw()
show()
return 0
# Make an acquisition of a channel
def acq_channel(carrier, fmc, ch, adc_fs, adc_nbits=16, pause=0.01):
# Make sure no acquisition is running
......@@ -165,27 +199,10 @@ def acq_channel(carrier, fmc, ch, adc_fs, adc_nbits=16, pause=0.01):
carrier.set_irq_en_mask(0x0)
channels_data = [hex2signed(item) for item in channels_data]
channels_data = [digital2volt(item,adc_fs,adc_nbits) for item in channels_data]
#plot_all(channels_data, [mean(channels_data[0::4]),mean(channels_data[1::4]),mean(channels_data[2::4]),mean(channels_data[3::4])], 0.1)
#raw_input("press enter")
channel_data = channels_data[ch-1::4]
return mean(channel_data)
# Plot data from all channels
def plot_all(data, mean, ylimit):
sample = arange(len(data)/4)
clf()
plot(sample, data[0::4], 'b', label='Channel 1')
plot(sample, data[1::4], 'g', label='Channel 2')
plot(sample, data[2::4], 'c', label='Channel 3')
plot(sample, data[3::4], 'm', label='Channel 4')
plot(sample, [mean[0]]*len(sample), 'r')
plot(sample, [mean[1]]*len(sample), 'r')
plot(sample, [mean[2]]*len(sample), 'r')
plot(sample, [mean[3]]*len(sample), 'r')
ylim(-ylimit-(ylimit/10.0), ylimit+(ylimit/10.0))
grid(which='both')
legend()
draw()
show()
return 0
return channel_data
# Set channel offset with the DAC
def set_offset_dac(fmc, channel, offset_volt, dac_fs=10.0, dac_nbits=16, dac_corr_flag=False):
......@@ -228,7 +245,10 @@ def make_meas(carrier, fmc, box, dac_value, in_value, in_range, adc_fs, repeat):
# Perform an acquisition
meas = []
for i in range(repeat):
meas.append(acq_channel(carrier, fmc, ch, adc_fs))
data = acq_channel(carrier, fmc, ch, adc_fs)
#plot_channel(ch, data, mean(data), adc_fs)
#raw_input("press enter")
meas.append(mean(data))
# Calculate mean and delta of acquisitions
ch_meas.append(mean(meas))
ch_diff.append(max(meas)-min(meas))
......
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