Magnetic switch to mechanical counter
Buck Rogers
Posts: 2,187
in BASIC Stamp
Hello!
I have two mechanical counters here, one uses 24v to click its armature to increment its displayed count. And the uses 12v to do the same thing. And also a collection of NC (Normally Closed) reed switches, and a collection of NO (Normally Open) switches as well. I'm brainstorming for a simple program that would wait for the switch to either open in the case of NC ones, or conversely close for the NO ones, and then cause a connected solid state relay to have one of the two, simply count.
It's the glue in the form of a BASIC program that has me peeved.
---
Mascot away.
I have two mechanical counters here, one uses 24v to click its armature to increment its displayed count. And the uses 12v to do the same thing. And also a collection of NC (Normally Closed) reed switches, and a collection of NO (Normally Open) switches as well. I'm brainstorming for a simple program that would wait for the switch to either open in the case of NC ones, or conversely close for the NO ones, and then cause a connected solid state relay to have one of the two, simply count.
It's the glue in the form of a BASIC program that has me peeved.
---
Mascot away.
Comments
This bit of code samples the inputs and waits for a change. By using XOR we can find the pins that changed state -- a "1" bit in delta tells us the corresponding input changed. By looking at the actual value in the last scan, we can respond to that input as required.