
PRO
Rio Makers
USA
Asked
We are using Lewansol servo skill in conjunction with Auto Position skill. We have connected the LX-16A servo on serial UART 1 connected to the EZ-B v4 controller on pins 5 and 6. When we go to "get and set all positions", it sends an incorrect number back for the current degrees that the servo has been set. When the servo is at 1 degree, 90 degrees or 180 degrees, it reports back a degree number that is very close. But when the servo is moved to any degree between 1 and 90 or 90 and 180, the number retrieved from the servo is incorrect by many degrees. Why are the degrees reported back incorrect?
Related Hardware EZ-B v4
I updated the robot skill to v28, which includes testing. But I need you to do me a favor for further testing because I do not have a servo to use...
Update to the latest robot skill version 28
Run this JavaScript again
In the robot skill. Click in the LOG text area and press CTRL-A to select all text.
Now press CTRL-C to copy all text to the clipboard
Paste the text into a message here please
DJ,
Here is the text from the robot skill,
This the text from the script,
The servo responded in 10 degree movements. But in Auto Position the "Get and Set All Positions" is always returning 180 degrees.
Thank you for providing the information that DJ had requested. This will help us verify the details of the received packet for the servo. We will be looking at it today and have an update shortly.
A new version (version 29) has been posted for you to use, which should correct the issue.
I will explain what is happening so you can see how it works.
If you were to review the datasheet, you would notice a send packet is 7 bytes to request a position, and the return packet is 7 bytes with the response. The UART's TX and RX are connected because the servos use a single wire for bi-directional communication. This means that any data transmitted on the TX from the EZB is received on the RX of the EZB. That is to be expected and is accounted for.
By reviewing each packet, you can see the first 7 bytes and the last 7 bytes. The product datasheet poorly documented the last 7 bytes containing the response. The datasheet defines response indexes 2 and 3 as holding the low and high bytes of the integer. This is incorrect, as most of the LewanSoul datasheet was translated from Chinese and is incorrect. The actual indexes containing the low and high bytes are 11 & 12.
Now, if you were by chance using a TTL/USB Debug Board (which you're not), you would only get 7 bytes in the response packet. The TTL/USB debug board prevents the transmitted packets from returning to the RX buffer. That is why there is a checkbox for it in the configuration screen.
Let's look at a complete packet...
The two bytes are 133 (low) and 1 (high). If we were to convert those to bytes into a 16-bit integer, we'd get 389
How did we get that?
Well, a 16-bit integer is 2 x 8 bytes.
So we have to combine the two bytes and create a single integer; this is done with a simple function such as...
The issue you were experiencing was that the incorrect index positions of the response array were being parsed and converted into the integer. This was due to LewanSoul having an incorrect datasheet.
DJ,
I tested version 29 and it returns the correct degrees except from 0 to 20 and 170 to 180. It appears to limit to 23 and 157. This is far better and more usable than before. Thank you for spending the time on this.
Start ARC: 0 Servo: 23 ARC: 10 Servo: 23 ARC: 20 Servo: 23 ARC: 30 Servo: 29 ARC: 40 Servo: 40 ARC: 50 Servo: 50 ARC: 60 Servo: 60 ARC: 70 Servo: 70 ARC: 80 Servo: 80 ARC: 90 Servo: 90 ARC: 100 Servo: 100 ARC: 110 Servo: 110 ARC: 120 Servo: 120 ARC: 130 Servo: 130 ARC: 140 Servo: 140 ARC: 150 Servo: 150 ARC: 160 Servo: 157 ARC: 170 Servo: 157 Done (00:00:22.0590857)
No need to thank me. Thank Synthiam support for doing the work to fix it. From reviewing the fix, it seems the servo must not be accurate in that range. There’s nothing which can be done to further improve the resolution at the lower end.
by reviewing the log you provided, it shows the servo as returning the same value for the first 20 positions.