Measuring voltage with a pin on the SX/28?
eagletalontim
Posts: 1,399
Is there any command like the ANALOGIN that will work with the SX/28? I need to measure the voltage of one wire from my car and process the voltage variable in the chip.
Comments
·- Sparks
In the help file under Reference and Commands the ANALOGIN command is the first one listed.
Please post if you need further help.
·- Sparks
BTW: ANALOGIN has a resolution of 0.02v (5.00 / 255).
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"A government big enough to give you everything you want, is big enough to take away everything you·have."·· Thomas Jefferson
"It is our choices, Harry, that show what we truly are, far more than our abilities."·Dumbledore from Harry Potter
www.iElectronicDesigns.com
·
ANALOGIN InPin, OutPin, Volt
Volt = Volt / 255
Is that correct?
See attachement.
In your case:
Vdd = 5v
Uinmin = 0v
Uinmax = 1v
This yields
R2 = 5*R1
R3 = 1.25*R1
leave R4 out
The C is not critical, 0.1u will do.
This gives you full range 0-255 representing 0-1 volt.
regards peter
Is the math :
TrueVoltage = ((225 / Volt) * 5vdc) / 10)
If that is the case, the 1.5v battery measured at 85 for the Volt variable and if plugged into the formula above, it gives 1.324 vDc.
The only problem I have is that if I put 5vdc to it, I get 225 as the Volt. If plugged into the formula, it is .5vdc. What am I doing wrong?
Don't get discouraged... you are learning tons here, and lots more to go!
Please dissect Peter's formulas to the point where you fully understand them..... there is a wealth of information in them.
You will find that as you bias the sensing circuit of te A/D to near the switching threshold, the effective amount of ampification possibe grows greatly. Although I have not (yet) had the time to pursue this concept, I believe that one could make a nice, albeit low frequency, software amplifier out of that D/A circuit, and enhance the resolution of it to 1 millivolt, say minus to plus 128 mV. Now in order to do that, the software would need to be written in a very deterministic manner, and would, at least at this time, certainly require the useof assembler code.
I'm anxious to find the time to pursue this, but alas it will have to wait for a while.
Cheers,
(the other) Peter V (pjv)
The ANALOGIN produces a 8bit value, 0-255, that represents the full scale.
In case of the sx/b help file example, both resistors are equal and the
input range is 0-5v.
TrueVoltage = (Volt/255)*5v
Your measured 85 therefore represents (85/255)*5v = 1.66v
More generally, using Uinmin and Uinmax
TrueVoltage = Uinmin + (Volt/255)*(Uinmax-Uinmin)
Note that when you use this formula directly in sx/b you will
not have a result in decimals due to the integer division.
To have 2 decimals let TrueVoltage = 100 represent 1.00v
TrueVoltage = 100*Uinmin + (100*Volt/255)*(Uinmax-Uinmin)
Use words to do the math.
regards peter
Well, you would need to scale it. Presumably you are using a 5volt setup, so 256 counts would represent 0 to 5 volts, so as Bean said, each count represents 5 divided by 256 = 0.019, or approximately 20 millivolts. And if you are reading 85 counts, then this means you are measuring a voltage of 85 times 20 millivolts = 1.7 volts approximately.
To display that number you would need to take the reading of 85 and multiply by 20 to see 1700. Optionally you could divide that result by 100 in order to see 17 , and park a decimal between the two digits.
Cheers
Peter (pjv)
R2 = 5*R1
R3 = 1.25*R1
so...
R1 = 10k
R2 = 50k ??????
R3 = 12.5k ??????
I did not know those sizes existed or i am doing something totally wrong
10k is available, 50k equals two 100k parallel, 12k5 equals 10k in series with 4x 10k parallel.
You could use 12k instead of 12k5 which gives a small change in input range.
regards peter
Hope this helps
That sounds interesting, could you post any of your code or schematics?
Thanks,
Russ
Very nice, looks like I'll have to buy some more proto boards for another project.. Way too many great ideas on this board!
Russ