Connect with us

PIC I/O Questions

Discussion in 'Electronic Basics' started by Allen Bong, Dec 22, 2005.

Scroll to continue with content
  1. Allen Bong

    Allen Bong Guest

    Hi Group,

    The schematic below (in ASCII art, please view with Fixed font) shows
    how my friend connects a switch and an LED to one port, so he can make
    use the port to read a switch in input mode and then changes the port
    direction to light up the LED.

    My questions are:

    1. Would this design cause the port to overload and eventually get
    destroyed if the switch is pressed too long?

    2. Isn't it advisible to have a diode or resistor added between the
    switch and the port to prevent the above from happening?

    3. If 26 LEDs each consuming 15mA, were connected to the PIC, and all
    were switched ON during startup test for a few seconds. Would this
    endanger the PIC (say 16F877 as an example)?

    4. I have seen in schematic examples that 10 LEDs were connected to a
    4017 without any current limiting resistor. Does the CMOS output has
    some special properties to limit its output current?

    5. The PIC datasheet says that each port can source or sink 25mA. Is
    this the Max current or working current?

    Thank you for reading. Any feedback is welcomed.

    Merry Christmas and regards.

    Allen Bong





    VCC
    |
    |---o---|
    .-----------------------. | | |
    | | \ o\ o\ o
    | PIC | \ \ \
    | | \. \. \.
    '-----|------|-----|----' sw1o o o
    | | | |sw2|sw3|
    o------|-----|---------o | |
    | o-----|---------|---o |
    | | o---------|---|---o
    | | | | | |
    V -> V -> V -> | | |
    -LED1 -LED2 -LED3 | | |
    | | | | | |
    | | | | | |
    .-. .-. .-. .-. .-. .-.
    | | | | | | | | | | | |
    220| | 220| |220| | | | | | | |
    '-' '-' '-' '-' '-' '-'
    | | | 10k|10k|10k|
    | | | | | |
    o------o-----o---------o---o---|
    |
    |
    GND
    (created by AACircuit v1.28.6 beta 04/19/05 www.tech-chat.de)
     
  2. If the output is low and you hit the switch then you could damage the
    output.
    You'd force the LED on too when a switch is pressed, I assume that is
    acceptable?
    Although it is possible to have the software ensure that the output is
    never activated *and* low at the same time.
    Only if the softare does not do as described above..
    Could very well do.
    The PIC will have a maximum rating for its power pin. 200mA for the
    16F88 for example.
    Why do you need 15mA for each LED anyway, that is a lot for most
    purposes. 5mA is usually enough, some LEDs even work fine on 1mA or
    less.
    Each "port" on the PIC also has it's own maximum rating.
    Yes, it has a higher output resistance.
    Probably not the best practice though!
    That is the absolute maximum figure before damage could occur.

    Dave :)
     
  3. Allen Bong

    Allen Bong Guest

    1. Would this design cause the port to overload and eventually get
    If the output is low and you hit the switch then you could damage the
    output.
    You'd force the LED on too when a switch is pressed, I assume that is
    acceptable?
    ------------------------------------

    Yes, it's supposed to light the LED when the switch is hit. Then the
    PIC would take over using its internal latch.
    The LED would flash at 1Hz and become permanently on once the PIC
    receives acknowledgement from another PIC on the Remote end.
    ------------------------------------

    Although it is possible to have the software ensure that the output is
    never activated *and* low at the same time.

    -----------------------------------------

    How would you do it if it were your project, Please ?
    OR some pointers would be appreciated! I am using PIC Basic Pro.

    Allen Bong
     
  4. If the pin is set to be an output pin and it is set to low (0), then yes
    it could damage the port pin. This is not a very good design.
    IMHO, yes. Resistors are cheap.
    Yes. It would greatly exceed the maximum capacity of each port and of
    the entire device.
    Just some resistance. Depending upon the design, this resistance might
    be very low. This would be yet another example of how not to do
    something.
    I think you mean that each individual pin of a port can source/sink that
    much current. AIR that device has a limit of 100mA per port and a total
    device limit of 200mA. I didn't check the data sheet, but you should.
    ;-)
     
  5. Ok, sounds good then.
    This is a common technique and works as follows:
    Simply write a "HIGH" to all the output pins and leave it like that.
    Then you acually toggle the output state by setting the mode enable
    line for that pin. So the output pin actually toggles between
    "Output-HIGH" and "Input", and never has a chance to go "Output-LOW"
    i.e. you never actually write a LOW to the output pin.

    Hope that makes sense?

    Dave :)
     
  6. Allen Bong

    Allen Bong Guest

    This is a common technique and works as follows:
    Simply write a "HIGH" to all the output pins and leave it like that.
    Then you acually toggle the output state by setting the mode enable
    line for that pin. So the output pin actually toggles between
    "Output-HIGH" and "Input", and never has a chance to go "Output-LOW"
    i.e. you never actually write a LOW to the output pin.

    Hope that makes sense?


    Dave :)

    got it. Thanks very very much, Dave!

    Allen
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-