Driving various loads with PIC18F87K22

Discussion in 'Embedded Systems and Microcontrollers' started by Chris11jed, Apr 24, 2014.

  1. Chris11jed

    Thread Starter New Member

    Dec 15, 2013
    16
    0
    Hello,

    I've just got a PIC18F87K22 with a development board which is great. The board has some SMD LEDs and some ways to communicate with the outside world, also good. And the whole thing comes with a few examples to get you going with the PIC18F87K22. :cool:

    I was having a quick read through some of the datasheet when I noticed the "Electrical Characteristics" section mention that some port pins sink or source only 2mA, others 8mA and then there's a few that do 25mA. I'm used to PIC's that do 25mA. I know I can hook up an LED and drive 15 to 20mA through it ok. I can drive a relay with an N-Channel MOSFET, and can do a few other things as well.

    My question is about these pins that can only handle 2 or 8mA. Does anyone have a guide to using such pins. I read they will do digital cct's okay, so I'm thinking if one wants to do something with an IC that only really needs hi or lo that's okay. BUT, if an LED at 20mA is to be run, you'd need a buffer or some switching cct like a npn and pnp transistor cct or a MOSFET.

    Could anyone give a guide to my pin loading worries? Am I right in thinking the 2 and 8mA max sink/source pins on this device should be handled with extra switching circuitry type-of-care? :confused: Can these low current pins be safely used for non-digital (Hi or Lo) circuits, either driving or receiving?

    Sorry to ask such a silly question. I think I know how to proceed if i was to build a PCB and use such a chip. But I thought I'd post my concerns and questions before doing any damage to the cct or the chip :D

    Thanks
    Chris
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,387
    1,605
    I don't get your question. You correctly understand the data sheet and the limits it imposes.

    Just keep within the lines and all is well.
     
  3. Chris11jed

    Thread Starter New Member

    Dec 15, 2013
    16
    0
    Hi ErnieM and all,

    Good advice,
    I suppose I was a little surprised to see such a low value in the datasheet.

    Chris
     
  4. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Regarding driving LEDs with 2mA port pins, you can buy a bag of 100 LEDs "high intesnsity" 6000 mCd brightness on ebay for a few dollars.

    These new high intensity LEDs are incredibly bright at 20mA, but the other point is that they can give excellent visibility as indicators at 1mA or even 0.5mA LED current.

    Driving LEDs at 20mA is really a 1970's standard, most of the indicator LEDs in modern appliances run perfectly at a fraction of a mA. You just need a good modern LED. :)
     
    Chris11jed likes this.
  5. Chris11jed

    Thread Starter New Member

    Dec 15, 2013
    16
    0
    Thanks you for the LED advice. I will do some homework on them. :D

    I must say I have calmed down somewhat from my original confused state. And have just resigned to the fact that there's a few ways to tackle these low current pin in/outputs. Thank goodness for the internet and search engines :)

    Chris
     
  6. Art

    Distinguished Member

    Sep 10, 2007
    785
    61
    Unless things have changed, most pic IO pins will sink more current than they can source,
    so if this is the case, you should be able to connect slightly higher load between + 5 Volts
    and the IO pin made an input before needing switching transistors.

    Some 2x16 LCDs use no more current than a midrange pic IO pin can supply,
    but so long as you can power it from a supply that's probably just a waste of a pin.

    You are on the right track with the FET,
    you need to choose a device that will switch the current that the load will use.
     
    Chris11jed likes this.
  7. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,534
    2,369
    I keep a stock of 2n7000 and IRL530's logic gate FET's on hand which cover many needs for power switching from a Pic.
    Max.
     
    Chris11jed likes this.
  8. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    This PIC is a 3.3v type, often run from 2 AA cells which can be as low as 2.5v in operation.

    A high gain bipolar transistor might be better than a FET at those voltages, although it requires one more component (base resistor).
     
  9. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,387
    1,605
    You would think if some guy could design a MOSFET that works inside an IC at 3.3V some other guy could design a discrete MOSFET to work outside.

    Well... they did.

    While then 2N700 is showing its age modern MOSFETs can be obtained with incredibly low threshold voltages. A quick search on Digikey finds 250 hits for N channel MOSFETs with Vth of 1.5V and under.

    Be prepared: I did not see any devices with leads. All SMD.

    But buying parts with leads is so 1990's anyway.
     
Loading...