Jump to content
  • 0

AD2 external trigger in python


darth458

Question

At this point I have given up on trying to trigger one instrument from another. Finally I decided to trigger two instruments from the pattern generator. I placed a jumper from T1 to D0 on the BNC adapter board header and with the code below I do get a 10 khz digital drive at pin d0. But I get no triggering of either channel. Here is the code:

 

hdwf = c_int()
sts = c_int()
hzSys = c_double()

dwf.FDwfDeviceOpen(c_int(0), byref(hdwf))
if hdwf.value == hdwfNone.value:
    print "failed to open device"
    quit()

dwf.FDwfDigitalOutInternalClockInfo(hdwf, byref(hzSys))

##*********************************************************************************************
##setup pattern

# 10kHz pulse on IO pin 0
dwf.FDwfDigitalOutEnableSet(hdwf, c_int(0), c_int(1))
# prescaler to 2kHz, SystemFrequency/1kHz/2
dwf.FDwfDigitalOutDividerSet(hdwf, c_int(0), c_int(int(hzSys.value/1e4/2)))
# 1 tick low, 1 tick high
dwf.FDwfDigitalOutCounterSet(hdwf, c_int(0), c_int(1), c_int(1))

dwf.FDwfDigitalOutConfigure(hdwf, c_bool(True))   ##  starts the pattern generator forever

##*********************************************************************************************
##setup analog OUT

dwf.FDwfAnalogOutNodeEnableSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_bool(True))
dwf.FDwfAnalogOutNodeFunctionSet(hdwf, c_int(0), AnalogOutNodeCarrier, funcCustom) 
dwf.FDwfAnalogOutNodeDataSet(hdwf, c_int(0), AnalogOutNodeCarrier, rgdSamples, c_int(1000))
dwf.FDwfAnalogOutNodeFrequencySet(hdwf, c_int(0), AnalogOutNodeCarrier, c_double(100000000.0))
dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_double(0.5))
dwf.FDwfAnalogOutTriggerSourceSet(hdwf, c_int(0), trigsrcExternal1)                           ##external trig 1

##*********************************************************************************************
##setup analog IN

dwf.FDwfAnalogInChannelEnableSet(hdwf, c_int(0), c_bool(True))
dwf.FDwfAnalogInFrequencySet(hdwf, c_double(100000000))
dwf.FDwfAnalogInChannelRangeSet(hdwf, c_int(0), c_double(4))
dwf.FDwfAnalogInBufferSizeSet(hdwf, c_int(1000))
dwf.FDwfAnalogInTriggerSourceSet(hdwf, trigsrcExternal1)                                      ##external trig 1


print "sleeping 2 sec"
time.sleep(2)

##*********************************************************************************************
##  START THEM UP this should run forever

dwf.FDwfAnalogOutConfigure(hdwf, c_bool(False), c_bool(True)
dwf.FDwfAnalogInConfigure(hdwf, c_bool(False), c_bool(True)

IMG_0287.jpg

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Archived

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

×
×
  • Create New...