So here's an update.... This has turned out be a bit of a nightmare. After much faffing I managed to set up an Arduino to arduino network to test the rs485 communication. Pretty much everything i needed to know was here:
That way i could set up the instuction packets as per the rx-64 manual. So far so good. Right so now powered up the servo, and send the data across, just to test comms by turning the LED on the servo on and off aaaannnndd........ Nothing, nada, rien.
Have checked the message is ok, wiring is same as the working ard-ard rs485 network. Have tried serial.print(0xFF, byte) and serial.print(0xFF, BIN) and neither work....
Someone out there must have done this before!
Here is my code to turn the light on and off, please tell me if you can see anything wrong..
//___________________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Xbee to dynamixel via rs485
//___________________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Define/preallocate parameters
int ledPin = 13; // LED connected to digital pin 13
int i = 0;
byte startAddress;
byte servoID= 0x01;
byte ledOn = 0x01;
byte ledOff = 0x00;
//_______________________________________//
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Run setup Function
void setup() {
Serial.begin(57600);
//int DEPin= 2; // The pin to be used for enable/disable signal
//digitalWrite(DEPin, HIGH); // tell max485 to transmit
pinMode(ledPin,OUTPUT);
}
//___________________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Run main Function
void loop() {
//Transmission section
delay(1);
if (i%2 ==0){
activateServos(servoID, ledOn);
delay(200);
}else{
activateServos(servoID, ledOff);
delay(200);
}
i++;
if (i>1000){
i=1;
}
}
//_____________________________________________________//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//Function Definitions
//___________________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void activateServos (byte servoID, byte newValue){
int checksum_ACK;
byte notchecksum;
startAddress = 0X19; // Turning on led
checksum_ACK = servoID + 0x03 + 0x03 + startAddress + newValue;
notchecksum = ~checksum_ACK;
digitalWrite(2,HIGH); // Notify max485 transciever to accept tx
delay(5); // Allow this to take effect
Serial.print(0xFF,BYTE); // 1.These 2 bytes are 'start message'
Serial.print(0xFF,BYTE); // 2.These 2 bytes are 'start message'
Serial.print(servoID,BYTE); // 3.Address 1 is target servo or 0xfe which is broadcast mode
Serial.print(0x03,BYTE); // 4.Length of string
Serial.print(0x03,BYTE); // 5.Ping read write or syncwrite 0x01,2,3,83
Serial.print(startAddress,BYTE); // 6.Start address for data to be written
Serial.print(newValue,BYTE); // 7.Turning on signal
Serial.print(notchecksum,BYTE); //8. the notchecksum
delay(3); // allow last byte to go through
}