Considerations When Making a Current Shunt Sensor

For battery powered projects, current consumption is a really important consideration when designing the circuitry. While designing my final year project I spent a huge amount of time researching how to put together a simple current sensor. Considering most applications for me are DC, fairly low current and low voltage, the most obvious design is to make a current shunt. The basic idea of a current shunt is that you put a very low value resistor between the circuit you want to measure and ground, and measure the voltage across it. When one side is of the shunt resitor is ground it is low side, there are also high side versions but are mlre complex. As the resistor has a small resistance, there will be a low voltage drop (usually mV) across it meaning it shouldn’t affect the load circuitry. The voltage will also be proportional to the current running through it, meaning if you measure it, and do the right maths you can get a consistent and reliable current reading. This post is about how to get that tiny voltage into 1’s and 0’s, while thinking about the considerations that have to be made about the design to make it accurate and reliable in the environments you want.

Final Year Project
My final year project needed current sensors on the motors as well as monitoring the drain on the battery.

The first thing that needs to be decided is the shunt resistor itself. A shunt resistor is basically a low value resistor, with very tight and known tolerance usually with a fairly high power rating. It can be used in AC and DC circuitry, with the concept behind it being that as a current flows  though it, a voltage is induced across it. The voltage can then be measured and using a simple calculation (based on ohms law) converted into a value for current. The value of the resistor depends on what it is measuring and what is measuring it. Start with what is measuring it. If you are like me, it is likely that it will be read by an ADC, probably on a 5V or 3V3 microcontroller. The voltage across the resistor is going to be amplified between 10 and 100 times (we will get to why in a moment) so pick a maximum voltage within that range. I tend to go with 100mV maximum voltage drop, which for a 5V ADC would require an amplification of 50. Then, take the maximum value of current you want to be able to measure. You can then use ohms law to figure the resistance you need. For example if I wanted to measure 1A, the resistor would be 100mV/1A = 100 mohm. Now we know the resistor value, use the power equation to work out the power eating we want. For this example we would need P = I V = 1 x 0.1 = 100mW. This is the minimum power rating you need, I personally would get a 250mW or even a 500mW just to keep the temperature of the circuit down.

The simple equation to work out what sizesunt resistor to use. Credit: Texas Instruments 

Now we have a voltage that will be somewhere between 0 and 100mV with reference to ground. We want this value to be scaled up to 0 to 5V. To do this we are going to use an operational amplifier. There are plenty out there, and most people have their favourites and I’m not here to convince you otherwise. I tend to use an op amp that I am using somewhere else in the circuit to make life easier. There are a few things you do need from an op amp in this circuit though, it needs to be rail to rail, and have a low input offset voltage. Offset voltage in an op amp is the voltage difference on the inputs, and even though they are tiny differences they can have a big effect because we are amplifying small voltages, and any noise or offset will be amplified too. The op amp needs to be in a simple non inverting configuration. The equations needed to design this are in most first year textbooks and there are plenty of calculators online. I have set a gain of 50 in my calculation, which is in the fairly common range. The output of the amplifier can then go straight straight into an ADC to be measured.

The basic layout of a current shunt sensor showing where the shunt resistors and gain resistors go in the circuit. Credit: Texas Instruments 
The first version of my current sense test circuit, using an OP170 made by TI.

Now let’s look at a few places where errors can come into a design like this. There are two types of errors that occur in a circuit like this, gain error and offset error. A gain error is one where the output error gets further away from the ideal output as the current gets higher. An offset error is one that has the same amount of error whatever the input, just like an offset. The only common source of offset error in a circuit like this is from the offset error in the op amp discussed previously, solved with an improved choice of amplifier. The gain errors are usually due to a difference in resistance from the ideal. Many things can cause this, one is the tolerance of the resistor used, we want to use a precision resistor of 1% or less tolerance. Another cause could be temperature changes in the resistor itself, it may be next to a large MOSFET or other hot component, or could have too low of a power rating making it heat up, wither way a change in temperature means change in resistance. Layout can also be an issue, if tracks are too thin or too long they can add extra unwanted resistance.

Great graphs showing the difference between gain an offset error. Credit: Texas Instruments.

If you want to add a bit of fancyness into the project, or really need to measure down to low currents, you need to tackle the zero-current error. The problem is that when using an op amp, even a rail to rail one, it never quite reaches the power rails. Even the best ones can only get within 100mV or so of the power rails, this is known as saturation. Solving this involves moving the power rails slightly so the saturation point is less than ground. If you have a negative voltage rail you can use that but home projects tend to be single supply, so we need another power source. This can be made using a voltage inverter (a type of charge pump). Usually only needing an external capacitor to work, they are cheap and easy to integrate into a project. I used a LTC1983, which creates a negative 5V rail, but there are plenty of others such as the LM7705. Research what fits your circuit and cost point, and just attach the negative output to the negative supply rail of the op amp.

 A great graph showing how the zero current error occurs, and what it would look like if you tested it. Credit: Texas Instruments.

Most issues with error can be fixed during the hardware design phase. You can pick better op amps, such as ones designed to combat offset voltage. Some amplifiers have internal calibration procedures, and some such as chopper stabilizers are specifically designed to correct these problems. You can also use a potentiometer instead of a power resistor, but they are more susceptible to temperature and can be knocked. Another way is to fix issues in software by creating a calibration procedure. Using a calibrated precision current source and a multimeter, measure the reading of the ADC and compare the value to the reading from the instruments. You should get an offset and gain value that can then be used to calibrate the sensor.

A simple set up that I used to calibrate an early sensor, with a big power resistor as the load and a variable power supply to change the current. Marked down to put into calibration.

I would suggest trying out a few of these sensors in future projects, they don’t cost too much, and can be a valuable addition to a design. Especially for power sensitive devices, or smart sensors, this could be a better solution than an off the shelf or breakout board solution. If you want to hear more about my current sensor designs, and how well the testing and calibration went then comment or tweet at me. I already have some documentation that I may release at some point.

Follow @TheIndieG
Tweet to @TheIndieG

Current Sensing: High Side vs. Low Side

Occasionally, you will be designing an electronic project, and there will be a need to to measure the current being drawn by a particular section, or  even the whole thing. When designing, prototyping, or even testing the design you can use a calibrated multimeter. In the field though, or inside a real product, how can you monitor current.

A very popular way is to use a very low value power resistor in series with the load you want to measure. As current flows through it it will induce an e.m.f (voltage) across the resistor. This resistor voltage can then be measured by an ADC in a microcontroller. The value will be linearly proportional to the current running through it. Using Ohm’s law you can deduce that the voltage across the the resistor is equal to the currentresistance. As the resistor may be slightly off, the device might need calibration.

An issue with this though, you want the minimum voltage drop possible across the resistor. This reduces power loss, and minimises the effect you will have on the load. For this reason a very small resistor needs to be used. There are plenty of resistors out there for this purpose, known as shunt or sense resistors. This tiny voltage could be as small as 0.1v, or maybe even lower, way too small for a standard ADC to pick up reliably. For this reason There is a need for an amplifier, to multiply this voltage by 20 or 50 times. This enables the swing to be measured across the range of the ADC. So if you have a 5v ADC, and the maximum voltage across the resistor will be 0.1v, the amplifier will need to have a gain of 50. There are two main categories of current sensors like this, High side and Low side.

schematics-project-1

The above image shows the basic configuration of these two types of measurement. The difference is based off on the location of the sense resistor. Low side sensing is between load and ground, with high side sensing between power and the load. It shouldn’t make much difference, the voltage across the Sense resistor will always be the same.

One reason for not using the the low side method is for the fact it is based off the ground reference. If anything between the power and the high side of the load is shorted, the current sensor wont pick it up. It is just one thing thing that you can’t then implement into your design.

Also be careful when choosing the amplifier and the resistors you intend to use. There are many amplifiers on the market designed for this specific purpose. The TSC101 is an amplifier I recently included in a project, for this exact purpose. A high side current sensor, with a precision trimmed preset gain of either 20, 50, or 100. Adding in a laser precision trimmed power resistor to this, and there is an output for a microcontroller, a very simple current sensing application. for less than £2 in your application.