Question: Project Name: - ADC _ ( L ) CD Description: - This program reads the Analog voltage from the potentiometer on input AN 0

Project Name:-
ADC_(L)CD
Description:- This program reads the Analog voltage from the potentiometer on input "AN0
(RA0)" and displays the 10Bit ADC result (i.e.0-1023) on the first row of an LCD display. It
also displays the calculated Analog Input voltage on the 2^(nd ) row of the LCD display.
Add the file "lcd.h" to the Header Files folder and "lcd.c" Source Files folder as sohwn
below to the project in MPLABx:-
Include the "lcd.h" within "main.c":-
#include "..LLCD ()/(lcd.h)"
Create a macro name for ON and OFF :-
E.g. #define ON 1
#define OFF 0
Setup PORTB pins RB 7:0> as Digital Outputs.
Setup AN(0)/(R)A0 pin as an Analog input.
Setup the ADC as follows (see ADCON0 & ADCON1 registers on pages(114)/(115) of the
PIC16F188 Datasheet):-
ADCON0
- Setup ADCS 1:0> bits to select the internal RC
-
Create a 16-bit variable called "adc val", to store the 10-bit adc result.
Inside a continuous loop, start an ADC conversion by writing to the "GO_(D)ONE" bit.
Wait until the ADC conversion has completed.
Align the 10bit ade value from ADRESL & ADSREH inside the variable "adc_(v)al". Call
the function "display bar(adc_(v)al)".
Calculate the value of vin using the following calculation:-
vin =(( float ) adc_(v)al *5)()/()1023;
Print the values of "ADC_(V)al" and the calculated "vin" to two decimal places to the
LCD screer ne shown halow.
Add comments to your coade (marks lost ior no comments).
Ensure all code is properly indented (i.e. marks lost for no indentation).
Within Proteus, rather than copying the contents of the main.c code from MPLABx since
there are now multiple files, it is eaiser to point to the compiled hex file
Project Name: - ADC _ ( L ) CD Description: -

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!