NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Sensors, Actuators, and Robotics » Hall effect sensor - increasing speeds

January 13, 2013
by mcgroover
mcgroover's Avatar

Hi,

I have set up a system for measuring bike wheel speed. It works well when the speed is low, but when I speed up the wheel, the microcontroller doesn't seem to pick up all the revolutions (maybe 1 in 5).

I put a magnet on the wheel and set up the hall effect sensor (http://sensing.honeywell.com/product%20page?pr_id=45312) with my nerdkit. I set it up via the instructions: Middle pin going to ground, and a 750 ohm resistor across the other two pins.

I am at a loss as to why speeding up the wheel makes the system fail. The switching capability of the sensor is 100KHz and I am measuring the voltage of the sensor on every microcontroller cycle (not using interrupts). I thought potentially I might need a pull up/pull down resistor, but I am not sure.

Any ideas?

January 13, 2013
by JimFrederickson
JimFrederickson's Avatar

It would be helpful if there were some actual numbers associated in regards to your statement:

"It works well when the speed is low, but when I speed up the wheel"

What is "the speed is low"?
What is "when I speed up the wheel"?

Those are subjective statements. Actual numbers would be helpful. How are you determining it is "missing revolutions"?

Just because you are spinning faster, or do you have some other method of counting for testing purposes?

Most likely the problem is a "coding problem". If you are getting any consistent readings from your ADC that seem to be what you expect the most likely the hardware is working.

I would though:

1 - Make sure that the connections to the Hall Affect Sensor are soldered.
    (They probably already are, but just in case...)
2 - Use longer wires to your breadboard, and make sure the wires are anchored
    prior to connecting to your breadboard.
3 - Make sure that the bicycle tire and breadboard are on separate surfaces.
4 - Make sure your magnet is as close as possible, try doubling up your 
    magnet too. (While getting your magnet "extra close" may not work
    in a "production/live environment" right now you are testing so this
    may help.
5 - Make a graph/marks on the tire, when the magnet is first detected, maximum
    detection and last detection.  (This could help with creating a mental
    picture of what is happening mechanically.

These steps should help eliminate vibration as a potential problem, and give you a better understanding of what is happening physically. A graph/marks will also give you the ability to determine what your "timing" will be for detection of a range of RPM's.

If anywhere in your code you are using any "delay_ms()" function calls look at those carefully. They could be causing problems.

If you are updating your LCD Display Continuously, you should change that to update the display at some "timed interval", or otherwise determined interval. (A "timed interval" will require a time base of some sort.)

The "primary purpose" of your code is to "count revolutions", displaying the results is a necessary but "secondary purpose". Your code should reflect that as well.

If at some point in time you expect/plan to be able to do actual "RPM's" other than just "counting revolutions" you will need to implement a time base of some sort. That will require a timer and interrupt to do well.

January 14, 2013
by Ralphxyz
Ralphxyz's Avatar

If you are getting any consistent readings from your ADC

mcgroover, are you using the ADC or looking at pin change?

And like Jim asked how are you "timing" your revolutions?

Ralph

January 17, 2013
by Keyster
Keyster's Avatar

Hey Groov,

i have not used the ADC in a while but if memory serves it is not an instantaneous reading. once you fire it off your program "waits" for it to take numerous readings and then it averages them and then spits the answer out. this may be the the delay you are having problems with. i wrote a Bicycle POV a while back and just used the interrupt to take the reading and it never missed a beat. if you are totally not wanting to use interrupts then you could just watch for a PIN change and take your reading each time it does.

i would say the only time you would use the ADC with a HALL Effect sensor is if you needed to know the distance the magnet is from the sensor (and you had a sensor that worked like that).

on my POV i used rare earth magnets that i ordered from somewhere in china (probably DealExtreme) and i did not have to get the magnet very close to the sensor at all. they are about half the size of a dime and twice as thick. if you want to check it out go over to www.bryankey.com and click on the electronics page.

Bryan

January 27, 2013
by mcgroover
mcgroover's Avatar

Hi all,

Thanks for your replys and apologies for my late reply.

So to clarify a few things:

  1. I am actually just pedalling the bike, so for me to make an estimate, the "low" speed would be a 2-3 RPMs, and the fast would be about 3 times that.
  2. I am using the pin change, not the ADC (probably should have made that clearer in my original post).
  3. I am not using any interrupts and just measuring the pin voltage on every microprocessor cycle.
  4. I have actually already converted those measurements to update speed on my screen. (Basically working out after each detection how long it has been since the last detection).
  5. The reason I can tell it is not picking up the magnet is a) the speed doesn't update and b) the speed reading is very inconsistent, it can change from 1 to 9, back to 3 with approximately the same speed of the wheel. This would also happen because if it misses a few revolutions, the next speed update would be very low.
  6. There are no delays in my code.

I did an interesting experiment that might help solve this. If I just agitate the wheel when the magnet is near the sensor, it does pick up all of the detections at a higher "RPM" (even though the wheel itself is not going through a full revolution). What this tells me is that the system is capable of picking up increasing RPM speeds (which I think could eliminate coding (?)), but has trouble when the linear speed of the magnet increases.

I am wondering whether the sensor needs a stronger magnetic force when the magnet passes by faster in order to detect it and maybe I need the rare earth magnets Bryan suggests.

I guess the only other factor is that higher linear speeds also means an increase in vibrations. The reason why I feel the vibrations shouldn't matter is that the sensor can switch when the magnets are within about 7mm and my setup has the magnet about 2mm from the sensor, so I wouldn't expect vibrations to move it 5mm back and forth.

Thanks for your input!

January 27, 2013
by mcgroover
mcgroover's Avatar

Bryan, are these the sort of ones you used?

http://dx.com/p/super-strong-rare-earth-re-magnets-15mm-x-1mm-10-pack-10303

Nice project. The whole POV concept is very cool.

January 27, 2013
by JimFrederickson
JimFrederickson's Avatar

The reasons that I thought you were using the ADC are when you posted:

I am measuring the voltage of the sensor...  
just measuring the pin voltage...

Technically what you are doing is not "measuring voltage", but rather you are "measuring/reading/checking the logic level". (Either a "0" or a "1"...)

You should also "track revolutions", at least during your debugging period. More information is almost always more helpful than "less information". Also since you are only viewing "processed information" there could be some issue regarding your algorithm.

What is "speed" to your application?

"Speed", is by definition the "rate of motion"...
is "imebase" for determining this rate?
(you said in your post "I have actually already converted those measurements to update speed"...)

Your "speed measurement" is: "inches/second",
"feet/minute",
"miles/hour",
"Revolutions/hour"?

Also in order to calculate "speed" you need to have a "timebase".
(Also in your post "working out after each detection how long it has been since the last detection"...)

Where is this "timebase" coming from?

You had said "I am not using any interrupts", is that true or did you just mean in the reading of the Hall Affect Sensor?

Are you using an interrupt to generate your "timebase"?
If there is no interrupt being used to generate your "timebase" how are you determining "how long it has been"?

I think I would get rid of your "750 ohm resistor" and just use the "internal pull-up on your I/O pin". The Hall Affect Sensor you are using is already grounding your I/O through it's output pin so the internal pull-up on the Atmel Microcontroller should work without problems. (One less component to be concerned about.)

It doesn't sound like vibration is an issue, but your could temporarily mount your hall affect senor, or the magnet, on some folded over tape. (Whichever of those 2 components that is stationary...) That way that tape can side over the other component and the affects of vibration would be reduced for testing purposes. You wouldn't be able to run longterm that way, well maybe with mylar you could, but for testing it could be helpful.

Is your I/O from the Hall Affect Sensor "debounced and validated"? (Well probably
"debouncing" is not necessary, but validation is definitely necessary.) Your Program should be "waiting for a valid detection state" and then it should be "waiting for a valid no detection state". (you will need to determine what a "valid detection state" is for your Application.)

January 28, 2013
by Keyster
Keyster's Avatar

Hey McGroover,

i am not sure if that is the same magnets, i am at work right now but will measure them when i get home tonight and post results. those look much larger in the picture BUT if they fit your situation and are very strong (which rare earth ones usually are) they should work fine.

i was thinking more about your problem. are you displaying the speed on an LCD screen or something like that? if so, i have run into problems where the LCD display slows things down tremendously (in CPU time anyway). if this is the case here is what i would do, in fact, i would probably do this anyway just to "know for sure".

turn off the display, in other words don't display any information. just blink an LED when the magnet is detected. maybe toggle it. turn it on the first time around and then turn it off the second time around, etc. this will tell you if you are missing a "detect" or if something in the code is going bad. if you go back and look at my video you can see that I blink an LED every time my board passes the magnet. i originally did this so i would know when it was firing but just left it because i liked it being there as a "magnet marker".

like Jim asks; are you using an Interrupt to capture the time per revolution? if not, how are you getting the time without an interrupt?

January 28, 2013
by Keyster
Keyster's Avatar

hey McGroover,

the magnets i used with that project are 8mm diameter and 3mm thick. i also went to dealextreme and checked my orders all the way back to 2009 and did not see any magnets in the list so i must have got them somewhere else. heck, i may have picked them up at Radio Shack a long time ago.

the main thing i would do is try blinking the LED like i mentioned earlier. since there is (virtually) no lag in that it will help narrow down the timing problem.

bryan

March 06, 2013
by BStory
BStory's Avatar

Maybe you could put a magnet on each side of the wheel to help with the balance. Account for that in code. Also, I agree with Jim that tracking the revolutions would be a good idea. It would be impossible to count the wheel rotations but you could count the peddle rotations and find the wheel to peddle ratio. You could slowly spin the peddle 1 or 5 or however amount of rotations and count how many full rotations the wheel makes. So if you spin the peddle 1 full rotation and the wheel spins 8.6 times, just multiply your peddle rotation count by 8.6. You know it's working right when your count is pretty close to your measured rotations.

If you use the 750 Ohm and the internal pullup resistor, the total resistance will actually be a little smaller than 750 Ohms because they are in parallel... I don't really know that it matter anyway but the datasheet for your sensor, in the wiring design that doesn't use the pnp transistor, recommends 10k Ohm between VCC and your pin. There are quite a few different applications on that sheet.

According to the sheet, when it activates it pulls the pin low(Am I reading that right?). Using a pnp transistor might not be a bad idea. At the least, keep in mind that the line is at +5V in it's idle state and pulses to 0V when the sensor activates.

Post a Reply

Please log in to post a reply.

Did you know that our customers love us? Learn more...