Input pin help


Closed Thread
Results 1 to 6 of 6

Thread: Input pin help

  1. #1
    Join Date
    May 2007
    Location
    Suffolk, UK
    Posts
    59

    Default Input pin help

    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

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    Look in the book that came with your Picbasic pro at while......wend

  3. #3
    Join Date
    May 2007
    Location
    Suffolk, UK
    Posts
    59


    Did you find this post helpful? Yes | No

    Default

    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

  4. #4
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    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.

  5. #5
    Join Date
    May 2007
    Location
    Suffolk, UK
    Posts
    59


    Did you find this post helpful? Yes | No

    Default

    Thank you Mat - that looks really interestiung. I'll try it.
    Kind regards

    Adrian

  6. #6
    Join Date
    May 2007
    Location
    Suffolk, UK
    Posts
    59


    Did you find this post helpful? Yes | No

    Default

    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

Similar Threads

  1. Is this a K Type sensor?
    By jessey in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st November 2009, 13:55
  2. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  3. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 01:50
  4. 16f88 - pin RA4 as analog input
    By savnik in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 15th December 2006, 13:55
  5. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts