Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating continuous sine wave as task that can be started and stopped externally

Hi there,
I am trying to generate a sinusoidal signal from the DAQmx Analog Out port. Basically, I need to call this vi from Teststand, so that it can start generating the sine wave, return control to Teststand so that some more measurements can be made using this stimulus after which, this sine wave should be stopped.
 
I have browsed through all the DAQmx examples related to generating waves and while that is not a problem, I am stumped by being able to run it as a task that i can start and stop while having control returned in between. I even tried running it on a separate thread in Teststand, but that does seem to work the way I intended either.
 
Any suggestions?
0 Kudos
Message 1 of 5
(3,650 Views)
Hi Heather,

What you can do is make a VI that sets up your sine wave and the DAQmx task and starts it.  Create an indicator out of the start task vi for the task and assign it on the connector pane so you can pass the task back to TestStand.  Then, do what you want in TestStand... the task is still running.  When you want it to stop, have a VI that has a DAQmx Clear Task.vi and passes in the Task.  

I was able to do this myself, so let me know if you have any questions.
Kristen
National Instruments
0 Kudos
Message 2 of 5
(3,619 Views)

Hi Kristen,

I have tried two main approaches, neither worked.

1. Modify the Cont Gen Voltage Wfm-Int Clk.vi found in the DAQmx example vis by copying everything upto the start task vi, to which I then added an indicator in the task out parameter. I then put the remaining "is task done" and clear task blocks in a separate vi. The idea was to be able to generate the voltage, get the task name and then pass the task name back to the clear task vi so that it can be stopped. I dont have to necessarily do this in Teststand, as I can simply use the variable for task name passed to me. I know we use this method for other instrumentation control. Anyway, the problem, I found with this was that the wave was only generated once! I discovered this by probing with a scope probe on the DAQ break out box for the analog out line. Although the display on the vi shows the waveform it generated, it just seems to do it once. Unfortunately, to keep it going, I would have to put it in some kind of a while loop, which would then not allow me to resume control after starting this wave generation. Oh yes, I also modified this vi in various ways, such as using stop task and clear task instead of using the is task done.

2. Create task on MAX. I was able to test it successfully, since my options at that point were to start and stop. While its started, the wave generation is constant, I saw it on the probe. However, the same issue when I call it using a created vi that starts the task, gets the task name as a variable, which I then pass onto another vi to clear the task. It only generates once, which is easier to see if you highlight the execution.

Also, looking at the help files and associated documentation, the continuous generation does require the daq assistant vi or other express vis to be run inside a loop. So that wasnt an option either.

So, I have tried what you recommended, but perhaps I was working off a less applicable example vi. Maybe you can advise me on which vi was your starting point.

0 Kudos
Message 3 of 5
(3,605 Views)
Hello,

I also started with the example Cont Gen Voltage-Int Clk.vi.  I put everything up to the start task VI in one VI, and in my second VI I only have the clear task.  It did not work when I put the loop with the "is task done" in the 2nd VI, so I removed it. 

To test it, in TestStand I call the first VI, then I have a step that pops up a message box, then I call the second VI.  I wired my Analog Output into my Analog Input and used a Measurement and Automation Explorer test panel to see what was being output.  So, when I had moved onto the step with the message box, my waveform was still being output, and then when I pressed OK, and it went onto the VI with the clear task the waveform stopped outputting. 

Let me know if you have any questions.
Kristen
National Instruments
0 Kudos
Message 4 of 5
(3,584 Views)

Hi Kristen,

Thank you for looking into this. I tried with the examples you and Matt sent and actually I have been in touch with him. I was not able to generate the same behaviour as you did. When the control returns from start.vi, I find that the output stops. I also tried it on the DAQ breakout box SCB-68 by connecting the analog output to the analog input and watching on the DAQmx test panel.

So I believe, he is now working on trying it with hardware specific to us, the 6289 pxi.

Thanks for your response.

0 Kudos
Message 5 of 5
(3,577 Views)