Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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:

  1. Number sign #

  2. Servo ID number as an integer

  3. Action command (two to three letters, no spaces, capital or lower case)

  4. Configuration value in the correct units with no decimal

  5. End with a control / carriage return '<cr>'

Ex: #5PD1443<cr>

Additional Parts:

Hookup with Power-hub

...

Example Code for Arduino

While the Arduino library is not necessarily needed to control the smart servos, some of these examples make use of it.

...

Code Block
languagecpp
#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);
}

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 the buttonsyour code.

Code Block
languagec#
#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);
int ServoPosition = 0;
bool counting = true;
int resetTime = 0;
int lastMovement;

void setup() {
  servoSerial.begin(LSS_BAUD);
  // Initialize the LSS bus
  LSS::initBus(servoSerial, LSS_BAUD);
  Serial.begin(LSS_BAUD);
  myLSS.move(0);
  // allow time to move to 0 position
  delay(3000);
  myLSS.setMaxSpeed(600, LSS_SetConfig);
  //buttons 
  pinMode(11, INPUT);
  pinMode(10, INPUT);
}

void loop() {
 delay(1000);
  if (counting) {
    int seconds = (millis() - resetTime)/1000; // see below for an explanation of resetTime 
    ServoPosition = seconds * 60;  // if we divide 360 by 60 we get 6.0 degrees
    myLSS.move(ServoPosition); // move servo to position
    Serial.println(seconds);
    lastMovement = millis();
  } else {
    resetTime = millis() - lastMovement; // this helps us return to the last position of the clock movement
  }
  // buttons 
  if (digitalRead(10) == HIGH) {
      // stop or start
     counting = !counting;
     Serial.println("Start/Stop");
     // this could be improved on with a debounce!
  }
   if (digitalRead(11) == HIGH) {
    // reset
      Serial.println("reset");
      myLSS.move(0);
      delay(2000);
      resetTime = millis();  // we use this to restart our counter from 0 
  }
}

Here is a better solution, that is non-blocking and implements debouncing with a debounce library.

Code Block
#include <LSS.h>
#include <SoftwareSerial.h>
#include <ButtonDebounce.h>

#define pinStopStart 10
#define pinReset 11

SoftwareSerial servoSerial(8, 9);
ButtonDebounce buttonStartStop(pinStopStart, 250);
ButtonDebounce buttonReset(pinReset, 250);

// 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);
//
bool timing = true;
long timer = 0;
long lastTimer = 0;
int lastTimerSecond;

void setup() {
  servoSerial.begin(LSS_BAUD);
  // Initialize the LSS bus
  LSS::initBus(servoSerial, LSS_BAUD);
  Serial.begin(LSS_BAUD);
  myLSS.move(0);
  // allow time to move to 0 position
  delay(3000);
  myLSS.setMaxSpeed(600, LSS_SetConfig);
  //buttons
  buttonStartStop.setCallback(startStop);
  buttonReset.setCallback(resetTimer);
}

void loop() {
  buttonStartStop.update();
  buttonReset.update();
  if (timing) {
    updateTimer();
    if (getTimerSeconds() > lastTimerSecond) {
      int ServoPosition = getTimerSeconds() * 60;  // if we divide 360 by 60 we get 6.0 degrees
      myLSS.move(ServoPosition); // move servo to position
      Serial.println(getTimerSeconds());
      lastTimerSecond = getTimerSeconds();
    }
  }
}

void startStop(int state) {
  // start or stop the timer 
  if (state == HIGH) {
    // stop or start
    Serial.println("Start / Stop");
    timing = !timing;
    lastTimer = millis(); // record that time when we last started or stoped the timer 
  }
}

void resetTimer(int state) {
  if (digitalRead(11) == HIGH) {
    Serial.println("reset");
    myLSS.move(0);
    timer = 0;  // reset Timer
    lastTimerSecond = getTimerSeconds();
  }
}

int getTimerSeconds() {
  return floor((timer) / 1000);
}

void updateTimer() {
  timer += millis() - lastTimer;
  lastTimer = millis();
}

Wifi and Lynx Smart Motion

Here is an example for connecting processing to Arduino wifi rev 2 wirelessly with shiftr.io.

View file
nameWiFiLynxMotion.zip