Need a hand with the dual serial controller and arduino

I am running the exact same setup as the fella with the issue and I am having similar problems myself. When I first got my arduino talking to the motor controller and had ther motors up and running they would run for about 5 to 10 secs then cut off. I had the speed setting set at what ever the manual called for i think it was 100 out of the max 128. I first dialed that back to 25 and then even lower because my little bot is only following a wall and doesn’t need that speed. Now it will run but every once in a while the motor controller turns off while the arduino stays on. I reset the arduino and it runs fine until the motor controller dies again. It seems to be random. I’m new to electronics and breadboards and I hear breadboards aren’t good for high currents and what not, how can i tell how much current the motors are drawing. The reset pin on the motor controller is supposed to be kept high at all times right? My impression is that the arduino is keeping its “finger” on the power button of the motor controller and if the arduino loses power the motor controller loses power because its power button is no longer held down. I’m thinkin maybe I’ll just throw in an if statement that if the IR sensor value isn’t changing(b/c the motor controller died) I will cycle the power to my reset pin. But that really doesn’t get to the bottom of why the thing is dying to begin with.

#include <SoftwareSerial.h>

int motorRxPin = 10;//unused
int motorTxPin = 12;
int resetPin = 11;
 int MIN = 175;
 int MAX = 260;
 int distance;

SoftwareSerial motorSerial =  SoftwareSerial(motorRxPin, motorTxPin);

void setup() {
  pinMode(motorTxPin, OUTPUT);
  pinMode(motorRxPin, INPUT);
  pinMode(resetPin, OUTPUT);
  Serial.begin(9600);
  motorSerial.begin(9600);

  digitalWrite(resetPin, HIGH);//start motor controller up
  delay(100);//let motor controller wake up

 // buff[0]=0x80;//start byte
  //buff[1]=0x02;//config command type byte
  //buff[2]=4;//Motor number and mode byte, motors 4 and 5, two motor mode
  //for(int i=0;i<3;i++){
    //motorSerial.print(buff[i],BYTE);
  //}
  //delay(20);//give the controller a chance to remember what you told it

 // Serial.println("sent config");

  digitalWrite(resetPin, LOW);//reset motor controller
  delay(1);//reset delay (it doesn't have to be long at all)
  digitalWrite(resetPin, HIGH);
  Serial.println("reset controller"); 
  delay(200);//wakeup delay again
}

void loop() {
 
  // read the IR
  
  distance = IRread();
  Serial.print(distance, DEC);
  Serial.println("," );
  
 if (distance < MIN) // veer left
 {
   Serial.println("veer left");
   motortalk(5, 12); // speed up right 
   motortalk(7, 8); // slow down left   
 }

 else if (distance > MAX) // veer right
 {
   Serial.println("veer right");
   motortalk(5, 8); // slow down right
   motortalk(7, 12); // speed up left
   
 }

 else // go straight
 {
   Serial.println("go straight");
   motortalk(5, 10); // same speed
   motortalk(7, 10); 
 }

delay(1000); 
 
  
}



int IRread(){
  int sum;
  int val;
  int avg;
  int IRpin = 2;
  
  for (int i=0; i<3; i++){
    val = analogRead(IRpin);
    sum = sum + val;   
    delay(10);
  }
  
  avg = sum / 3.0;
  //Serial.println("irreadworks");
  return avg;
}

void motortalk (int motornum, int spd){ // takes motor number and direction following form (motor number * 2 + 0(fw) or +1 (bw)) and speed
  
  unsigned char buff[4];
  
  buff[0]=0x80;//start byte
  buff[1]=0x00;//Device type byte
  buff[2]= motornum;
  buff[3]= spd;
  
    for(int i=0;i<4;i++){
    motorSerial.print(buff[i],BYTE);
  }
}

-Dan

p.s. i didn’t want to use hex or bits for motor num and direction so i just used dec I’m not sure why it works cause i thought the motor controller was programmed only to accept hex or bit values

Hello.

As Jan posted earlier in this thread:

Your reset problem is most likely caused by motor noise; there are several steps you can take to address this:

  1. Solder .1 uF capacitors across each of your motor’s terminals as close to the motor’s case as you can.
  2. Keep your motor leads as short as possible.
  3. Twist each motor’s leads around each other in a tight helix.

As you noted, breadboards aren’t great for large currents and could be part of your problem. If you want to find out how much current your motors are drawing, you can use a lab power supply to power your setup, or you can use a multimeter. What are you using as your power supply?

The concept of a number exists independent of its representation. Notions of “decimal”, “hex”, and “binary” only come into play when we want to express that number’s value in a way that others can understand what we mean. For example, if I hand you ten apples, I don’t have to tell say anything about decimal or hex. You don’t care what the base of my number system is because you can just count the apples for yourself in whatever base system you prefer. If instead I want to tell you that I have “10” apples for sale, now you need to know how to interpret my “10”. If I’m writing in binary, I’m trying to tell you that I have two apples for sale. If I’m writing in hex, I’m trying to tell you that I have sixteen apples for sale. As long as you know what base number system I’m using, you can understand me. This is how it works for computer programs. Your computer program internally is dealing with numbers; the method you choose in your code as your representation tells the compiler how to interpret what you have typed, and then the value of that number is sent. For example, the following lines of code are identical:

int value = 10;
int value = 0x0A;
int value = 0b00001010;

Does this make sense?

- Ben

Please let me know if you get this one sorted out… I have not been abl to get mine to work…

Side note, if you are running an arduino decimilia, ladyadas motor shield is out now too… its much bigger though, and the voltage is too high for these little motors.

Ok, I jut took my breadboard out of the picture.
I soldered all my leads directly to the controller with solid copper wire.
I put caps on each lead of the motor.
I cut the motor leads no short as physically possible, and wound from each motor.

Still the same problems.

when using 3v for vmot(2 AA batteries) with any speed setting , I get no motion at all.
when using 6v for vmot(4 AA batteries) with speed set to 50% I get very noisy movement for about 10 seconds, then it just stops
when using 6v for vmot(4 AA batteries) with speed set to 10% I get very noisy movement… but it is way to slow

Besides I think these motors should be running at 3v right? 6v for any extended period will burn them out.

What is the voltage drop across this circuit? Can I get away with 4.5v(3AA batteries) without burning out the motors or the controller? I though the specs of these motors was 1.5 - 3.0v, so even if there is a drop.

Sorry if you already mentioned it earlier, but what kind of batteries are you using? We recommend using three NiMH cells, which gets you somewhere around 4 V when charged.

The motor controller MOSFETS have on-resistances in the few-hundred-mV range, so the voltage drop across them should be a fraction of a volt even at several amps.

When you say the movement is noisy, you mean audibly? How does it compare to when you connect your 3 V directly to the motors?

One other thing you could try is snapping the motors out of the gearbox to lower the load to see what happens then.

- Jan

The motors are audibly noisy. Very noisy.

I’ll try with the motors out of the gearbox.

I will also try with 3 AA batteries. I don’t have any rechargables. I may be able to scrounce up a single cell LiPo at 3.7v at the LHS though.

The gearboxes are somewhat noisy, and it’s hard to tell if what you’re hearing is normal or excessive. Let’s see what happens with the motor out and consider the gearbox if things work without it.

I really recommend getting some NiMH batteries and a charger. They are much better suited for powering motors (they can deliver bigger bursts of current as needed), and you’ll otherwise go through a lot of alkaline batteries. LiPo cells can be dangerous, and you can damage them if you discharge them too far (our motor controller definitely does NOT have any undervoltage shutdown that you would find on some controllers made for LiPo packs), so I would use those only if you know what you’re doing.

- Jan

I know this topic has been quiet for a while, but I figured I’d throw in my two cents.

(Actually, they’re Jan’s two cents–I’m just borrowing them.)

I found success with my Tamiya dual-gearbox motors by soldering 0.1uF capacitors between the two leads and soldering capacitors from each lead to the metal case of the motor (three caps per motor).