View previous topic :: View next topic |
Author |
Message |
donnie
Joined: 13 Nov 2003 Posts: 12 Location: Kissimmee Florida
|
Voltage question ??? |
Posted: Wed Jun 30, 2004 7:02 am |
|
|
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
|
|
Posted: Wed Jun 30, 2004 7:49 am |
|
|
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
|
|
Posted: Wed Jun 30, 2004 7:51 am |
|
|
.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
|
|
Posted: Wed Jun 30, 2004 7:52 am |
|
|
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! |
|
|
|