LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Waveform graph grows over time

Solved!
Go to solution

I'm looking to generate a 10 kHz sinusoid waveform with varying (pseudo)random peak amplitudes. This is in an attempt to simulate voltage readings from an external sensor that measures fluid levels in motion, sampling at 10 kHz.

 

The problem that I am seeing is that my waveform's amplitude displayed on the graph seems to be extremely attenuated for small values of t (x-axis), and grows as t gets larger, eventually "settling" into the desired behavior. I assume that I am ignorant of some facet of the waveform array generation or of its display on the graph, or that I otherwise misunderstand something about the process entirely.

 

I'm also not well-versed in Signal Theory, and the ideas of sample frequency and number of samples is still something that I'm trying to wrap my head around. I notice that adjusting the Fs value, I can minimize this small t attenuation. I've attached 2 images that demonstrate this. The first image ("random sinusoid generator output (small fs).png"), generates a 10 kHz waveform with Fs = 20050 indicated by the red arrow. This really exemplifies what I'm talking about here. (Values of Fs ~= 2*frequency seem to kill off my waveform amplitude for all values of t (another perplexity), so this was as close as I cared to get.) The second image is sampling the same waveform but at Fs = 50000, and reduces the effect, but it is still apparent (red arrow).

 

I couldn't get any informative results from my google-fu, so I imagining that I'm not fully understanding the relationship between sampling and the graph, and therefore don't know what to search for. Would anyone be able to offer any insight or advice for this situation? I've included a snippet of my code and a previous save version for referral.

 

Thank you so much!

 

random sinusoid generator.png

P.S. I modified the equation I found in an example to generate the waveform, which I just kind of tweaked until I got something that looked like it might resemble some good randomness (see below). It's a clunky equation, but it gives me a 10 kHz sinusoid with varying peaks. Any advice on creating a better equation would also be very welcome!

 

y = a * sin(w*t) * (4 - rand() * 8 * sin(rand()*500*pi(1)*t))

0 Kudos
Message 1 of 3
(1,232 Views)
Solution
Accepted by topic author curiositas

Hi curiositas,

 


@curiositas wrote:

I'm also not well-versed in Signal Theory,  …

The first image ("random sinusoid generator output (small fs).png"), generates a 10 kHz waveform with Fs = 20050 indicated by the red arrow. This really exemplifies what I'm talking about here. (Values of Fs ~= 2*frequency seem to kill off my waveform amplitude for all values of t (another perplexity), so this was as close as I cared to get.)


You really should read up on the basics of Signal theory, especially anything written by Shannon and Nyquist!

 

Using a sample rate of 22.05kHz for a 10kHz signal is near the Nyquist frequency: you will get an aliased result. What you see is expected…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(1,209 Views)

@GerdW wrote:

You really should read up on the basics of Signal theory, especially anything written by Shannon and Nyquist!

 

Using a sample rate of 22.05kHz for a 10kHz signal is near the Nyquist frequency: you will get an aliased result. What you see is expected…


Thank you very much for the suggestion, I will definitely head it.

 

While I'm reading up on it, can I take your last sentence to mean that by increasing the sampling rate that I should see this issue resolve?

 

Thanks a mil for your insight!

0 Kudos
Message 3 of 3
(1,201 Views)