Pololu Low-Voltage Dual Serial Motor Controller ARDUINO HELP

I need some help on wiring up an arduino duemilanove to the Pololu Low-Voltage Dual Serial Motor Controller. the pdf directions wherent the most detailed so i have no clue how to wire it PLZ HELP !!!

also some sample code would be awsome so i know how to run it :slight_smile:

Hello.

Did you see pages three through five of the user’s guide? What detail is lacking? After you have everything wired correctly the code should be as simple as sending the correct bytes using the Arduino’s software serial.

- Ryan

well, the part labeled vcc and the logic voltage thing make no sense to me at all

oh sry about not being detailed enough in my last post. when the manuel states the logic supply is the voltage that your controller operates at, my arduino is powered of 9v and the motors will be powered off of 2 or 4 AA batteries, i used the 5 or the 3 Volt rail on my arduino. no luck

Thank you for your second more-thought-out post. Keep in mind that you have the ability to edit your posts as well.

The Arduino’s ATmega operates at a logic-voltage level of 5V, so in your case Vcc as labeled in the pictures in the User’s Guide should be 5V. Saying “no luck” is not that helpful, you need to say what test you did and what the result was. Also, please don’t try to run code until you are absolutely sure of the wiring. Connecting something to different pins hoping it will work is a very good way to break something. If you draw a picture of your wiring, or even just list what you have connected to each pin, we can actually verify your wiring.

- Ryan

Ah ok, i got wired up now. It would be really great also just to get a little tiny smaple code for arduino of this thing setting up and just moving foward or something on dual motor mode (im really bad at programming and serial commands are just impossible to me)

I will also put up a pic of my wiring tomorrow morning

Here is the picture, lets hope it uploads right xD

the red cable is to 5v

and the black cable is to ground

the green cable to furthest left is on TX (pin 1) pin

the green cable to right is on pin 2 as for reseting the board (not the arduino rst pin)


Hello.

I’m not familiar with the pinout of the Arduino protoshield you are using, but if your description is correct, the wiring in the picture looks good. You still haven’t explained what you meant by “no luck” earlier. For the code, I would recommend looking into the Arduino software serial examples. You can use this sample code to translate the PBASIC code in the User’s guide into the Arduino’s C++. For example:

SEROUT 5, 84,[$80,0,5,64] 

after some serial setup would translate to something like:

serial.print(0x80, BYTE);
serial.print(0, BYTE);
serial.print(5, BYTE);
serial.print(64, BYTE);

- Ryan

this is my code

int rstPin = 2; // Reset Port connected to digital pin 2

void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(rstPin, OUTPUT); // sets the digital reset pin as output

Serial.print(0x80, BYTE);
Serial.print(0, BYTE);
Serial.print(5, BYTE);
Serial.print(64, BYTE);
}

void loop() {

digitalWrite(rstPin, HIGH); // sets the sets rst pin on full to continue

Serial.write((byte)0x80);
Serial.write((byte)0x00);
Serial.write((byte)00000011); // in this line is where i get confused, with the longer byte
Serial.write((byte)0x7F);

}

The new setting byte and the motor number and direction are what confuse me. an example of those are what i need plz

Hello.

Why are you not using software serial? For most Arduino projects it is better to use the software serial because you are less likely to interfere with peripherals while programming the Arduino. I would suggest you move your TX line to another digital IO pin and use software serial. Also, those Serial.print statements I wrote should not be in the setup() they should be in the loop(). Where did you come up the third byte you send in your loop() that you don’t understand? If you just delete what serial commands you have in the loop() and put what you have in the setup there, it might work. You still haven’t said what result you are seeing that convinces you things are not working either. Next time you post code, can you use the Code button to make the code look nice?

- Ryan

by no luck i meant no lights where blinking on the board, and im a lttle confused about your last post, canyou fix my code and put up what you mean if thats what iwill work (im totally lost right now)

Hello.

Here is some example code that I expect to drive motor 2 at full speed in the forward direction:

int rstPin = 2; // Reset Port connected to digital pin 2
void setup() {
  Serial.begin(9600);	// opens serial port, sets data rate to 9600 bps
  pinMode(rstPin, OUTPUT); // sets the digital reset pin as output
  digitalWrite(rstPin, HIGH); // sets the sets rst pin on full to continue
}

void loop() {
  Serial.write(0x80); // command
  Serial.write(0x00); // device number
  Serial.write(0x05); // motor 2 forward
  Serial.write(0x7F); // full speed
  delay(100);
}

The line that you were saying was confusing was the line that you were writing in binary. C and C++ do not let you write numbers directly in binary. If you convert your binary number you made into a hex number, you can write it literally in C and C++. For example, 00000011 in binary becomes 0x03 in hex.

- Ryan

Hello,

I just wanted to mention that you can actually write 0b00000011 (or just 0b11) to get binary directly in C, at least in some compiler versions. It comes in handy sometimes!

But if you write 00000011, C will interpret that as octal (base 8), which is the same as (decimal) 9.

-Paul

The sample code you put up has a ton of errors. plz plz plz fix those so i can get this working

Hello.

Do you at least understand what Ryan’s code is trying to do? If you can’t fix the errors in the incredibly simple example Ryan posted, how can you ever hope to get something more advanced working? What happens when the custom code you write has an error? I think it would be a great learning experience for you to try to understand what is causing the errors (have you read the compiler messages and looked at the command reference for the Arduino functions being called?) and to fix them on your own.

Please feel free to ask if you need help understanding something or get stuck trying to figure out what’s going on. However, don’t expect us to write your entire program for you, and note that you’ll get a more positive response if you demonstrate that you’re trying to put some effort into this, too.

- Ben

i did put a crap load of effort into trying to get this thing to work but im really noobish when it comes to arrduino as im just a beginner. i looked at the errors and i dont have a clue wut i means even after going throgh a TON of forum topics on arduino.cc and i really just need an example of the robot moving foward becuase i want to make a robot that backup and turn when it gets within 6 in of a ping sensor on the front. i already have the if-then ping senser code (the then being a light turning on) and i want to put that light turning of with backup and turn. i just want an example of the robot moving fowards. if you even have a motor controller that will work for the tamiya gearbox that is simpler that would be ven more helpful than the code

Hi,

I put my code into the Arduino Environment and clicked the Verify button and it said:

sketch_feb07a.cpp: In function 'void loop()':
sketch_feb07a:9: error: call of overloaded 'write(int)' is ambiguous
R:\Documents\arduino-0022\hardware\arduino\cores\arduino/HardwareSerial.h:57: note: candidates are: virtual void HardwareSerial::write(uint8_t)
R:\Documents\arduino-0022\hardware\arduino\cores\arduino/Print.h:41: note:                 virtual void Print::write(const char*)

I looked at that line and saw that I forgot to cast the integers to bytes before passing them to the write function. Here is the updated code:

int rstPin = 2; // Reset Port connected to digital pin 2
void setup() {
  Serial.begin(9600);   // opens serial port, sets data rate to 9600 bps
  pinMode(rstPin, OUTPUT); // sets the digital reset pin as output
  digitalWrite(rstPin, HIGH); // sets the sets rst pin on full to continue
}

void loop() {
  Serial.write((byte)0x80); // command
  Serial.write((byte)0x00); // device number
  Serial.write((byte)0x05); // motor 2 forward
  Serial.write((byte)0x7F); // full speed
  delay(100);
}

If you run in to more problems, can you please actually describe the error you are getting? In your last posts you never even copied and pasted the compiler error into the forum.

- Ryan

Can you continue this thread please?

I used the code below. Compile was good. Upload was good. Using Arduino 1.0.
I followed the wiring diagram in the post.
Pin5 Reset connected to Arudino Pin 2
Pin4 Serial Control connected to Arduino Pin1

The setup configure seems redundant. I just want to be sure.
I get the Motor Controller to do 3 green led blinks with 5 second intervals.
NO MOTORS connected. Just testing voltage output before doing actual connections.

My Problem: I am applying a voltage probe to Pin6 Motor1 Positive and Pin7 Motor 1 Negative and I donot get any voltage reading. Tested the probe with the battery source (a 3.7 Lithium Polymer) and it was ok.

Do you have any ideas?
Thanks

int rstPin = 2; // Reset Port connected to digital pin 2

void setup() {
  Serial.begin(9600);   // opens serial port, sets data rate to 9600 bps
  pinMode(rstPin, OUTPUT); // sets the digital reset pin as output
  digitalWrite(rstPin, HIGH); // sets the sets rst pin on full to continue
  Serial.write((byte)0x80); // command
  Serial.write((byte)0x02); // Configure
  Serial.write((byte)0x02); // 2 motors and motor number 2
  delay(100);
  digitalWrite(rstPin, HIGH); // sets the sets rst pin on full to continue
}
void loop() {
  Serial.write((byte)0x80); // command
  Serial.write((byte)0x00); // device number
  Serial.write((byte)0x05); // motor 2 forward
  Serial.write((byte)0x7F); // full speed
  delay(100);
  
  Serial.write((byte)0x80); // command
  Serial.write((byte)0x00); // device number
  Serial.write((byte)0x07); // motor 3 forward
  Serial.write((byte)0x7F); // full speed
  delay(100);
  
  delay(5000);
}