1
0

scan.py 630 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. """ scan the offset for each gain and save the data """
  2. from struct import*
  3. import ctypes
  4. import array
  5. import numpy as np
  6. import matplotlib.pyplot as plt
  7. import time
  8. from ADUCv2p0 import*
  9. chip1 = ADUCv2p0(0x50,True)
  10. chip1.set_channel(3) #ADC
  11. chip1.set_remote_trigg(1)
  12. ADC = np.zeros((7,1000))
  13. chip1.set_pga_state(0x18)
  14. for g in range(1,8):
  15. chip1.set_pga_state(16*g+8)
  16. for k in range(0,1000):
  17. chip1.set_Vout(0,k*4)
  18. time.sleep(0.05)
  19. data = chip1.read_data()
  20. ADC[g-1,k] = np.mean(data)
  21. print(g,k,np.mean(data))
  22. plt.plot(ADC[g-1])
  23. np.save("tmp",ADC)
  24. plt.show()