How to Configure and Use Smart Servos LewanSoul (LX-16A)

10K1518

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:

https://www.swarthmore.edu/NatSci/echeeve1/Class/E...

https://www.digikey.com/en/maker/blogs/2018/how-to...

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

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?

Hello! You are pretty much the only person I have found using these servos (And the reason I know about them haha), I was wondering if you could share how to control them either through Arduino (You mention connecting an arduino but I don't quite see how it is used here) or a Raspberry PI as I am planning out a project that uses a Jetson Nano but I can use either C/C++ or Python. I cannot seem to find anywhere that has example code for communicating with these servos other than an Arduino library that does not work with smaller boards.
Hi, so for the python code I receive an error that 'str' object has no attribute 'write'. As far as I can tell when creating the object for the servo I pass the COM port as the serial however, when I attempt to test it by seeing if I can get_servo_id() I receive that write error (Line 107, self._serial.write(bytearray([ ). I also receive this error when trying to use the move_start() function so I am assuming I am missing something.
The file "test" is the lewansoul_lx16a_controller.py file
Try to use the lx_setup.py running under Python3:
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 :)
Hi - I have purchased the LX-16a servos and have one plugged into the servo board (with 7V) which is plugged into the RX & TX ports of the Pi4. (the servo works via the control board supplied).
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!
The lx_setup.py was initially only giving me error!! however now it is working, I didn't realize I needed to use the install command :) .
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
The LX-16a servos has similar principal of controls than other smart servos. So you can try to start first with well documented Dynamixel servos to get an idea of how to control it (it also has better software and UI :):
https://emanual.robotis.com/

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.
I will definitely check out the dynamixel servos to see how they are used, I am still lost on how I communicate with the servo control board. With the debug board you communicate through a COM port however with the control board it doesn't show up as a COM port, is this why you used an arduino or do I have a faulty board/missing something?
It seems you are using wrong board, the correct one that provides the COM communication (like FTDI) looks like:

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).
Ohhh okay, yeah that's where I've been confused. I thought the debug board was only for debugging (Hence the name) and the control board was for controlling. I still have no idea what the control board is for but, I suppose either way I saved money buying the bundle that came with it rather than buying everything individually 😅
I figured out what the control board is for (Kinda), from what an Amazon user was able to tell me the control board is a microcontroller for the servos that uses code stored on the servos to control them without being connected to the computer. So I'll be using the debug board to control my servos then haha. Thank you again for all the help!
Yes, If you are talking about the board I supposed then it is a some kind of Arduino board to controll simple projects like robot arms without computer.