Overview

Let’s try using Kondo Science’s KXR-A3S robot arm using three serial servos with GR-ROSE.

Preparation

  • Prepare a GR-ROSE board, USB cable (Micro B type), and completed KXR-A3.
  • Set the IDs of the three servos as 1, 2 and 3 from the bottom as shown in the figure.
  • Check that the servo of ID1 is connected to Serial1 of GR-ROSE.
Image
GR-ROSE Part Identifications

Starting the Kit

Let's move it. Before executing the program, perform the following steps.

Power is supplied to the serial servo and GR-ROSE is recognized as a USB memory.

  1. Connect USB to GR-ROSE
  2. Turn on the power switch
  3. Press the GR-ROSE reset button
Image
How to start GR-ROSE

Motor Operation Check (1-Axis)

Execute the following program. The motor with ID1 at the bottom operates.

As a servo motor specification, specify a value of 7500 at 0° of the origin. Specify 11500 for the maximum operating range of 135° and 3500 for the minimum operating range of -135°. Since these values are not versatile, the program provides a function called "krs_setposition" so that the motor can be operated by specifying radians. In addition, a function called “krs_getposition” that can obtain the motor position is prepared and radians are output to the serial monitor.

Image
The motor position is displayed in radians
The motor position is displayed in radians
#include <Arduino.h>
#include <ICS.h>

#define KRS_MIN 3500
#define KRS_MAX 11500
#define KRS_ORG 7500
#define KRS_FREE 0
#define SERVO_MIN -135
#define SERVO_MAX 135

IcsController ICS(Serial1);
IcsServo servo1;

void krs_setposition(IcsServo* servo, float radian){
  int angle = radian * 180 / PI;
  int pos = map(angle, SERVO_MIN, SERVO_MAX, KRS_MIN, KRS_MAX);
  if(pos > KRS_MIN && pos < KRS_MAX){
    servo->setPosition(pos);
    delay(1);
  }
}

float krs_getposition(IcsServo* servo){
  int pos = servo->getPosition();
  delay(1);
  int angle = map(pos, KRS_MIN, KRS_MAX, SERVO_MIN, SERVO_MAX);
  return angle * PI / 180; // angle to radian
}

void setup() {
  Serial.begin(9600);
  ICS.begin();
  servo1.attach(ICS, 0x01);
  
  krs_setposition(&servo1, 0);
}

void loop() {
  static bool id1, id2, id3;
  krs_setposition(&servo1, (PI/2));
  delay(1000);
  Serial.println(krs_getposition(&servo1));
  krs_setposition(&servo1, -(PI/2));
  delay(1000);
  Serial.println(krs_getposition(&servo1));
}

Motor Operation Check (3-Axis)

Now let's move the three servos. Execute the following program.

IcsServo class objects are generated as an array to simplify the program.

The motor is moving at random in the range of -45° to 45°.

#include <Arduino.h>
#include <ICS.h>

#define KRS_MIN 3500
#define KRS_MAX 11500
#define KRS_ORG 7500
#define KRS_FREE 0
#define SERVO_MIN -135
#define SERVO_MAX 135

IcsController ICS(Serial1);
IcsServo servo[3];

void krs_setposition(IcsServo* servo, float radian){
  int angle = radian * 180 / PI;
  int pos = map(angle, SERVO_MIN, SERVO_MAX, KRS_MIN, KRS_MAX);
  if(pos > KRS_MIN && pos < KRS_MAX){
    servo->setPosition(pos);
    delay(1);
  }
}

void setup() {
  Serial.begin(9600);
  ICS.begin();
  for(int i = 0; i < 3; i++){
    servo[i].attach(ICS, i+1); // id1 to id3
    servo[i].setStretch(30);
    delay(1);
    servo[i].setSpeed(30);
    delay(1);
    krs_setposition(&servo[i], 0);
    delay(1);
  }
}

void loop() {
  for(int i = 0; i < 3; i++){
    int angle = random(-45, 45);
    float radian = angle * PI / 180;
    krs_setposition(&servo[i], radian);
    delay(200);
  }
}

How to Connect with ICS Manager

CS Manager is PC software provided by Kondo Science.

You can set the serial servo ID value and initial settings.

By running the following program, GR-ROSE operates as a USB serial bridge and ICS Manager.

You can control the serial servo.

Image
ICS Manager
ICS Manager
// For using ICS manager
#include <Arduino.h>

void setup() {
  pinMode(PIN_LED1, OUTPUT);

  Serial.begin(115200); // to USB
  Serial1.begin(115200, SERIAL_8E1); // to Motor
  Serial1.direction(HALFDUPLEX);
}

void loop() {
  if(Serial.available())
  {
    char c = Serial.read();
    Serial1.write(c);
  }

  if(Serial1.available())
  {
    char c = Serial1.read();
    Serial.write(c);
  }
}