How to Configure and Use Smart Servos LewanSoul (LX-16A)
Intro: How to Configure and Use Smart Servos LewanSoul (LX-16A)
The LewanSoul produces where interesting and cheap smart servo (LX-16A) that can be used in different DIY projects.
For example:
https://www.instructables.com/id/How-to-Make-a-New...
It almost 3 times cheaper (~$15) to its close analog the XL430-W250-T (~$50).
And here you can compare it with other Dynamixel servo:
http://www.buildlog.net/blog/2017/09/lewansoul-lo....
The advantage of smart servos is that they very accurate and provides the feedback about their position, temperature and voltage. Also they has protection from overloading.
The disadvantage is that they uses sophisticated protocol that could be a problem for using them in DIY projects.
Lets try to decrease this a little disadvantage to get the big advantage :)
STEP 1: Wire the Servo to Controller
To control the LX-16A smart servos you need a special controller board
(you can buy it together with the servo on aliexpress).
The simplest one ($7) that shown on picture can control 8+ servos.
All you need is to connect it to smart servo, attach the power supply and then connect the controller to computer using USB cable.
Then you will able to send the special commands from computer to the controller board to control the servo and get feedback from it.
STEP 2: Software
To control the servo from computer you need a special software.
I suggest to use the Python for that purpose since it very easy to setup it can be used on different platforms (Windows/Linux/MacOS).
Install the Python 3:
https://realpython.com/installing-python/
Download the python scripts for controlling the servo:
https://github.com/RoboLabHub/LewanSoul
Extract it and run the command prompt (cmd.exe), then go to folder where you extracted the script:
cd "C:\Users\Test\Downloads\LewanSoul-master\LewanSoul-master\src"
Now you ready to open the world of smart servos for your DIY projects :)
STEP 3: Get the COM Port
Now you need to get the COM port where your controller attached to computer.
The easiest way to do it is to run the Arduino IDE and check it there.
Then adjust it in your local copy of python script (at line 6):
C:\Users\Test\Downloads\LewanSoul-master\LewanSoul-master\src\lx_setup.py
If you have trouble with finding the COM port number then please use these links for help:
STEP 4: Get the Servo Status
If you have only one servo attached to the controller board then you can run the following command:
python lx_setup.py
It will show the id of servo (8), its position (0) and temperature (29 °C).
If you already know the servo id then specify the command argument info with servo id (8):
python lx_setup.py info 8
(this command is useful when you have several servos attached to the same controller board).
To get the list of all command arguments run:
python lx_setup.py help
STEP 5: Move Your Servo
Now its time to move your servo.
The LX-16A servo has moving range from 0 to 240 degree that corresponds to position from 0 to 1000.
So, to move the servo you have to set it position by command :
python lx_setup.py set_pos 8 500
(to move the servo with id 8 to position 500 that corresponds to 120 degree).
And then check that servo really moved to its new position by running:
python lx_setup.py info 8
STEP 6: Other Commands
Here the list of some useful commands that may help you to setup the servo.
Scan all servos ids attached to the controlled board:
python lx_setup.py scan
Test servo range (move servo to 0, then to 1000 and then to 500):
python lx_setup.py test 8
Reassign servo id (from 8 to 3):
python lx_setup.py assign 8 3
Reset servo (reset servo internal state to default and set its id to 1):
python lx_setup.py reset 8
STEP 7: Some Videos and Spec
Some helpful video about LX-16A (found in google):
The LX-16A servo spec: https://github.com/RoboLabHub/LewanSoul/blob/mast...
STEP 8: Finally
And when you will be a little bit more familiar with that servo you may want to build something really interesting.
For example, quadruped robot:
The 6DOF robot arm:
https://github.com/RoboLabHub/RobotArm_v1.0
Or buy a ready kit (~$240), but it is only 5DOF robot arm :)
13 Comments
Ravaged Time 2 months ago
Hi,
I have been struggling to configure the LX-16A. I connected the servo to the debugging board and connected the board to my computer (no power supply). I was able to access the information about the servo (position, id, temperature), but there is a fourth line that says "led error: 7" I don't know if this is a direct cause, but the servo doesn't move at all even when I called the set_pos command with proper syntax. I tried connecting a 9V battery to the board with everything else still the same, but then the script just says "Error!," so I guess I can't connect the debugging board with the power supply and computer at the same time. Any idea why this is happening?
jasoncweidman 3 years ago
robolab19 3 years ago
I don't have examples for Arduino, but you can adapt the following C++ code (used in Raspberry PI robodog project):
https://github.com/RoboLabHub/RoboDog_v2/blob/master/sources/LX16a.cpp
jasoncweidman 3 years ago
robolab19 3 years ago
python3 lx_setup.py
There are a lot of error can be easily made, so the better way to take the existing code and modify it step by step until you get what you initially supposed :)
AlanE 1 year ago
I've run the python3 lx_setup.py command and it brings an error with trying to import lewansoul_lx16s line 11 from serial.serialutil import Timeout....... the error reads "ModuleNotFoundError: No module named 'serial.serialutil' .
Im pretty new to coding and Python, I don't know where to go to fix this error? Could you please point me in the right direction?
Many thanks!
jasoncweidman 3 years ago
How do you control the servo(s) with the control board instead of the debug board. If I try using the control board the COM port doesn't work so I'm assuming there is another way of communicating with the board. You also wouldn't happen to know how to detect when the servo has a larger load (Like in the dog project, when the leg hits the ground the servo knows to stop trying to move)?
Sorry for all the questions, I haven't used serial bus servos before and haven't been able to find much additional info. I really do appriciate the help though :D
robolab19 3 years ago
To understand that leg hit the ground you can use the difference between actual servo position and its recent goal. In case of load it will be larger than in idle move.
jasoncweidman 3 years ago
robolab19 3 years ago
The COM port will appear after connecting LX-16A servo and attaching the external power (6-8.4v) over Power Interface shown on photo. I didn't use Arduino for communication with servo (the Arduino was used just to help found the COM port number on Windows).
jasoncweidman 3 years ago
jasoncweidman 3 years ago
robolab19 3 years ago