04-18-2016 01:44 PM
Hello All,
Here's the iamge that describes what like to accomplish. I would like to trigger the AO outputs with the Falling edge of the counter.
I have set the Clock for my AO as the Counter.
The Analog Output needs to be triggered every time the Digital Counter signal falls SAMPLE_SIZE = 80 SAMPLING_RATE = 40 #Samples are written every 25 milliseconds TIME = float((SAMPLE_SIZE)/(SAMPLING_RATE)) *CREATE TASK *CREATE AO CHANNEL *CONFIGURE CHANNEL TIMING DAQmxCfgSampClkTiming(taskHandleAO,"PFI12",SAMPLING_RATE,DAQmx_Val_Falling,DAQmx_Val_FiniteSamps,SAMPLE_SIZE) *CREATE TASK *CREATE COUNTER CHANNEL # Time low + Time High equals 25 milliseconds and is commensurate with Sampling Rate DAQmxCreateCOPulseChanTime(taskHandleD,"DAQ/ctr0","",DAQmx_Val_Seconds,DAQmx_Val_Low,0.00,0.005,0.020) # DAQmx Write Voltage Values DAQmxWriteAnalogF64(taskHandleAO,SAMPLE_SIZE,0,10.0,DAQmx_Val_GroupByChannel,Voltage,None,None) # DAQmx Start AO Task DAQmxStartTask(taskHandleAO) # DAQmx Start Counter Task DAQmxStartTask(taskHandleD) #TIME is equal to total time for writing samples DAQmxWaitUntilTaskDone(taskHandleD, 2*TIME)
I get an error every time I run the Task:
DAQError: Finite acquisition or generation has been stopped before the requested number of samples were acquired or generated. in function DAQmxStopTask
This is because my AO Task is stopped for some reason.
Is there an obvious problem with the code. Can it be structured differently?
warm regards,
Ravi
Solved! Go to Solution.
04-18-2016 01:55 PM
OK, so I made the following change, PFI12 counter output is no longer the clock source.. but a Trigger source..
and for some reason things seem to work.. I have to run more checks.. thought I will update here first..
DAQmxCfgSampClkTiming(taskHandleAO,"",SAMPLING_RATE,DAQmx_Val_Falling,DAQmx_Val_FiniteSamps,SAMPLE_SIZE) DAQmxCfgDigEdgeStartTrig(taskHandleAO, "PFI12", DAQmx_Val_Falling)
04-18-2016 01:59 PM
I do all my programming in LabVIEW so I'm pretty limited at helping with text programming syntax. That said, here's what I *think* I see:
Your AO task makes a call to DAQmxCfgSampClkTiming but your Counter task doesn't. This probably leaves you with a counter task that creates only a single pulse, thus causing only a single AO D/A conversion. In LabVIEW when I need a pulse train, I'd call a similar timing function with the clock mode set as "Implicit".
Hope this helps you get started, I just don't know enough to give you the specific syntax in text.
-Kevin P
04-18-2016 03:24 PM
Thanks Kevin,
that fixed it.
warmest regards,
Ravi