Signal Conditioning

cancel
Showing results for 
Search instead for 
Did you mean: 

frequency of sine waveform VI

Hi all,

 

I want to regenerate a sine wave by detecting the amplitude and frequency of the simulate signal. The results show me that their amplitudes do match, and the problems I am having are:

 

1. althought the charts show that they almost have the same number of peaks, the time scales don't match (e.g. simulate signal dt = 1s; regenerate sine dt equals almost 20 minutes);

2. the peak detection VI cannot detect the amplitude correctly when I set the frequency to be below 10 Hz;

3. the second chart freezes when I set the frequency to be an integer (e.g. freq = 11 Hz freezes and freq = 11.1 Hz doesn't).

 

Can someone help me out with this?

 

Thank you!

0 Kudos
Message 1 of 17
(10,199 Views)

1. The charts are deceiving you. Put a graph on the front panel. You will see that on each iteration of the loop you only get a small fraction of a cycle of the sine wave.

 

Deceptive chart.png

 

The conversion to (the EVIL) Dynamic Data Type connected to Waveform Chart 2 also hides some information. Wiring the output of the Sine Waveform.vi directly to the chart produces this:

 

reconstruction.png

 

The time scale differences are due in part to the sampling settings. The Simulate Signal.vi generates 100 samples representing 0.1 second while the Sine Waveform.vi generates 1000 samples representing 1 second on each iteration of the while loop. So chart 2 gets 10 times more data points than chart 1.

 

2. When the freqeuncy is <10 Hz you get less than 1 cycle in the 0.1 second of samples at the output of Simulate Signal.vi. So the Peak detector may not always get a real peak.

 

3. It is not frozen. It just happens that the amount of data represents a complete cycle on each iteration.

 

4. The frequencies detected by the Extract Single Tone Information.vi will not be very reliable. Internally it uses FFT methods and the FFT does not work well with fewer than 3-5 cycles in the input data. 

 

Lynn

0 Kudos
Message 2 of 17
(10,190 Views)
Hi Lynn,

Thanks for your thorough explanation! I finally get why it doesn't detect the amplitude correctly now!
Sine you mentioned that Extract Single Tine is not very reliable, do you have any suggestions for getting the frequency of the sine wave?

Cheryl
0 Kudos
Message 3 of 17
(10,160 Views)

Cheryl,

 

The choice of measurement technique for frequency depends on many factors.

 

What is the source of the real signal you want to measure? What is the range of frequencies? How much frequency resolution do you need? How many samples (at what sampling rate) do you have available at the time of the measurement? Are there interfering signals or noise in the same frequency band?

 

Lynn

0 Kudos
Message 4 of 17
(10,157 Views)

Lynn,

 

I am trying to produce a perfect sine wave and use my EMG signal to constantly adjust its amplitude and frequency. I would say the range of frequencies would be 1-20 Hz for which my arm can possibly perform. I might send in my EMG wave once every few seconds, depending on whether I need to alter the state of the sine wave. Also, my EMG signal is a little bit noisy, but not as bad as the uniform white noise. And I am not worried about it not having high frequency resolution for now.

 

But at this stage, I am just making sure I can output a sine wave by detecting the amplitude and frequency from somewhere else.

 

Another question regarding your previous reply is that how can I fix the time scale problem? If I understand you correctly, you meant that chart two took more data points than chart one, and each point was set to be equidistant, so the time-axis in chart two was longer in order to distribute all the points. This means that the time-axis doesn't represent the real time. Is that right? If so, how can I check that the produced sine wave has the exact same frequency as the simulate signal while they have different dts?

 

I really thank you for taking the time reading my post.

 

Cheryl

0 Kudos
Message 5 of 17
(10,150 Views)

Cheryl,

 

You will be acquiring an EMG signal and want to find its frequency. And then you want to generate a clean sine wave at the same frequency. Did I understand you correctly?

 

The EMG signals I have seen usually do not have a well defined frequency, so this may be a challenge. Do you have any EMG data you could post? If you do post data also indicate what frequency sine wave you expect from that data.  I have been working on a similar problem involving EEG signals (for 15 years), so I may be able to help.

 

Lynn

0 Kudos
Message 6 of 17
(10,146 Views)

Lynn,

 

Your are exactly right.

 

Here is a snapshot of the video -- sorry that's the most recent one I have in hand. The green line is my EMG signal, and I was trying to track the 0.5 Hz sine wave which is the red line. As for what I am working on right now, so far I am not able to display the two signals on the same chart in the VI I posted here because of the dts. If you could help me with this as well it would be great.

 

Thank you very much!

 

Cheryl

0 Kudos
Message 7 of 17
(10,142 Views)

The extract single tone detection is quite good, IF   you have a constant frequency for 10 to 20 periodes. Yes it's DFT based but there is a good presentation of the NI programmer at NIweek 99 explaining it. Since I can't find anymore I repost it here
You would need something more like a tracking of the base frequency. Wavelet??    Or simply low pass filter?  Maybe a DFT based filter?

Post some data (not pictures) and explain exactly what you want/need.

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 8 of 17
(10,137 Views)

Cheryl,

 

The signal in your image is quite similar to the EEG signals I have been analyzing.  

 

What is the duration of the signal? How soon after it starts do you need to know the frequency? Does the frequency change while the signal is present or does it stop and then restart at a different frequency? Does your clean sine wave need to be in phase with the EMG signal? If so, exactly how are you defining the phase of that somewhat noisy and non-sinusoidal signal?  

 

Is your sampling rate and number of samples read on each iteration fixed or can you change them? What values are you using?

 

Lynn

0 Kudos
Message 9 of 17
(10,121 Views)

Henric,

 

Unfortunately, I haven't recored any numeric data so far. At this stage, I have just been monitoring the signal on the screen. Sorry about that!

 

Cheryl

0 Kudos
Message 10 of 17
(10,114 Views)