ADC loopback testing
authorDan White <dan@whiteaudio.com>
Mon, 7 May 2012 18:34:49 +0000 (13:34 -0500)
committerDan White <dan@whiteaudio.com>
Mon, 7 May 2012 18:34:49 +0000 (13:34 -0500)
python-lib/mpsse-test.py

index 308eecd141687e3a09cb0905d786c48547bada4c..fd78f9b7a74669c523b3718a16d51af13e5772c4 100755 (executable)
@@ -144,7 +144,7 @@ for h in chain.h:
         ota.fast = 1
         ota.gain = 8
         ota.offset = 0
-#chain.write()
+chain.write()
 
 mux.selA = 48
 mux.selB = 48
@@ -153,7 +153,7 @@ for ota in mux.ota:
     ota.fast = 1
     ota.gain = 8
     ota.offset = 0
-#mux.write()
+mux.write()
 
 
 # Secondary Chain1
@@ -166,7 +166,7 @@ for h in arb.h:
         ota.fast = 1
         ota.gain = 8
         ota.offset = 0
-arb.write()
+#arb.write()
 
 amux.selA = 48
 amux.selB = 48
@@ -175,7 +175,7 @@ for ota in amux.ota:
     ota.fast = 1
     ota.gain = 8
     ota.offset = 0
-amux.write()
+#amux.write()
 
 
 
@@ -188,6 +188,50 @@ dac.vinb(0.9)
 
 
 
+##############################################################################
+# 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