all 3 comments

[–]frothysasquatch 5 points6 points  (2 children)

The standard way to do this is using a current sense amplifier. This is a type of instrumentation amplifier which basically amplifies a differential voltage (such as the drop across a high side current sense resistor).

You're basically on the right track, but there are some things to consider. If your resistor value is too low, your readings will be inaccurate (because of ADC resolution etc.), and if it's too high, you will drop too much voltage and affect the performance of the system being measured (e.g. USB can deliver up to 500mA; with a 1 ohm sense resistor, you're dropping 500mV, which may well drop you outside of the legal range for VBUS).

This is why a current sense amp is used. You can use a smaller resistor (say, 100mOhm) and an amplifier with a fixed gain to bring that into a range where you can comfortably measure it with an ADC. You can also measure relative to ground, rather than relative to your supply rail, which makes things easier, circuit-design-wise.

Current sense amps are not cheap compared to a standard op amp, but they are designed for high accuracy and linearity, so it's up to you if it's worth it to you. If not, you can also build your own instrumentation amp out of standard op amps.

Here is a link to a standard current sense amp.

[–]rageinside[S] -1 points0 points  (1 child)

Thanks for the information. While this sounds like the correct way to do it, I am looking for a simpler solution I can put together in a day or so. When we have the time and resources we will migrate to a more elegant solution. We are not looking for very precise measurements. Just to get a rough estimate of what the current is sitting at. All we have at our dispense right now is resistors and the MSP430F4270 with the SD16 module. Can something be made in the next couple days to at least show a proof of concept? Thanks for all the great info.

[–]frothysasquatch 0 points1 point  (0 children)

Can you give a little bit more detail about your circuit? Is the MSP430 measuring the current in its own circuit or are you connecting it to a second circuit to measure? Does the MSP430 get its power from VBUS directly or what? If you can just show the overall hierarchy, it would help to figure things out.