Closed adamgarbo closed 2 years ago
@PaulZC reminded me that we've encountered this issue before!
https://github.com/sparkfun/OpenLog_Artemis/issues/11#issuecomment-637340564
By the sounds of it, the higher resistance is worsening our accuracy and a correction factor will be needed to calculate the correct battery voltage measurement.
Hi Adam (@adamgarbo ), You've correctly spotted that the second divider will be loading the first and throwing the measurement off, but yes the 100k divider will still limit how fast the ADC sample-and-hold capacitor can charge up leading to further scale errors. In this case, I think you need a hybrid model that takes both effects into account. All the best, Paul
As I have learned recently with the RTK Surveyor, you may be better off with a fuel gauge IC such as the MAX1704x family (MAX17048 is what we use). These very low power devices are much better at correctly measuring a battery in a low-power situation.
Hi @PaulZC,
I'm revisiting this issue as I have a number of projects based on the Artemis Processor on the go and am hoping to find a way to make use of the Artemis' onboard battery voltage divider.
I read over your GitHub issue investigating using a voltage divider with the OpenLog Artemis. Would you be able to offer any insight on how to calculate a correction factor to use with the voltage dividers on the Artemis Processor and Data Logging Carrier Board? Will it be a matter of applying known voltages to the circuit and calculating backwards to properly scale the readings? This has really been making my brain hurt!
@nseidle is the plan to do away with the voltage divider entirely on the next hardware revision of the Artemis Processor?
Cheers, Adam
Hi @adamgarbo , Here's what I would do: Apply a known, measured voltage. Step the voltage up in say 0.1V increments. Record the raw ADC codes from the analogRead. Throw the results into a spreadsheet and fit a y = ax + b line to them. You need to find the gain term (a) and there is probably an offset too (b) which may be negative. I had to do the same thing on an ESP32 project recently. It's a bit more tricky if you're calibrating the battery voltage circuit as you are then limited to say 3.6V up to whatever the maximum the voltage regulator can handle is. Usually around 6.0V. But it works. Everything should be linear, you shouldn't have to introduce an x^2 term. Cheers, Paul
Here's the spreadsheet from the ESP32 project. Column A is the 'battery' voltage from a lab power supply. Column C is the raw ADC reading. The graph is raw ADC vs. voltage. It's linear. Cell B6 is the voltage range (max - min). Cell D6 is the ADC range (max - min). Cell D8 is the calculated gain term: ADC range / voltage range. Cell E8 is the offset term, entered manually and tweaked up and down until the values is column F look right - when compared to column C. Column E is battery voltage minus offset. Column F is (battery voltage - offset) * gain term. Column H is the predicted voltages from the equation (ADC / CellD8) + CellE8 which, as I check, I compare visually to column A. So, in this case, battery voltage = (raw ADC / 392) + 0.565. Enjoy!
Thanks, Paul!
It sounds like it's time to go dig up a power supply from the lab.
Am I correct in assuming the op-amp issues with the Artemis Processor shouldn't be a problem when characterizing the voltage measurements, since BATTVIN3 will only see at most 6.0 V / 3 = 2.0 V, which is within the limited 2.9 V range?
I see now why Nathan recommends the MAX17048 IC fuel gauge!
Cheers, Adam
@adamgarbo I think the best option to power Apollo3 chips is to use LiFePO batteries as the highest voltage this chip can tolerate is 3.63V. LiFePOs suit better for ultra low power applications than LiPOs, can tolerate cold wheather much better, have much longer lifecycles and cost way less per Wh, though their energy density is lower. Now all the Sparkfun boards can be operated with LiPO batteries only as the SFE boards include power regulators that suit LiPOs and output constant 3V3 ...but exactly that is why reading the voltage divider built into the Apollo3 chips does not make any sense on SFE boards.
Instead i rely on a 2M and a 1M external resistor to have rough estimate readings for LiPOs... as the voltage of LiFePOs hardly changes, dividers do not make much sense with that type of batteries.
IMHO the best option is what Nathan suggested.
Would be nice to have Artemis boards that also offer directly powering the board from LiFePOs by adding a switch or jumper to bypass power regulators needed by LiPOs.
Hi @idea--list,
Thanks for your input. The main issue is there is a loaded resistor divider that prevents users from readily performing measurements of the battery voltage using the onboard voltage divider. Paul provided some good instructions on how to characterize the circuit in order to be able to do so but this is beyond the capacity of most users.
Hopefully, the Artemis Processor will eventually see a hardware revision that removes this circuitry in favour of a fuel gauge, as Nathan suggested. Ideally, I'd like to see all of the 20 kΩ/10 kΩ resistor dividers on MicroMod products changed to higher impedance values, but the Artemis really doesn't like high impedance.
Cheers, Adam
@idea--list also see: https://github.com/sparkfun/MicroMod_Artemis_Processor/issues/4 for more background on the issues with analog measurements and the op-amp circuitry.
The Artemis Processor can only make analog measurements between 0-2.9 V and if these voltages are coming from a resistor divider the readings will be incorrect.
Fingers crossed one day the issues with the Artemis Processor will be fixed!
Issue closed as unresolved.
Hi there,
I've been attempting to calculate the battery voltage using the Artemis Process and MicroMod Data Logging Carrier Board (MMDLCB).
From the schematics, we can observe that the 20 kΩ/10 kΩ voltage divider from the MMDLCB is loading the 100 kΩ/150 kΩ voltage divider on the Artemis. The circuit simplifies down to the following:
I've done the math to calculate the voltage across VR4, which seems to checkout, but the problem is the same calculations using the analog readings I'm getting on the Artemis don't appear to add up. I wrote the following code to test:
I'm wondering if perhaps I'm missing something regarding which ADC voltages are used. I've been operating under the assumption that the 2.0 V reference should be used.
Would be great to get some clarification on this (or for someone to double-check my math).
Cheers, Adam