Jump to content
  • 0

Analog Discovery help with synchronizing analog out with digital out


vata

Question

Hi I have a situation in which I want to perform a function with analog discovery and unclear it is feasible. Can this be done programmatically?

 

-Master Enable V+/V-

Then synchronously have the analog outputs and digital outputs on as follows:

-5 V amplitude, 10 MHz sine wave lasting 300 ns on W1 then wait for some time>250 ms

-wait of 300 ns then 3.3V amplitude pulse lasting time>250 ms on W2 (to be used as external trigger on another equipment)

-wait of 300 ns then high on Digital IO pin 1 lasting the time>250 ms 

 

Is there a configuration script in python that can be shared or example file that allows setting this up. I am unclear how to have the analog and digital I/O be synchronized and be repeating so clarity or illustrative code is very appreciated. 

 

We are considering buying a new Analog Discovery 2 to replace the old one so your help setting this up would go a long way to being convincing for our application.

 

Thanks for the attention!

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Hi @vata

There are various triggering and delay/wait options but I think the script below is easies for your task.
The script is executed on one device and it is captured with WF app by another device.

image.thumb.png.dea99fa9d1df137a3ec6abb64260f111.png

image.thumb.png.f84339b0ab0b991d2d512d290c1d60b6.png

from ctypes import *
import time
from dwfconstants import *
import sys

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")


version = create_string_buffer(16)
dwf.FDwfGetVersion(version)
print("DWF Version: "+str(version.value))

# continue running after close
dwf.FDwfParamSet(DwfParamOnClose, c_int(0))

#open device
print("Opening first device...")
hdwf = c_int()
dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))


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

# the device will be configured only when calling FDwf###Configure
dwf.FDwfDeviceAutoConfigureSet(hdwf, c_int(0))


# set up analog IO channel nodes
# enable positive supply
dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(0), c_double(1)) 
# set voltage to 5 V
#dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(0), c_int(1), c_double(5.0)) # AD2
# enable negative supply
dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(1), c_int(0), c_double(1)) 
# set voltage to -5 V
#dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(1), c_int(1), c_double(-5.0)) # AD2
# master enable
dwf.FDwfAnalogIOEnableSet(hdwf, c_int(1))
dwf.FDwfAnalogIOConfigure(hdwf)

# wait for rails and DUT to stabilize
time.sleep(0.1) 


# Wavegen1 trigger on Pattern, 10MHz 5V for 300ns
# Wavegen2 trigger on Pattern, wait 300ns, 250ms 3.3V pulse 
# Pattern  wait +300ns, DIO-0 250ms 


# Wavegen 1
wave1 = c_int(0)
dwf.FDwfAnalogOutNodeEnableSet(hdwf, wave1, AnalogOutNodeCarrier, c_int(1))
dwf.FDwfAnalogOutIdleSet(hdwf, wave1, DwfAnalogOutIdleOffset)
dwf.FDwfAnalogOutNodeFunctionSet(hdwf, wave1, AnalogOutNodeCarrier, funcSine)
dwf.FDwfAnalogOutNodeFrequencySet(hdwf, wave1, AnalogOutNodeCarrier, c_double(10e6)) # 10MHz
dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, wave1, AnalogOutNodeCarrier, c_double(5))
dwf.FDwfAnalogOutTriggerSourceSet(hdwf, wave1, trigsrcDigitalOut)
dwf.FDwfAnalogOutWaitSet(hdwf, wave1, c_double(0.0)) # 
dwf.FDwfAnalogOutRunSet(hdwf, wave1, c_double(300e-9)) # 300ns
dwf.FDwfAnalogOutRepeatSet(hdwf, wave1, c_int(0)) # repeat indefinitely
dwf.FDwfAnalogOutRepeatTriggerSet(hdwf, wave1, c_int(1))
dwf.FDwfAnalogOutConfigure(hdwf, wave1, c_int(1))

# Wavegen 2
wave2 = c_int(1)
dwf.FDwfAnalogOutNodeEnableSet(hdwf, wave2, AnalogOutNodeCarrier, c_int(1))
dwf.FDwfAnalogOutIdleSet(hdwf, wave2, DwfAnalogOutIdleOffset)
dwf.FDwfAnalogOutNodeFunctionSet(hdwf, wave2, AnalogOutNodeCarrier, funcPulse)
dwf.FDwfAnalogOutNodeFrequencySet(hdwf, wave2, AnalogOutNodeCarrier, c_double(2.0)) # /2 = 250ms high
dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, wave2, AnalogOutNodeCarrier, c_double(3.3))
dwf.FDwfAnalogOutTriggerSourceSet(hdwf, wave2, trigsrcDigitalOut)
dwf.FDwfAnalogOutRepeatTriggerSet(hdwf, wave2, c_int(1))
dwf.FDwfAnalogOutWaitSet(hdwf, wave2, c_double(300e-9))
dwf.FDwfAnalogOutRunSet(hdwf, wave2, c_double(0.25))
dwf.FDwfAnalogOutRepeatSet(hdwf, wave2, c_int(0)) # repeat indefinitely
dwf.FDwfAnalogOutConfigure(hdwf, wave2, c_int(1))

# Pattern Generator
dwf.FDwfDigitalOutRunSet(hdwf, c_double(1.0)) 
dwf.FDwfDigitalOutRepeatSet(hdwf, c_int(0)) # repeat indefinitely
# DIO 0
dio0 = c_int(0)
dwf.FDwfDigitalOutEnableSet(hdwf, dio0, c_int(1))
dwf.FDwfDigitalOutDividerInitSet(hdwf, dio0, c_int(19+30)) # DAC/pipeline delay + 300ns
dwf.FDwfDigitalOutDividerSet(hdwf, dio0, c_int(100000)) # 1kHz for counters
dwf.FDwfDigitalOutCounterInitSet(hdwf, dio0, c_int(0), c_int(1)) # start low and count 1
dwf.FDwfDigitalOutCounterSet(hdwf, dio0, c_int(10000), c_int(250)) # 250ms high and long low

dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))

dwf.FDwfDeviceClose(hdwf)

 

Link to comment
Share on other sites

Thanks Attila I actually see the W1,W2,D0 signals as expected but the voltages do not adjust on the multimeter shown in AD1_noSupplyVoltages.jpg but the multimeter readings adjust on the multimeter for instance when I set them manually see the reading in AD1_manualSupplyVoltages.jpg

I also tried to uncomment the lines for AD2 but I did not notice a difference. Is there a recommended modification so the supply voltages can remain enabled on without interruption?

 

AD1_noSupplyVoltages.jpg

AD1_manualSupplyVoltages.jpg

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...