Motor Controler broken?

Hey Community,

I have one question about the rational direction. I already started to think that my motor controller is broken. First I will tell you my set up: 4 motors , 2A Dual Motor Controller. My problem is that i cant change the rational direction in my programm code (HIGH, LOW). So its impossible to drive curves. I changed the poles in the motor controll and checked every cable. Do you know a solution of this problem?

Sry for my english:)

Sincerly

Wendt

FYI,
The correct term in English is ROTATIONAL direction, (not rational, although I’m not sure if your being rational since have posted no code. Telling us your code doesn’t work and not posting it is an exercise in
futility because you will get no help. It’s even more irrational to omit any link or detail about your motor
controller. A little history on your circuit would be nice too. (like is this your FIRST motor controller or your FIRST arduino circuit ?)

So its impossible to drive curves.

I think you mean “impossible to turn”

Sry:) This is my first Arduino and first motor controller. This is my controller:http://www.dfrobot.com/index.php?route=product/product&product_id=66&search=motor&description=true

And this my code: (I can change the rotational direction but nothing happens and the robot is driving straight forward.)

int E1 = 5; //E1 pin -> Digital pin 5 -- muss ein PWM-fähiger Anschluss sein
int M1 = 4; //M1 pin -> Digital pin 4
int E2 = 6; //E2 pin -> Digital pin 6 -- muss ein PWM-fähiger Anschluss sein
int M2 = 7; //M2 pin -> Digital pin 7

int linetrackL = 0;
int linetrackM = 0;
int linetrackR = 0;



int velocity = 70;

void setup(){
  pinMode(M1, OUTPUT);
  pinMode(M2, OUTPUT);
}

void loop (){
 linetrack();
  if (linetrackL == 1 && linetrackM == 1 && linetrackR == 0)
  { 
    corner(1, 380);                       
  }
  else if (linetrackL == 0 && linetrackM == 1 && linetrackR == 1)
  { 
    corner(0, 380);                        
  }
  else if (linetrackL == 0 && linetrackM == 0 && linetrackR == 0)
  { 
    corner(1, 25);                      
  }
  else if (linetrackL == 1 && linetrackM == 0 && linetrackR == 0){ 
    corner(1, 25);                      
  }
  else if (linetrackL == 0 && linetrackM == 0 && linetrackR == 1)
  { 
    corner(0, 380);                      
  }
  else if (linetrackL == 1 && linetrackM == 0 && linetrackR == 1)
  {
    forward ();                            
  }
}
//Funktionen
void forward(){
    int valueright = velocity*1.5;
    int valueleft =  velocity;
    digitalWrite(M1, LOW); //Drehrichtung
    digitalWrite(M2, HIGH); // Drehrichtung
    analogWrite(E1, valueleft); // PWM Speed Control
    analogWrite(E2, valueright); //mit analogWrite werden PWM-Signale angegeben  
}


void linetrack(){
   
  linetrackM = digitalRead(14);//Auslesen der Sensoren
  linetrackR = digitalRead(15);
  linetrackL = digitalRead(42);  
}


void stopp (int duration) {
    digitalWrite(M1, LOW); //Drehrichtung
    digitalWrite(M2, HIGH); // Drehrichtung
    analogWrite(E1, 0); // PWM Speed Control
    analogWrite(E2, 0); //mit analogWrite werden PWM-Signale angegeben 
    delay(duration);
}

void corner (int dir, int duration){          
    if(dir == 0)        //links
    {
     digitalWrite(M1, LOW);
     digitalWrite(M2, HIGH);
    }
    else if(dir == 1)    //rechts
    {
     digitalWrite(M1, HIGH);
     digitalWrite(M2, LOW);
    }
    analogWrite(E1, velocity);
    analogWrite(E2, velocity*1.5);
    delay(2.5*duration);

}

Ok. So where did you get the code ?

Dude, did you read the entire Wiki Doc ?

The sample code didn't have any German, so where did you get that code ?

I understand it is a line-following robot and the sample code is not line following code but did you do a system test with the sample code to verify the motors and controller were working before you dumped the line following code on your arduino ?

I can change the rotational direction but nothing happens and the robot is driving straight forward.

If the robot continues straight then I would say you CANNOT change the rotational direction. It sounds like you are getting WAY TOO FAR ahead of yourself. Forget about the line following. comment out ALL of the line following code or just load the sample code from the controller link page. You need to be able to do the following BEFORE you even think about line following: 1. both motors turning forward. (1 - 2 seconds) 2. both motors turning in reverse. (1 - 2 seconds) 3. left motor forward, right motor reverse (1 - 2 seconds) 4. right motor forward , left motor reverse. (1 - 2 seconds) 5. both motors stopped. (1 - 2 seconds) 6. repeat.

Post a sketch that does the above

Hi, Try something a bit simpler for a start! Like this to drive both motors forward, I'm not sure what E & M are in you code but if it's Motor-E and Motor-M, then.

digitalwrite(E,Hight) //one motor terminal=Pos digitalwrite(E,LOW) //one motor terminal=Neg motor runs, reversing this it moves in oposite DIR.

digitalwrite(M,Hight) //two motor terminal=Pos digitalwrite(M,LOW) //two motor terminal=Neg motor runs, reversing this it moves in oposite DIR.

to go forward the righthand wheel always turns opposite to the lefthand wheel, also reverse. IF both wheels turn say clockwise then it turns!

Is this a line following robot?? you don't say, I've not got around to one of them yet! But you can see some of my early bots at www.melsanders.co.uk under Electronics.

Hope it helps, Regards.

Mel.