Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
PicFan Senior Member Joined: 18/03/2014 Location: AustriaPosts: 133
Posted: 10:46pm 11 Apr 2015
Copy link to clipboard
Print this post
Hello !
I use 2 x 470k and 100 nF to GND without problems. The device is powered by batteries.
The only problem I have is when replacing the batteries - very often the program is lost. (MK2, 4.6B)
PicFan
redrok Senior Member Joined: 15/09/2014 Location: United StatesPosts: 209
Posted: 03:05am 12 Apr 2015
Copy link to clipboard
Print this post
Hi WhiteWizzard;There is no diode drop.
It's more likely the resistor values are not precisely 4K7 nor 470K. Measure them with an ohmmeter and use these values in your software calibration code.
I bet you will find the readings will be the same after resister calibration.Mainly how rapidly the micro can read the AtoD with code written in assembler.I don't think MMBasic will be able to read at maximum speed as MMBasic insulates us, somewhat, from the internal workings of the AtoD.No!, the 200mV is merely an artifact of resister divider accuracy.
Try this:
(Rhi + Rlow) / Rlow * AtoD = Vin
Rhi is the resistor connected to the thing you are measuring.
Rlow is the resistor connected to ground.redrok
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2933
Posted: 04:38am 12 Apr 2015
Copy link to clipboard
Print this post
Ok - new problem to solve
Taking the equation (highlighted by redrok as): (Rhi + Rlow) / Rlow * AtoD = Vin then to manually 'plug' in the measured values for Rhi and Rlow is ok (and sure gives the correct reading as expected). BUT how can this be 'automated' in code (imagine mass production - you don't want to have to measure and insert resistance values for each unit)
I can only think of using high spec resistors (i.e. with a very low tolerance value). So by pure math, the lower the resistance used (along with low tolerance value) then the better.
Is there a better way to measure an external voltage between 2.5v and 4.5v that will self/auto calibrate to give accurate readings? Readings to 0.1v is acceptable. I prefer not to have to use additional ICs (i.e. OP amps) but will wait to see any responses . . . .
WW
twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1576
Posted: 04:52am 12 Apr 2015
Copy link to clipboard
Print this post
Precision resistors (0.1%-1%) are not necessarily more expensive (~0.10-0.15€).
Michaelcausality ≠correlation ≠coincidence
redrok Senior Member Joined: 15/09/2014 Location: United StatesPosts: 209
Posted: 10:01am 12 Apr 2015
Copy link to clipboard
Print this post
Hi WhiteWizzard;I figured that would work!There is no other, cheap, solution than to do this other than to use good resistors. And, as twofingers said, they are not expensive.
Besides, even if you use an op-amp that would also require a pair of precision resistors.
I commonly take a bag of 200 5% resistors, measure them, and match them up in bins. You would be surprised how many come out as accurate 0.1% pairs, often 25% or more. Now you have accurate divide by 2 networks. OK, not what you really want for a production board. But if your only making 10 or 50 units not too onerous.
As an aside, hardly any 5% resisters are outside of the 1% boundaries.
Who actually sets out to make 5% resisters anymore, that would be crazy.
The resistor production tools are far superior to what was used years ago.
BTW, worst case 1% resistors should be able to divide 4.5V by 2 and still read to 90mV worst case plus the AtoD error.
0.1% would be 9mV worst case plus the AtoD error.redrok
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 09:44pm 12 Apr 2015
Copy link to clipboard
Print this post
Instead of calibration being something you have to do it can be a lesson.
A very valuable lesson even as it shows what needs to be done to get accurate measurements.
Even programmers are not free from this knowledge as otherwise it would result it some bad products.
You could provide a bag of 10 resistors and have one of the lessons be finding a match.
Or you could provide a little program that when a known voltage (directly from a voltage regulator) is applied to a pin it shows the values to be used for the two variables Rhi and Rlow. The curious then can study that program how it is done, the others can just copy the values.
Or you can use a potentiometer (with the resistance being about 5-10% of the used Rhi and Rlow resistor values) for calibration in between the Rhi and Rlow. Applying a known voltage would then allow a calibration to be done by turning the potentiometer.
A small program can then just show the measured input and students can try to get it exactly right. Maybe a 10 turn precision potentiometer if costs allow it?
Edited by TZAdvantage 2015-04-14Microblocks. Build with logic.
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2933
Posted: 11:51pm 12 Apr 2015
Copy link to clipboard
Print this post
I like your thinking TZA - albeit this is more suited for an 'electronics' lesson rather than a coding lesson.
The issue I am trying to solve is actually the last thing I need to sort out for the 'internals' of the kids computer. I am trying to get a simplified but accurate measurement of the LiPo's status. I am fed up with 'devices' telling me a battery is flat (when it actually isn't), or likewise saying there is charge remaining when in fact it is near flat. So I have incorporated several technologies into the kids computer to provide a simple (yet accurate) summary of battery status.
I am fully aware that voltage isn't an accurate representation of battery status in its own right - I just need it to give accuracy to another technology I am using (but not going into the detail of that here as it is something that is quite innovative).
My preference at the moment is to use high tolerance resistors and then read the AIN value when the LiPo charge is complete. Whatever the value is, I can then calculate a 'multiplier' to adjust the read value to 4.2v. This multiplier can then be applied to all read values.
Please feel free to let me know if there are any flaws with this method!
WW
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 11:55pm 12 Apr 2015
Copy link to clipboard
Print this post
wrong topic. :) Sorry
Edited by TZAdvantage 2015-04-14Microblocks. Build with logic.