Jump to content

Yannik Arnold

Members
  • Posts

    1
  • Joined

  • Last visited

Yannik Arnold's Achievements

Newbie

Newbie (1/4)

0

Reputation

  1. Hello Digilent, we are working with the Analog Discovery Pro in Python: we send a square waveform (externally generated) to input TRIGGER 1 we like to start the output of a predefined signal from WAVEGEN OUT 1, when in TRIGGER 1 (for example 1.5 V) in a positive rising edge is detected With the software WaveForms this works wundefully, but unfortunately not in python. I guess I don't understand "6. Analog Out (Arbitrary Waveform Generator)" in the manual (https://digilent.com/reference/software/waveforms/waveforms-sdk/reference-manual) properly. So far this is the python-script we use: from ctypes import * from dwfconstants import * import time import sys import matplotlib.pyplot as plt import numpy if sys.platform.startswith("win"): dwf = cdll.dwf elif sys.platform.startswith("darwin"): dwf = cdll.LoadLibrary("/Library/Frameworks/dwf.framework/dwf") else: dwf = cdll.LoadLibrary("libdwf.so") #declare ctype variables hdwf = c_int() sts = c_byte() #open device "Opening first device..." dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) if hdwf.value == hdwfNone.value: print("failed to open device") quit() ################################################################################################ hzRate = 10 # frequency to change from continous output-value rgdSamples[i] to rgdSamples[i+1] cSamples = 5 # number of continous values duration = cSamples/hzRate # duration of output # c_int(0): channel 1 # c_int(1): channel 2 channel1 = c_int(0) channel2 = c_int(1) rgdSamples = (c_double*cSamples)() for i in range(0,cSamples): rgdSamples[i] = (-1)**i; # signal to start if triggered dwf.FDwfAnalogOutNodeEnableSet(hdwf, channel1, AnalogOutNodeCarrier, c_bool(True)) dwf.FDwfAnalogOutIdleSet(hdwf, channel1, c_int(1)) # DwfAnalogOutIdleOffset dwf.FDwfAnalogOutNodeFunctionSet(hdwf, channel1, AnalogOutNodeCarrier, c_int(31)) # funcPlay dwf.FDwfAnalogOutNodeDataSet(hdwf, channel1, AnalogOutNodeCarrier, rgdSamples, cSamples) dwf.FDwfAnalogOutNodeFrequencySet(hdwf, channel1, AnalogOutNodeCarrier, c_double(hzRate)) dwf.FDwfAnalogOutRunSet(hdwf, channel1, c_double(duration)) # run for pattern duration #set up trigger dwf.FDwfAnalogInTriggerSourceSet(hdwf, trigsrcExternal1) # Trigger1 dwf.FDwfAnalogInTriggerTypeSet(hdwf, trigtypeEdge) dwf.FDwfAnalogInTriggerLevelSet(hdwf, c_double(1.5)) # 1.5V dwf.FDwfAnalogInTriggerConditionSet(hdwf, trigcondRisingPositive) # dwf.FDwfAnalogInConfigure(hdwf, c_bool(False), c_bool(True)) for iTrigger in range(10): while True: dwf.FDwfAnalogInStatus(hdwf, c_int(1), byref(sts)) if sts.value == DwfStateDone.value : dwf.FDwfAnalogOutConfigure(hdwf, channel1, c_bool(True)) break time.sleep(0.001) print(1) We would be very happy to figure out, how 1. and 2. works with a python script. Regards, Yannik Arnold
×
×
  • Create New...