Strange happenings PBP and 12F683


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263

    Default Strange happenings PBP and 12F683

    I'm hollering "Uncle!" on this right now.

    Attached are two segments from a larger program that, as of right now, works perfectly. It records keypresses (TRIGR) at 8 frames per second and plays them back. This is running on a 12F683 and uses Darrel's interrupts for timing.

    What I've been trying is to add (somewhere) a test: If the key is stuck or still held down, I want further execution to stop until the key is released.

    And that's where the trouble begins. Sounds silly, simple, and should be straightforward, right? But I've tried an amazing number of combinations of IF . . . ENDIF, WHILE . . . WEND, GOTOs, and GOSUBs. Nothing works quite right. Obviously, I'm not seeing something.

    The most common result is that the test "sticks" on odd-numbered attempts and won't release back to the program when the key is released until the key is pressed again. (I've even used ALED as a blinky/status indicator.)

    Did I fry one too many brain cells back in the 1960s?
    Attached Images Attached Images
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Russ,

    I don't see any way out of PLOOP.

    Since it doesn't increment FRAME, it'll never make it to 240 or find a $FF in EEPROM.
    <br>
    DT

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Untested, but something like this will probably work. Designed to be called from a timer interrupt.


    Code:
    Gosub ReadKey
    
    If Key = Pressed THEN
       IF KeyPressedFlag = 0 THEN 
         KeyCounter = KeyCounter + 1
         IF KeyCounter > DebouncePeriod THEN
         KeyCounter = 0
         KeyPressedFlag = 1
         GOSUB Routine_for_KeyPressed
       ENDIF
       KeyDownCounter = KeyDownCounter + 1
       IF KeyDownCounter > ToleranceLimit then 
          HSEROUT ["Dummy, Get off the key!"]
       ENDIF
    ELSE
       KeyCounter = 0
       KeyPressedFlag = 0
       KeyDownCounter = 0
       GOSUB Routine_for_KeyReleased
    ENDIF
    Charles Linquist

  4. #4
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Hi Russ,

    I don't see any way out of PLOOP.

    Since it doesn't increment FRAME, it'll never make it to 240 or find a $FF in EEPROM.
    <br>
    FRAME is incremented in the interrupt handler for both the PLAY and RECORD subroutines.

    Remember, these are just the fragments where I tried trapping the "continued key-on" condition; the whole program works just fine as-is.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  5. #5
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default Another example

    Here's an example of one of many different attempts.

    When the flag is 1, it works just fine.

    When the flag is 0, it works fine when there is no data present (the first byte read is $FF). As long as the switch is held down, it flashes the LED one way; when it is released, the LED goes back to its "idle" condition.

    For any other data present, it sometimes seems to go directly to PLEXIT; other times, it works as it should.

    In fact, I'm playing with it now. On one attempt (with data present), it seems to jump directly to PLEXIT; on the next, it plays back the data. Then the cycle starts over again: One wrong response, one correct one. Time after time.
    Attached Images Attached Images
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi Russ,
    I remember back in the early nineties making a 3 wire timer the 3 wires being hot ground and load. When you activated the timer by momentarily switching power to the load the timer would activate and hold power on the load for 15 seconds. The circuit used a transistor and a capacitor to feed the base and a 555 timer and another transistor to carry the load. My point is maybe you could use a capacitor on your inputs, when it charges up it drops the load and requires you to release the switch to reactivate.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink You do not dream ... halas.

    Hi, Russ

    I remember having had similar issues some years ago whith a 16F628 ...

    IF THEN tests didn't work at all ... whether the condition result.

    Was for a R/C failsafe sequence ... rather annoying, indeed.


    I just got out of that by re-organizing my subs ( that were called by goto's ...) a bit more "rationnaly" ...

    May be posts are not fallen into Archives yet ... ( I'll dig somewhat ... )

    Alain

    PS: Got it ... but hurry up !!! I Won't be able to post a lot until it passes the limit ... lol
    http://www.picbasic.co.uk/forum/showthread.php?t=1952
    Last edited by Acetronics2; - 6th February 2009 at 09:05.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  8. #8
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Joe, the switch drives an optoisolator which in turn drives the PIC input (GPIO.3 configured as input, not MCLR). (I've looked at the switch and the output from the opto on the scope; there's not much bounce.)

    Alain, my general arrangement of the program is:

    PROGRAM (things done at power-up only)

    MAIN LOOP (you've seen it)

    SUBROUTINES (you've seen the one that is the problem)

    INTERRUPT HANDLER

    END

    I'll try moving some things around, but I continue mystified and frustrated.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

Similar Threads

  1. How to use LM34 to full range with PBP
    By polymer52 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 9th January 2010, 13:43
  2. New to PBP
    By GoldStar in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th May 2009, 16:24
  3. New project help rapidfire on 12f683
    By thm ov3rkill in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 27th December 2008, 19:59
  4. 12F683 HPWM Usage
    By MARAD75 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th November 2007, 02:16
  5. upgrade to PBP 2.46 and using 12F683
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd March 2005, 07:13

Members who have read this thread : 0

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