Analog to digital converter use microcontroller and Mikro C code
In this tutorial I am show you how to working analog to digital converter in PIC16F877A. PIC16F77A Microcontroller has 8 channel ADC module. I am use this project analog channel 0.
you can watch the video or read the written tutorial below.
ADC module receive analog voltage. The analog voltage can be (0-5)V. ADC module it convert 10 bit digital value corresponding analog signal. PIC ADC module has software selectable high and low voltage reference input and some combination of VDD , VSS , RA2 & RA3.
Mikro C Pro For Pic provide a ADC library with comfortable working with the ADC module.
ADC Library On Mikro C Pro For PIC
ADC (Analog to Digital Converter) module is available with a number of PIC MCU modules. ADC is an electronic circuit that converts continuous signals to discrete digital numbers. ADC Library provides you a comfortable work with the module.
Library Routine
- ADC_Init
- ADC_Init_Advanced
- ADC_Init_Sample
- ADC_Read
Circuit Diagram
Mikro C Code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned int adc_result; | |
void main() { | |
ADCON1 = 0X80; | |
TRISA0_bit = 1; // RA0 is analog input | |
Adc_Init(); // Adc module initialize | |
TRISB = 0X00; // PORTB is output | |
PORTB = 0X00; // clear PORTB | |
while(1){ | |
adc_result = adc_read(0) ; // adc read channel 0 | |
PORTB = adc_result; | |
delay_ms(100); | |
} | |
} |
DOWNLOAD
You can download mikro C and protiues file. Click the download button.
![]() |
download |
No comments