LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculating frequency with hall effect sensor and arduino

Hello, my current VI is using LINX to get voltage measurements from an arduino analog pin and displaying the data (current,power etc). I have a hall effect sensor set up that would get the pulses from a vibrating structure and potentially display the frequency at which the the structure is vibrating on the same VI. How can i implement this with my current design? I have tried to come up with a way to count the number of pulses in LabVIEW but couldn't find a way to efficiently do that so i can do the calculation of the frequency.  Any help will be appreciated. Thanks

0 Kudos
Message 1 of 6
(2,999 Views)

Hi marios,

 

how do you want to detect and count pulses when all you have a single sample in the loop? Usually you need an array of samples!

 

What's the point of that wait function set to wait for ~4e9 ms?

Why did you delete the labels of those controls?

Best regards,
GerdW


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

Hi GerdW,

As you can understand I'm a beginner with labVIEW, how do you mean by a single sample in the loop? It keeps looping with the frequency of the arduino serial i thought until i hit the stop button. the wait function I've put it there as a way to not start unless I press the start button on the front panel of the VI.

 

Thanks,

Marios

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

Hi Marios,

 

the wait function I've put it there as a way to not start unless I press the start button on the front panel of the VI.

You completely miss to THINK DATAFLOW with that wait function!

That wait runs in parallel to your case structure: all it does it to prevent to VI from stopping - but it will not prevent executing the case structure…

 

how do you mean by a single sample in the loop? It keeps looping with the frequency of the arduino serial i thought until i hit the stop button.

Yes, the inner loop keeps running. With each iteration you read just one sample from your Arduino. You plot that single sample in a chart.

To detect and count pulses you need to collect your samples in an array.

This is pretty basic LabVIEW stuff, so I suggest to take the Training offers in the header of the LabVIEW board:

check.png

Best regards,
GerdW


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

Hello,

 

I have updated my VI with a solution, it is currently able to count the pulses of the hall effect sensor and display the number but I don't seem to be getting a correct value from the frequency calculation. I am doing the following calculation to find the frequency (1/elapsed time(s))*counter).

 

Best regards,

Marios

0 Kudos
Message 5 of 6
(2,928 Views)

What is the maximum frequency expected from the hall effect sensor?

 

The arduino on its own might not be fast enough to sample and count each pulse event from the sensor.

 

Are you using interrupts or polling to check the pin state? What else is the arduino doing?

 

I have done similar things in the past, but the microcontroller wasn't fast enough for my application.

I ended up using a dedicated 32 bit counter chip connected to the microcontroller over SPI.

I then polled the counter chip at fixed intervals to obtain the frequency, then reported this value back to the main application.

 

0xDEAD

0 Kudos
Message 6 of 6
(2,916 Views)