ArduinoGeneral

Smart servo shield problem

userHead Account cancelled 2016-09-03 10:39:18 1361 Views0 Replies
Hello,

I recently purchase your smart servo shield to use with 2 Dynamixel ax-18a servos.

I am on Arduino 1.6.11, Mac OS 10.11.6, product SKU: DRI0027.

I am trying to control them independently but not having any luck. I assume I need to change the ID of each servo, because what happens is that they move together. They are daisy chained together.

I have tried to use the 'SetID' function with one of them unplugged by putting 'myServo.SetID(1, 2)' in the setup, so that I can change the ID of one servo to 2, but no luck, they both stay on ID number 1 - I can tell because if I put myservo.write(1, v) then both servos move, but if I put myservo.write(2, v) neither of them move.

I started out with the example code from the ServoCds55 library, and then made my own custom code to control it via serial. I am able to control the servos via serial with this code, but I'm having no luck at all controlling them separately - they both move together. Any help would be appreciated.

Code below:
Code: Select all

#include <SPI.h>
#include <ServoCds55.h>
ServoCds55 myservo;

int servoNum = 1;

void setup () {
Serial.begin (115200);
myservo.begin ();
myservo.setVelocity(300);
// myservo.SetID(1, 2);
}

void loop () {
static int v = 0;
if ( Serial.available()) {
char ch = Serial.read();
switch (ch) {
case '0'...'9':
v = v * 10 + ch - '0';
break;
case 's':
myservo.write(1, v); //ID:1
v = 0;
break;
case 'w':
myservo.write(2, v); //ID:2
v = 0;
break;
}
}
}