Saturday, February 16, 2013

Driving external loads using ULN2803 with PIC16F887

Here I’m going to drive external loads such as motors,relays,lamps…etc using a Darlington pair setup.The current can be provided by an I/O pin of a uC is not sufficient to drive such large loads.Even if you try to do so,you microcontroller will be damaged. Surprised smile 

ULN2803 is a popular Darlington pair IC with 8 Darlington pairs in open collector configuration.Open collector configuration is much useful to drive devices with different voltage requirements than the uC.You can find more information on ULN2803 from its datasheet. I got ULN2803 for around Rs50 (US$0.4) and it’s easy to use than building from scratch.But please note that output voltage is up to 50V while maximum output collector current is 500mA.  You can also use cheaper ULN2003 but it has only 7 Darlington pairs.

I’m going to build a simple circuit (by modifying the circuit from previous post) as follows to demonstrate the ULN2803’s usage Winking smile

DSCF5576_800x600

Here I’m using LED with a series resistor as the load.The Vcc2 is used as +5V too.If you are going to drive motor or other device you have to use the needed voltage for that device as the Vcc2 (12V or so).

Here’s the driving of the led and the MikroC code for it.

DSCF5571_800x600

Note that bolded lines are use to bling this green LED Winking smileConfiguration bit for the project is same as for the previous post.


void main() {
    osccon = 0x70;
    ansel  = 0;
    anselh  = 0;
    trisa = 0;
    trisb = 0;
    trisc = 0;
    trisd = 0;
 
  for(;;){
  portd.f4=1;
  porta.f7=1;
  delay_ms(5000);
  portd.f4=0;
  porta.f7=0;
  delay_ms(5000);
  }
   
}

No comments:

Post a Comment