PortD on 18f4550 cofig pullup for switches


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Dec 2004
    Location
    Scarborough UK
    Posts
    77


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by Melanie View Post
    pull down with a switch externally for minimum component count.

    Try not to wire +5v to things like Switches and Sensors.
    Hi Melanie

    Thanks for your reply, could you please elaborate on a couple of things ?, I'm not sure what you mean about pulling down externaly with a switch ?,

    What im trying to do is have a switch with just 2 wires connected that can work active high or active low. (without resistors)

    This project is a kind-of one chip does everything scenario, and so I cant use resistors, will it damage my pic if i put +5 to a pin ?.

    Thanks
    Reading the datasheet & understanding it are two different things.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Somehow I get the feeling you could do with some basics...

    DIGITAL only has two states, On or Off, High or Low, 1 or 0. That's why we call it Binary.

    A PIC pin when used for DIGITAL can only have two states... High (or 1) or Low (0). 1 or Zero that's all you got. There's no 'in-between', no half-way or part way. Your choice is 1 or Zero. That's it - no other choices. This is also why everybody does DIGITAL and very few people do ANALOG. Because with DIGITAL life is easy. You learn 1 and you learn Zero and that's it - you're a computer expert because there's nothing else to learn.

    This means one of two things...

    Scenario A. You preset the PIC's pin with a HIGH (ie set it to a Logic 1) and you do this by pulling it UP to +5v via a Resistor (say 10K for arguments sake). This pin is normally now sitting at +5v (Logic 1 or High). You connect a pushbutton or switch between the PIC's pin and Ground (0v). When you push the button, you short that pin down to 0v, forcing it LOW. You need a Resistor, because otherwise you'll be shorting the +5v Power Supply out! Lots of PICs have pull-up Resistors inside them on many of their pins which can be switched-in to do the job and save you from providing one externally. So here, with the switch being OPEN-circuit, the PIC sees a HIGH (Logic 1) on it's pin, and when you press the Button the PIC sees a LOW (0) on it's pin.

    Scenario B. You preset the PIC's pin with a LOW (ie set it to a Logic 0) and you do this by pulling it DOWN to 0v via a Resistor (say 10K for arguments sake). This pin is normally now sitting at 0v (Logic 0 or Low). You connect a pushbutton or switch between the PIC's pin and Supply (+5v). When you push the button, you connect that pin up to +5v, forcing it HIGH. You need a Resistor, because otherwise you'll be shorting the +5v Power Supply out! PICs don't carry internal pull-down Resistors inside, so you need to provide one externally. So here, with the switch being OPEN-circuit, the PIC sees a LOW (Logic 0) on it's pin, and when you press the Button the PIC sees a HIGH (1) on it's pin.

    You CANNOT leave a PIC pin 'floating' unconnected. This is because the pin can acquire a charge (or discharge) and set the pin HIGH or LOW or even flicker between the two - which is kinda defeating what you want the pin to do if you can't even predict what state it is going to be in at any point in time. You pull it LOW with a switch and it might stay there when the switch is released, then some time later it might float High. You pull it High with a switch, then it might stay there forever after you release the switch - again not what you want it to do.

    And in answer to your question - No, you won't damage a PIC's pin (when it's set for INPUT - TRISx=1) by connecting it directly to +5v or to 0v.

  3. #3
    Join Date
    Dec 2004
    Location
    Scarborough UK
    Posts
    77


    Did you find this post helpful? Yes | No

    Unhappy

    Hi Melanie

    Its not realy the basics i'm after, Im looking for what seems to be an advanced answer.

    I am simply asking if it is possible to get an active high input on a pin ? using any method whatsoever without the need for an external pull-down resistor?.

    If the answer is no then thats fine, but all I seem to be getting is ambiguous replies or lectures that dont answer my question.

    I had one person that told me to look at the 18f4550 datasheet (which I already had done), he didnt even look himself before making a reply :-(.

    I've thought of a simple workaround to the problem myself (although not ideal), have a changeover switch that has the common as the pic pin and the changeover contacts as 0v and +v.

    I dunno Melanie I love pic's etc and just do it for fun, but It feels a bit like a bit of a club on this website, and asking for help on hear is hard work, I feel like a noob again. :-(
    Reading the datasheet & understanding it are two different things.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I've thought of a simple workaround to the problem myself (although not ideal), have a changeover switch that has the common as the pic pin and the changeover contacts as 0v and +v.
    But then that is THREE wires and you specified two a couple of posts ago. But yes, that'll work providing your switch is the break-before-make type otherwise you'll be shorting out your +5v line.

    I am simply asking if it is possible to get an active high input on a pin ? using any method whatsoever without the need for an external pull-down resistor?.
    Without external components, your simple answer is NO.

  5. #5
    Join Date
    Dec 2004
    Location
    Scarborough UK
    Posts
    77


    Did you find this post helpful? Yes | No

    Red face

    Thanks Melanie

    Like I said the change over switch idea is not ideal, but I cant think of anything else just off hand.
    If there is no way to do it by programing the pic then that only leave's phisical methods, hmm, gonna have to give this project some more thought before deciding if it is viable.
    Thanks very much for taking the time to reply :-).
    Reading the datasheet & understanding it are two different things.

  6. #6
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Bonxy, The change over switch as you call it is nothing more than a single pole/double throw. As far as shorting out the +5 volts to ground if it is a make before break, just tie the +5 volt side through a 4.7K resistor. The resistor will allow a small current to flow through it but not short the supply.

    Dave Purola,
    N8NTA

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    This is the whole issue here Dave, if only Bonxy would use a Resistor all his problems would go away - but he won't.

  8. #8
    Join Date
    Dec 2004
    Location
    Scarborough UK
    Posts
    77


    Did you find this post helpful? Yes | No

    Talking

    Hi Dave

    thanks for that :-), I have been trying that with a standard 3 pin changeover 'microswitch', BUT, while I have been experimenting with it I have 'somehow' managed to get a switch working either as active low or as active high without any resistors and with only 2 wires, despite what I have been told it seems to be working ?????, I am not holding my breath though because the person that told me this cannot be done is prety expert on this stuff.
    Im thinking that there may be something I've overlooked on my dev board (EasyPic3), Ive removed all the pull-up/pull-down jumpers to be sure and it seems to be working ?.
    This is strange, lol :-), its doing exactly what i want it to, that worries me.
    Reading the datasheet & understanding it are two different things.

Similar Threads

  1. 18F4550 to 18F2550
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th September 2007, 23:13
  2. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

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