Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Low-Voltage Dual Serial Motor Controller ARDUINO HELP


#22

Thanks for the advice Darth Maker. I did as you mentioned
Unfortunately results were the same. I could not get any voltage reading off M1+ and M1- nor from M0+ and M0-
I much appreciate the help.
Testing was done for MOT voltage input of 3.3 and 4.5v. Results were the same.
Melvin

Connections are as follows: Probing the SER with an LED shows it lit up. No LED on the Pololu board blinks during operation. Probe on input voltage is ok 3.3V. Proble on VCC is 5V.

Code as suggested is presented below. I hope I understood you correctly.
I tested it also for backwards.

#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1);
int rstPin = 2; // Reset Port connected to digital pin 2
void setup()  
{
  mySerial.begin(9600);
  mySerial.write((byte)0x80);  // sets 0x80 start of command
  mySerial.write((byte)0x02);          // configure
  mySerial.write((byte)0x02);          // 2 motors and motor number 2
  pinMode(rstPin, OUTPUT); // sets the digital reset pin as output
  digitalWrite(rstPin, HIGH); // sets the sets rst pin on full to continue
  delay(200);
  Serial.begin(57600);
  Serial.println("The program initialized and just started");
}
void loop() {
  delay(120);
  Serial.println("Foward Motor 2 - 3 seconds - then stop");
  mySerial.write((byte)0x80); // command
  mySerial.write((byte)0x00);   // device number
  mySerial.write((byte)0x05); // motor 2 forward
  mySerial.write((byte)0x7F);       // full speed
  delay(3000);
  mySerial.write((byte)0x80); // command
  mySerial.write((byte)0x00);   // device number
  mySerial.write((byte)0x05); // motor 2 forward
  mySerial.write((byte)0x00);       // full stop
  delay(1000); 
  Serial.println("Foward Motor 3 - 3 seconds - then stop");
  mySerial.write((byte)0x80); // command
  mySerial.write((byte)0x00);   // device number
  mySerial.write((byte)0x07); // motor 3 forward
  mySerial.write((byte)0x7F);       // full speed
  delay(3000);
  mySerial.write((byte)0x80); // command
  mySerial.write((byte)0x00);   // device number
  mySerial.write((byte)0x07); // motor 3 forward
  mySerial.write((byte)0x00);       // full stop
  delay(1000);
}

#23

You need to change the Software serial pins. Pins 0 and 1 are already used for hardware serial. Pins 3 and 4 would work. I believe there is a way to declare the input pin “null” for SoftSerial, but I do not recall how at the moment. That would save you a pin from being wasted.

Right now you have a conflict between software and hardware serial, which I would guess hardware serial is winning.


#24

Thanks again for a quick reply
I did as you mentioned, I changed the code and used 3 and 4. I assume RX, TX. Connected the Pololu SER PIN to the TX which is Arduino PIN 4. Ran the code.
Probe tests are good for RST, SER, VCC but the pair of M1+/- plus the pair of M0+/0- both have no voltage reading.
I learned a lot but it still not working.
Be patient please
Melvin
Changed the code to

#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 4);
int rstPin = 5; // Reset Port connected to digital pin 2

#25

It’s hard to tell from you picture, do you have ground connected from the Arduino to the driver? From your previous post mentioning that no LEDs on the board are on, it sounds like it might not be getting any power to the logic. If you run your test probes to Arduino ground, but don’t have that ground on the driver, it wouldn’t turn on, but you would measure the correct voltage.

I’ve run out of ideas otherwise.


#26

Lets summarize. I hope someone can add and help soon. I bought 6 of these to use with Arduino and Tamiya Plasma Dash Motors.

  1. I confirm that the grounding of the motor driver to the the Arduino is done. Ground Wire connected to both Motor Source and Arduino Ground.
  2. Connections are all Good.

Test with serial.write on the Arduino:
n.b. All code had RESET pin set to low followed by 200ms delay then to HIGH and 200ms delay.
a) Running changing of configuration for the drivers resulted with the proper LED blinks.
a.1 Connection to Motor and Motor Power Source are disconnected. Only GND, SER, VCC and RESET connected to Arduino.
b) Running motor move left, right forward and backward is unsuccessful.
b.1 NO Voltage output
b.2 LED in motor drivers don’t light up (they should when moving forward or backward - green or red)

Test with Serial Interface on the Arduino: (using 3,4 and other PIN pairs)
n.b. All code had RESET pin set to low followed by 200ms delay then to HIGH and 200ms delay.
a) Running changing of configuration for the drivers resulted NO REACTION.
a.1 Probed the TX Signal of the Serial Interface with an LED and voltage probe and it turned HIGH.
b) Running motor move left, right forward and backward is unsuccessful.
b.1 NO Voltage output
b.2 LED in motor drivers don’t light up (they should when moving forward or backward - green or red)

I am now officially stuck and don’t know how to proceed using this with Arduino.


#27

Ok, it sounds like you are measuring M0/1+/- with you meter, and expecting to read voltage from them without a motor power source. To read anything from M0/1+/1 you will need power connected to VMOT.

Just noticed something in your code. I had suggested removing the second digitalWrite(), but you removed the first. It should be like this:

pinMode(rstPin, OUTPUT); // sets the digital reset pin as output digitalWrite(rstPin, HIGH); // sets the sets rst pin on full to continue delay(200); mySerial.begin(9600); mySerial.write((byte)0x80); // sets 0x80 start of command mySerial.write((byte)0x02); // configure mySerial.write((byte)0x02); // 2 motors and motor number 2 Serial.begin(57600); Serial.println("The program initialized and just started"); I’m not sure what the default state of Arduino pins is, but that could be causing a problem.


#28

Thanks a lot.
First, No, I had the VMOT connected to a power source (a voltage adapter).
But yes, you found my BUG in the code.
I have it working already. All tests successful.
Tamiya Plasma Dash Motors + Arduino + Pololu Low Voltage Dual Motor Controller.

My mistake is that the RESET PIN should be set before the serial begin or opening the serial line.
For others, who will read this, make sure you DONOT MIX in the same program configuring the motor driver and actually running it. Configuring should be done in a separate program (configure only).

The final working code after running the configure routine is shown below.
Hope this helps others!

[code]

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
int rstPin = 12; // Reset Port connected to digital pin 2

void setup() {
pinMode(rstPin, OUTPUT); // sets the digital reset pin as output
digitalWrite(rstPin, LOW); // this is important at the start with the delay following it. The setting the HIGH.
delay(200); // setting to LOW clears out previous state of the Arduino and the HIGH will trigger the
digitalWrite(rstPin, HIGH); // motor controller to initialize.
delay(200);
mySerial.begin(9600);
/* mySerial.write((byte)0x80); // sets 0x80 start of command
mySerial.write((byte)0x02); // configure should be used separately from running the motors
mySerial.write((byte)0x02); // 2 motors and motor number 2
*/
}
void loop() {
delay(120);
mySerial.write((byte)0x80); // command
mySerial.write((byte)0x00); // device number
mySerial.write((byte)0x05); // motor 2 forward
mySerial.write((byte)0x7F); // full speed
mySerial.write((byte)0x80); // command
mySerial.write((byte)0x00); // device number
mySerial.write((byte)0x07); // motor 3 forward
mySerial.write((byte)0x7F); // full speed
delay(5000);
}[/code]


#29

Hi,
I want some help regarding this motor controller
I have been trying to get the low voltage motor controller to work for weeks. The LED does not blink at all. I went through the issues faced by other users in this forum but still no progress.

The connections are as follows:
VMOT -> DC power supply 3 V
GND -> Arduino ground and DC power supply gnu
VCC-> Arduino VCC - 3.3 V
Serial-> TX1 Serial 1 of the Arduino
Reset-> Digital Pin 22 Arduino
Pin 6-9 - No connection

After the connection and power up I checked the serial data with oscilloscope to check if it is transmitting correctly. The transmission does exactly comply with the one in user manual. I hooked up the scope to verify that the RESET line is always high. The VCC is 3.3 V and ther transmission is good but still no led blink.

Here is my code:
I added delay of 1us after each command. still no effect

[code]int rstPin = 22; // Reset Port connected to digital pin 2

void setup() {
Serial1.begin(9600); // opens serial port, sets data rate to 9600 bps
delay(300);
pinMode(rstPin, OUTPUT); // sets the digital reset pin as output
digitalWrite(rstPin, LOW);
delay(200);
digitalWrite(rstPin, HIGH); // sets the sets rst pin on full to continue
delay(200);
//Configure the MC
Serial1.write((byte)0x80); // start byte
delay(1);
Serial1.write((byte)0x02); // change config
delay(1);
Serial1.write((byte)0x02); // set motor 2 and 3
delay(1000);

}
void loop() {
Serial1.write((byte)0x80); // command
delay(1);
Serial1.write((byte)0x02); // device number
delay(1);
Serial1.write((byte)0x05); // motor 2 forward
delay(1);
Serial1.write((byte)0x5F); // speed
delay(1000);

}[/code]


#30

Hello.

Thank you for posting your code and details about your connections. You should not need the delay between sending the bytes that make up one command. I noticed that you are changing the configuration in setup(). As stated in the Low-Voltage Dual Serial Motor Controller user’s guide, after configuration, the motor controller must be reset before you can continue using it. Could you try removing the delays and toggling the reset line after your configuration commands?

Also, the second byte of the command in loop() , which you labeled “device number”, should correspond to the device type. This should be 0x00 for this motor controller.

-Brandon


#31

Thanks Brandon worked for me.
I have got the motors controller working for a while. When I initiate the program the motor runs forward for around 10 seconds and the motor stops running, also the leds turn off. I have to rerun the program to run the motors and same results repeat again.

I am using 2 motors with 3V operating voltage
Free run current draw: 150 mA
Stall current: 2100 mA

I have connected 3 V in VMOT in the motor controller.

I have attached 01.uF capacitor between the nodes in the motors.

I have read through the user guide could not find anything regarding it. The software is working fine. I have a print statement each time it sends instructions to the controller.

Any help would be much appreciated.


#32

It sounds like you might have a power issue. What are you using for a power supply? If you are using batteries, can you double check that they are charged or fresh? If this does not fix the issue, can you post your updated code?

-Brandon


#33

Hi,
I have got the motors controller working for a while. When I initiate the program the motor runs forward for around 10 seconds and the motor stops running, also the leds turn off. I have to rerun the program to run the motors and same results repeat again. I am using a lab DC supply. Charge is not the issue

I am using 2 motors with 3V operating voltage
Free run current draw: 150 mA
Stall current: 2100 mA

I have connected 3 V in VMOT in the motor controller.

I have attached 01.uF capacitor between the nodes in the motors.

I used an oscilloscope to check the reset line. There is a lot of noise for some reason. When the motor stopped the rst line goes down to 1.46 V (VCC 3.3V)
I have also attached 0.47 uF capacitor between the rst line and gnd to reduce. I had previously used 0.1 uF capacitor. Even increasing the capacitor to handle noise did not work.

I have read through the user guide could not find anything regarding it. The software is working fine. I have a print statement each time it sends instructions to the controller.

Any help would be much appreciated.


#34

Hi Brandon,
I am using a Lab DC power regulator so charge should not be a problem. Some further information.

The software is not a problem because the debug print statements are working just fine.

I hooked up oscilloscope to see if the rst line had some noise. I noticed that when the motor/controller stops the rst line goes down to 1.46 V (my VCC is 3.3 V). This is causing the motor controller to stop. To solve this I installed a 0.47 uF cap (first tried 0.1 uF).

Thanks


#35

Here is my code:

[code]int rstPin = 22; // Reset Port connected to digital pin 2
int spd =0;
int msg =0;

void setup() {
Serial.begin(9600);
Serial.println(“RESET”);
pinMode(rstPin, OUTPUT); // sets the digital reset pin as output
digitalWrite(rstPin, LOW);
delay(200);
digitalWrite(rstPin, HIGH); // sets the sets rst pin on full to continue
delay(200);
Serial1.begin(9600); // opens serial port, sets data rate to 9600 bps
delay(300);
Serial.println(“CONFIG”);
//Configure the MC
Serial.println(“0x80”);
Serial1.write((byte)0x80); // start byte
Serial.println(“0x02”);
Serial1.write((byte)0x02); // change config
Serial.println(“0x02”);
Serial1.write((byte)0x02); // set motor 2 and 3
delay(200);
digitalWrite(rstPin, LOW);
delay(200);
digitalWrite(rstPin, HIGH); // sets the sets rst pin on full to continue
delay(200);
}
void loop() {
motor_backward();
delay(5000);
motor_stop();
delay(5000);
motor_forward();
delay(5000);
motor_stop();
delay(5000);
motor_right();
delay(5000);
motor_stop();
delay(5000);
motor_left();
delay(5000);
motor_stop();
delay(5000);
}

void motor_right(){
move_motor(0x07, 0x00);
move_motor(0x05, 0x7F);
delay(1000);
}

void motor_left(){
move_motor(0x05, 0x00);
move_motor(0x07, 0x7F);
delay(1000);
}

void motor_backward(){
move_motor(0x04, 0x7F);
move_motor(0x06, 0x7F);
delay(1000);
}
void motor_forward(){
move_motor(0x05, 0x7F);
move_motor(0x07, 0x7F);

delay(1000);
}

void motor_stop(){
move_motor(0x05, 0x00);
move_motor(0x07, 0x00);
delay(1000);
}

void move_motor(int msg, int spd){
//Forward
Serial.println(“0x80”);
Serial1.write((byte)0x80); // command
Serial.println(“0x00”);
Serial1.write((byte)0x00); // device type
Serial.println(“0x00”);
Serial1.write((byte)msg); // all motor 2 forward
Serial.println(“0x7F”);
Serial1.write((byte)spd); // speed
}[/code]


#36

I noticed that you posted this problem in another forum as well. To make it easier for us to help you troubleshoot and for others to follow, we have moved that post to this thread. Thank you for posting your code; I have not looked through it thoroughly yet, but I did notice that your comment says that the reset line is connected to pin 2, but you declare it as pin 22. You might double check that the physical connection matches the code.

If adding a capacitor across the terminals did not make enough of a difference in your application, you might try adding two more capacitors, one from each terminal to the motor case, as mentioned in the “Dealing with Motor Noise” application note. This post by Jon demonstrates how much these extra two capacitors can impact the noise. If you are still having trouble after that, could you post some pictures of your setup, including all of your connections?

-Brandon


#37

Thanks Brandon,
Adding capacitor across the terminals, and adding capacitors from each terminal to the case helped reduce the noise. This was causing the problem.

The code is working fine. It is a type in the comments.

Thank you


#38

At the risk of a thread high-jack…

Is the capacitance the same for high-voltage applications? is it appropriate to use a 0.1μF capacitor with 24v motors?


#39

Hello.

Adding capacitors to the motor should help even for higher voltage applications. 0.1 μF capacitors should be fine. I recommend using a ceramic capacitor that is rated for at least twice the voltage the motor is running at; for your application, you should select one that is rated for at least 50V.

- Jeremy


#40

That’s helpful - thank you, JeremyT.


#41

Also, if you have a motor controller with over-current detection, and you’re not sizing the system for high-current motors, then the inrush current of the 100 nF capacitors may be enough to trip the overcurrent protection. I had this happen on a Zumo with micro metal gearmotors and a 100 nF ceramic capacitor.
You can calculate the inrush current based on the ESR of your capacitor, integrated over the detection time of your current sensor (which may not be easy to find documented.)