Well I slept on the “dead bug” idea for the op amp I needed to complete my circuit. When I woke up this morning I really didn’t fancy doing that. Since arduino shields are stackable, I thought “Why not just squeeze in another shield with the op amp, transistor and any other bits I need on it?”
That’s the extra layer. Digital pin 10 controls the transistor – when pin 10 is high, the collector of the transistor sinks current and this, effectively, pulls the current we’re sinking to zero. This will be for battery protection.
Upper half of op amp is a buffer for the controlling voltage of the circuit and this goes to analog pin A2. The load voltage is buffered on the bottom half of the op amp and then passed through a voltage divider before going to pin A3. This means I’ve abandoned the voltage dividers I carefully soldered under where the LCD display sits. Whatever.
I did a quick test and wasn’t happy with the bottom half of that op amp – it really didn’t seem to like any voltage over about 3V6 and behaved as if it was saturated. Couldn’t be bothered changing it so I ended up bypassing it and just routing the load voltage to pin A3 via yet another voltage divider (and I’m now almost out of 1% 10KR).
The above picture shows the board in place with the connections to the rest of the circuit. All that was needed then was to pop the LCD on top…
That worked out quite well. It’s not that much different to what it was before and I don’t have an op amp dangling off the side somewhere 🙂
But will it work?
I connected up a couple of Maplin Hybrid AA batteries and threw some initial code at it. It seems to work just fine although there’s an offset of about 50mV between the load voltage I calculate and what my DMM reads. Not entirely sure why that should be, I may look into that later but 50mV is neither here nor there really. The voltage from the pot is spot on – well, within the error of my DMM. Measuring stuff is really easy, measuring stuff accurately – not so easy.
So, time to write some proper software which means thinking about what I want it to do and how it should operate. A stand-alone mode would seem essential so you can just power it up, plug in a battery and get basic mAh readings etc. Being able to read data from the device and post-process it (or plot it in real time) would also be handy – that should just mean dumping everything to the serial port.
I’m minded to let the device control everything (battery protection for instance) and not have the facility to switch the load on/off from a connected computer. That boils down to stand-alone operation with serial output for any computer that happens to be listening – the device won’t care if it is or not! That should be enough to get started…