LSS - communication protocol for sequential actions

Is there any way to run sequential actions in the LSS Config software without entering each command individually? For example if I wanted to LSS servo to continuously move back and forth between -30 and 30 degrees:

#1D-300
#1D300
#1D-300
#1D300
#1D-300

If this is not possible through LSS Config software then what is the recommended approach?

@superglue Welcome to the RobotShop Community! The LSS Config is really only intended as the name implies - a configuration and general interface software.

A quick sketch in Arduino can have it loop between two angles and would only need a few lines of code. Same for most software to be honest (Python etc.)

What interface electronics are you using between the PC and the servo(s)?

1 Like

I have it connected to the Lynxmotion SES-V2 LSS Adapter Serial & Power Distribution Board.

Then you’re good. The LSS Adapter is effectively a serial to USB adapter. You can use pretty much any programming software you want to create a looped command. Are there any programming languages you’re comfortable with? The bulk of the program will be setting up the baud rate, COM port, and looped serial command. You might try Python. ChatGPT:

import serial
import time

# Open serial port with a baud rate of 115200
# Replace 'COM3' with your serial port name (e.g., 'COM3' on Windows or '/dev/ttyACM0' on Linux)
ser = serial.Serial('COM3', 115200)

while True:
    # Send a message
    ser.write(b'Hello from Python!\n')

    # Wait for a second
    time.sleep(1)

# Close the serial connection (this line will never be reached in this example)
ser.close()

In this script:

  • serial.Serial('COM3', 115200) opens the serial port with a baud rate of 115200. You should replace 'COM3' with the appropriate port name for your system.
  • ser.write(b'Hello from Python!\n') sends a byte string to the serial port. The \n is a newline character, similar to println in Arduino. You would place one of the #1D300 commands here, followed by a timed delay and a second one at -300.
  • time.sleep(1) pauses the loop for 1 second.
  • The loop will run indefinitely, sending a message every second.
  • ser.close() is there to close the serial port when you’re done with it. However, in this infinite loop, this line is never reached. You might want to handle this in a more elegant way in a production script.

To run this script, you need to have Python installed on your computer along with the pyserial package. You can install pyserial using pip:

bashCopy code

pip install pyserial

Make sure that the serial device you’re communicating with (like an Arduino) is programmed to handle the incoming data at the specified baud rate.

1 Like

Thank you. This helps a lot. My ability in Python is very basic, but I should be able to handle this.

This might also help:

1 Like