Jump to content
  • 0

record analog data from 2 devices simultaneously -- python


hgriffin

Question

Hello,

I have a python script to output a signal while recording from both input channels at the same time.

I want to incorporate using a second analog discovery for two additional channels of data acquisition.

From the device_enumerate.py, I see that both devices can be recognized in the same script, but how do I actually specify which device to record the data from?

For example, here are some current (relevant) code snippets where I acquire data from both channels of one device. How would I specify the second device channels.
 

...
	"Opening first device..."
    dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))

    if hdwf.value == hdwfNone.value:
        print "failed to open device"
        quit()
...

	#set up acquisition
    dwf.FDwfAnalogInFrequencySet(hdwf, c_double(20000000.0))
    dwf.FDwfAnalogInBufferSizeSet(hdwf, c_int(4096))
    dwf.FDwfAnalogInChannelEnableSet(hdwf, c_int(0), c_bool(True))
    dwf.FDwfAnalogInChannelRangeSet(hdwf, c_int(0), c_double(10))
    dwf.FDwfAnalogInChannelEnableSet(hdwf, c_int(1), c_bool(True))
    dwf.FDwfAnalogInChannelRangeSet(hdwf, c_int(1), c_double(10))
...

dwf.FDwfAnalogOutConfigure(hdwf, channel1, c_bool(True)) # starts the waveform
    while True:
        dwf.FDwfAnalogInStatus(hdwf, c_int(1), byref(sts))
        if sts.value == DwfStateDone.value :
            break
        time.sleep(0.001)
 
    time.sleep(0.1)
    while (j < pulses + 1):
        try:
            print j
 
            dwf.FDwfAnalogOutConfigure(hdwf, channel1, c_bool(True)) # starts the waveform
 
            #begin acquisition
 
            while True:
                dwf.FDwfAnalogInStatus(hdwf, c_int(1), byref(sts))
                if sts.value == DwfStateDone.value :
                    break
                time.sleep(0.001)
 
            time.sleep(0.1)
            print "Acquisition finished"
 
            dwf.FDwfAnalogInStatusData(hdwf, 0, rgdSamples1, 4096) # get channel 1 data
            dwf.FDwfAnalogInStatusData(hdwf, 1, rgdSamples2, 4096) # get channel 2 data


Any help or example code would be greatly appreciated!

Cheers!
Harry
 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Hi @hgriffin

To synchronize the devices you could use the trigger IOs.

AnalogOutIn_Synchronization.py

In this example the first device generates the signal and outputs on T1 the analog-out (AWG1) state. The Scope (analog-in) of all devices trigger on T1, so connect T1 of all device together.
Here the first listed device is used to generate the signal and drive the trigger, but you can identify the device based on SN or by name, after renaming it.
You can also start the AWG1 of each device and use T2 as trigger output, and the W1 actually connected will drive your circuit and the T2 will drive the T1 or all devices.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...