• 0
Sign in to follow this  
hgriffin

record analog data from 2 devices simultaneously -- python

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
 

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this