PDA

View Full Version : Input pin help



Adrian
- 1st July 2007, 15:30
I would be very grateful to receive some help, advice, suggestions or techniques that I might utilise in a lap counter that I wish to construct. Basically the laps are counted manually by a timekeeper who activates a microswitch. I can debounce that OK. With a change of state I can decrement a constant in EEPROM and make that activate other circuits. That’s OK as well. As a beginner I am struggling with how to look at the state of the input pin to ensure that if the timekeeper holds the microswitch down the software will ignore this 'constant' state ie I want the software to respond to a rising debounced pulse and not reactivate until the pin has gone low again. Is this straightforward? I hope this is clear...

Many thanks for any advice

Adrian

mat janssen
- 1st July 2007, 15:51
Look in the book that came with your Picbasic pro at while......wend

Adrian
- 1st July 2007, 17:29
Hi Mat

Thank you for replying. I'm still unable to fathom out how this helps. Please put me right. While...Wend allows me to check the pin status while, for example, the pin is high but if the timekeeper holds down the microswitch then the pin will be held continually high and my 'checking' will continue and therefore continue to decrement the following counter etc. What I want is the pin to go high from the timekeeper, check the circuit (decrement the counter) and be unable to check again until the pin has gone low (timekeeper releases the microswitch) and then goes high again (he presses it again). Every time he presses his switch the value in the EEPROM is decremented towards zero. If the pin is held high continually, how do I stop the loop rolling round and repeadedly decrementing the counter?

Adrian

mat janssen
- 1st July 2007, 19:35
With the folowing lines an input pin gives a pulse during 1 complete program cycle and a new pulse wil be generated after changing the input state back to 0 and brought back to 1 again yust what you want.

HULP0 VAR BIT
PULSE VAR BIT

INPUTPIN VAR PORTX.Y

PULSE = INPUTPIN & ~ HULP0
HULP0 = INPUTPIN

succes with it.

Adrian
- 1st July 2007, 21:04
Thank you Mat - that looks really interestiung. I'll try it.
Kind regards

Adrian

Adrian
- 2nd July 2007, 09:35
Mat - the code worked great - also, as a newcomer to these techiques my understanding and use of bitwise operators has taken a leap forward. Thank you once again

Adrian