Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Contineously increasing amplitude square wave

Solved!
Go to solution
Solution
Accepted by lahorimunda
Hello lahorimunda,

I was looking through the NI example finder in LabWindows/CVI and I found an example that I believe can be modified to fit your application.  The project name is ContGen-IntClk.prj and it can be found in LabWindows/CVI by going to Help>>Find Examples.  Once the example finder opens you can select Hardware Input and Output>>DAQmx>>Analog Generation>>ContGen-IntClk.prj.  One of the things you can do is use a sawtooth wave but average the values out to the nearest integer, thus creating the step wave that you've been seeking.

You can use the TruncateRealNumber function in the source code to take the array of float data and convert them to integers.  One way to do this is to put a for loop before the PlotY function, and the for loop will go through each value in the buffer and truncate it to a real number.  Here is an example of what I'm talking about:

 for(i=0; i< sampsPerBuffer ; i++){
            data[i] =      TruncateRealNumber(data[i]);
        }

I hope this helps.

Have a great day,
0 Kudos
Message 11 of 12
(949 Views)
Thanks a lot Brandon for helping me out on that. I would never had thought of changing the triangle wave one. These are the disadvantages of being a newbie. Anyways I have tried what you have said and it worked out. I have been able to generate the waveform I wanted. I will now play with it a little more now and add a few more control options to it. Once again thanks a lot for all your help.
Regards,
Farhan Ahmad.
0 Kudos
Message 12 of 12
(936 Views)