I'm trying to read rpm from 2 pin hall sensor ATS642. I've succesfully managed to get the signal from it. Each time as metal object passes it generates a pulse.
Without metal touching it/passing by - 630mv
With metal touching it/passing by - 1280mv
The signal is stable and nice. BUT when I hook up wire to arduino - and use sketch with interrupt... it just does not work. Arduino does not detect FALLING/RISING.
Your high level at the Oszi is around 700mV. To get high level you need 2V minimum.
I suggest for the software to have a two state statemachine. One state for rising edge one for falling edge.
The interrupt sloap can be set with the EICRA Regsiter
#define EICRA_RISING_EDGE 0b00000011 // EICRA bit ISC01 and ISC00 are set, rising edge
#define EICRA_FALLING_EDGE 0b00000010 // EICRA bit ISC01 is set, falling edge
#define EICRA_CHANGE_EDGE 0b00000001 // EICRA bit ISC00 is set, change edge
eg
EICRA = EICRA_FALLING_EDGE;
Then measure the time when rising edge was detected, adjust interrupt to falling edge and once falling was detected take the time again. Then calcualte the delta and adjust interrupt to next rising edge and so on..
Hello Victor
I suggest to use the Analog Comparator like jremington already has menthoned.
Check the Atmega 328 Handbook with chapter "Analog Comparator". Within the comparator there is already an interrupt generation included. So would perfectly fit.
This is correct, but the wiring diagram is not.
Try using the sensor between pin and ground (polarity matters).
The resistor then goes between pin and 5volt.
The FALLING pulse (produced by the sensor, not the resistor) could be sharper than the RISING pulse.
Leo..
So its clear that voltage is below factory threshold that arduino can detect.
So how do I increase signal voltage without increasing 5v that are sent to sensor? Can you give me schematic? I have LM393 comparators but don't know how to wire them properly (I thought that comparator can strengthen the signal).
The output will go LOW when the input goes above about 970mV and the output will go HIGH when the input drops below 890mV
For the unused comparaors, connect the + input to ground through a 10K resistor and connect the - input to 5V through a 10K resistor