Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Facing problem in Set the Vref voltage using interal ADC of pic18f4550

Not open for further replies.


Full Member level 2
Dec 30, 2011
Reaction score
Trophy points
Activity points
Dear All.
i want to interface interface ADC of PIC18f4550. i have temperature sensor LM35DZ. whose value i want to show on LCD. My problem is that i am unable to understand that what value i set in Vref ? if i set any value like 2.5 V or 1 V then how should i do calculation so that i can get exact reading in LCD. Please help me.
Thank You


There will be a formula in ADC (section) datasheet with the relation of ADC code to input voltage (including VRef value).

And there will be a formula in temperature sensor datasheet with the relation of output voltage to temperature.

Use both formulas to create a new formula with the relation of ADC code to temperature, to use it in your program.

If you need more detailed help, then please post both formulas from the datasheets.


The value of your output voltage is depends on the Vref which you are going to set. For example in some cases the output of your ADC could be "2 x Vref". But it also depends on your ADC operating voltage which should not be lesser than the maximum output voltage.

When coming to the sensor side. Following is the formula which has given in the datasheet.

VOUT = 10 mv/°F × T
• VOUT is the LM35 output voltage
• T is the temperature in °C

Now join both these two to attain the final value to be displayed on the LCD.

Hope it cleared your doubt.

The number of ADC steps is constant, it has a 10-bit ADC so there are 1024 possible readings from 0 to 1023.
The steps are equally spaced between Vref- and Vref+ so if you know what those are, you can work out the voltage represented by each step in measurement.
Multiply the ADC value by the step size and it will give you the actual voltage on the input pin but bear in mind if you used a Vref- other than ground, your reading is relative to that and not 0V.

Vref+ should never be less than the voltage you want to measure or higher than VDD. Vref- should never be higher than the voltage you want to measure or less than 0V (not be negative). In other words the voltage should be kept between Vref- and Vref+.

Example, if Vref- is ground and Vref+ was 2.5V, each step would be (2.5 - 0)/1023 = 0.00244V and and ADC reading of 123 would mean the actual voltage at the pin was (123 * 0.00244) = 0.3V.

Not open for further replies.

Part and Inventory Search

Welcome to