...
The Lynxmotion Smart Servos (LSS) are compact, modular and configurable actuators designed to be an evolution of the standard RC servo for use in multi-degree-of-freedom robotics. The servo lineup currently includes three “smart servos” which appear physically the same, sharing the same dimensions, mounting points and output spline, but differing in maximum torque and speed.
...
The lynx motion has a simple serial protocol for controlling the motor, that is human-readable:
Number sign #
Servo ID number as an integer
Action command (two to three letters, no spaces, capital or lower case)
Configuration value in the correct units with no decimal
End with a control / carriage return '<cr>'
Ex: #5PD1443<cr>
Additional Parts:
...
While the Arduino library is not necessarily needed to control the smart servos, some of these examples make use of it.
This example is for changing the ID cycles through the LED colours of the servo motorsmart servos.
Code Block | ||
---|---|---|
| ||
#include <LSS.h> #include <SoftwareSerial.h> SoftwareSerial servoSerial(8, 9); // IDgive setthe toid defaultmatching LSSyour IDdevice = 0 #define LSS_ID_old (254) // ID 254 to broadcast to every motor on bus #define LSS_ID (0) #define LSS_BAUD (LSS_DefaultBaud) // Create one LSS object LSS myLSS = LSS(LSS_ID); void setup// Create one LSS object LSS myLSS = LSS(LSS_ID); void setup() { servoSerial.begin(LSS_DefaultBaud); LSS::initBus(servoSerial, LSS_DefaultBaud); } void loop() { // Loop through //each setof the data8 rateLED for the SoftwareSerial port servoSerial.begin(LSS_BAUD); // this is used to clear the serial buffer servoSerial.print("#0D1500\r"); delay(1000); LSS::initBus(servoSerial, LSS_BAUD); // Uncomment next two line for factory reset //servoSerial.print(String("#") + LSS_ID_old + String("DEFAULT")+"\r"); //servoSerial.print(String("#") + LSS_ID_old + String("CONFIRM")+"\r"); //change ID servoSerial.print(String("#") + LSS_ID_old + String("CID") + LSS_ID + "\r"); delay(2000); } void loop() { } |
This example cycles through the LED colours of the smart servos.
Code Block | ||
---|---|---|
| ||
#include <LSS.h>
#include <SoftwareSerial.h>
SoftwareSerial servoSerial(8, 9);
// give the id matching your device
#define LSS_ID (0)
// Create one LSS object
LSS myLSS = LSS(LSS_ID);
void setup()
{
servoSerial.begin(LSS_DefaultBaud);
LSS::initBus(servoSerial, LSS_DefaultBaud);
}
void loop()
{
// Loop through each of the 8 LED color (black = 0, red = 1, ..., white = 7)
for (uint8_t i = LSS_LED_Black; i <= LSS_LED_White; i++){
// Set the color (session only) of the LSS
//> https://www.robotshop.com/info/wiki/lynxmotion/view/lynxmotion-smart-servo/lss-communication-protocol/#H14.LEDColor28LED29
// Options are:
// LSS_LED_Black = 0
// LSS_LED_Red = 1
// LSS_LED_Green = 2
// LSS_LED_Blue = 3
// LSS_LED_Yellow = 4
// LSS_LED_Cyan = 5
// LSS_LED_Magenta = 6
// LSS_LED_White = 7
myLSS.setColorLED((LSS_LED_Color) i);
delay(1000);
}
} |
This example goes through the basic setup and movement
Code Block | ||
---|---|---|
| ||
#include <LSS.h> #include <SoftwareSerial.h> SoftwareSerial servoSerial(8, 9); // ID set to default LSS ID = 0 #define LSS_ID (0) #define LSS_BAUD (LSS_DefaultBaud) // Create one LSS object LSS myLSS = LSS(LSS_ID); void setup() { servoSerial.begin(LSS_BAUD); // Initialize the LSS bus LSS::initBus(servoSerial, LSS_BAUD); Serial.begin(LSS_BAUD); } void loop() { // Move the LSS continuously in one direction myLSS.wheelRPM(10); delay(5000); // Move the LSS continuously in the oposite direction myLSS.wheelRPM(-10); delay(5000); // faster! myLSS.wheelRPM(-60); delay(3000); // go Limp! myLSS.limp(); delay(5000); // move relative from current position in 1/10° (i.e 100 = 10 degrees) myLSS.moveRelative(100); delay(5000); // Move to specific position in 1/10° (i.e 100 = 10 degrees) myLSS.move(400); delay(7000); }color (black = 0, red = 1, ..., white = 7) for (uint8_t i = LSS_LED_Black; i <= LSS_LED_White; i++){ // Set the color (session only) of the LSS //> https://www.robotshop.com/info/wiki/lynxmotion/view/lynxmotion-smart-servo/lss-communication-protocol/#H14.LEDColor28LED29 // Options are: // LSS_LED_Black = 0 // LSS_LED_Red = 1 // LSS_LED_Green = 2 // LSS_LED_Blue = 3 // LSS_LED_Yellow = 4 // LSS_LED_Cyan = 5 // LSS_LED_Magenta = 6 // LSS_LED_White = 7 myLSS.setColorLED((LSS_LED_Color) i); delay(1000); } } |
This example goes through the basic setup and movement
Code Block | ||
---|---|---|
| ||
#include <LSS.h>
#include <SoftwareSerial.h>
SoftwareSerial servoSerial(8, 9);
#define LSS_ID (254) // ID 254 to broadcast to every motor on bus
#define LSS_BAUD (LSS_DefaultBaud)
// Create one LSS object
LSS myLSS = LSS(LSS_ID);
void setup() {
servoSerial.begin(LSS_BAUD);
// Initialize the LSS bus
LSS::initBus(servoSerial, LSS_BAUD);
Serial.begin(LSS_BAUD);
}
void loop() {
// Move the LSS continuously in one direction
myLSS.wheelRPM(10);
delay(5000);
// Move the LSS continuously in the oposite direction
myLSS.wheelRPM(-10);
delay(5000);
// faster!
myLSS.wheelRPM(-60);
delay(3000);
// go Limp!
myLSS.limp();
delay(5000);
// move relative from current position in 1/10° (i.e 100 = 10 degrees)
myLSS.moveRelative(100);
delay(5000);
// Move to specific position in 1/10° (i.e 100 = 10 degrees)
myLSS.move(400);
delay(7000);
} |
Multiple Servos
For controlling multiple servos, you will first need to give each motor a unique ID.
Code Block | ||
---|---|---|
| ||
#include <LSS.h>
#include <SoftwareSerial.h>
SoftwareSerial servoSerial(8, 9);
// ID set to default LSS ID = 0
#define LSS_ID_old (254) // ID 254 to broadcast to every motor on bus
#define LSS_ID (0) // the new ID
#define LSS_BAUD (LSS_DefaultBaud)
// Create one LSS object
LSS myLSS = LSS(LSS_ID);
void setup()
{
// set the data rate for the SoftwareSerial port
servoSerial.begin(LSS_BAUD);
// this is used to clear the serial buffer
servoSerial.print("#0D1500\r");
delay(1000);
LSS::initBus(servoSerial, LSS_BAUD);
// Uncomment next two line for factory reset
//servoSerial.print(String("#") + LSS_ID_old + String("DEFAULT")+"\r");
//servoSerial.print(String("#") + LSS_ID_old + String("CONFIRM")+"\r");
//change ID
servoSerial.print(String("#") + LSS_ID_old + String("CID") + LSS_ID + "\r");
delay(2000);
}
void loop() {
}
|
Exercise:
Build a stopwatch with the smart servo and two buttons.
...
Possible Solution: This one solution, but it could use some improvement: It needs a denounce and a pause without delay function to avoid blocking your code.
...