Off switch

I want my robot to turn itself off when the batteries get low.

Battery protector boards generally have a weakness: they are meant to be part of the battery. If you remove the battery from them, you need to charge the battery through them to reset them, so then you need an integrated charger in your robot.

This would be convenient: to charge the robot by plugging it into a USB socket. I bought some TP4056 boards - the ones with out+/- as well is battery connectors, but it turns out they are made with clones of the TP4056 that aren't always safe. That link recommends testing them for at least one charge cycle before using them. That's more trouble than I want to go to right now. I also have one other two cell charger, that was quite a lot more expensive, but really the same risks apply.

I'd decided when I designed roundbot with lithium batteries that it would be best to charge the batteries in a UK bought external charger. The point of the chassis design is to provide easy access to do so. I think that's all the more important now. I'll leave the idea of a built in charger on the shelf.

I could also design my own low voltage shut off. One low component count way of doing this is to have the micro controller sense the battery voltage, and switch itself off. In fact, you can make the micro-controller responsible for keeping itself on, after giving it a bit of time to start doing so, after you press the on switch.

This is a handy foundation for how to implement a latching switch. I've actually looked into this before, and I think I started here. I tried to turn it into a low side switch, which I think worked on a bread board, but not reliably when I soldered it together.

I'm not sure I want to give up two pins on the micro-controller board though. Better to make a latching switch instead.

So I took Dave's latching switch, and drew this, which replaces the pull up resistor in the latch with something that depends on the voltage:


I don't actually know if this works, but it just seems too complicated.  I think it basically draws no current like the design it's based on. It lets you turn on the device for a bit, even though the battery is low. That could be a feature: I could have a led under voltage indicator that comes on while you hold the button.

The shunt I'm actually going to use is an TSC432ACT A3G. It has such low current draw in it's off state, I think it's reasonable to use it to replace the transistor at the base of the mosfet:

That is certainly a lot simpler. Note R2 = R3, but once the T1 is on, and the button is still depressed, R2 and R3 are basically in parallel, so the shunt sees a higher voltage than is actually present. That's OK though: if the input voltage isn't high enough, the switch won't turn on, and as soon as the switch is released, voltage detection returns to normal.

I've tried this out, and it sort of works, except:

 - C1 drains very slowly, so you have to wait awhile before you can turn it on again
 - The input voltage you need to turn it on is higher than the shut-off voltage

The resistors are all ±5%, so I should replace them with ±1% and see if that sorts that out the discrepancy between switch-on and shut-off voltage, but I suspect there's something else I'm missing.

Aha - in the off state, when the switch is on, some current flows through R2, R3, and R6 into C1.

It's occurred to me I could replace the transistor with another shunt regulator. They are 7p each and I have 100 of them, after all! This is how you calculate the time constant.  It's all made a bit more predictable by knowing the threshold voltage exactly.

Here's another iteration. I've added reverse voltage protection with another mosfet. C2 is added so it defaults to off: it temporarily resists the voltage rise across R4, presumably because IC1 is initially unstable:



This is set to shut off at 6.6V, which I think is right for 2 lithium cells . It does work reliably, although you can't switch it on immediately after switching off: it needs a few seconds to reset. You can see the briefest flicker of the led as you turn it on, but it stays off.

I made one as a circuit, but I think I destroyed IC1 trying to tidy up my dreadful soldering. I redesigned the layout more carefully, to make it easier to build. The second one I'm quite proud of:


The other end will have a motor driver on it: just add microcontroller!

Popular posts from this blog

3D Printer ramblings

Balance Bot V2

Robot arm