Simple push button ON/OFF with battery level check:
Simple IC to manage a push button as ON/OFF switch with battery level monitoring
For long time, I was looking to have a simple IC to replace battery level monitoring (like comparator MAX 931) and also a button to switch OFF/On device with low consumption.
When doing some devices with battery power and solar cell charging, it need to monitor the battery level for switch on (more than 3.6V per example) and auto switch off if the battery level goes down to 3.2v. For this function, I always use a Max 931 or equivalent, comparator with hysteresis. The output of this comparator is connected to the enable input of the voltage regulator (often 3.3v) of the device,
More than 3.6v, the Max931 enables the regulator, and when battery falls down below 3.2v, it switch off the regulator.
Beside this, I wanted to replace the mechanical ON/OFF switch of some devices. I got many issues with oxidation and low quality switches. So, to have a simple (and debounced) push button can be good.
Looking to some IC which can manage power on/off with a push button (and debounced), there are some in TI IC offer, but quite expensive.
The proposal here is to combine these 2 functions, ON/OFF with a simple push button and battery level monitoring. If the battery level is too low, the device cannot power on. If the battery is above a fix level, the device can be power on and will be switch off if it's going lower than another fix level.
I found these TSOP uC from Microchip, I decided to do a small project , with simple code for this. Such uC cost less than $1, which is even a better choice. It self, it is much cheaper than the MAX931 and the TI IC, with very little place needed on the PCB.
The Software is simple:
- 2 output, one active low, one active high for different kind of voltage regulator
- Until the battery reach fix level (example 3.6 V), press on button will not activated the outputs
- Above activation level (example3.6 V), the output are active (low and high depending of the output pin) after long press on the button (and eliminating the bounce)
- New long press on the button will switch off the outputs
- if the battery goes below 3.2 V, both outputs are deactivated.
The software is written in C, under MikroCpro. There is a main loop with a sleep (to save energy) every 270 ms. The internal FVR (Fixed voltage regulator) is used to measure the battery level.
The software has 3-state management:
- OFF Mode
- ON Mode
.- Long press button mode (in ON mode)
When the SW detects a press on the button, it managed the debounce then detect the long press. If the time is shorter than the long press time, nothing happen.
For this application, the 10F322. is used (I had some issue with the 10F320 under some version of the MikroC) Very few ROM (512 words) and RAM (64 words) but just enough for this. Due to the small ROM, the calculation of the battery level cannot be very precise, but it is enough in that case (100mV accuracy).
The LF version is allowed for 1.8 V to 3.6 V and the F version for 2.3-5.5 V. As the plan is to use lithium battery, I use the F version.
When doing some devices with battery power and solar cell charging, it need to monitor the battery level for switch on (more than 3.6V per example) and auto switch off if the battery level goes down to 3.2v. For this function, I always use a Max 931 or equivalent, comparator with hysteresis. The output of this comparator is connected to the enable input of the voltage regulator (often 3.3v) of the device,
More than 3.6v, the Max931 enables the regulator, and when battery falls down below 3.2v, it switch off the regulator.
Beside this, I wanted to replace the mechanical ON/OFF switch of some devices. I got many issues with oxidation and low quality switches. So, to have a simple (and debounced) push button can be good.
Looking to some IC which can manage power on/off with a push button (and debounced), there are some in TI IC offer, but quite expensive.
The proposal here is to combine these 2 functions, ON/OFF with a simple push button and battery level monitoring. If the battery level is too low, the device cannot power on. If the battery is above a fix level, the device can be power on and will be switch off if it's going lower than another fix level.
I found these TSOP uC from Microchip, I decided to do a small project , with simple code for this. Such uC cost less than $1, which is even a better choice. It self, it is much cheaper than the MAX931 and the TI IC, with very little place needed on the PCB.
The Software is simple:
- 2 output, one active low, one active high for different kind of voltage regulator
- Until the battery reach fix level (example 3.6 V), press on button will not activated the outputs
- Above activation level (example3.6 V), the output are active (low and high depending of the output pin) after long press on the button (and eliminating the bounce)
- New long press on the button will switch off the outputs
- if the battery goes below 3.2 V, both outputs are deactivated.
The software is written in C, under MikroCpro. There is a main loop with a sleep (to save energy) every 270 ms. The internal FVR (Fixed voltage regulator) is used to measure the battery level.
The software has 3-state management:
- OFF Mode
- ON Mode
.- Long press button mode (in ON mode)
When the SW detects a press on the button, it managed the debounce then detect the long press. If the time is shorter than the long press time, nothing happen.
For this application, the 10F322. is used (I had some issue with the 10F320 under some version of the MikroC) Very few ROM (512 words) and RAM (64 words) but just enough for this. Due to the small ROM, the calculation of the battery level cannot be very precise, but it is enough in that case (100mV accuracy).
The LF version is allowed for 1.8 V to 3.6 V and the F version for 2.3-5.5 V. As the plan is to use lithium battery, I use the F version.
Connections The BP (push button) is connected to pin 1, with pull-up resistor (100k), Active high (1) output is on pin 3, Active low (0) output is pin 4. Pin 6 is the MCLR but it can be used as input. Not used at this moment.
Laurent
Mises à jour de l'auteur