Hi to all.
I’ve decided to control actuator using Arduino. It is necessary to track the number of revolutions of the motor actuator for this purpose it has a built-in reed switch. How to programmatically make the engine rev counter?
Hi to all.
I’ve decided to control actuator using Arduino. It is necessary to track the number of revolutions of the motor actuator for this purpose it has a built-in reed switch. How to programmatically make the engine rev counter?
Do you know what signal levels this reed-switch provides? Is it safe to connect it to an arduino? If you are not sure about this then I would worry about the electrical side of the problem first.
From a programmers point of view it is not that much different from detecting a button state change, except it is reading the logic level of the reed switch. Polling the pin for a changed state would be the simplest, but might not result in proper timing of the pulse repetition. As a final stage it’s probably better to use an interrupt routine with or without the built in comparator pin.
I would start with a program that detects the state of the reedswitch, and lights up a led on another pin (built in led on pin 13 would do fine). Just to be sure you are detecting it. Then if that works record the time since the last level change using the function millis() (or micros depending on the RPM) to determine the revolution period.
The problem is that when the magnet goes through reed-switch it changes its value 300 times: it is shorted and not.
Here reed-switch values:
1023
1023
1023
1023
1023
1023
764
1023
1023
1023
1023
1023
840
1023
790
1023
1023
1023
1023
992
1023
1012
1023
1023
1023
781
1023
1010
1023
1023
1023
1023
1008
1023
1023
1023
1023
1023
1023
1023
1023
1023
1023
955
1023
Actuator PA-03 from http://www.progressiveautomations.com
Well, just like press-switches, reed switches can bounce too. So you need a bit of filtering in there. A capacitor to ground on the input pin should help alot.
That said, if you use the pin as a digital input (it is an onoff switch remember) then it will not fluctuate as much. Those analog values seem to be above the Input High voltage threshold.