# Current control of DC motor using PI controller

awaiting
Hi everybody!

I am trying to implement current control of a DC motor using a PI controller and was having a few questions.

I am supplying 19V as input voltage (and capable of supplying current upto 2A) to the H- bridge and the controlling is done via a microcontroller using PWM.
When I connect 19V (100 % duty )directly to the motor (with a small mechanical load) I measured the current through the DC motor to be 15mA. Does this mean that I can control the current only upto 15mA.
If for this same load and supply voltage, I now give a reference current of 25mA will the controller be able to take power current from the source and give it to the motor. If so, how? (as it was giving 15mA for 100% duty at 19V.)
If not, does it mean that there can be no PI control above 15mA for this case?
Is it possible to make a PI controller for any range of loads connected to the motor ?

Thanks a lot for reading!
I appreciate your help

## Answers and Replies

The max current will be at max load ( stall) - If you can not find a datasheet for the motor - measure the DC resistance of it, and then use that to calculate the max current using good ol' Ohm Law. Then use this current to develop the rest of the solution - there are so many sources of info on using PI - I suggest fishing around a little before posing here - since you are more aware of the details of what you want to do. ( I like SParkfun.com for example - but there is also http://www.raspberrypi.org/ )

However as I looked for a little info I did find some bad examples - so if you have a specific case / example I am sure the group here can review and advise. It seems the max current you should expect / allow though a single GPIO - as an output is 16mA.

To you basic question - the PI is a controller - to run heaver loads ( almost ALL motors should be considered a heavy load relative to a controller )- you need a Driver Circuit. This takes the output of the PI ( as a very low load) - and provides a higher power output.

awaiting

I found the max current as you suggested by stalling the motor and then adjusted the proportional and integral gains to get 100% duty cycle.
The motor current is now following the reference as long as it is set less than the max current.

Mike_In_Plano
The motor current for a brush motor is proportional to the torque being transmitted to the load and losses.

However, using current mode control, controlling the motor current through the motor the motor's torque can be programmed and the speed will become load dependent until the motor enters what is termed speed limit.

Speed limit occurs when the motor is rotating fast enough to produce a back EMF (generated voltage) approaching the supply voltage.

Voltage mode control is accomplished by controlling the PWM for a fixed voltage source. Then, Vmot = 19V x PWM
Thus using the PWM as the control variable is a handy means of approaching the desired speed. Over a range of loads.

Now for the fun part, current mode control controls torque which then then interacts with the mass-moment of inertia, J, of the system as well as the load peculiarities. In the world of control systems, this means you have another pole ( integral ) in your control loop and the result is a more difficult system to stabilize.

Though voltage mode controlled motors still have to deal with inertia, the associated dynamics are at a higher frequency, making the control loop simpler to close.

- Mike