 # Microcurrent sensing

Hi fellows.

I'm controlling an big dc electromagnet, it is 17 ohms.For the voltage control i using Gammon's circuit to control it with pwm.I using 125Hz Pwm to make a high resolution control.I Pwm's period is 8000 Microseconds so if i give pin high time for 4000uS electromagnet have half of the input voltage.My ınput voltage is 12 volts but my multimeter measures 10 volts when duty cycle is full.It's okey, no problem.

As you know, Pwm making on (10 volts) and off (0 volts) but multimeter measures like analog voltage like if duty cycle is %10 voltage is 1V %30 3V .. etc.It is well too no problem.

I have to measure current of electromagnet for full control of magnet, just voltage control is not enough because e.magnet is heating, it makes resistance rising, current reducing, when current reduced electromagnetic force is reducing.But if i measure it's current i will adjust duty cycle depending on current.

Electromagnet's maximum current is 600mA(approsimately)
Electromagnet's minimum current is 15mA(approsimately)

One step up of duty cycle is 10v/8000= 1.25mV
One step up of duty cycle makes current diference is 65uA

Can you please recommend me a sensor?Can INA226 module (Datasheet) do this?Or can you guide me please?

You have 3 main choices for current sensing:

1. Shunt resistor

A big resistor of very low value - like 0.01 Ohms - usually put between the device under test and the negative terminal of the power supply. The Arduino must share the same ground as the power supply. Use an instrumentation amplifier like the INA series to amplify the tiny voltages developed on the resistor.

For small currents, use a higher value. If you use 1 Ohm then 1V readout is 1A of current.

2. Hall Effect, current transformer or other non-contact method

If you can wrap a sensor around a wire (but not both wires in a pair) or you can add one of the newer hall-effect modules into the circuit then you can measure current without sharing the ground with your Arduino. Best for mains-powered electricity.

3. Use a motor driver with current feedback

Something like the Sparkfun Monster Moto shield is great because the chip can drive huge currents (20-30 Amps) and gives you a small feedback pin which matches the current going out the main motor drive pins with a ratio like 1/300 or 1/800. Add a convenient shunt resistor and it's very easy to measure and calculate the current that the driver is driving. The Monster Moto shield already has the shunt resistor.

The Pololu TB9051 motor driver will easily handle that magnet, and provides a convenient current monitor output pin. Read the pin with an analog input, using the 1.1V analog reference.

Thank you for the responses.Can motor driver notice 65uA change?
The pololu motor driver says;
"The current monitor output, OCM, provides an analog current-sense feedback voltage of approximately 500 mV per A"

So 65uA of change of current means 7.7mV change of volts.And my PWM's period is 8000, arduino uno's adc has 1024 resolution.And in 5 volts.If the motor driver can do it i have to add an adc that bigger resolution of 8000 like it will bigger than 12bits(2^12=4096), it have to at leats 13 bits(8192)?

In fact i have to use adc in every way i guess.

If we use shunt resistor way i have to use 3 thing: shunt resistor, External adc(at least 14 bits), instrumentation amplifier am i correct ?

I've decaded to make shunt resistor way.i will use 0.1ohms shunt resistor.Which means at maximum current 600mA voltage drop of this resistor 0.06 volts.Then will add the circuit ins. amplifier ads623 Datasheet.Gain will be at 80, so 0.06volts will be at 4.8 volts.At minimum current 15mA amplificator output will be 0.125 volts.

In period of 8000uS pwm if i change duty cyle 4000(%50) to 4001 with a Ads1114 Datasheet the current change will 5 volts/2^16 =76.29uV.

Do you think is there a problem?

Don’t forget a magnet is an inductive load , when switched on the current will build up over time , so will appear unsteady during each PWM “pulse” - so a 50% duty cycle won’t be “equivalent” to driving it at a steady 50% voltage. There is also the problem of synchronising your current measurement with the PWM pulse .

Not easy .

That Quora article seems to be related to AC power. "Lag" and "lead" aren't relevant to PWM.

Just filter the feedback current with an appropriate analog filter before passing it to the Arduino analog input pin. In the case of the Sparkfun Monster Moto (which I am most familiar with) there is a filter but it does not adequately filter out the 480Hz pulses from regular Arduino analogWrite(). Add a 1uF capacitor in parallel (directly between the analog input pin and ground) and it will smooth out the PWM very effectively. You can do quite accurate and fast current control if you read that pin at whatever rate you require. No synchronization required.  MorganS:
Add a 1uF capacitor in parallel (directly between the analog input pin and ground) and it will smooth out the PWM very effectively. You can do quite accurate and fast current control if you read that pin at whatever rate you require. No synchronization required.

Do you mean like that?
İmage And i used 500mOhm resistor because of when PWM is full electromagnet's voltage is 9.5volts.And Adc1115 is max 5v.

No. Copy my circuit. R6 is the shunt resistor. R5 and C1 form the filter.

You are using a higher PWM frequency, so you don't need those exact values of R5 and C1 but they should work as-is.

MorganS:
No. Copy my circuit. R6 is the shunt resistor. R5 and C1 form the filter.

You are using a higher PWM frequency, so you don't need those exact values of R5 and C1 but they should work as-is.

Thank you very much.

The first thing I would is get your meter checked, I am assuming you are measuring across the motor. The on should be 12 volts - the drain source voltage drop on the FET. You should not be dropping 2V across the MOSFET. It needs to be a Logic Level FET, preferably avalanche rated. Use something in maybe the 10 amp or more range, they are not that much more and when building a few it is handy to have a few around. It will also be a lot cooler with your load. I would reduce your 150 Ohm resistor to less then 50 ohms and no capacitors in the gate lead. the INA226 should do fine but remember you have a AC component in your power to the magnet.
Good Luck & Have Fun!
Gil