How to interface UART servo? (LX-224HV)
Ask QuestionAsked yesterdayActive todayViewed 76 times1
I am trying to interface a RaspberryPi (2B) GPIO-UART to the this serial servo (Hiwonder LX-224HV), as a first step before to switch the Raspberry by an ARM MCU (STM32F407ZE on custom circuit).
The servo is supposed to follow a simple protocol, however, I am unable to manage any response from the servo (neither movement or UART response).
The documentation I found about the servo is limited (Note that this is another servo model, but according to vendor, their controller is compatible with both, consequently, I assume some compatibility):
For testing purpose, I am sending the following message through command line:
#Some ports initialization here echo "0" > /sys/class/gpio/gpio24/value # disable rx echo "1" > /sys/class/gpio/gpio23/value # enable dx echo -n -e "\x55\x55\xfe\x04\x0e\x01\xee" > /dev/ttyAMA0; sleep 0.001; echo "0" > /sys/class/gpio/gpio23/value # enable dx echo "1" > /sys/class/gpio/gpio24/value # disable rx
The message is made of:
- 0x55 0x55: transmission start tag.
- 0xFE: Id of the target servo, 254 means broadcast
- 0x04: Length of the block, including this length to ending checksum
- 0x0E: 14 is Read_ID, asking the servo for it ID.
- 0x01: default Id (not used?)
- 0xEE: Checksum ~(254+4+14+1) = ~(17) = 238
The circuit is set as follow:
simulate this circuit – Schematic created using CircuitLab
Note, I added a resistor to avoid burning any component in case of short-cut, It also allows to see variations in the signal if the servo tries to send any data.
The connection to the servo is done as follow:
- 0-5V to signal, high impedance most of the time.
- 12V to the VDD
- 0V to the GND
The breadboard look like this:
The result signal:
The resulting signal at the signal pin of the servo-motor is as follow:
There is no significant signal after this, which I interpret as the servo not responding for any reason.
Is there any obvious missing element in this approach? or ultimately, how to interface with this servo?
I found many others servos with similar interface, so I believe this could help further users..uartgpioservoshareedit follow flagedited yesterdayasked yesterdayAdrian Maire32822 silver badges1717 bronze badges
- 1Note: I also tried other types of messages (rotate), without more success – Adrian Maire yesterday
- AH, the datasheet looks detailed enough. Let me read it tomorrow and see if I can help. One weird thing is that the serial bus seems daisy chained, not the ordinary point to point, one bus for one device/servo type, (Of course not PWM controlled). Reference: (1) LC224-HC Servo: hiwonder.hk/products/…. See you tomorrow. Cheers. – tlfong01 yesterday
- 1I think the following document is more helpful: dropbox.com/sh/b3v81sb9nwir16q/AADXOwhdw7KLq5t5UM8ND3kwa/… Thank you – Adrian Maire yesterday
- Ah yes, your drop box doc of course is more helpful. Earlier I have difficulty opening your drop box. This time is smooth. See you tomorrow. – tlfong01 yesterday
- 1Multidrop serial on a bidirectional line is a quite normal thing; let’s please address the actual issue of the question not unfamiliarity with the concept. Some things to check would be that the baud rate is correctly set, that the device expects these voltage levels and this inversion sense (vs any of the RSxxx standards which would be opposite sense and possibly higher voltage), that the device address is correct, and that the transmit word is getting completely clocked out before the driver is disabled. Consider probing both sides of that series resistor… – Chris Stratton yesterday
- 1@Adrian Maire, Good morning. The docs in your drop boxed are very good and comprehensive. So I google and learned many more things I didn’t expect to know. Questions: (1) *Have you bought the LX-244 offline controller/tester? I am drafting a shopping list, including the offline controller. You might like to comment on my incomplete answer, or brainstorming me counter suggestions. Cheers. – tlfong01 22 hours ago
- (1) I did not bought the controller/tester board initially because I did not expected this to be so difficult, however considering the current situation, I did bough one yesterday which should arrive in some 1-2months. (2) Yes, the baud-rate is set to the expected frequency (excepting any error from my part). (3) the device address should be correct, as I am using broadcast. (4) The word is getting completely clocked out before the driver is disabled: Checked. (5) Voltages and levels: you see the wave from the oscilloscope, but I can’t ensure anything more. – Adrian Maire 15 hours ago
ActiveOldestVotes-2This post is hidden. It was flagged as spam or offensive content and deleted 6 mins ago by Community♦.Locked. This answer is not currently accepting new interactions. Learn more.
How come my LX-224HV doesn’t move?
/ to continue ,…
Let me introduce myself. I am an electronic hobbyist, already spent 100+ hours playing with toy servos.
All my hobbyist life I only played TowerPro MG995, SG90, and almost nothing else. I do once try to learn LX14 when an OP asked for help. I tried to help by learning together, but not too soon he mysteriously disappeared.
So this is my second chance to learn an UART Servo. All the servos I have been playing so far use PWM signals to control. But LX-224 servo seems using a special kind of UART protocol, so I am not sure if I can handle it, though I am very familiar with Rpi4B UART.
My long term plan is to use Rpi4B Thonny python and Cotrex M0. The OP likes to use Cortex M4, and open source C.
2. Warning UART servo newbies
For newbies like me, who only knows PWM servos, or doesn’t know any servo at all, this project is for advanced servo users only. Any newbie following this post building servo hardware or software are warned that No guarantee no nothing won’t melt down or blow up.
To those faint of heart, but brave enough newbies reading on, it is a good idea just sit back and watch how we buy, learn, play and fry servos.
I still remember vividly the first time I learnt to play the servo TowerPro MG995, way back in 2009, I was so excited that my hands started excitedly trembling when switching on, but then I unexpectedly saw my servo was also frantically trembling, but didn’t move. Long story short, I fried two new servos, …
Don’t ask me how many more servos I fried afterwards, but not too longer later I fried enough servos to have became a ninja and decided writing an advice the stupid newbies frying servos day after day. And unlike those genius geeks speaking Greek to newbies, Me IQ 97 can write newbie understandable language and so very soon my published SG90 Servo Newbie Guide climbed up to the Top of the Pops, and go translated into Spainish and many other languages,
My best selling SG90 PWM servo newbie guide was written in 2008. Now 2020, 12 years later, I hope to do it again, this time on the LX-224 UART servo.
3. Buying a UART servo
I live in HK, and ShenZhen, the World’s Factory, is just over the border, one hour away by train. So I can usually get EE toys day return, say in 6 hours. But now everything is miserably locking down, so I am locking down at home, writing friendly locking down rubbish to pass my gloomy locking down Sunday. Anyway I can still buy online from TaoBao, sort of AliExpress, but usually cheaper, except I must wait 24 long hours for express delivery by SF-Express (34 Yuen (US$ 8) min delivery charge for max 3Kg)
4. Which LX-224HV UART Servo to buy
Usually I will first window shopping LadyAda, SparkFun for the real thing, but most expensive high quality, and then browse Amazon, AliExpress, and finally TaoBao, for the cheapest fake versions for poor hobbyists like me.
So I browsed the TaoBao catalog, but found something I don’t understand.
(a) Only a year ago, I thought I should learn the new thing UART servo, and I remember the OP then was play LX-14, and I was jealous because I was only play cheap toy servos like MG995 and SG90, and my bad friends were LOL at me. But now I know LX-224 should stop them laughing me, and instead respect me more than I deserve. But them I still could not sleep well, because there a new model LX-824. Shall I buy future LOL proof, the most trendy LX-824.
So I think I should watch some videos before I leap, …
(b) The other thing I don’t understand is that I saw in the TaoBao catalog something like a PWM server tester (which can adjust by hand to PWM 0.5 ms to 1.5 ms signal. I was wondering the thing I don’t know is a similar tester, but output UART signals, instead of PWM?
Anyway, LX-224 YouTube watching first!
(c) I found the above YT disappointedly less then 2 minutes short, but does answer me the question about the test thing. It is called an “Offline Tester” and can control a couple of servos together, and also connected to PS3 controller. I watched one more video showing RGB LED showing status. This is good idea to show off to my jealous bad friends “my colours”
One more thing is that I learned from the YTs the LX-824 model looks ugly, compared to the LX-224 with a trendy bright metallic read casing. YT is indeed my friend. Also the HiWonder YTs are dated 2020jun, so it should take a long while before outdated, and my bad friends resumed LOL at me again.
Anyway, I think the 20 yuan offline tester is a must buy.
I googled further the LX-244’s manufacturer Lobot and found the Lobot servo catalog I found that there are more UART servos that I don’t know that I don’t know, including a 60 kg torque, also models smaller than LX-244.
So I have almost made up my mind what to buy. One more thing or good news I forgot to say, is that I read the Arduino code and found the function read position, implying that we can do feedback control. I am at the same time playing with stepping and BLDC motor which can also do speed and position reading, but the position reading is only by counting steps, or encoder A/B signals, which is not as reliable as UART LX-224, which is similar to PWM motor which you know the position by the PWM signal you sent.
5. LX-244 UART Servo Product Sheet and Pictures
- LX-224 Testing Plan
I looked at the OP’s test config and found it a bit low (hardware wise, not quality wise) level, perhaps to make it easy to switch to little ARM Cortex. Anyway, lazy will only test the UART AT command part, using the OP’s serial commands (the green bubble in Appendix A below).
7. LX-224 Tmall Order Status
I ordered and paid for LX-224 and the offline tester around Saturday 1:15pm, and the goods has already collected by SfExpress around 2:30 pm. I hope my toys would arrive tomorrow Sunday evening, to collect any time Monday. In the mean locking time, I would pass the time by reading boringly friendly datasheets and user manuals.
8. LX-224 BusLinker TTL/USB Debug/Test Board
R8.1 HiWonder LX-224HV 20KG Bus Servo (with Tutorial Video) – ¥20
R8.2 BusLinker Serial Bus Servo TTL/USB Debugging Board for LX-16A LX-15D LX-824 LX-224 LX-824HV LX-224HV LX-1501 Servo – AliEXpress US$4
Now I am looking at the feather sheet of the LX-244 BusLinker debug boad.
/ to continue, …
(1) How to interface LX-224HV UART Servo? – Adrian Maire, SE EE 2020aug29
(2) LX-224HV / 824HV Three Terminal Bus High Voltage Servo Catalog – TaoBao
(3) LX-224HV Tester ¥20 – TaoBao
(4) LX-224 Hiwonder HV/LX-824 HV Three Connectors High Voltage Bus Servo – YouTube, 2020jun19 83views
(5) LX-224 / LX824 2019 Hiwonder Lobot LX-824HV LX-224HV 11.1V BUS servo – US$17 ~ US$21
(6) LX15D Hiwonder Intelligent Serial Bus Servo with RGB Indicator for Displaying Robot Status – 2020jun19 138views
(7) LX-15D Bus Servo User Manual
(8.1) LX-15/224/824 Bus Servo Controller Doc
(8.2) LX-15/224/824 Arduino Docs
(8.3) LX-15/224/824 Windows PC Docs
(9) LoBot Rpi Robot Kit and Servo Catalog
(10) BusLinker Serial Bus Servo TTL/USB Debugging Board for LX-16A LX-15D LX-824 LX-224 LX-824HV LX-224HV LX-1501 Servo – AliEXpress US$4
(11) STM32F405xx STM32F407xx Arm Cortex-M4 32b MCU+FPU, 210DMIPS, up to 1MB Flash/192+4KB RAM, USB OTG HS/FS, Ethernet, 17 TIMs, 3 ADCs, 15 comm. interfaces & camera
(12) ST STM32F405xx STM32F407xx Arm Cortex-M4 32b MCU+FPU, 210DMIPS, up to 1MB Flash/192+4KB RAM, USB OTG HS/FS, Ethernet, 17 TIMs, 3 ADCs, 15 comm. interfaces & camera https://www.st.com/resource/en/datasheet/stm32f407ze.pdf
(12) NXP LPC1110/11/12/13/14/15 32-bit ARM Cortex-M0 microcontroller; up to 64 kB flash and 8 kB SRAM – 2014mar26
(13) Dynamixel AX12 and the Raspberry Pi
(14) TowerPro SG90 PWM Servo Arduino C++ Demo Program for Absolute Newbies – tlfong01 2008
Appendix A – The OP’s LX-224HV UART Servo Hardware and Software Testing Setup
- The OP’s test config seems a bit low level, perhaps as the OP pointed out making it easy to later implement/switch to ARM MCU (STM32F407ZE on custom circuit).
- I think it is easier for lazy me to test everything in Rpi on board or even USB UART level, using Rpi4B buster Thonny python 3.7.3. I can even forget python, just use Win10 RealTerm/puTTY, Rpi CuteCom to direct just say hello to LX-224, then later use python to make long chats.
Appendix B – LX-224 Tmall Order Status – last update 2020aug28hkt1649
Appendix C – Rpi 3V3 to 5V Logic Level Shifter for LX-244HV
/ to continue, …
This is not the end of answer, but only the beginning. Stay tuned.shareeditflagedited 41 mins agoanswered yesterdaytlfong0152044 silver badges66 bronze badges
- 2Is there an answer to the OP’s question buried somewhere in there? – brhans 22 hours ago
- Ah, this is just an introduction. My answers are usually over the SE word limit, ie 30k words, with at least 20 pictures. Ah, my apologies to the misleading note “End of Answer” of my incomplete answer. Sorry for the misleading comment. I will delete/modify that immediately. Cheers – tlfong01 22 hours ago
- 1Happy to hear that you are involved in trying this :-). I agree that my testing setup with command line is bad-quality. I plan to switch to C/C++ implementation as soon as I get an answer from the servo, because I don’t want to fight too many problems at the same time. I am also waiting for the board, but it will take 20-30 days to arrive here, so let me know if you discover something before me. Thanks for your great response. – Adrian Maire 15 hours ago
- Ah, I never thought that your CLI commands are bad quality. I think if you are fluent in linux bash and also script writing, using a few CLI commands to just say Hello is most efficient. But of course, when later you want to do more complicated things, then C/C++ is more human time efficient than script commands. Before playing with Rpi python, I used Arduino C++. I once used MS Studio C/C++/C# and found them very good, better that Rpi C/python. But at that time MS studio full version is not free. So I gave up and switched to Rpi. I am only a hobbyist programmer. So python suits me best. – tlfong01 13 hours ago
- 1I read my comments again and realized why you think me saying that your code is “low quality”. As explained above, I am saying that your using hardware, like HC126 etc, and reading the results using a scope is indeed in bits and bytes level. I am using python to talk in text strings “Hello”, “AT”, “OK” etc, so it is like the high level language C comparing to low level assembly language or even machine.Of course this misunderstanding is not important, but I am glad you pointed out the cause of misunderstanding. Cheers. – tlfong01 12 hours ago
- Another misunderstanding is this: You read that you will finally switch to Cortex with a part number. I did not pay attention to the part number and thought you mean Cortex M0, because I have been playing with Cotrex M0 (lpc1114, last time I used C, actually). So I thought your Cortex is also M0. But was very surprised to later found that Your Cortex is M4, and me only M0. That is a huge difference, like comparing a Porsche 911 with a BMX Bike! – tlfong01 12 hours ago
- Also I totally agree with you saying that “I found many others servos with similar interface, so I believe this could help further users“. So it would be a good idea to make sure that there are as little as possible ambiguities in our Q&A, so not to confuse and scary away UART servo newbies. – tlfong01 12 hours ago
- 2″I once used MS Studio C/C++/C# and found them very good, better that Rpi C/python. But at that time MS studio full version is not free”. You don’t need (and even don’t want) MSVC, you just need g++ and cmake. Any IDE works, I especially like QtCreator and KDevelop (all of them open-source, cross-platform and free). – Adrian Maire 8 hours ago
- 1-1 This is yet another example of your despicable habit of posting chatty non-answers! You really need to familiarize yourself with the rules – Chris Stratton 57 mins ago
- Thank you for your advice on EE SE Q&A rules. Perhaps I should delete ALL the comments, chats, and cartoons, AFTER I finish my answer. Cheers. – tlfong01 38 mins ago
- This is spam it only exists to promote a product or service – Voltage Spike♦ 6 mins ago
comments disabled on deleted / locked posts / reviews
Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.
Add Another Answer
Leave a Reply