Hi from Australia.
I am using a simple normally open limit switch to signal the end of stroke for a farm machine. This uses an interrupt plus calculation to reveal the RPM of the device. The Arduino then triggers a relay if the RPM is above 0. Arduino deactivates the relay if the RPM is 0. Thats the easy part. The trouble is, if the implement stops at the point when the switch is closed, the relay is then continuously ON until the switch is in the open position. I
ve tried several online rpm and mph sketches but all seem to have the same drawback.
Basically, the farm implement has to be moving for it`s pump to be operating, but when it stops, the pump needs to stop.
Any help would be greatly appreciated.
Implement a statechange detection on the limit switch. You want to detect when it becomes activated, not that it is activated.
Ok, been reading the tutorial on state change, but do I insert the code for it in loop or the interrupt routine?
Thanks, Greg.
You need to post your program so we can see what you can see.
And I strongly recommend that you change your user name to something other than your email address unless you enjoy being flooded with spam.
...R
Hi,
Welcome to the forum.
How many RPM does the shaft rotate at?
Tom...
How can a single switch detect zero RPM? Zero in your case will always be "less than a certain speed".
As you use an interrupt, you're probably dealing with high RPMs (like well over 1000, otherwise using the interrupt wouldn't be necessary). I don't think your limit switch will survive long. For that part, you may want to look into a contactless solution: optical or magnetic.
Problem solved. I was thinking too technical. As was pointed out to me, why was I using an interrupt to just detect movement at low rpm? So I just used a digital input and some simple calculations using millis() to detect motion between certain thresholds.
Thanks guys you made me think outside the square and found the simple, obvious way.