Tuesday, 25 August 2015

A Simple Plan

Exploring New Stuff

A Simple Current Shunt Amplifier




A while ago, I took advantage of a free PCB offer to knock up a quick project, which is still 90% finished.  Or more correctly, not finished.


This was a chance to do some things I'd not done before, including running off a coin cell and using methods such as sleeping the micro to to save battery life.  In face the datasheet states that the micro in sleep mode can reduce current draw to 100nA.  WOW!


Of course, my basic multimeter will not come close to being useful for measuring current this low.  But really, how low do I need to measure?  A typical CR2032 coin cell has around 200mAh of capacity, and at 1uA that's 200,000 hours, or 22 years.  So realistically speaking if I could confirm a current draw in the order of uA, I'd be happy.  Of course that's 22 years of *sleeping* - actualy use will reduce battery life significantly!

Off The Shelf

So the first option is to look at what's out there that will let me take a measurement of such low magnitude.  The first option is the excellent EEVBlog uCurrent but at nearly $100 delivered, I'm too tight to shell out for that!

Option Two?  DIY!

The uCurrent uses a virtual ground, and has a positive / negative output swing.  This is useful when measuring (for example) a battery that is charging and discharging.



Above shows the schematic of the original uCurrent.  The uCurrent Gold is more complicated to give greater bandwidth, but works in the same way.

Anyway, as I'm not interested in charging batteries, only estimating the draw under load, I can reduce part count by nixing U2 and associated parts.  Also, to keep things simple I decided to use jumper links rather than dip switches, and I used a blue LED for low battery indication.  Why?  Well a blue LED needs about 3V to light it, and if the coin cell is flat the LED won't light.  Not a high precision technique but good enough.

The uCurrent also uses very stable shunt resistors with excellent temperature coefficients, but for my 1% tolerance will be good enough, so I've chosen basic 1% bits.  My version appears below.


Because I have access to an LPFK mill at work, I knocked the above up in a break time, and milled a quick board.  There wasn't any need to rush, as the sample MAX4239's weren't delvied yet, but you do these things.  I was pretty chuffed that I made it single sided, without links.

One other experiment was to mill designators and other text on the component side, and to try colouring these to make it easier to read.  I'd thought I'd also make two, so I can give one to my mate.




NASCO - As is Nick And Simon Co.


TO get the coloured text, I simply drew over the engraving with a whiteboard marker, and then wiped over the board with a dry tissue.  The colour effect worked quite well if you ask me.



Assembly was quote straight forward, and it was soon ready for testing.  


You'll notice that the green connectors aren't loaded yet, and that the layout is a little different from the render at the start of this post.  The reason is simple.  THE PROTOTYPE DIDN'T WORK.

The gain seemed to be too high - on the mA scale with a gain of 100, 10mA (0.010A) should output 1 volt.  I was getting closer to 2 volts.  Why was the gain out by a factor of two?

As I punched this design out in a break at work, I let a real simple rookie mistake creep in.  If you look at the schematic, you'll see that I thought I was clever in using just two jumpers rather than 'complicated switches'.


For the uA range, I'd select the 10R resitor as a shunt, and for the mA range I'd select the 0R1 (0.1 ohms) resistor.  I only tested on the mA range when I discovered my issue - can you guess why?

I didn't take into account the fact that the jumper themselves have a small contact resistance.  By dumb luck it was close to 0R1 as well, doubling the effective shut resistance, which doubled the burden voltage of the circuit, which was then amplified correctly and confused the heck out of me.

So the fix?  Version 2.0


You will see that i now have four jumpers, where two have to be inserted to select a range.  Why?

To measure the mA range correctly, jumper P6 is needed to connect the load to the 0R1 resistor, and P4 is needed to connect the input of the amp to the load. Conversely P3 and P5 are used for the uA range.  If you take a second look at the original uCurrent, the switching is done in this same manner.

Live and learn (to copy properly if you are going to copy something).

V2.0 Testing

So it was time to get on with Version 2.0, and still using Altium, knocked up this second prototype.  You'll see that I also changed the name to 'Simple Current' to avoid ripping off the uCurrent name.


Yes the LED is on, but wont photo for crap on the 'ole iPhone...


Bottom View.  I need to learn to solder....

For the prototype, I didn't have my preferred values to hand.  Also you'll see the value in the schematic set the gain to only 10, where I prefer 100.  Why the difference?  PEBKAC.

Anyway, for the prototype I used 56k and 39k for R4 / R5 (for a total 95k) and with 1k fitted for R6 the expected gain should be 95.  My testing resistors only have 5% tolerance, so the gain could vary from 90.5 to 99.75.  Close enough!

The test set up used my version of a constant current load, my cheap and trusty multimeter and lots of hook up wire.


With 200mA being drawn, there should be 20mV across the 0R1 resistor, multiply y the (almost x100 gain) and the expected output voltage is 2.00V.  Meter says 2.19V, nearly 10% error.  Nothing in my rig is calibrated and if I had to bet on it I'd say the biggest error might be in the eBay display on the current load.  I'll borrow a meter from work (one day) and pin it down, but for now, close enough!

The next step for me in a project like this might have been to call it done and post a story, but I really wanted to be able to share my designs in a way that's better than posting my Altium files.

Open Source Adventure

Since May this year I've been involved with the Circuit Maker open beta programme.

With this I tried my hand at importing my Altium design into Circuit Maker (CM).  The schematic copied straight over, but none of the parts were linked to the Ciiva database.  Long story short it was easier to drag new parts in than link the old ones, and the effort to do that wasn't much less than redoing the schematic from scratch.


CM Version of Schematic

From there, I tried to import my Altium PCB file.  No dice, CM wont import Altium and fair enough, they need to protect their business tool.   What I could do in Altium was save the layout in a legacy format (Binary V3 PCB) but losing 3D parts, board shapes and polygon fills in the process.  The imported board into CM is presented below.


In addition to the above list of omissions, the fonts were mangled and the SMD footprints were lost.  However the trackwork is there and part centres are shown.  An evening of updating footprints and models later, the following was ready.



Lesson learnt - don't bother importing from Alitum, just start again from scratch!

Manufacturing

Once I released the project in CM the manufacturing files (gerbers and nc drill) were available and I ordered some boards from Elecrow.  I also made a tin can solder paste stencil and then got busy waiting for the rest of the parts to come in from overseas.


Bottom View.



Top View.

Once my parts arrive, I'll post build results and maybe borrow some calibrated equipment from work to check actual performance!




1 comment:

  1. Years late to read this but I am about to build my own and am thinking that your dual shorting jumper idea for the 0r10 resistor probably should have just been left in circuit full time as it wouldnt affect the 10r resistor to much of an extent

    ReplyDelete