#Picaxe 20M2
#Terminal 4800
ADCCONFIG %011 'Set ADC to FVR
Do
FVRSETUP FVR2048 'Set Fixed Voltage Reference = 2.048 Volts
ReadAdc10 C.3, w0
SerTxd( #w0, CR, LF )
Pause 1000
Loop
Try this: Grid Frequency MonitorWhen y'all get this voltmeter working, please post the code and schematic.
I'd like to build one. Had in mind a power line monitor. Range between 100 and 130 VAC.
Even have a optocoupler link and some 7 segment LED's floating around here someplace.
Very cool project!
#picaxe 20m2
main:
debug
symbol batt = w0 ' symbol for w0.. b0-6
FVRSETUP FVR2048 'Set Fixed Voltage Reference = 2.048 Volts
ADCCONFIG %011 'Set ADC to FVR
readadc10 C.3, batt' 24v input
batt= batt*35
bintoascii batt ,b2,b3,b4,b5,b6
serout C.0,N2400,(254,192)
serout C.0,N2400,(" ",b2,b3,".",b4," volts")
pause 10
goto main
That would seem to be as expected with a 10K on-board pull-down resistor after multiplying the reading by 35.1k and 15k resistor,
10volt input
reading 0.58 into picaxe
W0 reading 10150
That would also seem be as expected after multiplying by 35.24v input
1.37 volt at picaxe input
W0 24000
If the result is changing between 23600 and 24200 the raw READADC10 reading must be changing between 674 to 691, that's equivalent to 682.5+/-8.5, an input voltage of 1.366V+/-0.017V.BUT wanders about .... getting 23.6 to 24.2 v (23600 to 24200)
tried 1uf.. same... 10uf, 100uf....fk it 330uf... better 29.8v to 30.1 volt on display with 30v inPut a capacitor - say 1uF or so - between ADC input pin and V- ; NOISE of one sort or another is very common in this wonderful field of electronic measuring... ;-0
15K Pot
Fuse ___ ___
Vbat+ >--O==O----.---|___|---|___|-
.|. /|\
1K |_| `---------> ADC
|
Vbat- >----------^-----------------------> 0V
Vbat+ >-------.
.|.
|_|
|
}-----.
.|. .|.
|_| |_|
} | |
Vbat- >---.---' }---->|---.---> ADC
_|_ _|_ | .|.
_\ /_ === | |_|
| | | |
-^---------^---->|---^---> 0V
the diode at the 24v input was for reverse polarity but left behind.. now removed.That diode between Vbat- and 0V I would guess allows the entire battery supply to float, so a lot of noise would not be that unexpected.
And on top of that you have one resistor divider between Vbat+ and Vbat- and another between its output and the PICAXE 0V courtesy of the pot and the internal ADC input pin resistance.
Code:Vbat+ >-------. .|. |_| | }-----. .|. .|. |_| |_| } | | Vbat- >---.---' }---->|---.---> ADC _|_ _|_ | .|. _\ /_ === | |_| | | | | -^---------^---->|---^---> 0V
___
Vbat+ >---|___|-----.-----.--------> C.3
68K .|. _|_
10K|_| _ _ 100nF
| |
VBat- >-------------^-----^--------- 0V
#Picaxe 20M2
#Terminal 4800
Do
ReadAdc10 C.3, w0
SerTxd( #w0, CR, LF )
Pause 1000
Loop
#picaxe 20m2
main:
debug
symbol batt = w0 ' symbol for w0.. b0-6
FVRSETUP FVR2048 'Set Fixed Voltage Reference = 2.048 Volts
ADCCONFIG %011 'Set ADC to FVR
readadc10 C.3, batt' 24v input
batt= batt*35
bintoascii batt ,b2,b3,b4,b5,b6
serout C.0,N2400,(254,192)
serout C.0,N2400,(" ",b2,b3,".",b4," volts")
pause 100
goto main
#picaxe 20m2
main:
debug
symbol batta = w0 ' symbol for w0.. b0-6
symbol battb = w4
symbol battc = w8
FVRSETUP FVR2048 'Set Fixed Voltage Reference = 2.048 Volts
ADCCONFIG %011 'Set ADC to FVR
readadc10 C.3, batta' 24v input
readadc10 C.3, battb' 24v input
let w0+w4 = w8 ' error............................................................
battc = battc*35
bintoascii battc ,b2,b3,b4,b5,b6
serout C.0,N2400,(254,192)
serout C.0,N2400,(" ",b2,b3,".",b4," volts")
pause 200
goto main
Try -let w0+w4 = w8 ' error
battc = battc*35
let battc = batta + battb / 2
battc = battc * 35
battc = 0
For b0 = 1 To 35
ReadAdc C.3, battb
battc = battc + battb
Next
That represents a 20% variation which seems way to high to be just as a result of noise. What are you using to provide the 10V level?W0 wanders from 9500 to 1150 ish
tried this, same wanderTry -
But you would probably be better off with the following ...Code:let battc = batta + battb / 2 battc = battc * 35
Code:For b0 = 1 To 35 ReadAdc C.3, battb battc = battc + battb Next
let battc = batta + battb / 2
battc = battc * 35
For b0 = 1 To 35
ReadAdc C.3, battb
battc = battc + battb
Next
using power supply, but also tried batteries..late_voyager,
You said in post #65.
That represents a 20% variation which seems way to high to be just as a result of noise. What are you using to provide the 10V level?
Try a battc = 0 before the For loop.didnt quite get this, understtod what trying to do but kept counting up.
Yes; apologies for forgetting to include that in my suggestion.Try a battc = 0 before the For loop
That is my feeling as well. How well any smoothing or averaging solution works will depend on the nature of the noise and particularly its periodicity.But IMHO it's not the ultimate solution and I still suspect a hardware (layout ?) problem. There's a very old computing motto: "Garbage in, Garbage out".
ok oops...NO, you need to halve the potential divider, e.g. change 1k -> 2k or 15k -> 6.8k .
Cheers, Alan
And what is the actual battery voltage measured with your meter ?great w0 now 10290 to 10350.....10.2/10.3 volts....
23.95 on meter, 23.9 on picaxe displayAnd what is the actual battery voltage measured with your meter ?
10.29 to 10.35 is a much better result, just an apparent +/-30mV variance. If it happened to have been 10.29 to 10.34 software rounding to one decimal place would have delivered 10.3 in both cases. Adding some averaging for one reading to the next would probably smooth that out nicely.
I would move the 100nF capacitors closer the their associated chips (particularly the 20M2). Why? Because it can be easily done and technically better. (I'm sure you know about the air-wires too.)the project so far and not finished... brain ache..