COUNT = 2048 FREQ = 2000 #You must set up both DAC channels with the same settings, or the output will be #incorrect. However, the buffer values may be different. #set initial values for the buffers #the buffer values must be interleaved, a 2D buffer is teh best way to do this #The signals are dynamically updated square waves which will rise in Vmrs but #retain the same Vpp buf0 = np.zeros((COUNT), dtype=np.uint16) buf1 = np.zeros((COUNT), dtype=np.uint16) + 60000 buf = (np.column_stack((buf0,buf1))) buf_flatten = buf.flatten() devName = daq.GetDeviceList()[0] print "Connecting to %s\n\n" % devName handle = daq.Open(devName) if handle == -1: print "Cannot conncet to device\n" print "Exit" sys.exit(handle) #settings for channel 0 #Set for a static waveform daq.DacSetOutputMode(handle, daqh.DddtLocal, 0, daqh.DdomDynamicWave); #Immediate Trigger, (the final paramater is not yet used) daq.DacWaveSetTrig(handle, daqh.DddtLocal, 0, daqh.DdtsImmediate, 0) #Use the Local DAC clock daq.DacWaveSetClockSource(handle, daqh.DddtLocal, 0, daqh.DdcsDacClock) #Set the frequency
STOPSOURCE = DatsScanCount CHANCOUNT = 1 SCANS = 1000 RATE = 100 #Hz #used to configure scan buffer = np.zeros((SCANS * CHANCOUNT, ), dtype=np.uint16) #WORD buffer[SCANS*CHANCOUNT]; gains = [DgainDbd3kX1] #gains[0] = DgainDbd3kX1; #gain of X1 channels = [0] #channels[0] = 0; #select channel 0 flags = [DafBipolar] #flags[0] = DafBipolar; #select Bipolar mode # This is the default name for a DaqBoard3000 when configured through the # Control Panel Applet. If you have named your device differently than the default, # it must be changed here for this example to function. devName = daq.GetDeviceList()[0] #find 1st IOtech device print "Connected to %s\n\n" % devName handle = daq.Open(devName) if handle == -1: print "Cannot conncet to device\n" print "Exit" sys.exit(handle) print "Setting up scan...\n" daq.AdcSetAcq(handle, DaamNShot, 0, SCANS) #Scan settings daq.AdcSetScan(handle, channels, gains, flags) #set scan rate daq.AdcSetFreq(handle, RATE)
def __init__(self): self.devName = daq.GetDeviceList()[0] # Find 1st IOtech device