Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > sci.electronics.design > #391039
| From | Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> |
|---|---|
| Newsgroups | sci.electronics.design |
| Subject | Re: Todays tronix: funny divider ratios |
| Date | 2015-12-26 10:25 +0000 |
| Organization | Datemas.de http://www.news.datemas.de |
| Message-ID | <n5lpv0$jkb$1@news.datemas.de> (permalink) |
| References | <n5gljg$4ul$1@news.datemas.de> |
This will probably not help you, but mm maybe even Con Fuse you more than you already are,
but
To measure voltages with a PIC ADC (or any other ADC)
first some things, and requirements.
And some things we can chose.
I have chosen to use PIC asm and 32 bit signed integer math.
In case you dunno what signed means, it means bit 31 is the sign bit (well there is more to it, but read up on it).
Second let us assume we have a 36 V battery pack, and want to measure it.
AND we have a 10 bit ADC, that is one that counts from 0 to 1023 FYI.
Also we use a 2.048 reference, that is the PIC internal 1024 mV reference x 2, the maximum we can use at 3.3V PIC supply voltage.
We need 3.3 V supply for the PIC because it interfaces to a 3,3 V ethernet module,
that would probably work too with a 5 V PIC and a resistor divider, then we could use a 4096 reference.
But just for the suspense we use 3.3 V and a 2.048 V reference.
So 1023 steps on the ADC is in fact 2.048 V on the ADC input pin.
Simple City says that the battery pack will have 9 cells, and the max voltage per cell is 4.2 V (set by a parallel regulator per cell),
so 9 * 4.2 , and I use wcalc in a terminal in Linux, easy to do mazz with:
> 9 * 4.2 = 37.8
Interesting, we like binary, so let us say Max Voltage (you know him right?) is lower than 40960 mV.
Now to avoid doing too much mazz maybe you can see that if we make 1023 steps on the ADC correspond to 40960 mV on the battery.
There are a number of issues
1) the PIC 1024 mV reference has a tolerance (unknown).
2) the resistors in the voltage divider have tolerance, say even if we use 1 % resistor then that is still a lot, as 1% of 40960 mV is 400 mV,
almost half a volt, and since we need to know battery voltage of each cell within say 40 mV, all these things need software correction, with a given hardware.
Now, if we leave out the sign bit, than we have 30 bits to play with.
The ADC is ten bits, that leaves 20 bits to multiply the ADC value with:
2^20 = 1048576
So here is the mazz for a 40960 mV on the input, a 20 x resistor divider (say 190 k versus 10 k), 1023 steps on ADC, and 40960 mV battery voltage:
-> ((1023 * (1049602 + 0 ) ) / 1048576) * 2 * 20 = 40960.038986 -> 40960
steps fudge cor 2^20 2xVref divider display in mV only integer part
if we add 25 counts correction then
-> ((1023 * (1049602 + 25) ) / 1048576) * 2 * 20 = 40961.014595 -> 40961 mV displayed.
So we can calibrate display value to 1 mV easily.
Of course the ADC has only 1024 steps, so 40960 / 1024 = 40 mV resolution, say +/- 40 mV that would be between cells too, so 4.2 4.16 4.24 per cell.
Setting the fudge factor a bit lower than 1049602 and adding a 16 bit correction value (0-65535) in EEPROM, set via RS232 once, will make in possible
to calibrate out most errors due to reference voltage and resistor divider.
The math in integer stays simple.
Will It Wurk?
BTW I received via interstellar link the message it is not spelled mazz, but mazzel (if this works).
Back to sci.electronics.design | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Todays tronix: funny divider ratios Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> - 2015-12-24 11:40 +0000
Re: Todays tronix: funny divider ratios John Larkin <jjlarkin@highlandtechnology.com> - 2015-12-24 09:31 -0800
Re: Todays tronix: funny divider ratios Robert Baer <robertbaer@localnet.com> - 2015-12-24 22:25 -0800
Re: Todays tronix: funny divider ratios dagmargoodboat@yahoo.com - 2015-12-25 01:08 -0800
Re: Todays tronix: funny divider ratios John Larkin <jjlarkin@highlandtechnology.com> - 2015-12-25 07:56 -0800
Re: Todays tronix: funny divider ratios Winfield Hill <hill@rowland.harvard.edu> - 2015-12-25 08:22 -0800
Re: Todays tronix: funny divider ratios krw <krw@nowhere.com> - 2015-12-25 11:34 -0500
Re: Todays tronix: funny divider ratios John Larkin <jjlarkin@highlandtechnology.com> - 2015-12-25 09:02 -0800
Re: Todays tronix: funny divider ratios krw <krw@nowhere.com> - 2015-12-25 13:06 -0500
Re: Todays tronix: funny divider ratios Robert Baer <robertbaer@localnet.com> - 2015-12-27 21:39 -0800
Re: Todays tronix: funny divider ratios John Larkin <jjlarkin@highlandtechnology.com> - 2015-12-25 09:11 -0800
Re: Todays tronix: funny divider ratios John Larkin <jjlarkin@highlandtechnology.com> - 2015-12-25 17:18 -0800
Re: Todays tronix: funny divider ratios Bob Engelhardt <BobEngelhardt@comcast.net> - 2015-12-25 19:36 -0500
Re: Todays tronix: funny divider ratios John Larkin <jjlarkin@highlandtechnology.com> - 2015-12-25 18:12 -0800
Re: Todays tronix: funny divider ratios Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2015-12-25 17:05 -0500
Re: Todays tronix: funny divider ratios dagmargoodboat@yahoo.com - 2015-12-28 08:05 -0800
Re: Todays tronix: funny divider ratios amdx <nojunk@knology.net> - 2015-12-25 10:45 -0600
Re: Todays tronix: funny divider ratios Robert Baer <robertbaer@localnet.com> - 2015-12-24 22:23 -0800
Re: Todays tronix: funny divider ratios Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> - 2015-12-26 10:25 +0000
Re: Todays tronix: funny divider ratios John Larkin <jjlarkin@highlandtechnology.com> - 2015-12-26 10:12 -0800
Re: Todays tronix: funny divider ratios krw <krw@nowhere.com> - 2015-12-26 16:16 -0500
Re: Todays tronix: funny divider ratios Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> - 2015-12-26 14:35 +0000
csiph-web