PortD on 18f4550 cofig pullup for switches


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Analog input problems resolved

    Thanks for your/and others invaluable help in guiding me along.

    The faulty analog inputs an8, an9 and an12 when connected to a pot 0-5v would, when the applied voltage was reduced, indicate the correct voltage until the voltage went down to 1.5v. I then connected a milliamp meter in circuit with the analog input and measured a current of 1.6 ma. After reading the sbc44 manual I now believe these inputs cannot be used as analog inputs but can be used as digital i/o? I do however have 10 analog inputs that work correctly, as I shall be using lm35/ad22100 to measure temperatures, hopefully.

    PS I have now succeeded in getting pc vb2005 to usb pic4550 and believe I now understand how it works. Does upgrading to vb2008 express give any problems?

    Tom

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


    Did you find this post helpful? Yes | No

    Default

    Tom , VB2008 work as VB2005, but it has few less bugs and few new improvements.

    Assuming you might use EasyHid DLL, I can't tell how good, bad it will be for Vista or VB2008 as I no longer use that DLL.

    Check your ADCON0 setting, I already use all Analog channel on that one, and never got issues.

    Bonxy
    BUT, How do I get a switch to work active high now ?,
    Same thing, but you need a pull-down resistor instead of a pull-up.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Unhappy Try again

    Hi all

    Does anyone know how to read a switch connected to a port pin on 18f4550 (active high).

    eg: switch is connected between port pin and +5v

    without using an external pull-down resistor
    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

    Not recommended. A pin will 'float'... sometimes it might acquire a charge from internal capacitances and over a period of time you will read a High when earlier it was a Low.

    Use internal Pull-Up's where available and pull down with a switch externally for minimum component count. Try not to wire +5v to things like Switches and Sensors... especially if that same +5v supplies your PIC or other Logic... all you're doing is asking for noise to be induced into your Power Supply circuits which could then cause you grief elsewhere.

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

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

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

Similar Threads

  1. 18F4550 to 18F2550
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th September 2007, 00:13
  2. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 03: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