Controlling a 21v3 driver with Arduino board

Hi, I’m trying to control the motor speed through a 21v3 board and an Arduino Uno development board.
However after many trials the results were disappointed.
In the code I wrote the first option to test was SoftwareSerial but I didn’t see any output from the pin declared as transmitter.
Secondly I’ve decided to use the Serial interface that comes with Arduino verifying the output with an oscilloscope and apparently now is writing something.
The code is as follows:

Serial.print(0xAA); //I didn’t use the usual println because it adds some extra bytes (LF and CR)
delay(100);
Serial.print(0xE1);
delay(100);
Serial.print(0x76);
delay(100);

At the same time, I was checking with the Pololu Jrk Configuration Utility if a possible error (0x80 or 0x800) raised but everything seemed normal.
I’ve also tried to delete the delay but didn’t change. The communication speed is set at 9,600 bauds.
I want to say that the motor works perfectly if the control is made through Pololu Utility plus USB connection.
Could you please give me an advice?
Yours sincerely

Hello.

Could you try removing the delays and replacing your Serial.print commands with Serial.write? Serial.print sends the data as readable ASCII text, whereas Serial.write will send a byte containing the raw value. If removing the delays and replacing Serial.print with Serial.write does not fix the problem, can you post your complete code and your jrk settings file?

-Brandon

Hi Brandon:

Before entering into details I’d like to thank you for your tips since now it seems to work fine.
I attach the code as you requested, because the motor performs what I’m asking for only if the USB cable is plugged. Otherwise it executes one of the rotations movements (just turn to the right) and the next one (turning to the left) is forbidden because the error led is powered on.

#include <SoftwareSerial.h>
const int Rx=10;
const int Tx=11;
byte Right[]={0xB3,0xE1,65};
byte Left[]={0xB3,0xE0,50};

SoftwareSerial mySerial(Rx,Tx);

void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  mySerial.begin(9600);
}

void loop() // run over and over
{
  mySerial.write(Right,sizeof(Right));
  delay(1000);
  mySerial.write(Left,sizeof(Left));
  delay(1000);
}

I repeat myself, is the USB cable is plugged; the system doesn’t have any problem and work effortlessly.
I’ve tried to use the code 0xB3 for cancelling any kind of error before writing a new command but without success.

Regards.

It sounds like a ground issue might be causing the problems when you are not connected to USB. Could you check that you have a good ground connection between your Arduino board and the jrk?

-Brandon

Hi Brandon, I’ve verified all grounds and power. I’ve thrown away a power supply (it seemed defective) and now the system is working smoothly.
Thank you again for your help.