Summary of Analog to digital 8 bits For CSS Compiler
This code configures a PIC 16F877 microcontroller to read analog data from channel AN0 and display the raw ADC value (0-1023) on an LCD screen in real-time. It initializes the internal clock, disables unused peripherals, sets Port D as output for the LCD, and continuously loops to update the display with the current sensor reading converted via a hex-to-BCD function.Parts used in the PIC 16F877 ADC LCD Monitor:
- PIC 16F877 Microcontroller
- LCD Display Module
- Analog Sensor connected to AN0
- 4MHz Clock Oscillator
#include <16F877.h>
#device adc=8
#FUSES NOWDT ,XT
#use delay(clock=4000000)
#include <Lcd_4bit.c>
int8 value;
void main()
{
setup_adc_ports(AN0_AN1_AN3);
setup_adc(ADC_CLOCK_DIV_2);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
set_adc_channel(0);
set_tris_d(0x00);
set_tris_A(0xff);
Lcd_init();
while(true){
set_adc_channel(0);
delay_ms(10);
value = read_adc(); // 0-1023
Lcd_row_col(1,0);
Lcd_putc("setpoint=");
hex_bcd(value);lcd_row_col(1,9);sent_Lcd();
delay_ms(50);
}
}
Quick Solutions to Questions related to PIC 16F877 ADC LCD Monitor:
- What is the primary function of this program?
The program reads analog values from channel AN0 and displays them on an LCD. - How does the code initialize the LCD?
The Lcd_init function is called within the main setup section before the loop begins. - Which ADC channel is selected for reading data?
The set_adc_channel function selects channel 0 for reading analog input. - What range of values does the read_adc function return?
The function returns integer values ranging from 0 to 1023. - How long is the delay between ADC readings?
A 10 millisecond delay occurs after setting the ADC channel before reading the value. - What port is configured as output for the LCD?
Port D is configured as output using the set_tris_d command with a value of zero. - Is the Watchdog Timer enabled in this code?
No, the FUSES directive explicitly disables the watchdog timer with NOWDT. - What clock speed is used for the system delay?
The system uses a 4 MHz clock speed defined by the device delay directive.
Related projects
PICDEM FS USB Mass Storage Device using PIC18F4550 with Proteus Simulation
Introduction This microcontroller project demonstrates how to simulate a USB Mass Storage Device (MSD) using the PIC18F4550 in a Proteus simulation environment....
Peripheral TutorialsHands-On Digital I/O Lab with PIC18F46K22 Microcontroller
PIC18F46K22 Microcontroller Digital I/O specifically explores the design of simple combinational circuits using the digital I/O capabilities of the PIC18F46K22 microcontroller. Moving...
Peripheral TutorialsDesign for manufacturing and assembly: DFA&DFM
Product developers understand the challenges involved in creating a market-ready product. Even experienced designers often go through multiple prototype iterations before reaching...
Peripheral Tutorials · PIC16F877AKeypad 4×5 for microcontrollers v. 1.1 using PIC16F877
What's this? The circuit here described is a simple 4x5 keypad that can be used in particular with the PIC 16F877 microcontroller,...
Peripheral TutorialsMatrix scankey 3×4 for Lcd 2 line For CSS Compiler
Peripheral Tutorials · PIC16F877APIC16F877 timer1 code and Proteus simulation
This PIC16F877 microcontroller tutorial answers the question, " How to use timer1 of PIC16F877 and how to handle its interrupts? " Using...