Hello friends, I hope you are doing well. In the previous tutorial, we studied the working principle of a relay. Today, we will connect a 12 V relay to a PIC18F4550 microcontroller through a ULN2003A driver. A relay coil needs more voltage and current than a microcontroller pin should provide. It is also an inductive load, so it produces a voltage transient when switched off. The ULN2003A solves these interface problems by providing seven low-side Darlington drivers and seven internal clamp diodes in one package. The key point is that the ULN2003A does not convert a 5 V logic signal into a 12 V output. The 12 V energy comes from a separate 12 V supply. A logic high merely turns on one internal driver, which connects the low side of the relay coil to ground. We will examine that current path, calculate the important values, build the circuit and write a small test program. Suppose the relay has a 12 V coil rated at 400 mW. Its approximate current is: Icoil = Pcoil / Vcoil = 0.400 W / 12 V = 0.0333 A = 33.3 mA The approximate coil resistance is: Rcoil = Vcoil / Icoil = 12 V / 0.0333 A = 360 ohms A PIC18F4550 output operates from its logic supply and is not a 12 V power output. Microchip's PIC18F2455/2550/4455/4550 datasheet lists 25 mA per pin under absolute maximum ratings, but an absolute maximum is a damage boundary rather than a recommended operating point. Output-voltage specifications, total port current and device power dissipation impose additional restrictions. A 33.3 ...
Hello friends! In this tutorial, we will design an LED blinking project using the PIC16F877A microcontroller. It is a simple project, but it introduces several ideas that appear in almost every embedded system: configuring an I/O port, choosing an oscillator, building a reset circuit, calculating LED resistors, generating a time delay, compiling a program, and loading the resulting HEX file into Proteus. We will connect eight LEDs to PORTB and switch the complete port between logic low and logic high. Once this basic version works, you can change the output patterns and timing to create a running light, binary counter, or status display. The important objective is to understand why every connection and every program statement is present. The PIC16F877A is an 8-bit microcontroller from Microchip's PIC16F87XA family. It has a 14-bit instruction word, Flash program memory, RAM, data EEPROM, timers, an analog-to-digital converter, two Capture/Compare/PWM modules, a USART, and serial interfaces that can operate as SPI or I²C. For this first project, we only need its clock, reset, power, and PORTB digital-output functions. The 40-pin PDIP device provides eight PORTB pins named RB0 through RB7. The TRISB register controls their direction. A TRIS bit equal to 1 makes its corresponding pin an input; a bit equal to 0 makes it an output. Therefore, writing TRISB = 0x00 configures all eight PORTB pins as outputs. Microchip lists the PIC16F877A as an in-production device and provides the ...