DC Motor moves with Program load and reset

I am using a Mega and a dual 15A HBridge (noname) for driving 2 DC motors in parallel (same synchronuos movement is essential). When loading the program one of the motors (only M2) starts to move. In my setup code I do first a pin assignment for output and immediately write a 0 value to prevent any movement but this does not help. When I press Reset motor M1has repeatedly a short movement which causes my motors to get unsynched. I needed to set different speed settings for the 2 motors to stay in sync. Do not know whether the controller or the motors cause this behaviour. My test program is dead simple. I only have setup code for the PWM and direction Pins to be OUTPUT's and my loop sets first direction, then speed for 1 sec, then sets PWM to 0. Beside the strange behaviour with loading and resetting the moves are as expected. I am thinking now about adding a relay to only provide motor power to the controller when I want them to move? Any other hint? Juerg

My test program is dead simple.

But you have not posted it so that it can be seen. Before you post it please read this before posting a programming question

You need physical pull-downs on the control signals I suspect - during reset the Arduino pins float, and if your motor controller inputs are also floating that's going to allow random behaviour at power up.

Direction is given with a digitalWrite(pin, LOW/HIGH) but I do not care about direction.
To drive the motor a PWM signal is needed, you propose I can pull that pin down to GND with e.g. a 10K resistor to prevent any movement during reset?

TableControl.txt (704 Bytes)

Yes.

thougt about this but the idea to pull down a PWM pin just looks strange to me - how can the signal go to 5v then? And if this works - why is the pulldown resistor not implemented on the controller board by default?
And how can a floating gate create a pwm signal?
Added a relais now for providing motor power only during movements and this works for me now.

the idea to pull down a PWM pin just looks strange to me - how can the signal go to 5v then?

The processor applies 5V through the pin driver. It looks strange because you don't understand electronics.

And how can a floating gate create a pwm signal?

A signal, even an electrostatically induced state, is a signal. Write a program to read a floating pin and print the value, so you can watch the input randomly go HIGH and LOW.

Added a relais

Much easier, cheaper and less power costly to add a pulldown resistor.

Hi, Welcome to the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :)

OK, understood, lack of electronic knowledge for sure.

As I read to the pages for Arduino PWM handling before asking this question it looks a bit strange to me that the Arduino has built in programmable resistors for the Input ports but not for the PWM’s?

And that in the PWM section of the Arduino there is no mention of this behaviour (unwanted motor actions in reset state) and how to protect against it?

In my case it caused a lot of mecanical stress on my structure and of course it could easily burn the controller when trying to move in unforeseen ways.

As for the code, I had added it as txt file - not a good variant?

And for the drawing - the controller has a pin for the direction and one for the PWM signal. Direction is connected to Pin 28 (Mega) and PWM to pin 8. Can’t see how a drawing would help?

Anyway - great forum - thanks. The right answers and blowing fast!

Hi,

guegi: OK, understood, lack of electronic knowledge for sure.

And for the drawing - the controller has a pin for the direction and one for the PWM signal. Direction is connected to Pin 28 (Mega) and PWM to pin 8. Can't see how a drawing would help?

Anyway - great forum - thanks. The right answers and blowing fast!

A drawing of your circuit will tell us how you have connected EVERYTHING together, not just a couple of pins. How are you powering the motors? Have you got gnds connected correctly to controller? Post a picture too please? Thanks... Tom... :)

the Arduino has built in programmable resistors for the Input ports but not for the PWM's?

It's the AVR that has built-in pull up resistors, because pull ups on inputs are a common requirement, pull ups (or downs) on outputs less so.

And that in the PWM section of the Arduino there is no mention of this behaviour (unwanted motor actions in reset state) and how to protect against it?

Because it is a common behaviour, and not unique to PWM outputs. The behaviour of all pins at reset will be defined in the processor data sheet