CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to get/determine internal VDD voltage?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








How to get/determine internal VDD voltage?
PostPosted: Mon Feb 09, 2009 8:36 pm     Reply with quote

Hi everyone,

I'm working on a project and I need to determine the exact value of the VDD voltage of the PIC MCU without measuring through a Digital Multi-Meter. I need the exact value of the VDD voltage since it affects the computed temperature value of the temperature sensor that I am using.

Here is the working code that I am using which converts Analog voltage from the temperature sensor to a DC level signal for the PIC MCU. In my code, I assumed the value to have 3.28 volts.
Code:

float getTemperature()
   {float temperature;
    float adcValue;
    float voltage;
   
    setup_adc_ports(sAN0);
    setup_adc(ADC_CLOCK_INTERNAL);
    set_adc_channel(0);
    delay_ms(100);
    adcValue=read_adc();
    setup_adc(ADC_OFF);
   
    voltage=3.28*((adcValue)/1024); //--> need to replace the '3.28' w/ the real VDD voltage value.
    temperature=(voltage-0.5)/0.01;   
         
    return temperature;
   }

I will implement this code to several hardware modules and they would have different VDD values. So hard coding the "3.28" is not recommended in achieving the exact value of temperature.

I hope someone could help me solve this problem.

Thanks in advance!Smile
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Feb 10, 2009 12:52 am     Reply with quote

Can't work without a known reference voltage.
Guest








PostPosted: Tue Feb 10, 2009 2:47 am     Reply with quote

Hi FvM,

"Can't work without a known reference voltage."

--> does this mean that it is not possible to determine the VDD value without using any reference voltage in the code?

Thank you! Smile
Ttelmah
Guest







PostPosted: Tue Feb 10, 2009 3:20 am     Reply with quote

At heart, yes.

Basically, there has to be something to compare with.

There are several trickish ways of finding your Vdd, but all will involve some form of 'reference'.

For instance, if you use the ADC, setup to use 'Vdd', as it's 'reference', to read an external voltage that comes from a source, whose voltage you _know_ (so the source is the real reference), you can then calculate Vdd.

Realistically, the best way for your hardware to work, would be to attach a known reference to the ADC, and do all your calculations from this. However,if you need to use the full supply range for your temperature sensor (some sensors use the full supply range), then the 'answer' is to attach a known voltage to another pin of the ADC, and use this to measure Vdd. For this, the 'point' is that if you have (for instance), a voltage of 2.5v, fed into AN2, and you read it, getting a value of 'X', using Vdd as the reference for the ADC, then Vdd, is:

(2.5/X)*1024

Best Wishes
Guest








PostPosted: Tue Feb 10, 2009 9:43 pm     Reply with quote

Ttelmah

I think i would just use the hard way on measuring the VDD voltage using a Digital Multi-Meter then hard-code the measured value or just stick using '3.28' as the VDD reference.

Thank you for your time answering!Smile
Ttelmah
Guest







PostPosted: Wed Feb 11, 2009 3:24 am     Reply with quote

The problem is that a supply from a typical regulator, will change significantly with temperature, and often with time, for example, so the overall stability of readings your system will then be rather poor. Using a better reference, either as a way of 'testing' the supply every few minutes, or (better) as the Vref for the ADC, will give much more accurate long term readings.
You "pays your money".....

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group