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

Voltage question ???

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



Joined: 13 Nov 2003
Posts: 12
Location: Kissimmee Florida

View user's profile Send private message Send e-mail Visit poster's website

Voltage question ???
PostPosted: Wed Jun 30, 2004 7:02 am     Reply with quote

Iam using the 16F876 as a meter. What i need to do is as the voltage decreases i need to display a number that increases on the display.
What i have is a log det that as the power increase a voltage comes out and goes to an att chip and decreases signal.
so if i have 1V it should read 100mw if its .75V then 200mw as an example.

Thanks,
Donnie
alexbilo



Joined: 01 Jun 2004
Posts: 39
Location: Trois-Rivières

View user's profile Send private message

PostPosted: Wed Jun 30, 2004 7:49 am     Reply with quote

Don't know but if you want to get an answer, I think that you should ask a question first...
_________________
Alex
donnie



Joined: 13 Nov 2003
Posts: 12
Location: Kissimmee Florida

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Jun 30, 2004 7:51 am     Reply with quote

.75V should be 100 on the display and 1V should be 200 on the display.

So as the voltage goes down the scale needs to go up.

Thanks,
Donnie
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Wed Jun 30, 2004 7:52 am     Reply with quote

If the relationship is linear then it is a simple equation, mx+b where m is the slope of the line (negative), x is the voltage in question and b is the reported power when the voltage is zero.

If the relationship is not linear then you need a more complicated formula. You could do piece-wise linear or a polynomial fit which would be the next simplest methods.

To convert from the ADC word to voltage you compute

V = adc_word * vref / max_word

adc_word is the value returned from the ADC,
max_word is the maximum word the ADC could ever return
vref is the referenece voltage value

Try to avoid using floating point operations in your calculations. Generally you can scale things to fit integers and also pre-calculate scaling factors lime vref / max_word rather than do them each time you need a new voltage.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
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