Jump to content
  • 0

AD + python: how to create a analog DC output voltage


tutu

Question

Hi everybody,

I want to create a DC output voltage as simple as possible. In the end I came up with this

ch = c_int(0) ## first DAC channel
nd = dig.AnalogOutNodeCarrier
dwf.FDwfAnalogOutNodeEnableSet   (hdwf, ch, nd, c_bool(True))
dwf.FDwfAnalogOutNodeFunctionSet (hdwf, ch, nd, funcCustom)
#dwf.FDwfAnalogOutNodeFunctionSet (hdwf, ch, nd, funcDC)
dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, ch, nd, c_double(1))

cdata = (c_double*1)(*[1.0])
dwf.FDwfAnalogOutNodeDataSet     (hdwf, ch, nd, cdata , c_int(1))
dwf.FDwfAnalogOutRunSet (hdwf, ch, c_double(1e-6))
dwf.FDwfAnalogOutIdleSet (hdwf, ch, c_int(2)) ## go to initial value
dwf.FDwfAnalogOutConfigure(hdwf, ch, c_bool(True))

this produces a DC voltage for a short time. With the idle function the value should be kept alive, even when I go into the wait or done state. I think, this is preferable against a DAC running for ever.

Is this the right way to do, or is there a much simpler method?

Especially, the funcDC parameter seems to be foreseen for such a case .. but haven't found any documentation about.

best regards and thanks in advance

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

Hi @tutu

The DC output on AnalogOut (AWG) channel is configure with the offset (manual: "funcDC : Generate DC value set as offset.")

dwf.FDwfAnalogOutNodeEnableSet(hdwf, channel, AnalogOutNodeCarrier, c_bool(True))
dwf.FDwfAnalogOutNodeFunctionSet(hdwf, channel, AnalogOutNodeCarrier, funcDC)
dwf.FDwfAnalogOutNodeOffsetSet(hdwf, channel, AnalogOutNodeCarrier, c_double(2.5))
# ...
# the outputs will be stopped on device close or process exit
dwf.FDwfDeviceClose(hdwf) 

 

Link to comment
Share on other sites

I am trying to do something similar,  with an idle offset value and then switch to a different DC offset value after a trigger.  However, with the code below, I am getting the FuncDC/NodeOffset value immediately when I configure the channel, instead of the idle value prior to the trigger.  It only goes to the idle value after the RunSet duration.  Could you please explain how to get it to idle at a low value prior to the trigger? 

Quote

self.dwf.FDwfAnalogOutNodeEnableSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_int(True))
self.dwf.FDwfAnalogOutTriggerSourceSet(hdwf, c_int(0), trigsrcExternal1)            
self.dwf.FDwfAnalogOutTriggerSlopeSet(hdwf, c_int(0), c_int(1)) #rising edge
self.dwf.FDwfAnalogOutRunSet(hdwf, c_int(0), c_double(self.active.xduration))  #set run duration   

self.dwf.FDwfAnalogOutOffsetSet(hdwf, c_int(0), c_double(0))  #idle offset value = 0v
self.dwf.FDwfAnalogOutIdleSet(hdwf, c_int(0), DwfAnalogOutIdleOffset) #idleoffset      
      
self.dwf.FDwfAnalogOutNodeFunctionSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_int(0))  #  0=funcDC = DC offset
self.dwf.FDwfAnalogOutNodeOffsetSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_double(3))  #DC offset value after trigger = 3v       
self.dwf.FDwfAnalogOutConfigure(hdwf, c_int(0), c_bool(True)) #start analog


 

 

Link to comment
Share on other sites

Hi @spri

This will output 3V for xduration after each trigger event.

self.dwf.FDwfAnalogOutEnableSet(hdwf, c_int(0), c_int(True))
self.dwf.FDwfAnalogOutTriggerSourceSet(hdwf, c_int(0), trigsrcExternal1)            
self.dwf.FDwfAnalogOutTriggerSlopeSet(hdwf, c_int(0), c_int(1)) # rising edge
self.dwf.FDwfAnalogOutRepeatTriggerSet(hdwf, c_int(0), c_bool(True)) # arm after each run cycle, with false it would wait only at start
self.dwf.FDwfAnalogOutRepeatSet(hdwf, c_int(0), c_int(0)) # unlimited repeat 
self.dwf.FDwfAnalogOutRunSet(hdwf, c_int(0), c_double(self.active.xduration))  # set run duration    
self.dwf.FDwfAnalogOutWaitSet(hdwf, c_int(0), c_double(0))  # no wait
self.dwf.FDwfAnalogOutIdleSet(hdwf, c_int(0), c_int(1)) # DwfAnalogOutIdleOffset

self.dwf.FDwfAnalogOutOffsetSet(hdwf, c_int(0), c_double(0))  # offset value = 0v

self.dwf.FDwfAnalogOutFunctionSet(hdwf, c_int(0), funcSquare)  # 
self.dwf.FDwfAnalogOutSymmetrySet(hdwf, c_int(0), c_double(100))  # 100% duty, only +amplitude while running
self.dwf.FDwfAnalogOutAmplitudeSet(hdwf, c_int(0), c_double(3))  # offset + amplitude after trigger = 3v       
self.dwf.FDwfAnalogOutFrequencySet(hdwf, c_int(0), c_double(1.0/self.active.xduration))  # not really needed here, but it could be used for burst signals

print("starting")
dwf.FDwfAnalogOutConfigure(hdwf, c_int(0), c_bool(True)) # start analog output #1

 

Link to comment
Share on other sites

Hi @spri

The offset has a settling time, it is not intended to be used to generate signal, but only to establish a static offset level.
The DC function outputs just the offset level. To generate some signal you need other function than DC.
In your previous code you have first configured the offset to be 0 then overwritten it with 3V, so the output was constant 3V after this.

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...