ota.fast = 1
ota.gain = 8
ota.offset = 0
-#chain.write()
+chain.write()
mux.selA = 48
mux.selB = 48
ota.fast = 1
ota.gain = 8
ota.offset = 0
-#mux.write()
+mux.write()
# Secondary Chain1
ota.fast = 1
ota.gain = 8
ota.offset = 0
-arb.write()
+#arb.write()
amux.selA = 48
amux.selB = 48
ota.fast = 1
ota.gain = 8
ota.offset = 0
-amux.write()
+#amux.write()
+##############################################################################
+# ADC testing stuff
+#
+dac.vina(1.1)
+
+#go to idle mode
+adc.setRegister(adc.TRIGGER_SCR, 0)
+
+#no average, SPI convst
+#16x accurate average
+adc.setRegister(adc.ADC_SCR, 0b11100001)
+
+# dac.vina --> adc.ch4
+adc.setRegister(adc.CHAN_SEL, 4)
+
+#ch4 setup
+adc.setRegister(adc.CH45_CCR, 0b00000000)
+
+# go to mode 2 (full manual)
+adc.setRegister(adc.TRIGGER_SCR, 2)
+
+print adc.read()
+
+n = []
+r = []
+for i in range(2**16):
+ x = i
+ dac.set(0, x)
+ adc.read() #sham to trigger conversion
+ sleep(200e-6) #ensure 160us conversion time delay
+ n.append(x)
+ v = adc.read()
+ r.append(v)
+ print i
+
+figure()
+plot(n, r)
+xlabel('DAC code')
+ylabel('ADC count')
+title('DAC_ch0 --> ADC_ch4 direct connection')
+savefig('dac-adc-loopback.pdf')
+show()
+
+
##############################################################################
# drop into an IPython shell