TIP120 control. Arduino resetting problem.

I'm not sure if best to start a new topic for this or not but ti relates to this previous topic of mine.

http://forum.arduino.cc/index.php?topic=201786.0

I have implemented the circuit I put up in this thread on prototyping board. My soldering is a work in progress but I managed to get the circuit put together and was surprised that it actually worked. I was able to turn on the motor using pwm on pin 11 of the arduino. I started noticing however that this only really works with values of up to approximitely 210 using analogWrite. When it goes above that value it resets the arduino.

Here is the code.

int TIP120pin = 11; 
int minPower = 51;
int maxPower = 255;

 void setup()
 {
   pinMode(TIP120pin, OUTPUT); 
   analogWrite(TIP120pin, 0); 
   delay(3000);
 }
 
void loop()
 {
    for(int i=minPower; i<maxPower; i++){
      analogWrite(TIP120pin, i);
      delay(100);
    }
    for(int i=maxPower; i>minPower; i--){
      analogWrite(TIP120pin, i);
      delay(100);
    }  
 }

Is there some current being leaked back to the pin or is the pin trying to draw too much current? I have a 5AA battery pack. The arduino is powered using 5 batteries from the jack and the motor circuit is powered by 4 of the AA batteries.

I have a small digital multimeter but I am not sure how to measure the current being drawn from the pin. When I put the multimeter in series and set to 200mA setting nothing happens. It sounds like the motor is getting something but it is not moving just a slight buzzing sound.

Is this circuit just trying to draw to much current or what else would cause the pin to reset the arduino?

rabn21:
Is this circuit just trying to draw to much current or what else would cause the pin to reset the arduino?

^^^ that is most probably the cause. Try putting a large (1000 uF or so) capacitor across the Arduino's power supply to supply the current spike demands

Thankyou for your help Krupski. It has only twigged with me now that this only happens when not powered using battery for both Arduino and motor. I have ordered a couple of 1000uF capacitors as all I have is a bag of 50 x 100nF ones.

Unless I could string all them together in parrallel on the breadboard in the mean time as a test?

What motor have you got - have you tried measuring the current it takes? or its stall
current?

You should be powering motors separately from the Arduino, BTW, for an easy life!

MarkT:
What motor have you got - have you tried measuring the current it takes? or its stall
current?

You should be powering motors separately from the Arduino, BTW, for an easy life!

I bought myself a small pocket multimeter a while back and was going to test the current but noticed it only seems to go to 200mA so didn't want to wreck it. Maybe I was being too cautious. The multimeter I have is this one.

To measure the motor draw you just put it before the motor in series right? Time to invest in a bigger multimeter or is there a trick you can use to measure larger currents using this small multimeter?

I was doing some digging around the web and found out about using a shunt resister to measure current via taking a voltage drop reading over the resister.

The motors I have the following specs.

Rated voltage 3V DC
No load current 0.34A max.
No load speed 16,400rpm ± 15%
Rated load 8.0 g.cm
Rated load curren t1.07A max.
Rated load speed 13,100rpm ± 12%
Length excluding shaft 25mm
Diameter 20mm
Width across flat s15.1mm
Shaft length 9.4mm
Shaft diameter 2mm
Weight 17g approx.

So I am expecting a maximum current to be roughly about the 1A mark under full load. So if I was to use a 1 ohm resister in the shunt I could equate the voltage drop to amps?

Motors pull a lot more than the full load current when starting from cold, or reversing
rapidly. The value known as "stall current" is measured by either:

  1. clamp the rotor stationary and apply the supply voltage across the terminals,
    measure the current (but not for long, the motor will overheat).

  2. Measure the winding resistance with the motor disconnected and stationary.
    stall-current = Vsupply / Rwinding. This is a simpler method. The ohms range
    on your multimeter might not go down low-enough though, and you have to
    subtract out the test-lead resistance by taking a baseline measurement with the
    probe tips shorted together.

Unless you ramp up the applied (effective) voltage smoothly with PWM you'll
get the stall current flowing momentarily upon startup and twice the stall
current flowing at the moment of reversing the drive.

Its commonplace to use a supply that can't supply the full stall current, in which
case the supply voltage will dip at start up and on reversing. This is why you
don't share supplies with logic circuits, because they just go wrong everytime you
start or reverse the motor.

Large motor/gear systems may not be able to handle full stall current without
mechanical damage, so typically the motor controller would be set to limit
maximum current.

MarkT:
Motors pull a lot more than the full load current when starting from cold, or reversing
rapidly. The value known as "stall current" is measured by either:

  1. clamp the rotor stationary and apply the supply voltage across the terminals,
    measure the current (but not for long, the motor will overheat).

Would I be able to measure this current using the shunt technique I mentioned above using these resisters?

http://www.ebay.co.uk/itm/2x-1-ohm-1R-1R00-10W-10-Watt-High-Power-Resistor-/400551189572?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item5d42b61c44

  1. Measure the winding resistance with the motor disconnected and stationary.
    stall-current = Vsupply / Rwinding. This is a simpler method. The ohms range
    on your multimeter might not go down low-enough though, and you have to
    subtract out the test-lead resistance by taking a baseline measurement with the
    probe tips shorted together.

Is Vsupply just a voltage reading across the battery supply?

Unless you ramp up the applied (effective) voltage smoothly with PWM you'll
get the stall current flowing momentarily upon startup and twice the stall
current flowing at the moment of reversing the drive.

At the moment I am starting with a value of 51 for PWM and ramping up from there as that was what it took roughly to get the motor spinning. Should I still just ramp up from 0 in small increments to avoid the stall current at startup?

Its commonplace to use a supply that can't supply the full stall current, in which
case the supply voltage will dip at start up and on reversing. This is why you
don't share supplies with logic circuits, because they just go wrong everytime you
start or reverse the motor.

I am going use a seperate power source for the arduino to save complications. What would some of the best options be for a lightweight rechargable power source that would power the arduino and a few sensors (9DOF chip and possibly a baromoter and a range finder)?

Large motor/gear systems may not be able to handle full stall current without
mechanical damage, so typically the motor controller would be set to limit
maximum current.

Thanks for taking the time to help. I am enjoying experimenting and learning from more experienced folks on here.