Hello,
I have connected my 11.1V battery to Vin and GND of Maestro. I am also supplying the +5V out to the Vservo pin and the grounds are connected. Now the servo is on Channel 1 and it is working fine with the Windows GUI Maestro control centre. I also have the datasheet of the servo (Power HD 1900A) which says its Pulse width range is 800 usec - 2200 usec.
Now when i connect the Tx pin (here, pin 4) of the Arduino Uno to the Maestro’s Rx pin with the following code uploaded in the Arduino:
#include <NewSoftSerial.h>
#define txPin 4
#define rxPin 3
NewSoftSerial mySerial(rxPin, txPin);
void setup()// run once, when the sketch starts
{
mySerial.begin(9600);
delay(1000);
}
void set_target(unsigned char servo, unsigned int target)
{
mySerial.print(0xAA,BYTE); //start byte
mySerial.print(0x0C,BYTE); //device id
mySerial.print(0x04,BYTE); //command number
mySerial.print(servo,BYTE); //servo number
mySerial.print(target & 0x7F, BYTE);
mySerial.print((target >> 7) & 0x7F,BYTE);
}
void loop()
{
delay(1000);
set_target(1, 8000);
delay(1000);
set_target(1, 4000);
}
with the Maestro set at UART Fixed Baud Rate (9600) as well as in Auto Detect Mode. I can not get it to work. I also tried this code i found in other similar posts:
#include <NewSoftSerial.h>
#define RxPin 10 // digital pin connected to Maestro TX
#define TxPin 9 // digital pin connected to Maestro RX
NewSoftSerial MaestroSerial = NewSoftSerial(RxPin, TxPin);
#define MAESTRO_BAUDRATE 9600 // set to the baudrate used.
void setup(){
pinMode(RxPin, INPUT);
digitalWrite(TxPin, HIGH); // keeps pololu board from getting spurious signal. Serial is idle high.
pinMode(TxPin, OUTPUT);
MaestroSerial.begin(MAESTRO_BAUDRATE); // init the serial communication to the board
}
void loop() {
MaestroSerial.print(0x84, BYTE);
MaestroSerial.print(1, BYTE);
MaestroSerial.print(8000 & 0x7f, BYTE);
MaestroSerial.print((8000 >> 7) & 0x7f, BYTE);
delay(1000);
MaestroSerial.print(0x84, BYTE);
MaestroSerial.print(1, BYTE);
MaestroSerial.print(4000 & 0x7f, BYTE);
MaestroSerial.print((4000 >> 7) & 0x7f, BYTE);
delay(1000);
}
No change in Servo movement.
And the last code was uploaded from the Arduino IDE beta v1. So, it does not allows the use of BYTE command. Instead it forces us to use the Serial.write() method. So, here is the modified code:
void setup()
{
Serial.begin(9600); // set up Serial communication with Maestro Micro 6-channel Servo Controller
// Serial Port #3 on Arduino Mega 2560
}
void set_target(unsigned char servo, unsigned int target){
//Send a Pololu Protocol command
Serial.write(0xAA); //start byte
Serial.write(0x0C); //device id
Serial.write(0x04); //command number
Serial.write(servo); //servo number
Serial.write(target & 0x7F);
Serial.write((target >> 7) & 0x7F);
}
void loop()
{
set_target(1,4000);
delay(1000);
set_target(1,8000);
delay(1000);
}
The point is - I am not able to run any sample sketch to test the Serial connection of my Maestro with the Arduino.