include Neil's ADC calc with attribution

This commit is contained in:
Thomas Göttgens 2023-03-28 11:40:42 +02:00
parent 0da7aa0b2a
commit c19b06e8da
2 changed files with 77 additions and 1 deletions

View file

@ -7,6 +7,7 @@ sidebar_label: Power
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import calculateADC from "@site/src/utils/calculateADC";
The power config options are: Power Saving, Shutdown after losing power, ADC Multiplier Override Wait Bluetooth Interval, Mesh Super Deep Sleep Timeout, Super Deep Sleep Interval, Light Sleep Interval and Minimum Wake Interval. Power config uses an admin message sending a `Config.Power` protobuf.
@ -28,7 +29,59 @@ Ratio of voltage divider for battery pin e.g. 3.20 (R1=100k, R2=220k)
Overrides the ADC_MULTIPLIER defined in the firmware device variant file for battery voltage calculation.
Should be set to floating point value between 2 and 4
Should be set to floating point value between 2 and 6
#### Calibration Process ([Attribution](https://wiki.uniteng.com/en/meshtastic/nano-g1-explorer#calibration-process))
1. Install the rechargeable Li-Polymer battery.
2. Charge the battery until full. Indication of this state may vary depending on device. At this point, the battery voltage should be 4.2V +-1%.
3. Input the "Battery Charge Percent" displayed on the screen or in your connected app into the calculator below.
4. If "Battery Charge Percent" (e.g., B 3.82V 60%) is not displayed on the screen, it means that the default value of "Operative Adc Multiplier" is too high. Lower the "Operative Adc Multiplier" to a smaller number (it is recommended to decrease by 0.1) until the screen displays "Battery Charge Percent". Enter the current "Operative Adc Multiplier" in use into the "Operative Adc Multiplier" field in the calculator. Also, input the "Battery Charge Percent" displayed on the screen into the calculator.
5. Click the "Calculate" button to compute the "Calculated New Operative Adc Multiplier", and set it as the new "Operative Adc Multiplier" for the device.
:::tip ADC Calculator
<table>
<tr>
<td> Battery Charge Percent: </td>
<td>
<input type="text" id="batteryChargePercent" defaultValue="65" />
</td>
</tr>
<tr>
<td>Current Adc Multiplier: </td>
<td>
<input type="text" id="operativeAdcMultiplier" defaultValue="2" />
</td>
</tr>
<tr>
<td>Calculated New Operative Adc Multiplier: </td>
<td>
<input
type="text"
id="newOperativeAdcMultiplier"
value="2"
disabled="disabled"
/>
</td>
</tr>
<tr>
<td></td>
<td>
<button
className="button button--outline button--lg cta--button"
onClick={calculateADC}
>
Calculate
</button>
</td>
</tr>
</table>
:::
:::info
It's important to note that this calibration method only maps 4.2V to Battery Charge Percent 100%, and does not address the potential non-linearities of the ADC.
:::
### Wait Bluetooth Interval

23
src/utils/calculateADC.ts Normal file
View file

@ -0,0 +1,23 @@
export default function calculateADC() {
//const variables
var BAT_MILLIVOLTS_FULL = 4.2;
var BAT_MILLIVOLTS_EMPTY = 3.27;
var BAT_FULL_PERCENT = 1;
//variable
var batteryChargePercent =
parseFloat(
(<HTMLInputElement>document.getElementById("batteryChargePercent")).value
) / 100;
var operativeAdcMultiplier = parseFloat(
(<HTMLInputElement>document.getElementById("operativeAdcMultiplier")).value
);
var result =
(operativeAdcMultiplier *
((BAT_FULL_PERCENT - 1) * BAT_MILLIVOLTS_EMPTY -
BAT_FULL_PERCENT * BAT_MILLIVOLTS_FULL)) /
((batteryChargePercent - 1) * BAT_MILLIVOLTS_EMPTY -
batteryChargePercent * BAT_MILLIVOLTS_FULL);
(<HTMLInputElement>(
document.getElementById("newOperativeAdcMultiplier")
)).value = result.toFixed(4);
}