$30
A) Voltage Meter:
Connect AN0 (RA0 @pin 2) directly to the wiper pin of a potentiometer (see schematics). Write a program that will measure the voltage input VL0 at AN0 (RA0) and display its value on the two 7-segment displays with the upper digit in
Volt and the lower digit representing the 1/10V unit. Turn on the Decimal Point (connected to pin RD7) of the leftmost digit (Upper digit) to show the decimal point. In addition, your team will need to show the same result on the TeraTerm software by doing the output through the use of ‘printf’.
Hint: Copy the function ‘get_full_ADC(void)’ used in the previous lab to measure the value of the input voltage. Make sure that on the register ADCON0 you select
AN0 (pin RA0) as the voltage source. Don’t forget to use the function ‘void
Select_ADC_Channel( char channel)’
Also, you must make sure that the register ADCON1 has the proper value to force the pin AN0 as an analog input. In addition, don’t forget to program that same register so that the external voltage VREF = 4.096V as the VREF+ reference voltage for the A/D while using GND as the source for VREF-. Do visit the datasheet of the PIC18F4620 at the A/D chapter and look for ADCON1’s definitions.
Make 4 measurements from 0.5 to 4V in increments of 1.0V (do not go past
4.0V). For each measurement, take only the data shown on the output of TeraTerm (not the display) and then measure the same voltage using a DVM. on TeraTerm for each measurement.
V(DVM)
V(TeraTerm)
% difference
0.5V
1.5V
2.5V