Motors driver card impulse at the boot up

I have an aruino mega for piloting a motor driver card, using PWM to control the speed and one pin other pin for controlling the rotation way.

 

Each time the arduino boot up (by connecting the USB or the 9V) also when I established a serial connection, the motors impulse at full speed for really short time.

 

The pin out from the arduino are connected directly to the motor board ; Do I need some kine of filter like capacitor, resistor ?

Do I need shielded cables ?

see the picture of the motor card bellow, bought on Ebay

http://www.ebay.com/itm/151020554752?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649

 

see the video here

https://www.youtube.com/watch?v=dwMAibieS8w&feature=youtube_gdata_player

here is the diagramm of the circuit

 

close picture

 

The code (really simple)

 

const int dir1 = 2; // motor 1 direction - white
const int pwm1 = 3; // motor 1 PWM - green
const int dir2 = 4; // motor 2 direction - brown
const int pwm2 = 5; // motor 2 PWM - black
void setup()
{
Serial.begin(9600);
pinMode(dir1, OUTPUT);
pinMode(dir2, OUTPUT);
Serial.println("Speed (0-9) or + - to set direction");
}
void loop()
{
if ( Serial.available()) {
char ch = Serial.read();
if(isDigit(ch))
{
int speed = map(ch, '0', '9', 0, 250);
analogWrite(pwm1, speed);
analogWrite(pwm2, speed);
Serial.println(speed);
}
else if (ch == '+')
{
Serial.println("+");
digitalWrite(dir1,LOW);
digitalWrite(dir2,LOW);
}
else if (ch == '-')
{
Serial.println("-");
digitalWrite(dir1,HIGH);
digitalWrite(dir2,HIGH);
}
}
}

Yes, all ground together

Yes, you need to connect all your grounds together. Always.

It’s a good thing.

I did, thanks

I did, thanks

code modified and relay added

I had a relay to to cut the power of the motors during the boot

Capture__2_.png

and I coding that

  // ARCOS //
  //
// constant declaration
    int solenoidPin = 6;        // relay coil connected to pin 2
    unsigned long currenttime;  // current time
    unsigned long boottime;     // system boot up time
    const int dir1 = 2;         // motor 1 direction - white
    const int pwm1 = 3;         // motor 1 PWM - green
    const int dir2 = 4;         // motor 2 direction - brown
    const int pwm2 = 5;         // motor 2 PWM - black
// setting up the system
  void setup()
  {
    pinMode(solenoidPin, OUTPUT); // relay coil pin is an output
    currenttime = millis();       // what time is it ?
    boottime = currenttime;       // record the time as a boot time
    Serial.begin(9600);           // set serial connection
    pinMode(dir1, OUTPUT);        // motor 1 direction pin is an output
    pinMode(dir2, OUTPUT);        // motor 2 direction pin is an output
    Serial.println("Speed (0-9) or + - to set direction"); // print on screen the instructions
  }
// main loop
  void loop()
    {
    currenttime = millis();
    if(currenttime >= (boottime + 10000));  // if 10 secondes past since the boot ...
      {digitalWrite(solenoidPin, HIGH);}   // relay activates
    if ( Serial.available());
      {char ch = Serial.read();
        if(isDigit(ch))
          {int speed = map(ch, '0', '9', 0, 250);
          analogWrite(pwm1, speed);
          analogWrite(pwm2, speed);
          Serial.println(speed);}
        else if (ch == '+')
          {Serial.println("+");
          digitalWrite(dir1,LOW);
          digitalWrite(dir2,LOW);}
        else if (ch == '-')
          {Serial.println("-");
          digitalWrite(dir1,HIGH);
          digitalWrite(dir2,HIGH);}
      }
    }

but that doesnt work, the relay is immediately activation without any delay, and also latching after power down the arduino, until I disconnect one of the solenoid wires !!!!

 

help!

Do I am the only guy with this problem ?

Somebody experienced this problem with arduino ? yes, how to fix it ?

is it my arduino bad or the motor driver ?

 

I feel disarmed, disapointed, please help me, any ideas ?

its fix !

I finnally fix it by installing a pull-down resistors (thank odd-bot), I put a 2k2 resistors, see the following schematic