PDA

View Full Version : Display Vdd



davesatu
- 11th February 2010, 04:25
Hi all. Newbie here so please be gentle. Using a 16F876 and 2.45a. Want to display Vdd on an up and running LCD. Can't figure it out. When displayed Vdd will then be adjusted to exactly 5 volts to be used as the reference to convert and display an input voltage through an ADC pin. A test 3 volt battery ADC input works well even to 3 decimal places but uses actual Vdd rather than 5 so this question.

Am I on the right track or is there a better way to get a correct ADC voltage on screen? LCD Pics here. Should mention the 4 shown at right hand bottom is a toggle from 4 to 8 when you press the Ohms button. It's a relay for this project.

Any help much appreciated. tks Dave.

HenrikOlsson
- 11th February 2010, 06:32
Not sure I understand... Have you connected Vdd to an analog pin or are you trying to somehow "internally" get a reading of it?

If you're using Vdd as Vref for the ADC then it simply won't work because whatever Vdd is is also your refenrece for full scale ADC reading. You'd need to configure the ADC to use external Vref and have a stable voltage reference that doesn't change as the battery voltage goes down (voltage reference IC, zener diode, voltage regulator etc). Then you can use a resistor network to "scale" the voltage to withing the Vref- and Vref+ for the ADC.

Does that make sense or did I completely miss the point?

/Henrik.

davesatu
- 11th February 2010, 23:40
Hi Henrik.

Thanks for the info. I would rather use the internal vRef which as you say moves with Vdd. So if I can adjust Vdd and so vRef to exactly 5 volts (from a mains variable supply) as the constant I can use the formula (ADC output/5) * 255 to display my readings. I can always set Vdd with a multimeter but as a learning exercise would like to do this through the Pic as well.

Perhaps I should explain what I am trying to do which is to display on LCD variables between 0 and 30 volts AC. The AC input is rectified through a diode then a 10uf cap and a voltage divider. Maybe add a 4v7 zener for safety? - still to try that. So 0-30 VAC becomes 0-5 VDC. Then just a matter of scaling the readings by 6.

Or is there more to it? Thanks Dave.

Archangel
- 12th February 2010, 00:33
That might not be as easy as you state. 30 volts A/C is an RMS value, which is an average of all the voltage, the peak value of an AC 30v will be much higher, and you will see the rectified voltage will result in a much higher DC voltage than 30 VDC.

davesatu
- 12th February 2010, 02:48
Thanks Joe.

Yes of course you are right. The rectified voltage will be 1.414 times the AC voltage. And it measures accordingly. That's why I have a voltage divider built in and probably a zener after that to cover any cases where the AC goes over 30 volts.

Any suggestions on how to do display Vdd/Vref ? Dave.

HenrikOlsson
- 12th February 2010, 06:15
I may still be missing the point but if you want to measure and display Vdd, ie the PICs supply voltage, you MUST use an external, stable, source for Vref that does NOT "move" with Vdd, otherwise you will simply get the same reading all the time.

Let's say your Vdd is 4.85V and therefor your Vref is 4.85V. A voltage of 4.85V on the analog inputs will now give you a full scale result (1023) from the ADC because 4.85V is what Vref is set to. Whatever you set Vref to is what will give you a full scale reading so as long as Vref=Vdd you can not measure and display Vdd with the ADC.

/Henrik.

davesatu
- 13th February 2010, 23:37
Thjanks again.

All received and well understood. But the original question remains : "how do you physically display the current value of Vdd on an LCD?"

HenrikOlsson
- 14th February 2010, 08:34
Hi,

But the original question remains
And has been answered IMO.....
You use some kind of voltage reference chip that produces a stable reference voltage over the whole operating range of your batteries. Let's say that voltage is 2.048V. You connect this reference voltage to the Vref pin on the PIC and set the ADC up to use that pin as Vref+ instead of Vdd.

Now you create a resistor network between Vdd and Vss and choose the resisitor values so that the voltage over the lower resistor is as close to 2.048V as possible when the batteries are fully charged. You connect this "signal" to the analog input of your choise.

Now the ADC will give you a reading of 2mV/count.

There is no way to internally "connect" Vdd to an analog input - except to the Vref+ pin. And there is no way to do measure Vdd without using an external reference voltage.

/Henrik.