I'm trying to use this sensor to measure the RPM of a spinning frame and am running into a issue with the sensor not triggering. If I hold a magnet over the sensor the interrupt (which just does a simple subtract op) works fine but anything over 10 RPM results in a small blip on the LED I have attached to it but not a registered change. I examined the datasheet (which I've provided a link to at the bottom) and it says the switching time is 1us for rise and fall, which is a few hundred times faster than a person can blink and should definitely catch the change.
In the datasheet their data assumes the sensor runs at 12v (which mine does) and then references a resistor RL and capacitor CL (in the output switching time section). I don't see these in the sample usages so this does mean anything in the context? My setup is just the 10k pullup from value to vcc.
I could see where the lack of a filter/capacitor could result in increased rise time but how would this be configured (inline RL with CL vcc to ground)?
What is the behavior when manually spinning the object to be read? Sensor positioning is rather critical and is in many applications going to have to be a "tweak until it works" approach unless you have a field strength meter to sniff for the range of fields the hall effect device wants. You may even have to place a small weak magnet behind the hall device to to bias the local field around the sensor such that the field interaction with the sensed object results in a readable net field at the sensor.
The magnet sensor is stationary with the "face" of the IC facing towards magnet. The magnet is mounted to the spinning frame. I tried changing distance and placement to no avail. Placing a magnet behind the sensor would not work as it is a omni/bipolar hall effect sensor so that would just register as "magnet sensed".
My current fix is to use a "latching" hall effect sensor instead and place two magnets on the frame, one facing +pole and one -pole then divide time by two (since I just want 1 full revolution and not two). This is quite unfortunate as I think the other solution is more elegant but whatever works...
Does anyone have any insight into the data on that capacitor and resistor in the datasheet?
Placement of the bias magenet isn't necessarily behind the sensor. Its purpose is to aid or oppose the sensory magnet's field. What kind of read distance do you have?
have you tried to measure the output with an oscilloscope.... if output current it higher than 5v arduino wong recognize it....... or have you check the scketh???
nd then references a resistor RL and capacitor CL (in the output switching time section). I don't see these in the sample usages so this does mean anything in the context?
RL and CL are not meant to indicate a load you must have, they are the test conditions under which the measurement was made. Not having an other capacitor will make the rise time faster. Adding a capacitor will only slow things down. Your 10K pull up is your value of RL, CL is defined by the stray capacitance of your arduino input pin.
n the datasheet their data assumes the sensor runs at 12v
I don't see any evidence of that. If it were me I would run it off 5V. You are not damaging the arduino anyway because the output is an open collector output.
What software have you got? It is possible that you are not sampling the input fast enough to see every pulse. Can you post your code.
I don't have an Oscilloscope so I haven't been able to check the signal directly but you are right -- I forgot to mention that I run the 12v output of the sensor through a 1kohm resistor that is hooked up to an LED in parallel to the arduino input. The resistor brings down the signal to 1.7v/10ma which is enough to not explode the LED and input but enough that it should definitely trigger an interrupt (at least I believe it is).
The sketch works when I apply and remove the magnet with a slower speed than the frame spins at. It's only when it is moving fast that I don't get the expected result.
I forgot to mention that I run the 12v output of the sensor through a 1kohm resistor that is hooked up to an LED in parallel to the arduino input.
When you said:-
My setup is just the 10k pullup from value to vcc.
Do you mean 12V?
If so disconnect it at once, because you are putting 12V into the arduino input, yes I know it is through a resistor but that doesn't matter it is still bad.
Connect the output directly to your arduino input and put a 10K pull up resistor to +5V. Do not connect an LED at the same time. It is probably the capacitance of the LED that is swallowing the narrow pulses and stopping you generating the interrupts.
beginRun() is called right before the frame starts spinning.
void interrupt_rotationDetected() {
if ( LCDM_RUNNING != lcdScreenMode ) {
return;
}
// softStart allows a grace period so skip check
if ( timeElapsedSinceStart < softStartRampupTime ) {
return;
}
int timeMs = millis();
int timeDifMs = lastRotTimeMs - timeMs;
lastRotTimeMs = timeMs;
float rps = 1000.0f / timeDifMs;
state.observedRpm = (int)( rps * 60.0f );
}
interrupt_rotationDetected() is the interrupt handler that is called when a change is registered on the interrupt pin (which in this case is arduino pin2, interrupt pin 0). observedRpm is declared as a volatile int.
Interesting, I think I see what you mean about the LED "swallowing the capacitance" (I had originally thought it was due to the inductance caused by the battery and PWM) but could you elaborate on what you mean on using a pullup to +5v?
The reason I use 12v to the sensor is because I piggyback off the same power that goes to the motor to reduce the number of power wires going everywhere. When I put the resistor in and hooked it up to the LED I figured it would be safe enough to connect to an Arduino Pin. Can you explain to me why this is incorrect? If I'm feeding 12v to the sensor but (and I am probably misunderstanding you) connect the pullup to the IC +5v supply that seems like a VeryBadThing, no?
I'll see about getting a picture tonight but basically the sensor hookup goes:
Motors are noisy devices even under the best of days, powering a sensor off of a motor leg can make the sensor not respond, or give errant output. Great pains and costs go into installations to keep sensory circuitry far removed from any load bearing circuit.
When I put the resistor in and hooked it up to the LED I figured it would be safe enough to connect to an Arduino Pin. Can you explain to me why this is incorrect?
Because when the output is off you have connected the arduino input pun to 12V. The maximum permitted voltage on an input is the supply voltage plus. 0.5V, it is in the data sheet.
So connect the pull up to 5V, loose that 1K resistor and remove the LED.
The 1K is slowing down the rise time because it is acting along with the stray capacitance on the input to make a delay or low pass filter.
If I'm feeding 12v to the sensor but .......... connect the pullup to the IC +5v supply that seems like a VeryBadThing, no?
No, it is a good thing, I don't understand why you might think otherwise. You then have the situation where you have no more than 5V on an input pin.
The sensor's output is open collector so you can connect it to where ever your want.