# Current measuring with PIC

I know it is possible to measure analog voltages with the ADC peripheral of advanced PIC microcontrollers. There is no peripheral to measure current though.

Is it possible to convert a current to a voltage so that I can measure that voltage with the ADC peripheral? Or are there ICs with serial or parallel output of a measured current? I'd rather have serial, with I2C or SPI.

I'll have to measure currents up to 200mA with fewer than 5mA deviation. The PIC I'm using is a PIC18F46K22, but that's probably no useful information.
I'll measure the currents of 5V / 3.3V chips connected to the PIC microcontroller (like LCD, RAM, other PIC, ...) so the current will go to ground. Also, a few tenths of a volt voltage drop is allowed.

• The simplest technique is the voltage drop across a known resister generates a known voltage you can read from one of your ADCs. – kenny Jan 18 '13 at 12:59
• I knew I was forgetting something. You may submit this as an answer (I'll wait with accepting it though) – Keelan Jan 18 '13 at 13:02
• As others have already noted, current to voltage converters are called resistors. However, that's the easy part. Is this current going to ground? Do you need to measure it in a segment that is floating somewhere? How much voltage drop can be tolerated? The circuit will look very different depending on these answers. – Olin Lathrop Jan 18 '13 at 13:14
• I don't quite get what you mean with 'a segment that is floating somewhere'? I'll use this to measure the current drawn by several 5V / 3.3V devices, so the current goes to ground. They are quite tolerant, so a few tenths of a volt is OK. I'll add this to my question as well, good point! – Keelan Jan 18 '13 at 13:18
• @CamilStaps - "floating" means that neither end of the "segment" is at ground, so it makes it more difficult to measure the voltage across it with e.g. a microcontoller ADC which (usually) has ground as it's low reference. In this case a differential measurement setup is required. – Oli Glaser Jan 18 '13 at 14:06

Another often overlooked current-to-voltage converter is a MOSFET that's on, which is pretty close to a resistor. Perhaps not as accurate, but many circuits that require current measurement already have a switching MOSFET in them, so this method is cheap and convenient. The datasheet will list the on resistance as $R_{DS\_ON}$.
For a step up in sophistication, look for hall effect sensors. Hall effect sensors measure magnetic fields; some of them are configured to measure the magnetic flux associated with a current passing through a wire. Here's an example product page to give you an idea. However, at $200mA$, I don't see much need. Typically this sort of product comes into play when the current is high enough that a resistor, even a small one, would represent a significant loss.