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.
ok, well i found that ANALOGIN may not be exactly what I was looking for since the voltage range i am trying to read is .001 vDc to 1.000 vDc. It appears ANALOGIN is only accurate to .50 vDc. Is there a different or more efficient approach to reading voltage on 1 pin?
You will have to use an external ADC chip for that resolution.
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
ok, I am completely lost now! I have tried several different resistors and several different formulas and all i can get for the Volt is 0, 1, or 2 when using the WATCH command.
Can someone better explain the formula to use with ANALOGIN to get the correct voltage to the nearest 100th or 10th decimal? I have tested a 1.5v AA battery and I got Volt to equal 85.
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.
Seeing all those letters and numbers is what confused me. I suck at math and need major help on how to simply read the exact voltage to the nearest 100th or 10th decimal then display it. For some reason, I can't get the chip to understand decimal points so this is being a major hassle so far. I am using the ANALOGIN example schematic in the Help section to get closer to where I need to get. So far, I can get the WATCH Volt to show 85 when I put a good AA battery to the test leads. Now, how to I convert that number into the actual voltage?
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.
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.
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.
That are the values for an input range of 0-1v.
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.
I have built a dc voltmeter using an analog devices adc 654. The IC converts voltage into frequency. A pin on the SX can be configured as a TTL input to receive this signal. The count command can be used to count pulses over time. The main program can be written to convert pulses over time to DC volts, an the program can be configured to manipulate output pins on the SX for peripherals.
Here is the code for a DC digital voltmeter using an analalog devices ADC 654. There are 3 scales selectable by a rotary switch. The rotary switch does 2 things. 1) It communicates with pins on the SX telling the program what scale the meter is on. 2) It connects the probes across·no voltage divider,·or one·of two voltage dividers. The ADC is configured at 1.00 VDC a frequency of 100KHZ. There are 3 scales 1, 10, and 100 VDC. The 1 volt scale uses no divider, basically just probes connected to the ADC. On other scales a voltage divider is used to convert 10VDC to 1VDC or 100VDC to 1VDC, where the divided signal is sent to the ADC. The program calculates tenth volts and displays on a 4 digit multiplexed display. This program is in its early stages and needs many improvments. It is configured to run on a 50 MHZ external resonator which is required for the count command to count at the required speed. On the 1 volt scale it is accurate to +_ .1 volt which gets magnified some on higher scales. I am working on this and believe it to be correctable as a configuration on the ADC. Look at the analog devices website an there are schematics and sample circuits. As far as my circuit I have no schematic yet. It will drastically change as I am now altering it to measure AC as well as DC. Some of my comments on the program may no longer apply due to some changes. The ADC is configured using a timing capacitor and a few resistors. By chosoing the values properly you can get a specified frequency at a wide range of full scale voltages.
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