Help with pic 12f629


Closed Thread
Results 1 to 40 of 53

Hybrid View

  1. #1
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Smile

    Thanks, My circuit is just real pic simulator, so no circuit yet.
    but it should be something like a push boton normaly open, and a led with the resistor.
    I think it is the ansel thing, to set things digital.

    Excuse my ignorance....but if there is a newbie, my level is the same as the pet, of the pet of the newbie.

    Well, thanks again for your help guys.
    I will keep doing as you say.
    Thanks.

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gutisie View Post
    Thanks, My circuit is just real pic simulator, so no circuit yet.
    but it should be something like a push boton normaly open, and a led with the resistor.
    I think it is the ansel thing, to set things digital.

    Excuse my ignorance....but if there is a newbie, my level is the same as the pet, of the pet of the newbie.

    Well, thanks again for your help guys.
    I will keep doing as you say.
    Thanks.
    I don't know if the simulator simulates switches as de-bounced or not. This is all the help I can be at this time, I too do not understand. It looks like it should be working to me. -Sorry

    I will keep watching to see what the "pro's" have to say.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Code:
    DEFINE OSC 4
       @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
        CMCON=7 
        
        cnt VAR BYTE
        boton VAR GPIO.2
        mosfet VAR GPIO.1
    
        cnt = 0
       
        CHECK:
        IF boton = 0 THEN TEST
        LOW mosfet
        GOTO CHECK   
        
        TEST:
        IF cnt < 3 THEN OFF_MOSFET
        IF cnt => 3 THEN ON_MOSFET
        GOTO CHECK
        
        OFF_MOSFET:
        PAUSE 100
        IF boton = 0 THEN
        low mosfet
        cnt = cnt + 1
        ENDIF
        GOTO CHECK
        
        On_MOSFET:
        HIGH mosfet
        pause 1000
        low mosfet
        cnt = 0
        GOTO CHECK
        end
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Code:
    DEFINE OSC 4
       @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
        CMCON=7 
        
        cnt VAR BYTE
        boton VAR GPIO.2
        mosfet VAR GPIO.1
    
        cnt = 0
       
        CHECK:
        IF boton = 0 THEN TEST
        LOW mosfet
        GOTO CHECK   
        
        TEST:
        IF cnt < 3 THEN OFF_MOSFET
        IF cnt => 3 THEN ON_MOSFET
        GOTO CHECK
        
        OFF_MOSFET:
        PAUSE 100
        IF boton = 0 THEN
        low mosfet
        cnt = cnt + 1
        ENDIF
        GOTO CHECK
        
        On_MOSFET:
        HIGH mosfet
        pause 1000
        low mosfet
        cnt = 0
        GOTO CHECK
        end
    Hi guys, thanks again, your are wonderfull!!.

    Unfortunately, this code gives me error 118.

    Thanks.
    Best regards.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    If you are setting the configs in code space comment that line out.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Hi Dave, yes thats it.

    When I delete the first 2 lines "define ocs" and "@...", both codes compile ok.

    Unfortunately, the behaviour is basicaly the same....they start with led off, and it should be on, more over, the counting is not regular, it depends in the speed of the click.
    Some times, it goes off at 3, others at 5...etc....

    I dont know....it is very over me.
    I have tried to cut here and there taking ideas from both codes, but it does not work either.

    I have to mention, that the clicks will be very fast, we could have posibly.......20 clicks per second, but we need to stop the mosfet after counting 3 clicks, hence the pause for 1 second.

    I am sorry, my spanish brain is too tyre and can not speak properly.

    Thanks for helping me guys.
    Much appreciated.

    Best regards.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    You might not need the
    DEFINE OSC 4
    but it is a good idea to put it in. That is the line that tell PBP how fast the chip is running. I assume you are using the 4MHz internal.

    The state of the mosfet/led depends on how you have the hardware setup. Just change the LOW/HIGH around to do what you want.

    Like I said before. This will need a good denouncing routine to work correctly. Now that you say the button could be pressed at 20HZ even more so. What is going to press a button that fast?

    Here are a couple of threads that might help you.
    http://www.picbasic.co.uk/forum/showthread.php?t=13516
    http://www.picbasic.co.uk/forum/showthread.php?t=2180

    Read them all the way through.
    Dave
    Always wear safety glasses while programming.

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