Pic 12f629


Closed Thread
Results 1 to 15 of 15

Thread: Pic 12f629

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    I'm a sucker for simplicity.

    Try this;
    Code:
    GPIO.4 ----/\/\/\---|<|----+5V.
                        LED
    
                 10K
    GPIO.0 --|--/\/\/\---+5V
             |--switch---GND.
    When you press the switch it grounds GPIO.0.
    Code:
    @ device  pic12F629, intrc_osc_noclkout, wdt_on, mclr_off, protect_off
    
        DEFINE OSCCAL_1K 1
        DEFINE OSC 4
        
        RELAY VAR GPIO.4   ' relay output
        Pswitch VAR GPIO.0 ' switch input
    
        TRISIO = %00000001 ' GPIO.0 input, rest outputs
        WPU = 0            ' input pull-ups disabled
        CMCON = 7          ' disable comparators
        PAUSE 10           ' POR delay
        
    MAIN:
        RELAY = ! Pswitch ' Relay pin = the opposite of Psiwtch pin    
        GOTO MAIN
        END
    Does this work?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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


    Did you find this post helpful? Yes | No

    Default

    Switch to ground. Definately the better way to go.

    I might suggest a different Main loop though.
    Code:
    MAIN:
        IF RELAY = Pswitch THEN
            RELAY = ! Pswitch ' Relay pin = the opposite of Pswitch pin    
        ENDIF
        PAUSE 20
        GOTO MAIN
    
        END
    Those pesky R-M-W's
    <br>
    DT

  3. #3
    Join Date
    Jan 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Hi all out there
    The last time I did a 8 pin pic was 10 years ago
    The problem was to do with the weak pull up
    I really want to thank all out there
    Bye for now

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Switch to ground. Definately the better way to go.

    I might suggest a different Main loop though.
    Code:
    MAIN:
        IF RELAY = Pswitch THEN
            RELAY = ! Pswitch ' Relay pin = the opposite of Pswitch pin    
        ENDIF
        PAUSE 20
        GOTO MAIN
    
        END
    Those pesky R-M-W's
    <br>


    Darrel,

    I just want to learn;

    Is it really a safe way to read the status of an output pin?

    Thanks
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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


    Did you find this post helpful? Yes | No

    Default

    Yes, in fact, from my understanding, it reads the content of the output-latch.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    Is it really a safe way to read the status of an output pin?
    Is it safe?

    Well, as far as doing damage, it's perfectly "Safe".
    In fact the chip "reads" the state of the OUTPUT pin, everytime you you change the state of any pin on the same port.

    The only un-safe part, is if you don't take the R-M-W problems into account.
    Can really mess with the program.
    <br>
    DT

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  3. program a pic 12f629
    By cancan in forum General
    Replies: 3
    Last Post: - 28th April 2008, 15:15
  4. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14
  5. Problem Pic 12f629
    By diegover in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 19th July 2004, 11:51

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