02-05-2008 07:15 PM
02-05-2008 08:43 PM
I think one or two things could be causing the problem.
1. Your DAQmx write is set for 1 sample. I don't know how that dynamic signal type works with such a setting. Perhaps it is just putting out the first sample of the signal that is generated.
2. The math for the frequency of the square wave does not make sense. You are adding a pulse delay with the pulse period, then inverting it to get the frequency. So a 1 second delay with 1 second pulse is a 1/2 Hz wave. A 4 second delay with a 2 second pulse would be a 1/6 Hz wave. That doesn't make sense to me.
I would recommend building your own waveform or array and not using the express VI. If you have a 1000 Hz frequency established let's say, build a 1000 element array. For a .1 second pulse, set replace 100 of those elements with a 100 element array of the voltage value you want. You can index it wherever you want in the array to account for whatever delay you want. If you want a 1 msec pulse, then just replace a single element of that array wherever you want.
02-05-2008 08:53 PM
02-06-2008 06:15 AM
02-07-2008 09:52 AM
Hi Guang,
I recommend taking a look at the DAQmx shipping example called Cont Gen Voltage Wfm-Int Clk-Variable Rate.vi which can be found in the Example Finder (Help » Find Examples…) by browsing by Task to Hardware Input and Output » DAQmx » Analog Generation » Voltage. This example allows you to generate a square (or other) waveform and change its parameters on the fly.
And some quick pointers: make sure you are checking the status of your error cluster in your while loop. That way when your write VI encounters an error, it will quit the generation loop automatically. Also, it’s a good idea to close the task after the loop has executed.
Post back if you have any questions. Have a great day!