LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Frequency and Amplitude Indicator

Hey guys, I'm trying to create a vi that is able to detect frequency at the 5Hz-25Hz range and indicate if the amplitude of this analog signal is above a certain threshold by using an indicator light/digital signal on a waveform chart.  I'm able to detect frequency pretty well, but I noticed that the indicator does not go on everytime the amplitude is above threshold.  It will sometimes "miss" seeing the amplitude go high and won't turn on the indicator light or make the digital value go high.  If I raise my sampling rate I can get the indicator light/digital value to go on every time the amplitude goes above threshold, however, the frequency detection becomes inaccurate.  Any ideas to resolve this issue?

0 Kudos
Message 1 of 12
(4,321 Views)

Hi amad,

 

you just made a classic Rube-Goldberg: IF true THEN true ELSE false... 😄

 

- Why do you have that inner while loop? It just creates problems on your "continuous" DAQmx task, so remove it! (It makes no sense to check the same value again and again as fast as your CPU will run...)

- In your VI there is NO "frequency detection". All you do is calculating an average of several sample values...

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 12
(4,315 Views)

I pulled it from a larger program and this is the issue we are running into.  I forgot thought I didn't need the while loop in this sample program, but I updated the file.  Thanks!

0 Kudos
Message 3 of 12
(4,312 Views)

Hi amad,

 

- You still use that Rube-Goldberg. You can delete that select function safely 😄

 

- As I can't test the VI (missing DAQmx installation on my computer): did you try to change some of those additional inputs of the "Extract single tone info" function?

 

When testing the VI with a simple function generator it displays the correct frequency (in the range of 5 to 25 Hz):

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 12
(4,300 Views)

Yes, I've used a middle frequency of 15 and a range of 10 below and above and still do not get an accurate frequency reading with a higher sample rate.  I've tested with a simulated signal before and it works, but I have issues with an actual analog signal.  With a lower sampling rate I can get an accurate frequency reading, but the indicator does not switch on and off quickly enough when I have the analog signal above the threshold 25 times per second.  With a higher sampling rate, the indicator switches fast enough, but the frequency is not detected accurately (it will show a frequency around 4k and updating too quickly to read).

0 Kudos
Message 5 of 12
(4,295 Views)

Hello Amad,

 

So I was also able to run this code using a simulated signal and observe expected behavior. This makes me think you may be having a hardware issue. If you could provide a little more information we can hopefully move towards resolving this issue.

 

First, what hardware device and which drivers are you attempting to interface with? Which version of Windows and LabVIEW are you using? 

 

Were you succesful in creating your task in the Measurement & Automation Explorer (MAX)? Can you succesfully self-test in MAX? Do you see signals as expected? It might be worth your time to check and see if the shipped LabVIEW example VIs will run correctly with your hardware. For instance, can you succesfully run the 'Voltage - Continuous Input.VI' example VI and see expected results?

 

Again, this looks like it may be a hardware issue. The next step is therefore ensuring that your hardware is working correctly.

 

Good luck,

 

Andy C.

Applications Engineering

National Instruments

0 Kudos
Message 6 of 12
(4,263 Views)

Andy,

 

I'm using LabVIEW 11.0 on WIndows 7 with an NI USB 6009 DAQ.  I am using some accelerometers and the signal appears correctly when I view them on a graph or when I test it with NI-MAX.  I have provided an image to better describe my issue.  When the green line goes high, this indicates that my amplitude has gone above the threshold (blue line) and my signal is the red line.  As you can see in the second half of the graph, my indicator isn't able to see these other times that my amplitude is high. 

0 Kudos
Message 7 of 12
(4,235 Views)

Andy,

 

I'm using LabVIEW 11.0 on WIndows 7 with an NI USB 6009 DAQ.  I am using some accelerometers and the signal appears correctly when I view them on a graph or when I test it with NI-MAX.  I have provided an image to better describe my issue.  When the green line goes high, this indicates that my amplitude has gone above the threshold (blue line) and my signal is the red line.  As you can see in the second half of the graph, my indicator isn't able to see these other times that my amplitude is high. 

Download All
0 Kudos
Message 8 of 12
(4,233 Views)

Hi Amad,

 

maybe you should attach your VI too?

How do you generate those plots?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 12
(4,215 Views)

Yes, here is the updated vi.  Thanks

0 Kudos
Message 10 of 12
(4,192 Views)