Instability with the 12F629


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Oct 2004
    Location
    Fayetteville Arkansas
    Posts
    44

    Default Instability with the 12F629

    I am very much a newby to these.

    Below is the code that I write originally my input was pin 7, but for some reason I could not get it to triger with a switch. The intent is to give the input pin a high by using a momentary switch, which will cause pin 6 to go hi for 2 seconds, then pin 5 for 2 seconds, the timeout for 3 seconds and then wait for another trigger event. When my hand gets near the switch which triggers pin 3, it triggers. If I get near it it tends to do the same. Any quips of wisdom would be appriciated.

    Butch

    SEN VAR GPIO.4
    POW VAR GPIO.1
    SHT VAR GPIO.2
    LOW SEN
    LOW POW
    LOW SHT
    INPUT SEN
    OUTPUT POW
    OUTPUT SHT
    LOOP:
    IF SEN=1 THEN
    HIGH POW
    PAUSE 2000
    LOW POW
    HIGH SHT
    PAUSE 2000
    LOW SHT
    PAUSE 3000
    ENDIF
    GOTO LOOP

  2. #2
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default Re: Instability with the 12F629

    That you HH?
    Have not used used any of the 12 series yet - but you might want to post some of your code that shows your 'configuration' settings.

  3. #3
    Join Date
    Oct 2004
    Location
    Fayetteville Arkansas
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Yep Arch, its me. Hey, I said I'm a newby, that IS all my code.
    Good to see ya

  4. #4
    thelightbrain's Avatar
    thelightbrain Guest


    Did you find this post helpful? Yes | No

    Default

    The input pin that you are connecting the switch to should also be connected to ground via a 5K or 10K resistor. This will keep it from "floating".

    Or, to avoid adding another component, you can enable the internal "weak pullups" and connect the switch to ground. And change the input polling code to:

    IF SEN=0 THEN

    Also vave to make sure the input your using has the weak pullup.

    --Jim

  5. #5
    Join Date
    Oct 2004
    Location
    Fayetteville Arkansas
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Thanks Jim, I'll give that a try.

  6. #6
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Hey Butch - good to see ya starting on the programming - stuffs almost as addictive as the cams !!

    Was just looking over the 12F629 data sheet and it looks like it has lots of functions like comparators, A/D inputs, and such.

    There will be a bunch of registers like INTCON and OPTION_REG that are pre-set by PBP - you'll sometimes need to set them up manually in order to make sure all your pins are functioning as digital In/Outs, etc (unless you want the analog stuff).
    Caused some headaches for me on the 16F628's until I figgured it out (Brian helped out a lot!).
    Don't know what the PBP presets are for the 12F629.

    You might want to use the GPIO.2 'external interrupt' pin as your sensor input and assign weak pullups and trigger on falling edge (see INTCON and OPTION registers in data sheet).

    I think the "ON INTERRUPT" command could then be used while you put the chip to sleep (not sure on the '629).

    Arch
    Last edited by Archilochus; - 11th November 2004 at 01:42.

  7. #7
    Join Date
    Oct 2004
    Location
    Fayetteville Arkansas
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    It can Arch. Was on Yahoo with Stevo and figured out there is even more I need to learn. Thanks for the input

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    PIC12F629 have internal comparator

    to turn them of

    CMCON=7

    here a link for some specific setting on some PIC

    http://www.melabs.com/support/mcu_hints.htm

    regards
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello BGreen,

    BG>>When my hand gets near the switch which triggers pin 3, it triggers. If I get near it it tends to do the same. Any quips of wisdom would be appriciated.<<

    When you program the chip, Make sure your MCLR is set to input pin. If not, your body can difinitely turn this chip on and off. I ran into this just by touching things, and finally realized the Mclr was set to reset. You can pull it high if you don't want to set it as a input, and accomplish the same thing.

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  10. #10
    Join Date
    Oct 2004
    Location
    Fayetteville Arkansas
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Folks, thanks for the help. I used a 4.7k resister from the switch to ground and its solid as a rock. I had already put a pullup on pin 4. Jig I built is working fine. Now I need to learn the right way to do stuff, and how to use the sleep and interupts.

Similar Threads

  1. Input problems with 12F629?
    By achilles03 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 24th April 2018, 06:25
  2. Basic help for 12F629
    By Gene Choin in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd September 2009, 04:06
  3. sleep on 12f629
    By sirvo in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 8th February 2007, 14:08
  4. Servo control with 12F629
    By achilles03 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd June 2005, 23:34
  5. 12F629 I2C problems
    By AIW128ProGuy in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th November 2004, 23:41

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