Professional Documents
Culture Documents
Date
:
Section :
Student Names/ID :
EXPERIMENT 5
A/D Converter Application
Objective
To learn how to program in MikroC to run ADC (Analog to Digital Converter) in Easy Pic 5 board
which is a testbed for PIC programming.
A/D Converter
The EasyPic5 development board has two potentiometers for working with analog-to-digital
converter (ADC). Both potentiometers outputs are in the range of 0-5V. Two analog signals can be
connected to two different analog input pins simultaneously. The jumper group J15 enables
connection between potentiometer P1 and one of the following pins : RA0, RA1, RA2, RA3, or RA4
The jumper group J16 enables connection between potentiometer P2 and one of the following pins:
RA1, RA2, RA3, RA4, or RA5.
In order to measure analog signal without interference, turn off the corresponding switch on the
SW1. This will disable connection between PORTA pins and pull-up/down resistors.
1. ADC Example
Following code reads the voltage input through analog input pin of PIC and prints it on LCD in Volts in
the third decimal place. We use PIC 16F877A.
2. ADC Example 2
Write such a code that reads the voltage input through analog input pin of PIC RA0 and displays it on
LCD as an integer in Volts.
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
void main() {
}
}