Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate Pulse Train with PCI-6221

Hi,
I would like to generate a finite pulse train using a PCI-6221. Having looked at the DAQmx Gen Digital Pulse Train - Finite.vi, I think I can use this for my application. Are there any problems in removing the 'Wait Until Complete.vi' and 'Clear Task.vi' and simply calling the Timing and Start vi's each time I want to generate a pulse train?
I would configure the channel and clear the task outside of a while loop.
 
What I would like to achive is to generate a fixed frequency pulse train with a variable pulse train length. Im not sure if there a faster or more efficient ways to do this but any ideas would be appreciated.
 
thanks
David
 
0 Kudos
Message 1 of 12
(4,017 Views)
Hello DavidT,
I've got a few things to mention.  First, if using an example like Gen Dig Pulse Train-Finite.vi, you won't be able to use the DAQmx Timing VI to write new parameters to the task while it is still "running".  So you will need to do a DAQmx Stop Task prior to the DAQmx Timing VI the second time.  Also, the DAQmx Wait Until Done.vi is there to ensure the entire series of pulses has been output before the task is stopped or cleared.  If you stop or clear the task before the desired number of pulses has been output, you will probably get a warning message.  With those considerations, what you are trying to do is possible.  Take a look at the attached program.  I generate an arbitrary number of pulses in each iteration of the loop.  Hope this helps.
-Alan A.
Message 2 of 12
(4,007 Views)
Hi Alan,
Thanks for the response, but you have not attached your sample program. I do have a few more questions though.
Can the number of pulses be written to the task using a DAQmx property node?  If so, do I need to stop the task with this function aswell?
I would ideally like to complete the loop at an approximate rate of 20ms.
Thanks
David
0 Kudos
Message 3 of 12
(3,999 Views)
Whoops.  Here it is. 
And I don't think you can use a property node to achieve anything better than how it is done in this example.  You will still get an error if you try to set the number of pulses while the task is running.
-Alan A.
0 Kudos
Message 4 of 12
(3,996 Views)

OK, I just did some timing benchmarks on your example and using the 'wait till done.vi' does not allow me to run my loop any faster than 100ms. If i remove this, I can run it at 20ms, but like you said, it generates a warning message. Im not sure what impact this will have on my program but I guess it will have to do for now.

Thanks.

 
0 Kudos
Message 5 of 12
(3,994 Views)
Just one more thing.....If you had your loop software timed with a "Wait.vi" or "Wait Until Next Millisecond Multiple.vi" to achieve the specific timing you are looking for (20msec), then you wouldn't get that warning unless your pulse trains are longer than the loop time.  Another thing you could do is handle that warning by checking the error cluster for that particular warning and just clearing it if you don't want the popup.  Hope this helps:)
-Alan A
0 Kudos
Message 6 of 12
(3,991 Views)
Just thought of something else.  With M Series, you have the ability to do corellated digital I/O.  The digital I/O does not have its own timing engine, so you have to generate the sample clock with analog in, analog out, or a counter.  You could then output a series of 1s and 0s to a digital line to produce your pulse trains.  Just a thought.
-Alan A.
0 Kudos
Message 7 of 12
(3,992 Views)

OK, i have tried to write a pulse train with variable length without using the wait until done vi. This does not work as well as i had hoped and nowhere near as well as running it with the 'wait till done'.

Is there any way to write the pulse train faster? Im not sure what parameters need to be set. Generally, i would like to write between 0 and 1000 pulses at a specified frequency. No matter which parameters I change on the example, it usually takes 100ms to write the pulse train. Unfortunately, this is too slow as I need to perform AI DAQ and PID calculations at a rate of 20ms (the pulse train will be the output of the PID).

0 Kudos
Message 8 of 12
(3,981 Views)
On a further note, I previously did the same kind of thing using Traditional DAQ (using a finite pulse example) and a 6601 card which worked within the 20ms limitation. Now im using DAQmx 7.4 and a PCI-6221 card.
 
0 Kudos
Message 9 of 12
(3,982 Views)
What frequency are you using?  Is 20msec enough time to output 1000 pulses at that frequency?
-Alan A.
0 Kudos
Message 10 of 12
(3,958 Views)