DUELMILANOVE Pololu Low-Voltage Dual Serial Motor Controller PROGRAMMING

i need help with getting my code for Pololu Low-Voltage Dual Serial Motor Controller to work. the link is http://www.pololu.com/catalog/product/120. my code is here. all i want it to do is move foward (as an example so i can learn how to use this thing)

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(0x02, BYTE);
Serial.print(0x00, BYTE);
Serial.print(64, BYTE);
}

void loop() {

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

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




}

Hi Spookyjack

I'm not an H-bridge motor controller expert but I read the User Guide on Pololu.

I seems like you need to talk to the device though Serial. Please note that the guide says that RS232 voltage might damage the unit.

Try to look at NewSoftSerial: http://arduiniana.org/libraries/newsoftserial/

-Fletcher

Edit: ... or program it yourself: http://www.arduino.cc/en/Tutorial/SoftwareSerial

Do you want to tell us how the controller is connected to the Arduino?

What happens when you run that code?

when i run that code literally nothing happens. no blinking leds on the controller, no motor movement, no nothing. i have the reset pin on pin 2 and the tx pin as pin 1. check out my picture on this topic here for my exact wiring http://forum.pololu.com/viewtopic.php?f=15&t=3558

(im a little noobish at this so if plz plz plz fix the code itself and not say wut i need to do plz plz plz plz plz)

PLZ PLZ PLZ ANYONE :(

omg bump :((((((

Hi there

What part of the reply from RyanTM on pololu did you net undestand?

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.

-Fletcher

Just to clarify - the Serial.print sends the information through the usb link to the computer. You need to set up a separate serial link to the device from your arduino. Options as above - SoftSerial, NewSoftSerial.

Ok this code is really glitchy but uses new soft serial, can u guys fix this code

// include the SoftwareSerial library so you can use its functions:
#include <NewSoftSerial.h>

#define txPin 2
#define rstPin 3

NewSoftSerial=txPin

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(txPin, OUTPUT);
  pinMode(rstPin, OUTPUT);
  // set the data rate for the SoftwareSerial port
  NewSoftSerial.begin(9600);
}

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



}

Ok this code is really glitchy but uses new soft serial, can u guys fix this code

I looked glitchy up in my jargon dictionary. Nope, that definition doesn't apply.

Try describing your problem using some terms that we have a chance of assigning absolute meaning to.

This code causes the motor to...

This code fails to...

You might start by writing correct code. I'll give you a hint. This:

NewSoftSerial=txPin

Is not how you use NewSoftSerial.

my problem is it gives me error on the #define rstPin 3 expected unqualified-id beofre numeric constant. it gives the same on the txpin line directly above it. on the newdoftserial=txPin line it states explected unqualified-id before = token. on the new soft serial.begin(9600); line it gives the same error as newsoftserial=txPin line but with a '.' token instead. on the serial.write lines they give "call of overloadedwrite(int) is ambigous.

Bump halp tho plz

NewSoftSerial is a class. You need to create an instance of that class.

NewSoftSerial nss(rxPin, txPIn);

Of course, rxPin and txPin need to be defined.

Then, you use that instance to do things:

nss.begin(9600);
nss.write(0x80);

The Serial.write(0x00); call is causing problems because there are multiple ways of interpreting that 0. It could be a uint8_t or a const char *. Add , BYTE to the call to remove the ambiguity.

Serial.write(0x00, BYTE);

Please post your code after you implemented the NewSoftSerial correct.

-Fletcher

ok here is my new code, it is currently giving a Newsoftserial does not name a type, error on the
NewSoftSerial nss(rxPin, txPin); line. here is my code

// include the SoftwareSerial library so you can use its functions:
#include <NewSoftSerial.h>

#define txPin 2
#define rstPin 3
#define rxPin 4

NewSoftSerial nss(rxPin, txPin);

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(txPin, OUTPUT);
  pinMode(rstPin, OUTPUT);
  // set the data rate for the SoftwareSerial port
nss.begin(9600);
nss.write(0x80);
}

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



}

This code compiles on my computer, and does what you intended your code to do. Whether that is what you actually want/need to do, or not, is a different issue.

#include <NewSoftSerial.h>

#define txPin 2
#define rstPin 3
#define rxPin 4

NewSoftSerial nss(rxPin, txPin);

void setup()
{
  // define pin modes for tx, rx, led pins:
  pinMode(txPin, OUTPUT); // Don't do this - NewSoftSerial owns this pin
  pinMode(rstPin, OUTPUT);
  // set the data rate for the SoftwareSerial port
  nss.begin(9600);
  nss.print(0x80, BYTE);
}

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

ok, i fixed the code myself here, and i compiled it fine, however the motor controller is not responding (the LED’s are not blinking to indicate signal received so here is my code that compiles but has no reponse

// include the SoftwareSerial library so you can use its functions:
#include <NewSoftSerial.h>

#define txPin 2
#define rstPin 3
#define rxPin 4

NewSoftSerial nss(rxPin, txPin);

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(txPin, OUTPUT);
  pinMode(rstPin, OUTPUT);
  // set the data rate for the SoftwareSerial port
nss.begin(9600);
}

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



}

Are you not still mixing up the serial ports? Shouldn't the commands in your loop should be sent to your board using nss.write not Serial.write?

The board is accessed via the nss object, and the Serial object is for communication with the PC so you can see what is going on.

Hi there

How about somthing like this?

// include the SoftwareSerial library so you can use its functions:
#include <NewSoftSerial.h>

#define txPin 2
#define rstPin 3
#define rxPin 4

NewSoftSerial nss(rxPin, txPin);

void setup()  {
  // define pin modes for tx, rx, led pins:
//  pinMode(txPin, OUTPUT);
  pinMode(rstPin, OUTPUT);
  // set the data rate for the SoftwareSerial port
  nss.begin(9600);
  digitalWrite(13, HIGH);
  delay(500);
}

void loop() {
  nss.write(0x80); // command
  nss.write(0x00, BYTE); // device number
  nss.write(0x05); // motor 2 forward
  nss.write(0x7F); // full speed
  delay(2000);
  
  nss.write(0x80); // command
  nss.write(0x00, BYTE); // device number
  nss.write(0x03); // motor 2 backward
  nss.write(0x7F); // full speed
  delay(2000);
}

Non compiled (I don’t have NewSoftSerial installed) and non tested.

-Fletcher

ok, i noticed the void loop portion repeated it self unnecessarily so what i did was remove one of the motor start ups, then i noticed that on the nss.write(0x80); // command it gave me a an expected condtructor destructor or type conversion before “.” token. also the comtroller (as far as i know needed a configuration byte packet simler to the motor move one below so i will be coding that into this program once we can get it to even recive these commands in the first place. becuase the main problem with all my code so far is that the controller isnt even reciving them properly, if at all. but here is my newer code

// include the SoftwareSerial library so you can use its functions:
#include <NewSoftSerial.h>

#define txPin 2
#define rstPin 3
#define rxPin 4

NewSoftSerial nss(rxPin, txPin);

void setup()  {
  // define pin modes for tx, rx, led pins:
//  pinMode(txPin, OUTPUT);
  pinMode(rstPin, OUTPUT);
  // set the data rate for the SoftwareSerial port
  nss.begin(9600);
  digitalWrite(13, HIGH);
  delay(500);
}
  nss.write(0x80); // command
  nss.write(0x00, BYTE); // device number
  nss.write(0x03); // motor 2 backward
  nss.write(0x7F); // full speed
  delay(2000);
}
void setup()   {
  
  
}