Motor pulses at program start problem?

I have been trying to rebuild a heathkit hero robot using an onboard laptop and arduino.

I have had lots of success but suddenly I have a strange problem I am not able to properly fix or
diagnose the cause somehow.

The main drive motor of the hero robot is a regular dc gearmotor. I am using an l298 module
to control it. I'm sure in testing this was working without this power pulse or surge problem.
Now, while trying to get voice commands and dumping programs from voice command to the arduino
through arduinouploader, this problem started.

When a program starts to steer or drive the main drive motor, I get a pulse or something that activates the main drive motor for a second or so.

I put a delay (10000) before my program actually starts. That at least let me see the pulse or problem starts as soon as the arduino starts. What happens is the program starts. The drive motor pulses on for a second or so. Then the delay happens, then the drive motor correctly comes on in forward or reverse as it correctly should for each program.

I tried another arduino mega board, same problem.

Any ideas for how to fix this would be greatly appreciated. I am out of ideas. I've been pulling my hair out trying to fix this problem for 2 days.

The only thing left to test is that I added a usb hub. The laptop I am using is an asus eepc and has only 2 usb ports. I have 3 arduino boards on this robot so I needed this hub. I am going to try going straight to the laptop and see if this still happens.

I suppose I will re run the power lines from the battery to the motor and re-run the jumpers from the l298 module to the arduino, but I don't think this is the problem.

Best regards
Steven

I ran the arduino mega straight to the laptop. Same issue when uploading programs straight to the ide.

I'm not sure why this motor seems to be getting a short surge of power at program start. I am completely
lost as to how to fix this, so anyone with any experience with this? I would truly appreciate some other things
I can try to solve this issue.

Hi,

Look at the startup sequence.

Set the data to the L298 FIRST while the I/O pins are still in high-impedance mode. That data should have the motor stopped. THEN pinMode the motor driver bits...

You MIGHT need pullup or pulldown resistors to motor to guarantee correct startup before the Arduino I/O pins are enabled as output.

Similar problem with some relay boards; many are now active-low. See THIS PAGE..

Let us know....

Hi Terry. I tried your suggestion, but I'm not sure I did this right. Here is the program I am using.
This program moves the robot forward about 1 foot. I plan on controlling the robot via voice command
This would be "Move forward one unit" Works except for the about half second pulse before the program
actually begins. Notice the delay command (delay 8000) I did this to see where the pulse was starting.

At the program startup, the pulse happens, motor goes on for a sec, then the delay, then the motor correctly moves the robot forward about one foot. I will try your resister suggestion next, but just to clarify, am I supposed to use resistors on the lines going to the motor, or on the digital output control lines going from arduino to the l298 module? I don't have any here but can get some from radio shack tomorrow. What value or values of resistors would you recommend?

What is frustrating is that I am sure this was working before, but I was using a stepdown transformer to go from 12 to 6 volts. (12 volts seemed a bit too fast) I took that out because it appeared that sometimes the motor would not turn on at all. Here is the transformer I was using -

Now I removed that and I'm just using 12 volts straight from the battery.

Also, here is the l298 module I am using. I have used arduino and this module to control many different dc motors, and I have not had this problem before, most of those motors were not this big though -

I would sincerely appreciate any help. Everything else is working nicely. Kind of proud of myself because I was dreading the stepper motors in the head and steering motor (Never used steppers before) I got them
working no problem with arduino and the same l298 modules. So now everything is working, but this main drive motor pulse program has completely halted any progress on this project. My sincere thanks to anyone who can help. I desperately want to fix this so I can finish this project.

Here is the arduino program to control the main drive motor :

void setup() {

digitalWrite(12,LOW);
digitalWrite(13,LOW);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);

// put your setup code here, to run once

delay(8000);
digitalWrite(12,LOW);
digitalWrite(13,HIGH);
delay(1500);
digitalWrite(12,LOW);
digitalWrite(13,LOW);

}

void loop() {

// put your main code here, to run repeatedly:

}

I tried running new power lines straight to a 6 volt battery. The pulse is still there, but smaller so the robot just kind of jerks a bit at program start instead of actually moving. Maybe it was there before during testing but smaller at 6 volts so I didn’t notice it much. I’m guessing that is the case.

So I have tried multiple arduinos. Multiple power sources. Multiple l298 modules, all with the same results.

I never had this problem with any other motor, but then I’ve never tried controlling such a big beefy motor.
It may be the motor itself has a problem, but I don’t think so. And it would be very costly and difficult to
try and replace this motor.

Very frustrating. Any help or suggestions? I am all ears. Thank you Terry and anyone else for the help. I’m at my wits end trying to solve this issue.

Try:

  digitalWrite(12,HIGH);
  digitalWrite(13,HIGH);
   pinMode(12,OUTPUT);
  pinMode(13,OUTPUT);

Thanks I tried that as well as low high, and high low.

Same issue remains. I'm stumped. Tried different arduino, different l298 module, different batteries and voltages, and more.
Same issue remains. The pulse is strong enough at 12 volt to move the robot forward about 4 or 5 inches.

at 6 volt about 2 inches, but sometimes just a jerk with no movement at 6 volt.

Everything else is working, but still stuck in place not moving forward because of this issue.

I also tried putting some different value resistors on the lines going out to the motor from the l298 module and the motor. (tried this with both lines going to the motor separately) When I do that the motor does not turn on at all, not sure if I'm using too high a value, just tried about 10 different resistors I had around the shop.

No, the pullups or pulldowns go on the inputs to the L298, to pull them up or down when the Arduino
is in reset state. Otherwise the pin may be floating (undefined).

I tried a few more things, and I also noticed that even when I upload a completely blank program to the arduino, this same pulse happens.

The en pins are jumpered on the l298 module, as most of the simple tutorials I have seen that do not use these pins for pulse width modulation just leave the 2 pins jumpered on each side.

This works fine for turning motors on off and controlling direction with every other motor I have ever done this with. I have not used these pins ever before except once trying pulse width modulation.

I also noticed with only one line going to the l298, this issue does not happen.

Can anyone suggest what value resistors I should use for pullup or pulldown on the input pins of the l298 module? And to be clear and pardon my ignorane, very new at this, I would just put a resistor inline from the digital pin of the arduino (12 and 13) to the inputs on the l298? Do I need a resistor on just one line or both and any ideas on what value resistor?

Well I was about to give up, then I decided to rewire this WITH Pulse width modulation control on the enable pin...

That did it. So I needed one more line to the arduino and one more line of code

analogwrite(3,990)

I didn't want speed control, but now that I have it working I guess it can be useful some times.

2 days of pulling my hair out out are over.

Thanks for helping me think through the problem. When someone mentioned the enable pins I remembered my tests with pulse width modulation. So happy this is working now, no problems,
and I can adjust things now so the robots movement seems much smoother now.

Thanks guys!