Help with pic 12f629


Closed Thread
Results 1 to 40 of 53

Hybrid View

  1. #1
    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.

  2. #2
    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.

  3. #3
    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.

  4. #4
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Hi dave,

    Thanks for your help, I will have a look at the links later.

    Yes you are right, I am using the internal oscillator at 4 mhz.

    The botton is pressed by a piston.
    So I need to stop the piston after 3 pulses.

    Thanks.

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


    Did you find this post helpful? Yes | No

    Default

    Is it really a button type switch or some other kind of sensor?

    I ask because a mechanical switch may not be the best at high speeds.

    And the way you have the code implies the button is pulled high and at button press goes to zero volts. This can cause arcing as the contacts open giving the chance of several "make/breaks" on each press.

    If the switch were wired pulled low and pressing it brought it high then the arcing is almost not a problem.

    Just thoughts....
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Sep 2010
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Is it really a button type switch or some other kind of sensor?

    I ask because a mechanical switch may not be the best at high speeds.

    And the way you have the code implies the button is pulled high and at button press goes to zero volts. This can cause arcing as the contacts open giving the chance of several "make/breaks" on each press.

    If the switch were wired pulled low and pressing it brought it high then the arcing is almost not a problem.

    Just thoughts....
    yes the idea is a proper botton switch, the wired to pull it low it is some thing that i dont understand.
    The voltage for the circuitry is 5v....amperes very little, I think is not going to be a problem.

    I am more concern with the switch being able to work at that speed...i dont know...i rather first understand the code, see what it should be, have something that i can built my proptotype on, and then see pros and cons.
    Otherwise this can be very long...

    Thanks for the help guys.
    Best regards.

  7. #7
    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
    The voltage for the circuitry is 5v....amperes very little, I think is not going to be a problem.
    You should ALWAYS assume EVERY mechanical contact switch bounces. The effects can be made less with tricks like DAVE suggests, and with higher quality snap type switches. But heres the thing: as 1 contact approaches the other, they WILL arc. The arc is the "bounce" this happens when opening and closing. Also, switches HATE DC. So if you want this to work for any lengh of time, be certain the switch is DC rated. DC causes the contacts to "plate" and then the bounceing gets worse until the switch quits all together.

    I am more concern with the switch being able to work at that speed...i dont know...i rather first understand the code, see what it should be, have something that i can built my proptotype on, and then see pros and cons.
    Otherwise this can be very long...

    Thanks for the help guys.
    Best regards.
    Not a bad approace at all. Good luck!
    -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!

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


    Did you find this post helpful? Yes | No

    Exclamation

    Quote Originally Posted by gutisie View Post

    The botton is pressed by a piston.
    So I need to stop the piston after 3 pulses.

    Thanks.
    Some Hall effect sensor would be to consider, instead ...

    just me ...

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

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