Help with pic 12f629


Closed Thread
Results 1 to 40 of 53

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    # 20 updated to our friend's desires ...

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

  2. #2
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by Acetronics View Post
    # 20 updated to our friend's desires ...

    Alain
    oooooomg!!!! you did it!!! it works!!!

    but i had to change it a bit.
    I will post the results later
    I am still shaking....

  3. #3
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Wink

    hi, the code works fine under slow speed, it will count up to 3 and go off the led for 1 s, then on back again.

    Please see actual code.

    Code:
    DEFINE OSC 4
      
     
        cnt VAR BYTE
        delay var byte
     
        boton VAR GPIO.2
        mosfet VAR GPIO.1
     
     
     '   ANSEL           = 0     '12F675 for test
        CMCON           = 7
        OPTION_REG.7    = 0    'Pullups  enabled
        WPU             = %00000100
     
        cnt             = 0
        GPIO            = %00000110                 ' Nosurprise startup ...
        TRISIO          = %00000100 
     
    '******************************************************************************
    Detect: 'Button presses W/Debounce
    '
    delay = 0
    BUTTON Boton ,0,255,0,delay,1,pressed
                                      ' Slow Things down
        GOTO Detect
     
    '******************************************************************************    
    Pressed:  ' Some > 10ms press detected
        IF cnt <=1  Then 'tocount uptu 3, bigger values will add up.
     
            cnt = cnt + 1
     
        ELSE
     
            cnt = 0
            LOW mosfet
            PAUSE 1000
            high mosfet
     
        ENDIF
     
    WHILE !Boton : WEND                                ' Wait Boton release !!!    
    goto detect
     
    END
    I need much faster reading from the pic, other wise, it will count moreto go off, on breadboard, it may not even go on again.
    For some oscure reason, my Pbasic compiler, does not like the configuration line you put, after the OSCAL SETTING, in line one.
    So I have to set it manualy, using software configuration bit facility.

    See my circuit, but, instead of 2 only one led, on GP1, and Push boton on GP2.

    Best regards.



    Thanks Acetronics.
    Last edited by gutisie; - 26th September 2010 at 12:21.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi,

    oooooomg!!!! you did it!!! it works!!!
    Keep cool ... there's no miracle in that ...

    If you need faster response ... forget about your pushbutton !!! Button bouncings will give a totally random functionning ...
    another "detector" type has to be used.

    Now, modified code reacts for 2 pushings only ???

    The obscure reason is you use PM as an assembler and not MPASM with your Microcode IDE ...

    Alain
    Last edited by Acetronics2; - 26th September 2010 at 16:29.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  5. #5
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by Acetronics View Post
    Hi,



    Keep cool ... there's no miracle in that ...

    If you need faster response ... forget about your pushbutton !!! Button bouncings will give a totally random functionning ...
    another "detector" type has to be used.

    Now, modified code reacts for 2 pushings only ???

    The obscure reason is you use PM as an assembler and not MPASM with your Microcode IDE ...

    Alain
    Hi thanks for your response, much appreciated.

    The compiler, i use is Pbasic?..with Mplab ide....these are at least the software names.
    Do you need a screen capture of the compiling results?

    And about the button...what type would you use?...I am absolutly clue less.....and desperate...and tyre...and bald....and...etc...

    Any way....Ir sensors?...proximity switches?....

    I once more depend on your wisdom master....

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Some testings show the minimum time for 3 pushes is ... around 78 ms !!! @ 10ms debounce time and a Pause 0 for scanning ...

    so, I really doubt any finger could do that !!!

    Quote Originally Posted by gutisie View Post
    And about the button...what type would you use?...I am absolutly clue less.....and desperate...and tyre...and bald....and...etc...

    Any way....Ir sensors?...proximity switches?....
    so What moves the button ???

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

  7. #7
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Hi Ace,

    Thanks for your reply.

    The button is pressed by the piston on a gear box. As i said on other post, my actual reading is 15 to 20 cycles per sec. And i need to stop the piston, after 3 cycles.

    I have some Ir sensors. But putting them inside the gearbox or some where around, it is not a good idea.

    Hence, buttons is the best for my application i think.

    Thanks.

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