This is a shortened translation from Russian of my article published in Радио (Radio) magazine, no. 12 (2009) pp. 18-21. The micro-ampermeter described here is intended for experimenting with low-power devices. I have just a general multi-meter in my home lab, which is not very convenient to use. The reason for this is that now-days many electronic devices have a power saving mode, where their current consumption drops down in 1-3 orders of magnitude. Measuring current in a device that periodically enters a sleep mode makes it necessary to frequently adjust the multi-meter range, unless it is automatic. Unfortunately, my multi-meter is not automatic. Moreover, I often need to measure current along with voltage, which makes working with my measuring device even more inconvenient. The micro-ampermeter described here has the following features:
Schematic | Front view | |
The current sensing circuit is based on MAX4372F current-sense amplifier. I use version F of the IC with gain 50. It measures the voltage drop Vsense on current-sensing resistors R1 - R4 and converts it to an output voltage Vout, such that Vout = 50 · Vsense. Only one current-sensing resistor is used in any time, provided by a switching network on MOSFET transistors. Resistor R1 is for the range 0.03μA - 9.99μA, while R4 is for the range 1ma - 9.99mA. The output voltage comes to the PIC's built-in ADC for further processing. The ADC reference of 4.096V is built on DA4. If, say, R3 = 82Ω is used for sensing current Iin, then MAX4372 output voltage will be
Vout = 82·50·Iin = 4100·Iin
If Iin = 1mA (=0.001A), the above value becomes 4100Ω·0.001A = 4.1V, which is very close to 4.096V (within 0.1%). Therefore, by using a 4.096V voltage reference, the 10-bit ADC value will be then
NADC = (Vout / 4096)·1024 = 1024·Iin
(here 210=1024). However, in the case Iin = 1mA, 1000 should be displayed on LED instead of 1024, so the ADC value NADC must be scaled to obtain the correct displayed value NLCD as follows:
NLCD = NADC·(1000 / 1024) = 1000·Iin
In the considered case NLCD is the value of Iin in microamperes. The same equation is also valid for all other current ranges. The obtained value NLCD is forwarded to the LCD controller PCF8660 and further to the LED. The controller is connected to the PIC via an I2C bus with 10K pulling resistors and takes care on driving the 3-digit LCD (Lumex model LCD-S301C31TR) in static mode.
In order to select a current-sensing resistor I use MOSFET switches. Since the voltage at input pin "+" can be as low as 0.1V (this voltage is also present at the switch source pins) and MOSFET switches need at least 3V source-drain voltage difference for opening and low switch resistance, the voltage at gate electrodes of the (upper on schematic) MOSFET transistors must be negative. Therefore, a negative power source is needed. The negative voltage of -5V is produced by the TC7660 voltage inverter (DA2). I use 10μF ceramic capacitors for a better filtering, which are not much more expensive than corresponding tantalum capacitors. This way the channel resistance of MOSFET switches is very low (about 0.05ohm) and they do not noticeably contribute to the total inaccuracy.
Since the nominal LCD voltage is 5V and the circuit is powered from a 3V battery, I use a DC-DC converter on MAX619 (DA3). The SHDN pin of this converter must be grounded for a normal operation. When the device is off, this pin is attached to 3V via R14. In this mode MAX619 leaks just a few microamperes of current. Turning the device on is done by pushing the button S1. This causes the SHDN pin of MAX619 to be grounded. The DC-DC converter activates the PIC by delivering 5V to it. The PIC pulls pin 11 high and this voltage opens the switching transistor VT5, which short cuts the button so that the device keeps working even if it is released. Turning the device off is done in software.
The circuit is assembled on a one-sided board by using SMD components. The input 6-pin connector has all its bottom pins grounded. Its middle top pin is not connected, the top left one is for attaching the plus electrode of a power supply powering a testing circuit, while the top right one is for the "+" of the testing circuit. Hence, the "-" electrodes of the power supply and tested circuit are common.
Board | Back view | |
The board is designed for embedding it into Hammond 1591 plastic enclosure. Mounting the board inside the enclosure is done with 6 metal posts of height 5mm. The posts carry M2 threads and are epoxy-glued to the bottom of the enclosure. The LCD mounting height over the board is adjusted to match the posts height. This way it will touch the bottom of the case. The battery holders are super-glued to the back side of the board. I use two single ones from Radioshack. It turns out that those are narrower than a double AAA-holder, which does not fit into the case.
The code starts with necessary initialization of the PIC modules, setting the oscillator frequency FOSC=1MHz and ADC clock to FOSC/2, and initialization of the LCD controller. The last one needs to be instructed to use static mode and display a 0 on the LCD. Right after this the program enters an infinite loop. At each iteration of this loop we call the main method getCurrent(), whose returned value is converted to the BCD representation and sent to the LCD controller to update the LCD. After that a 0.25sec delay is performed to prevent very fast display updates. If the measured current is below 0.05μA, it is treated as 0 and the idle time counter is incremented. Due to current leaks in MAX4372 the displayed value alternates between 0.01 and 0.03 even if the current-sensing inputs are left hanging. As soon as the counter reaches the value 512 - this happens after approx. 3 minutes of inactivity - the device is turned off by grounding the gate of VT5.
The function getCurrent() called from the main loop starts with selecting a proper current range. It first configures the MOSFET switches to turn on R4 and perform a current sampling in the range 1mA - 10mA. If the obtained value is 10 or higher, it is displayed on the LCD. In this case the range is indicated by turning on both decimal points. The left point separates the integer and fractional parts of the number, while the right one indicates the range. In general, the output is formatted according to the following table:
LCD reading | Current range |
---|---|
0. 0. 0 | 0 - 0.05 μA |
1. 2. 3 | 0.03 - 9.99 μA |
1. 2. 3 | 10.0 - 99.9 μA |
1. 2. 3 | 100 - 999 μA |
1. 2. 3 | 1.00 - 9.98 mA |
-. -. - | above 9.99 mA |
If the sensing current does not exceed 1mA, the MOSFET switches turn on R3 and another current sample is taken after a short delay. The delay is needed to charge the VT1 - VT4 gate capacitors. If the measured current is above 100μA now, it is displayed. Otherwise, R2 is turned on and so on. After 4 or less initial samplings the current range will be set (it is assumed that the current does not change much between the measurements). As soon as the current range is determined, the code takes another 63 current samples in 1.5msec intervals. These values are then averaged and rounded off to the nearest integer. This way most of ADC noise is eliminated and the unit achieves a 100msec integration time.
After the sampling current I is averaged, the code normalizes it by multiplying the value by 1000/1024. To implement it efficiently, note that this ratio can be represented as 250/256. A division by 256 can be done by dropping the MSB of the result. To multiply I by 250, note that 250 = 256 - 4 - 2. Hence, the multiplication can be done by adding to I a byte of zeros first (this is equivalent to multiplication by 256) and then multiply I by 2 (implemented as a left shift) and subtracting it from the first number. Finally, multiply I·2 by 2 again (another left shift) and subtract it from the first result.
The micro-ampermeter is designed to measure low currents and has no indication and protection from incorrect polarity, so one must be careful. The current sensing IC MAX4372 is intended for high-side current monitoring only. This way, the micro-ampermeter should be connected between the positive terminal of the external battery (range 0.1 - 25V) and the testing circuit, and the negative battery terminal should be connected directly to the testing circuit (see the schematic below). This connection is also shown on the photos below, where the testing circuit is modeled by a resistor. A single AAA cell is the battery powering the testing "circuit" (resistor), while the 2xAA cells were used to power the micro-ampermeter itself in the code development phase. The 5-pin white header was used for programming. It is removed after finalizing the code. Note that the output of the voltage reference must be disconnected from PIC during programming.
Test circuit | Test | Test | ||
Summarizing external connections again, the input 6-pin connector on the PCB has all its bottom pins grounded. The top middle pin is not connected, the top left one is for attaching the positive battery terminal (external battery for powering a testing circuit) and the top right one is for the "+" of the testing circuit. Hence, the "-" electrodes of the power supply and testing circuit are common. Check another example of external connections shown n the picture at the top of this page. This picture shows a measurement of a current consumption of a sample board powered from two AA cells.
Last modified:Mon, Jan 23, 2023.