Connections

Ok, so I never got around to writing up the connections needed for Arduino Uno and my favourite 7 segment displays. I’ve had a few sets from this supplier and they’ve been a pleasure to deal with – very efficient, professional and courteous service. And a great product at a great price, what’s not to like?!

Some people have pointed out that you can get 7 segment digits much cheaper than this. Well, yes, but NO! If you want drive one of these (and you’re talking 12V for the feed) then you’d better factor in a shift register (Arduino soon runs out of pins), then you need a transistor to drive each digit (that’ll be 8 of those then) and a resistor for the base of each transistor (another 8). Don’t forget a resistor for each segment (Yup! 8 of those) and maybe a de-coupling cap for the shift register. That’s a lot of bits per digit. I like these because:

Job done!

Job done!

And they’ve added a 5V regulated supply – so you can power your Arduino from this. If you start to think about using all of those components (especially of the through hole variety) then the costs, the time to put it all together and the space required really start to add up. To my mind, this stuff is fantastic value – if I’m building a clock then I’m building a clock, all the other stuff just gets in the way.

Ok, how do we connect all of this up? One day, I’ll buy a proper camera but for now all I have is my phone…

All together now...

All together now…

Here are 4 digits, connected together and a socket added for a 12V feed.

LED Connections

LED Connections

So we have a purple wire on “S_IN” – this is the serial data in line and connects to “MOSI” (Pin 11) on the Arduino Uno SPI interface.

The green wire on “STB” connects to pin 8 on the Arduino Uno (it’s the pin I chose for “Chip Select”).

Yellow is “CLK” which goes to “SCK” (Pin 13) on the Uno.

Connect “GND” to, er, “GND” on the Uno and you’re nearly there.

One the Arduino has been programmed you can power it by connecting “VCC” to “5V” or “VIN” on the Uno – I prefer “VIN” as it just adds another layer of protection and keeps it away from the USB supply if you manage to connect both at once.

That’s really all there is to it.

Arduino Uno Connections

Arduino Uno Connections

I use the ShiftPWM library to drive the digits. My sketch is here – it’s setup for 4 digits and just cycles through 0 – 9 then “.” on each.

The result? Here you go…

All the fives

All the fives

That’s all there is to it. These things are really easy to drive – all the hard work has been done for you. If, like me, time to do stuff tends to be the problem then using these digits allows you to focus on what you want to do. You can’t beat that.

Posted in Uncategorized | Leave a comment

Another clock…

I came across these 2.3″ LED 7-segment digits the other week and just had to buy a set. I’ve been struggling to see the clock in our living room from where I sit and thought it would help if I could make something slightly (ahem) larger.

Before

Before

Yes, that’s the clock at the back of the unit on the right. If I zoom in on the original photo then I can make out that it was 13:01 when the picture was taken. It’s a real struggle to read it in bright light so time for a change…

After!

After!

That’s better 🙂

I’ve “fixed” the 6 since the photo was taken – it looks better with the top horizontal bar lit as well.

How did I make it? Well, it was fairly easy really as the digits are very easy to drive (once you’ve got over the complete lack of documentation and figured it out for yourself).

I used the excellent ShiftPWM library to drive the digits from an Arduino Uno clone and Adafruit’s RTClib to interface to a DS1307 chip.

The digits are like these ones at Futurlec – similar enough, anyway – but the boards I bought have an embedded shift register and voltage regulator. I’ve been driving them at 12V and then using Vcc from the LED board to connect to the Arduino Vin pin which is enough to drive it and the DS1307 clock shield.

I didn’t take lots of pictures of the build. The clock shield is just a bog-standard DS1307 setup with 3V lithium battery backup. It needs pull-up resistors on the I2C lines and a pull-up on the SQW/Interrupt output pin – all in the DS1307 datasheet. I also added a photo-resistor to let me control the intensity of the digits.

ShiftPWM seems to be really designed for driving LEDs rather than 7-segment displays. It’s fairly easy to abuse it to do so though. All of my code is on Github as usual and should be fairly self-explanatory (meaning I didn’t do a good job of writing comments). Since previous clocks I’ve done have been too sensitive to light, I used a 5 value rolling average this time – it also helps that ShiftPWM allows brightness from 0-255 so I can divide the analog reading by 4 which also reduces sensitivity. I’m running ShiftPWM at 100Hz so there’s no hint of flicker, even at the dimmest setting.

There are no buttons to set the time. It reads 4 digits from the serial port and sets the time on receipt of the final digit. I’m thinking about adding an ESP8266 to connect to an NTP server at some point – haven’t really had a chance to play with those yet so this will have to do for now.

I had some A5 acrylic sheets handy and used those for the back and front of the clock. After a bit of measuring I came up with a rough template:

Template

The Uno and shield are positioned in the bottom left corner. At this time I mistakenly thought that I could use the corner holes on the front sheet also and then use spacers to connect everything together. Obviously, he says, that won’t work because the digits occupy the top two holes (marked with a rectangle) and the Uno one of the bottom ones. Still, I’m sure a piece of translucent grey acrylic with holes in it will come in handy for something. Here’s the assembled clock with the cocked-up front cover:

Cocked-up clock

Cocked-up clock

So, once I’d sorted a replacement front cover and bolted the two halves together (using standard plastic spacers – I have black ones fortunately – that was all done. It’s powered by a 12V 1A wall wart (from an old cable modem I think) and it seems to work just fine. Don’t know what long term accuracy will be like – I guess that mostly depends on the 32kHz crystal that I used. I’m fairly happy with the way it looks, will just have to see if it gets SWMBO approval 🙂

Posted in Uncategorized | Leave a comment

Thoughts on battery testing

Batteries are handy things and these new-fangled 🙂 Li-ion ones seem to be fairly useful. I dismantled another unwanted netbook (aka “craptop”) power pack yesterday and acquired another 6 x 18650 cells. Some of these don’t seem to be up to much but I’ve found it difficult to keep track of what I’ve done. That’s been bugging me as it doesn’t make sense to test stuff if you’re relying on your memory to tell you which batteries are “better” than others. More on that later as my ideas start to come together.

I had been wondering about how accurate the dummy load circuit was. Well, why not test it? I put the μCurrent Gold in-line with a battery and compared the measured current drawn to the theoretical load of the circuit.

Measuring current

Measuring current

It’s a bit difficult to see but the estimate dummy load is 1003mA whilst the actual current drawn is 979mA. As the measurement continues the actual current falls to about 973mA in this case which, overall, isn’t too bad. I’ll test at other loads but we’re talking about less than 3% here so it’s no big deal in the scheme of things. If a battery test result shows a capacity of 2200mAh then it might actually be about 70mAh less. I would hope that the errors scale with current (i.e. stick at around 3%) but it’s also possible that there’s a fixed error or fixed + some component that scales. Either way, I’d like some estimate of what that error is, just so I know…

I’ve put my dummyLoad Arduino Uno code on Github. At the moment it relies on the user having some kind of serial connection to the Arduino to collect the data. You then have to copy that to a file and try to name things in such a way that you can figure out what you’ve done later. That’s harder than it seems, for me anyway.

What I would like is to be able to uniquely identify each battery and to be able to look at it’s test results however I want. Seeing how battery performance evolves over time might give some useful info and being able to compare different batteries is something I’ll definitely want to do.

Battery comparison

Battery comparison

I’m thinking a stand-alone GUI based application (written in Python and PyQt with a simple sqlite3 database) would fit the bill. This is the kind of stuff I’m working with a lot in the day job at the moment so I know it wouldn’t take long to do something fairly decent. It should interact with the Arduino and allow cutoff voltage to be overridden and the battery under test should be recorded in the database. It’s relatively easy then to add real-time graphs and graphing of historical results. All properly identified so I know exactly what has been done and, therefore, what the results mean!

Right, let’s see how much time I can kick loose over the next few weeks to get this done…

Posted in Uncategorized | Leave a comment

dummyLoad – first light…

Last day off for a while so I’ve mostly been “chilling” whilst the dummy load and a little bit of firmware did the hard work. The results I have are interesting but I need more data to draw any conclusions. The firmware (+ any plotting software I may write) will appear here at some point.

The scores on the doors are:

First 4 tests

First 4 tests

There are 2 different batteries involved.

The “flat” batteries are a bunch of old laptop battery cells that Chris gave me – there are no markings on them so it’s not clear what they are supposed to be. From the above, I’m guessing that they are nominally 1400mAh or 1500mAh but who knows if they used to be anything more. This is the same battery and it was “fully charged” in both tests. My default firmware has a 3V0 cutoff and that didn’t seem to be enough for these cells – that’s why I recharged and ran again with a 2V6 cutoff. So, “fully charged” means the battery charging circuit thinks it’s done – but if you discharge it and charge it again you get a fair bit more in there. Useful to know.

The 18650 batteries came from a netbook (I prefer the term “craptop” over “netbook” to be honest – it gives you a better idea about what you’re dealing with 🙂 ) and are 2.2Ah Samsung cells. Again, I started with a top up of a “fully charged” cell and ran it with the dummy load set at 1A. It didn’t seem to quite get to 2200mAh. Since one of the things I’m currently interested in making is a cheap 1W LED light (using 1W LEDs, obviously, plastic vitamin pill pots and 18650 batteries) then I set the dummy load to 350mA, recharged and ran again. Once more, this “charge after discharge” gives a higher starting voltage and gets much closer to the published limit. I can also see from the data that I get 6 hours of full brightness in this configuration which isn’t to be sniffed at given “full brightness” is bugger bright.

So, early days yet, but it looks like how/when you charge these cells is really important. Unless there’s some kind of “memory effect” (which I’ve never heard of in relation to this kind of battery) then you need to discharge before you charge to get the most out of the batteries.

I’ll push the firmware to GitHub soon but I’ve already got plans to improve it. I’d like to be able to capture the data more easily and provide metadata for each “experiment”.

It would also be useful to override the battery cutoff voltage since these “flat” cells seem to be happy going lower. Unless they’re just fsck’d of course.

The hardware also has limitations. If I supplied 12V to the op amps then I could easily get a voltage of 5V0 from the pot which would allow me to build a 5A version – with a chunkier MOSFET and heatsink. The pot is also too “twitchy” since I didn’t have any “10 turn” ones. Building a “new improved” version will happen but this gives me a chance to play with the software and to do useful (for what I need just now) tests on various batteries. I’m no battery expert – more a battery numpty to be honest – so this should help me learn some stuff.

Posted in Uncategorized | Leave a comment

Dummy load – final hardware steps…

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?”

Indeed…

Op Amp and friends...

Op Amp and friends…

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).

New board on top of the Arduino Uno clone

New board on top of the Arduino Uno clone

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…

All stacked up...

All stacked up…

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?

A quick test...

A quick test…

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…

Posted in Uncategorized | Leave a comment

More on the “Constant Current Dummy Load”

Not finished yet and there’s still software to cobble together when it is. I’ve had a bit of time today and made some progress with the LCD shield – well, it’s done which counts as “some progress” in my book.

Connections for typical HD44780 based LCD + a few bits and pieces...

Connections for typical HD44780 based LCD + a few bits and pieces…

The LCD (16 pins) attaches to the middle row on the upper half of the “shield”. There’s room for a trim pot on the top right (you can see the +5V, GND and the wiper output going to where the contrast pin of the LCD will be). Right next to that there’s a 3K3R for connection to an LM285 voltage reference diode which delivers 1.235V to the AREF pin of the Uno (upper orange wire).

At the bottom right of the board there are a couple of voltage dividers for the load voltage and (even though it’s not needed in this case) for the voltage that is controlling the current.

I’ve done some more tests and I really was getting screwy results on the breadboard. Everything seems to be working as it should and 1mV => 1mA of load. That’s really comforting to know because I was fairly sure my op amps weren’t that crap and that I’d put Dave Jones’ circuit together properly.

I’ve had a few other thoughts so this isn’t done yet – here’s what it looks like though:

Dummy load with LCD shield

Dummy load with LCD shield

So, what’s still to do? Well, sensing the load voltage for one thing and, if it’s a li-ion battery then turning the load off when the voltage gets to 3V0 to prevent any problems. I’m planning to (mostly) use battery protection circuits but they allow the battery to drop to 2V5 and, of course, I might forget.

How do we turn it off? Well, pin 5 of the op amp on the board above is the key. If that pin is pulled to ground then the voltage at the resistor is zero and no current can flow. That’s also where I need to measure the circuit voltage so I can display what current load is set.

I can use an NPN transistor to pull pin 5 to ground, there are plenty of pins left on the Uno to do that and it’s fairly straightforward. The transistor will easily squeeze in at the bottom left on the white proto board.

Measuring the circuit voltage is much more interesting. If I connected pin 5 direct to one of my voltage dividers (or just to an Uno analog pin) then current would flow and the voltage would change causing the current to change. I don’t really want that to happen and the way to avoid that is staring right at us in the picture above!

It needs another op amp, configured as a buffer just like pins 1-3 of the op amp already used. Since no current flows at the input doing this won’t change the voltage I need to measure and therefore won’t change the dummy load current. The same applies to battery voltage so I may as well do the same with that as I only have the TS-358 dual op amp chips.

Slight problem, there’s nowhere to put it! So, it looks like a “dead bug” solution will be needed. I’ve also decided to bypass the voltage divider and just read the circuit voltage directly – it’s always in range for the way this circuit is configured.

So, not much left to do once this is out of the way. Just the software…

Posted in Uncategorized | Leave a comment

Li-ion Battery Capacity Testing

Well I’m just getting into the wonderful world of li-ion batteries – cheers Chris!

The trouble is, I’m not sure where some of the older, recovered, laptop batteries I’ve acquired are at. Some of them really don’t seem to last as long as I expect, but then I don’t know what the capacity is supposed to be so…

Yesterday, I ended up watching a Dave Jones EEVblog video on “Constant Current Dummy Load for Power Supply and Battery Testing“. Well, it seemed to fit the bill 🙂

This circuit was shown…

What it says on the tin

What it says on the tin

So, I’ve got a pile of op-amps which I don’t know how to use. I’ve got N-channel MOSFETs, which I don’t know how to use…

I think I may have watched another Dave Jones video on the basics of op-amps but, whatever, this looked like a chance to test some batteries.

I had a bag of TS-358 single supply, dual op-amps which seemed to be close enough to what Dave used. I also had a FQP30N06L MOSFET and, again, that seemed “close enough”. So, I gave it a go starting with everything on a breadboard. That mostly worked, although I couldn’t get the current to be more than about 0.75A and it was obvious that the MOSFET was getting pretty toasty – fair enough, it should in this configuration. Since it seemed “close enough”, I chucked it all on some proto board…

Dummy load and friends…

As you can see, I added the biggest heatsink I had available and a 5V fan. Everything runs much better away from the breadboard and I can dial this up to a load of 1100mA. It’s all mounted on a Proto-Pic Arduino and Breadboard Baseplate that I had lying around – they’re not cheap at around £8 so that’s easily the most expensive part of this.

I want to add an LCD display so I used an “Arduino Uno” – well, it’s a cheap, as in $2.88 delivererd cheap, chinese version from here. (Shock horror! They’re now back up to $3.10, I must have been lucky 🙂 ). I’ve enjoyed making my own arduino clones on proto board but the damn proto board costs more than one of these things!

The scary yellow wire isn’t connected yet. That’s for sensing the battery/PSU voltage – only needed for info and to switch off at some predefined voltage if I decide to implement that. I probably will.

There’s a (yet to be) home made LCD shield to go on top of the arduino and I need to put a voltage reference on there as well as a couple of voltage dividers. I may sneak a transistor on the proto board so I can switch off the circuit if I want – that should be fairly straightforward.

So, not finished yet and there’s some calibration to do as that 1Ω resistor isn’t 1Ω. Calculations from the breadboard suggest it’s more like 1.6Ω but I’ll measure again since I really don’t trust breadboards with op-amps after what I’ve seen today.

All looking good, just need to get it finished and test a few batteries.

 

Posted in Uncategorized | 1 Comment