From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Detect RPMs using Hall magnetic sensor.

Hi all,

 

I'm currently working on a project to detect RPM of a shaft by using a Hall magnetic sensor and 1 magnet. 

 

I've figured out a way to count the edges of the Hall sensor (digital) in order to count the total number of turns, but I cannot seem to figure out a way to convert that into RPM. I have tried using feedback loops, feedback loops with delays, formula nodes inside for loops, creating sub-VIs that use their own timer, and all kinds of other combinations. The code below is just the latest thing I've tried.

 

 

Everything on the left is the motor motor control. Any help with this would be greatly appreciated. It's driving me crazy that I can't figure it out!

 

 

Thanks,

r0nius

 

rpm.PNG

0 Kudos
Message 1 of 4
(4,937 Views)

What DAQ card are you using?  Do you have any counter inputs available?  I have never used a counter in my applications but they use onboard clocks to count edges. There are lots of examples in the Example Finder on the Help menu.

 

I have used an analog input line to measure RPM signal from a laser encoder.  Basically it reads the output from the encoder (square wave signal) for a certain time period (i.e. 300ms) and then, using the frequency VI in the Mathematics pallet, I can calculate the speed during that 300ms time frame.  In my situation, I am measuring the RPM of a fan and so I have to divide the frequency by the number of blades on the fan to get the actual number of revolutions.  Each sensor is different.  Some, for example may output 60 pulses per revolution, others maybe more or less.  If you have an accurate timebase, a known number of edges within a certain amount of time, and a fixed number of pulses per revolution, the unit math is pretty simple. 

 

So let's say I acquire analog data for 300ms.

The frequecy VI tells me that during this time period, the frequency was 350 Hz, which is 350 pulses every second.

Now lets say that your encoder is set to output 30 pulses every revolution (1 pulse every 12 degrees).

So at that moment in time, the motor spun 350/30 = 11.7 revolutions per second.(If you only get 1 pulse per revolution....skip this step).

Multiple by 60 seconds = 700 RPM

 

Hopefully my example is not too convoluted and helps you.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 4
(4,899 Views)

I'm using a myRio 1900.

 

Yes, I agree the math is simple. However, I can't find a way to calculate the difference in ticks per second.

 

I can count the edge triggers just fine, which gives me the total number of revolutions. I need to go one step further:

 

Get a counter value

Wait some ms

Get new counter value

Subtract the two (change in counter value)

divide by ms -> (change in counter value/second)

multiply by 60 -> (RPM)

 

The Hall effect sensor only detects whether a magnet is in its vicinity, nothing else. So it's a digital signal, 0 (magnet close) or 1 (no magnet).

0 Kudos
Message 3 of 4
(4,893 Views)

I'm pretty sure you're taking the wrong approach here.

 

It looks like you're hoping you can poll your digital input 1000 times per second, find the times where it transitions, and then calculate RPM from there.

 

You should be skipping that and asking your hardware directly to do the polling for you, and then just ask it for the results.  

 

When you set up the input channel, you almost certainly set it up as a single digital input.  Instead, you should have set it up as either a digital input with 1 channel N samples, or as a counter.  A counter is preferable but I don't know if one is available on a MyRIO off the top of my head.

 

The reason is that LabVIEW isn't "real-time", meaning that even though you want to have each loop last exactly 1 ms, all adding that timing function in there does is guarantee that the loop will wait at least 1ms, but it might wait a fair amount longer.  It all depends on whatever else your PC is doing at the time.

 

You really want to outsource all precise timing jobs to your hardware and have it give you data either in the form of a boolean waveform with each measurement taken exactly X seconds apart, or a count of false-to-true transitions since the last time index you reset the counter.

0 Kudos
Message 4 of 4
(4,883 Views)