Jump to content
  • 0

Externally Triggering both Analog In and Analog Out signals


LiamP

Question

Hello,

I am using multiple Analog Discovery 2s (AD2) for data acquisition in an experiment. For repeatability, I am using an external triggering source, positive edge, to generate both AWG signals and to acquire data from the AD2 oscilloscopes. I am able to create the exact specification I need in the WaveForms GUI for the AWG and the Oscilloscope data acquisition, but am at a loss for trying to replicate this in a control program written in python, even after reviewing the .py exames in the WaveForms SDK like Device_Synchronization.py and AnalogOutIn_Synchornization.py. Is there an example for external triggering in the reference folder I am missing or am I going about using the wrong functions to trigger successfully?

Below is a sample of the commands I am using to try and set the external trigger for the Analog Out channel 0 and come either from example .py scripts or the SDK reference manual. The commented out code is some of the other command I have also tried to use to enable either DC output or a sine wave output to be triggered externally from a positive/rising edge.

# set channel parameters
dwf.FDwfAnalogOutConfigure(hdwf, c_int(0), c_bool(True))
# dwf.FDwfDeviceTriggerSet(hdwf, c_int(0),EXT)
dwf.FDwfAnalogOutTriggerSourceSet(hdwf, c_int(0), channel, c_int(11)) # exteral trigger souce
# dwf.FDwfAnalogOutTriggerSlopeSet(hdwf, c_int(0), DwfTriggerSlopeRise) # positive slope external trigger
# dwf.FDwfAnalogOutNodeEnableSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_bool(True))
# dwf.FDwfAnalogOutNodeFunctionSet(hdwf, c_int(0), AnalogOutNodeCarrier, funcDC)
# dwf.FDwfAnalogOutNodeOffsetSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_double(volt))
dwf.FDwfAnalogOutNodeFunctionSet(hdwf, c_int(0), c_int(0), c_byte(1)) # funcSine
dwf.FDwfAnalogOutNodeFrequencySet(hdwf, c_int(0), c_int(0), c_double(1.0e6))
dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, c_int(0), c_int(0), c_double(volt))
dwf.FDwfAnalogOutNodeOffsetSet(hdwf, c_int(0), c_int(0), c_double(0))

 

Thanks in advance for your help!

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi @LiamP

Similar as it is done in the Device_Synchronization.py example, first configure each input and output channels (or the needed ones) in each device, and arm them, wait each to finish and get the data.

for iDevice in range(cDevice.value): # open and configure
  dwf.FDwfDeviceOpen(c_int(iDevice), byref(hdwf))
  ...
  rghdwf.append(hdwf.value)
  
  dwf.FDwfAnalogIn... # configure range, offset... for channels, frequency, trigger position...
  dwf.FDwfAnalogInTriggerSourceSet(rghdwf[iDevice], trigsrcExternal1) 
  dwf.FDwfAnalogInConfigure(rghdwf[iDevice], c_bool(False), c_bool(True)) # arm inputs
  
  dwf.FDwfAnalogOutCount(hdwf, byref(cChannel))
  for iChannel in range(cChannel.value):
    dwf.FDwfAnalogOut... # configure signal, amplitude, offset... run length...
    dwf.FDwfAnalogOutTriggerSourceSet(rghdwf[iDevice], c_int(iChannel), trigsrcExternal1)
    dwf.FDwfAnalogOutConfigure(rghdwf[iDevice], c_int(iChannel), c_bool(True)) # arm outputs

while True: # wait for each device capture
  fDone = True
  for iDevice in range(len(rghdwf)):
    dwf.FDwfAnalogInStatus(rghdwf[iDevice], c_int(0), byref(sts))
    if sts.value != dwfstateDone
      fDone = False
      break
  if fDone:
    break
  
for iDevice in range(len(rghdwf)): # fetch and get data
    dwf.FDwfAnalogInStatus(rghdwf[iDevice], c_int(1), None)
    dwf.FDwfAnalogInChannelCount(rghdwf[iDevice], byref(cChannel))
    for iChannel in range(cChannel.value):
        dwf.FDwfAnalogInStatusData(rghdwf[iDevice], c_int(iChannel), ...

dwf.FDwfDeviceCloseAll()

 

Link to comment
Share on other sites

  • 0

Thanks, this provided a great starting point for me! I've been able to get the code I've wanted to work. However, I've been unable to get DC offsets to trigger. Is this a feature that has not yet been added?

For those looking at this in the future, you can use the function "FDwfAnalogOutTriggerSlopeSet" the set the required slope for an Analog Out output. 

Link to comment
Share on other sites

  • 0

Hi @LiamP

What do you mean by "DC offset to trigger" ?

For each instrument it can be specified the trigger slope, like rising, falling or either edge of external trigger, or wavegen rise when this starts and fall when stops.
FDwfAnalogInTriggerConditionSet, FDwfAnalogOutTriggerSlopeSet, FDwfDigitalInTriggerSlopeSet, FDwfDigitalOutTriggerSlopeSet

image.png.a68e75cf5b11af945106255e0f857316.png

Link to comment
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
×
×
  • Create New...