Shop OBEX P1 Docs P2 Docs Learn Events
Issue using Hall effect sensor and COUNT — Parallax Forums

Issue using Hall effect sensor and COUNT

Regards to all,

I'm using a Hall Effect sensor (Melexis 90217) and a BS2 to attempt to measure the RPM of an automotive cooling fan. The fan is not at the moment mounted in a vehicle, it is simply on a workbench powered by various power supplies. The magnet that triggers the sensor is mounted on the rotating portion of the fan about 3" from the motor axis.

The sensor is wired per the datasheet with the correct value cap and resistor (see attachment).

Following is the code I'm using...


' {$STAMP BS2}
' {$PBASIC 2.5}
MagnetPass PIN 7 'Hall sensor detects magnet pass - pin 7
Capture CON 2000 ' 2 second sample time
cycles VAR Word ' counted cycles
Main:
DO
DEBUG CLS,
"FAN SPEED", CR
PAUSE 500
COUNT MagnetPass, (Capture */ $100), cycles
DEBUG CR, DEC (cycles * 30), " RPM", CR 'multiply counts by 30 to derive number of counts per minute
PAUSE 1000
LOOP

When the fan is powered by a desktop DC power supply, the fan will draw about 3 amp and 7 volts and produces an RPM of around 1000 when using the above code. Since I have no way of independently measure the RPM, I've no idea if that is actually correct, but it seems reasonable.

When I power the fan with a 12 volt auto battery, it runs much faster (advertised at about 3000 RPM). When I run the above setup on it, the RPM's show as 0 (zero).

I don't have a way to "ramp up" the power to the fan, I either have my bench power supply, or switch to an automobile battery, thus no way to tell at what voltage the RPM indication drops to zero.

The possibilities that occur to me...

1. This isn't an appropriate use of the COUNT command.

2. The BS2 isn't an appropriate microcontroller for this task.

3. My code is just wrong.

4. ???

Any help would be appreciated.

Thanks,

John

Comments

  • WBA ConsultingWBA Consulting Posts: 2,933
    edited 2018-08-13 21:26
    Which BS2 module are you using? The higher RPM may be sending pulses too fast for the BS2 to count. Look at Page 149 of the Basic Stamp Manual to see the comparison of the different BS2 modules as well as the speed capabilities of the COUNT command. https://www.parallax.com/sites/default/files/downloads/27218-Web-BASICStampManual-v2.2.pdf

    EDIT
    Do you have a scope to measure the pulse width coming from the hall effect sensor?
  • I'm confused about the DURATION in your COUNT command.
    COUNT MagnetPass, (Capture */ $100), cycles
    DEBUG CR, DEC (cycles * 30), " RPM", CR 'multiply counts by 30 to derive number of counts per minute
    

    If you are using a plain BS-2, then the duration is specified in units of 1 ms, and 2000 would get you 2 seconds, times 30 gets you rpm.

    Why the */$100 operation?
  • It isn't something odd like the higher fan speed changing the geometry between the magnet and sensor, is it? :D
  • I hooked up a BS-2 and saw that */ 256 doesn't do anything, so that is clearly not the problem. But I'm still curious; why do it?
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2018-08-13 23:23
    */ $100 is unnecessary--Is the same as multiply times 1. (256/256)

    I wonder about the MLX sensor itself. It may be fairly low speed and fail to respond to faster pulses.
    It claims a bandwidth of only 15kHz. Tthe data sheet is short on details of what that means in practice.
    The sensor is reading flux into an analog to digital converter, and then doing some math processing, and only then coming up with a digital output. The math helps it adjust to differences in bias. But all that takes time.

    The BS2 should be able to count up to 120kHz, so I don't think the problem lies there or with your program. This is one of those things where a 'scope would be helpful to visualize what is going on.

    Have you tried playing with the position and orientation of the sensor? In the data sheet, the magnet is placed behind the sensor so that it can detect gear teeth. A simpler Hall effect or magnetostrictive sensor might be better for your purpose where the magnet is flying by.


  • Hi again,

    Just a further explainer about this project, and some answers to questions/comments.

    The vehicle in question no longer has an engine driven fan or water pump. The water pump and fans are controlled by a device that changes the speed of the water pump, and turns on (or off) the fans depending on engine coolant temperature.

    This make for a very efficient system, with one exception. The controller will run the fans regardless of the speed of the car. What I'm trying to determine is that speed at which the fans, when powered, are no longer helping.

    I'm using a BS2. I have some of the "faster" modules, as well as a propeller.

    The magnet can't really be changing orientation. It's very firmly seated, so I'm confident that's not the issue.

    I'm breaking out the prop scope to see if I'm missing pulses.

    The reason for the "/100" was that it was in the code that I originally copied to get this project going. As it turns out, it doesn't seem to do anything, so I've removed it, which hasn't solved the issue.

    Should have more data soon. Thanks for all the responses!

    John
  • Just a thought...
    I'm wondering if this sensor responds properly to a "flying magnet" since the datasheet suggests that the South side of the magnet should be glued to the unmarked side of the sensor and the marked side facing the flying metal. I believe it is looking for a change in a magnetic bias and not so much the presence or absence of a magnetic pulse.
    Or maybe just use a Hall Sensor that isn't quite so "smart".
  • Todays results...

    I'm rusty on the PropScope, but at lower speeds the pulses from the sensor were in pretty good agreement with the code. At 7 volts and 5 amps, the PropScope showed a pulse rate of 24 Hz, which is about 1440 RPM, which was pretty close to what the code would show.

    The acid test was hooking up the fan to the car battery. Pulse rate varied between 36 to 45 Hz (2100 to 2700 RPM) and the code again showed RPM of zero.

    One interesting observation. When the 12 volt car battery is taken off the fan, it naturally takes the fan some time to spin-down, maybe 10 second or so. During this spin-down period, the code RPM's continue to show zero. However, when I'm using a bench power supply at 7 volts/5 amps, I can watch the code RPM's decrease as the fan spins down. Part of me wants to reason that the magnetic field of the motor at 12 volts is playing havoc with the sensor, but since the magnetic field collapses when the power is taken off (or does it???) I would think I should still see spin-down RPM's.

    I don't have it in front of me at the moment, but now I do remember something about attaching the magnet to the sensor. I'll dig that out and reconfigure the set up.

    Oh, just for laughs I had a BS2e lying around. I threw that in the mix, no real change.

    Thanks,

    John

  • cavelambcavelamb Posts: 720
    edited 2018-08-31 03:28
    Sounds like the Hall sensor is being swamped by the motor's magnetic field.
    Can you spin the fan by hand and see RPM?

    Counter EMF of the motor spinning down?
Sign In or Register to comment.