Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate a sine wave

Hi 

I am a new user of mechanical background...I want to generate a sine wave of (10 sin (pi/20*t)) 

where t is 0 to 20 seconds.. Now i figured out the frequency i would require is 0.025 Hz..I used simulated signal option..so i put amplitude of 5 with offset of 5 and phase -90 so that it starts from 0 sec..but i have no clue on samples per second and no of samples ..so i used default value of 1000 and 100 respectively...at output end when i am connecting voltmeter to measure voltage i am getting 5.32 to 5.44...I put analog write to zero after the loop so that when i press stop button I get zero V at output...I didn't use DAQ assistant ...Can anyone help me in this regardquery.jpg

0 Kudos
Message 1 of 6
(3,757 Views)

We don't really need to see a picture of your entire desktop and an image is not debug-able code. Please attach your VI instead. What are the values of all your controls? How does the signal look like of the graph? What is the loop rate?

 

In order to calculate your frequency, you also need to know the number of points and dt between points. (your use of the term "frequency" is ambiguous, because you have the sampling frequency and he frequency of the sine wave.). Your are creating 100 samples, but are only writing one per loop iteration.

 

How do you "measure" the voltage (Oscilloscope, DC meter, AC meter, etc.). How is the signal terminated?

0 Kudos
Message 2 of 6
(3,725 Views)

Please find the attached file...I simulated this voltage in MATLAB and for that the step size i took 0.01 ...(10 sin (pi/20*t))  and total time was 20 seconds... Now that was the simulation part...If I want to generate the same in hardware using labview coding..how to do that? 

Thus a total of 2000 points need to be generated with time step (dT) to be 0.01 ..

I am measuring with DC meter..Signal cannot be terminated when I hit stop button so i am writing 0 to DAQ write after the loop...and then stop and clear DAQ command...

0 Kudos
Message 3 of 6
(3,694 Views)

Your VI has very little to do with your original picture and only contains the hardware output. Since you seem to have problems simulating the signal, show us your attempt at simulating instead. We don't really care about the IO.

 

Obviously, there are better ways to do hardware timed IO instead of using a poorly defined loop pushing one software timed point at a time.

 

As a first step, do a pure simulation, sending the data to a chart one point at a time. Tweak until that works. I doubt you need any express VIs.

0 Kudos
Message 4 of 6
(3,689 Views)

As per your suggestion to start with simulation ..Here is my labview file sinewave_generation ...The wavechart looks fine now ...This is the signal that i want to send to my daq card...I have also shared my attempt to send the wave to hardware... I find no response at hardware end..Please see both the files..kindly tell me where m i going wrong ?

Download All
0 Kudos
Message 5 of 6
(3,679 Views)

Now you are creating 1000 samples with each iteration, but are only sending [1Chan 1Samp] to the hardware, throwing away 99.9% of the data!

 

This makes absolutely no sense. Have you looked at the shipping examples? What determines your loop rate? Why are you starting the task with each iteration? Why are you ignoring all errors?

 

(Sorry, I don't even have DAQmx installed here)

0 Kudos
Message 6 of 6
(3,671 Views)