📄 battmon.txt
字号:
*************************************************************************
************* TRUE BATTERY STATE MONITORING - HOW TO ****************
*************************************************************************
I. What you need to do battery state monitoring
================================================
- a yampp-7 board Revision C or newer
- One additional 1kOhm SMD rezistor, and one 100nF troughthole MKT type
capacitor. The 100nF capacitor should be MKT type, because small ceramic
or SMD capacitors have poor temperature stability and the battery level
goes to change depended of temperature.
- New firmware (this package)
- Additionally, if you need calibration - the regulated power source (from
2.9V to 4.0V).
-------------------------------------------------------------------------
II. Theory of operation
============================
O V_BAT
|
-
| | R16
| | 51k
-
CPU |
O------*---> to VS1001
PB3 |
(AIN1) ---
--- 100nF
|
-
| | R13
| | 1k
-
|
--- GND
First the PB3 pin is held low for 5ms. The 100nF capacitor is discharged
via R13. Next timer 2 in CPU is started, and PB3 is switched to Hi-Z state.
Now the capacitor is charged via R16 and R13. The charging current is
proportional to battery voltage. If voltage at PB3 rise to 1.1V the
internal CPU analog comparator change output state (1.1V is internal CPU
voltage reference applied internally to second input of comparator).
Now the timer is stopped, The PB3 is switched to output and High state
(for VS1001 usage) and the value of TCNT2 is readed and calculated.
If V_BAT voltage is higher, the charging current is higher, the charging
time is shorter, and the timer value after stop counting is smaller.
If V_BAT voltage is lower, the charging time is longer, and the timer value
after stop counting is higher. The timer value is compared with constants
for minimum and maximum battery voltage, and recalculated to value bettwen
0 and 17. This value indicate the battery state.
During VS1001 controlling via PB3 pin, the R13 separate the capacitor, and
the capacitor don't block the CS signal for VS1001.
-------------------------------------------------------------------------
III. Hardware modifications
============================
- remove R13 from yampp board and replace it by 1 kOhm rezistor.
- cut track bettwen R13 and R16 (one track phisycally bettwen R13 and R16 place)
- solder 100nF capacitor in series to R13 (to two ends of cutted track)
The "BattMon.jpg" file have photo of this modification.
-------------------------------------------------------------------------
IV. Software modifications
============================
- edit the Constants.h file and uncomment the "#define BATT_MONITOR"
- do battery monitor calibration
Now the battery icon filling is proportional to battery voltage.
-------------------------------------------------------------------------
V. Calibration
============================
Before usage of battery monitor you need calibration of MAX and MIN values.
First change the values of both "#define BATT_MAX" and "#define BATT_MIN"
to zero, recompile firmware and download to yampp. Now you can see the
readed value of voltage converter at LCD display.
Next, replce battery by any power supply setted to 2.90V. You can use
discharged battery and voltmeter. Set the "#define BATT_MIN" value to readed
value at 2.90V. Next change the supply voltage to 4.00V, and set the
"#define BATT_MAX" value to readed value at 4.00V.
Now you can recompile firmware with your new settings and download it to
yampp. The calibration is completed and yampp is ready for usage.
****************************************************************************
Have fun !!!
MIS <romek_b@o2.pl>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -