""" scan the offset for each gain and save the data """

from struct import*
import ctypes
import array
import numpy as np
import matplotlib.pyplot as plt
import time

from ADUCv2p0 import*




chip1 = ADUCv2p0(0x50,True)

chip1.set_channel(3) #ADC

chip1.set_remote_trigg(1)

ADC = np.zeros((7,1000))



chip1.set_pga_state(0x18)
for g in range(1,8):
    chip1.set_pga_state(16*g+8)

    for k in range(0,1000):

        chip1.set_Vout(0,k*4)
        time.sleep(0.05)
        data = chip1.read_data()
        ADC[g-1,k] = np.mean(data)
        print(g,k,np.mean(data))
    
    plt.plot(ADC[g-1])

np.save("tmp",ADC)

plt.show()
