Block diagram of the current meter

I often add debug port suitable for USB-Serial converter direct connection. I can power up and have serial debug port at the same time. The main idea of the current meter was to be able to insert it between USB-Serial and the device I test.

Also important requirement was not to have multiple ranges and measure wide range of current from 0 to at least 50mA (practical limit as well as USB-Serial itself).

Shunt was fixed to 2 Ohms which corresponds to 2mV/mA voltage drop. ADC (MCP3561) provides analog Gain 16 and having high resolution allows to have single range with resolution 0.1uA.

UART1 is currently used to send measurements over serial port for logging. UART2 was added for debugging of the device under test, but currently not implemented.

PCB construction

The PCB is fairly simple, but had to have 4-layers for a good signal / noise performance. I usually very much against cuts in ground copper polygons, but this board has 2 of them and I think they are justified.

Calibration

Some measures were taken to minimize errors: voltage reference with 0.1% accuracy and low temperature drift was used. Shunt is also 0.1%. But there are inherent sources of errors within the ADC itself: offset error, Gain error (+-3%), etc.

Calibration mode was added: long button press initializes the calibration, result is stored in memory (this MCU has no EEPROM, but uses program memory for the same function).

During calibration zero offset is measured and saved. Scale (Gain) is adjusted in single point: 1mA. The reason for such simplistic calibration is to use 3.3K resistor with 3.3V power supply and assume that the current is close enough to 1mA. Larger currents (say 10mA) would be better for wider range, but practically voltage drop on shunt resistor and voltage reduction of the source LDO lead to larger error during calibration. Here is the resulting tolerance before and after calibration:

Tolerance could be improved further, but for practical purposes the achieved 1% seems like a good result. Keeping the cost down and calibration procedure simple were some of the goals for this design. I think it is a good compromise.