DC motor control using current sensing

Hello,
This is my first post in this fórum and I'm quite new to Arduino. However, I do have a relatively good knowledge in controls so Arduino really fascinates me. Sincé I never powered a motor I decided to start from there.

Here are my first questions: I bought an arduino shield R3 to drive a DC motor. The shield is powered by an external power supply that allows me to regulate voltage with good accuracy. The arduino board is powered via PC.
Today I was testing my code on a prototype: the idea is that the DC motor moves via a screw mechanism a plate in the axial direction. I want the plate to push with a certain forcé against a surface. Once the correct pressure has been reached the motor will start turning in the opposite direction and stop at the opposite end of the stroke. To measure the pressure I measure the current, and stop the motor once the current is high enough (cut off 1 amp).

  • I'm using A0 to sense the current and the signal is very noisy. I've added a filter, and hopefully that will help, but is it normal that current sensing is so noisy? Maybe I should add a condenser on the motor?

  • I have noticed that when the motor stops spinning but it still hasn't reached the cut off current the voltage on the motor is a lot lower (6-7 volts while the power supplies gives 18Volts). Is it normal?
    Maybe the motor driver draws a lot of energy when the motor doesn't spin? I should add that due to my pressure requirements the motor can stay a few seconds powered without reaching the required Amp.

  • cutt off current is set at 1 Ah, so well below the nominal 2Amps, however after an hour or so of test the driver stopped working and it had a very high current draw even if the engine wasn't spinning. I will check tomorrow if it is damaged or just went in high temperature protection. is it normal that they overheat so easily or am I doing something wrong?

thanks
luca

Post a circuit diagram (hand drawn, not Fritzing).

How are you measuring current with A0?

As the motor slows down, it draws more current. When it stops turning, it draws the stall current, with is 5-10X the normal running current. What is the stall current for your motor?

Finally, it sounds like the motor power supply cannot supply the required current.

piggdekk:

  • I'm using A0 to sense the current and the signal is very noisy. I've added a filter, and hopefully that will help, but is it normal that current sensing is so noisy? Maybe I should add a condenser on the motor?

Yes, noise will always be an issue with motors involved.

  • I have noticed that when the motor stops spinning but it still hasn't reached the cut off current the voltage on the motor is a lot lower (6-7 volts while the power supplies gives 18Volts). Is it normal?

Whether its normal depends on whether you intend the supply to be overloaded or not and whether the
supply is happy being overloaded (some are, some are not).

With a DC motor the current drawn is proportional to the torque load, the speed depends on the supply
voltage V less the IR losses in the winding. At stall I = V/R, you can measure the winding resistance to
predict this.

jremington:
Post a circuit diagram (hand drawn, not Fritzing).

How are you measuring current with A0?

As the motor slows down, it draws more current. When it stops turning, it draws the stall current, with is 5-10X the normal running current. What is the stall current for your motor?

Finally, it sounds like the motor power supply cannot supply the required current.

thanks for Your reply jremington,
there is really no circuit involved. I'm using a motor shield rev3 connected directly to an arduino Mega. I have cut the Vin jumper on the motor shield so that it won't supply power to the arduino.
To measure A0 I just use AnalogRead, but then I'm forced to use a first order filter to smooth it, something like:
Curr_Old = Curr;
Curr = AnalogRead(A0);
Curr=Curr0.1+Curr_old0.9;
So effectively I only use 10% of the new value and the rest is coming from the previous measurements.

What I find odd is that tension at the motors terminals is at least 1-2 volts lower than the tensión at the power supply. When the motor stops tensión at the motor terminals goes down to 3-4 volts (power supply stays at 18v). So I'm wondering if the massive V drop isn't happening across the motor shield due to the larger current draw.
thanks
luca

MarkT:
With a DC motor the current drawn is proportional to the torque load, the speed depends on the supply
voltage V less the IR losses in the winding. At stall I = V/R, you can measure the winding resistance to
predict this.

Thanks MarkT.
The power source is a decent one and allows me to control tensión and measure current. It is rated up to 36 Volts and 5 Amps and I am using 18 volts to power the shield. The current drawn displayed on the power supply is quite similar to the value I measure from A0 (altough generally 10-20% higher). In normal operation the motor uses between 300 and 400 mA to move, once it reaches the end of the stroke current quickly increases up to close to 1 Amp. As it reaches 1 Amp the code stops the motor, waits there a few seconds, and then spins backwards.

I've measured the winding resistance with a cheap meter and it is 9 Ohm. I will take a better one later just to confirm it, but assuming that's correct if I supply 18 volts the current draw should max at 2 amps. This is within the shield capabilities. Still I don't get why it overheated and why at the motor terminals voltage drops so much compared to the power supply.

Do You reckon a condensor across the motor terminals would reduce current noise? If so how big should the condensor be?
thanks, I really appreciate Your feedback
luca

"rev3" actually describes the layout of the pins on the Arduino, which match the shield. It isn't the name of the shield. We need to know the actual name of the shield. I'm guessing by your comments above it has an L293 chip in it. That type of driver is quite old and can never send all the voltage from the supply to the motor - there is always some losses in the chip.

You can't use a regular multimeter to measure the voltage or current going into the motor. The Arduino is sending out a string of pulses where the width of the pulse determines the amount of power sent to the motor. A normal multimeter can't measure the pulses. Any voltage or current value you report is meaningless.

Using analogRead() to read the voltage is also going to be difficult. The analog readings aren't synchronised to the PWM frequency and even if they were, they would not mean much. At any single moment in time, either there is a pulse and there's lots of voltage+current or there isn't a pulse and voltage and current are near zero. Averaging this is also meaningless.

To use an analogRead() as a current or voltage feedback, you need to filter the signal in the analog circuit, to "smooth out" the pulses. A simple resistor and capacitor are all that's required, but you need to know the PWM frequency and the frequency response of the filter.

Hi Morgan,
I'm referring to this shield:

I appreciate your input, as I mentioned earlier I have no experience with motors so this is all good learning for me.

the board is based on L298, not L293, but I guess the principle is the same and there will be some voltage drop.

I understand that the arduino sends a string of pulses to the L298 via PWM, but isn't the chip converting them into a relatively steady voltage to the motor? Also if I send 255 via analogwrite doesn't it mean that it should pass the whole voltage (minus some voltage drop to power the shield)?

The board above claims to provide current sensing reading via A0 and A1 for each motor, so I've assumed the chip takes care of measuring the actual current supplied to the motor. I don't have plots with me right now, but when I plot current on the serial plotter You can easily see how the current is measured and it's all but meaningless. It increases while I ramp up the speed and it peaks as I apply torque to the motor. The value itself matches what I see on the power supply current meter. The code can also use it quite well as it stops the motor once the current reaches the cut off value. Of course what you mentioned about synchronization might explain why the reading is so noisy.
thanks
luca

piggdekk:
but assuming that's correct if I supply 18 volts the current draw should max at 2 amps. This is within the shield capabilities. Still I don't get why it overheated and why at the motor terminals voltage drops so much compared to the power supply.

No, its within the chip + heatsink's capabilities, for a large enough heatsink. Max power/current is normally
quoted with full heatsinking since that's how you get max power handling...

Does you shield have a large heaksink (or medium heatsink plus a fan?)

MarkT:
No, its within the chip + heatsink's capabilities, for a large enough heatsink. Max power/current is normally
quoted with full heatsinking since that's how you get max power handling...

Does you shield have a large heaksink (or medium heatsink plus a fan?)

No MarkT,
it doesn't have any heat sink at all. I guess that's very poor design then.
if it hasn't fried I will try to install a large enough heat sink.
thanks
luca

Its cheap design - you can glue a heatsink on if you need more power handling, and/or point a
small fan at it.
You can spend a bit more on a decent high current MOSFET H-bridge driver too..

Many driver chips shut themselves down on overheating, so you just have to wait for it to cool and
go again.

yeah, I think I'll go for a mosfet one. What I liked about the arduino motor shield is that it already includes current sensing and I didn't need to buy an extra board for current sensing. Since I was aiming for 1 Amp I thought a board with 2 amps of nominal current was enough, but I was wrong.

In the meantime I will glue an heat sink I'll still from one of the many old laptops I have hanging around.
many thanks, I'll keep the thread updated with the progresses
luca