Web Hosting

Lecture 44 : Blinking LED with PIC16F877A

Objective
To demonstrate blinking of an LED interfaced with PIC16F877A
Description:
A LED is connected to RA0 pin of Port A. This pin has built-in internal pull-up which can source a current of up to 25mA. The circuit diagram is shown as follows -
Fig 44.1  Circuit diagram for blinking LED experiment
Assembly Code:
Sampling an analog signal periodically and displaying its digital value using PIC16F877A
Aim
To continuously sample convert an analog signal to its digital equivalent and read the digital value from one port of the PIC16C74A microcontroller
Components/Software
  1. PIC16F877A microcontroller
  2. Programmer (to program the microcontroller)
  3. Computer System with Windows 98 or later operating system and RS-232 Cable
  4. +5v D.C Power Supply
  5. Resistors, Capacitors
  6. 10 MHz crystal oscillator
  7. Signal Generator and CRO
Description
An analog signal is converted to digital value using an A/D converter (which is in-built in the PIC microcontroller). After conversion is complete, the eight digital bits are written to Port D. The process is then repeated. The A/D conversion is done on an interrupt basis.
Procedure
  1. Write the code using a desktop PC. Compile it and transfer it to the microcontroller using the programmer.
  2. Wire the microcontroller as shown in the diagram.
  3. Switch on the supply and push Reset button
  4. Observe the results
  5. Switch off the supply
Assembly Code
include PIC16F877A
org 000H
goto Mainline
org 004H
bcf PIR1, ADIF
movf PORTD, w
goto Mainline
org 20H
Mainline:
bsf STATUS, RPO
clrf ADCON1
movlw 30H
movwf TRISA
movlw 30H
movwf TRISE
bsf PIE1, ADIE
bsf STATUS, RPO
movlw 081H
movwf ADCON0
bcf PIR1, ADIF
bsf INTCON, PEIE
bsf INTCON, GIE
bsf ADCON, GO
Observation
The digital equivalents of the applied analog signal were observed. The digital bits were observed, one at a time, using the CRO.
Conclusion:
An analog signal is converted to digital one. The digital signal is observed at Port D of the PIC microcontroller.
Circuit Diagram:
 

No comments:

Post a Comment