tlfong013983Sep 10, 17:57(d) send request again, this time, RealTerm displayed more numbers (from servo, I guess). (e) I repeated send without signal connected, and then connected to servo). The RealTerm output is displayed below.
Now I need someone kindly to decode the seemingly reply from the servo, hopefully something like a Vin value of 5V. Ah, I am missing the locking down supper, will come back later this evening, … Adrian Maire13.4k
tlfong01Thanks a lot. So I will do my always dodgy calculation after supper. Cheers. Adrian Maire13.4kx55 x55: start communication frame
x01: ID from the servo replying
x05: length of the message, including this byte and following
x1B: command: 27 is response to VIN_READ
x4E and x14: value of voltage.
continuingx14=20, x4E=78: 5198 tlfong01Sep 10, 18:14Ha, so the value is 0x4E14. I will ask the online hex to decimal converter for help. Adrian Maire13.4k4E is lower bits and 14 higher, so you have to reverse them: x14 x4E14=20, 4E=78, so 20*256+78 = 5198There is no description of what does that mean, but considering other parameters, it seems like mV, thus 5.198V tlfong01Ah, yes I first tried 4e14 returning some rubbish, then 144e gives 5198. I hope it means 5.198V.tks bye Adrian Maire>JPG
Ohh! I though you had some tool to directly highlight the PDF. Like with Okular PDF-reader 23 hours later… tlfong013983Sep 11, 17:07@AdrianMaire Ah, yes, so there are two approaches: (1) Use Okular to edit the PDF file, and then screen capture to JPG, (2) Screen capture PDF to JPG, then PhotoShop editing.Progress report 2020sep11hkt1707.Now that I found the LX-824HV LeWanSoul tests with Windows RealTerm using BusLink and TXS0104 OK, I am moving to Rpi4B and CuteCom and test the ReadVin command again. I found the test OK, with some teething problems. I am saving a record for later reference and troubleshooting. Next step is to use Thonny python to do everything, ie, no more terminal emulators RealTerm or CuteCom.
tlfong013983Sep 11, 17:32
Jogging time. See you later. Cheers. Adrian MaireSep 11, 17:55Wooww! Nice testing environment 2 days later… tlfong013983Sep 13, 15:11I am glad you like it. Now I have merged the two proto boards together in an all-in-one board, and then used CuteCom to readVin some twenty times, to see how accurate or reliable are the measurements.
tlfong013983Sep 13, 16:00
tlfong013983Sep 13, 16:10Next step is to write a python program to repeatedly read Vin, and at the same time use a scope to display the request string from Rpi, and the reply string from servo. What I am curious to know is the response time between servo receiving request string, to servo sending the data (Vin) string. The LeWanSoul user guide says your need to be quick, but does not say how quick you should be. tlfong01Sep 13, 16:32Earlier I tried to upload a picture but got an error message saying that the image to upload could not be found, so I tried again and again. Now there are three identical images. Please use any one you like. 20 hours later… tlfong013983Mon 12:24So now I am writing a python to analyse the timing of request/reply Vin value, to make sure of the requirement of the Enable/Disable of the simplex UART commands using HC126. Though the TXS0102/04 seems to work, but I have no confidence that the OR’ing of output TxD/RxD won’t generate other problems. As I mentioned in my (already deleted) answer, I once studied the very expensive Danamixel bus servo but could afford to play with it.Now I am googling around to see if there is any alternative comparable with LewanSoul but not too expensive, and also have a good documentation. I found the following review and now reading it.(1) Review of Three Serial Bus Servos (Robotis Dynamixel, DST Robot, and LewanSoul Lobot) – Roger Cheng, Hackaday, 2018jul05
hackaday.com/2018/07/05/…. Cheers.One problem with the Chat Room here is that I am too slow to write a message. Usually I need more than 3 minutes to write and proofread. But my messages become “permanent” and I could no longer correct any spelling or SEMANTIC ERRORS later. This might cause big confusion to future readers.One workaround is for me to from time to time update my answer, after a milestone in our project, and also warning the future readers that ours is an exploratory project, and that many things discussed in the chat room is simply wrong if not misleading. But of course the future reading can skimmed through our chat record and understand why we did it this way or that way, after WE MADE MISTAKES. In short, we learn by making mistakes and correct them. 4 hours later… tlfong013983Mon 16:46Now I have completed the python program to read LX-824HV’s Vin value. The program logic is a bit complicated, so I have written a summary for it.
You might like to comment or make counter suggestion for my python program logic. If the test is successful, I will then tidy up and document the program and upload the complete listing here. But there is nothing urgent. So I will slow down now. Cheers.PS – I might goggle further on serial bus servo. The article I mentioned above is two years old, and it appears that there has not been too much progress in the area. Some 5 years ago I read about the “Open Digital Servo” proposed by SparkFun, but I sadly heard that it was a failure. I guess for now the expensive DynaMixal and cheap HiWonder are still the two serial bus servos that worth our time to invest. 7 hours later… Adrian Maire13.4kMon 23:31“but does not say how quick you should be.”
From the tests I did, I found it is much less than 1ms, I remember something slightly longer than the transmission of a byte by the UART (0.5ms – 1ms), from the last sent bit to the start of the servo reply.“This might cause big confusion to future readers.”
Nobody expect the chat to be a precise document. (IMO) is fine to have typos, and errors. (I am not even sure many people will read this)On my side, I continued to play a bit with the servos, and also trying to solve the enTX/enRx pin (like you).
Here is a question that I posted about it: stackoverflow.com/questions/…
One of the comments is interesting, I still need to test it. 11 hours later… tlfong013983Tue 10:25Ah, this is useful to me: “From the tests I did, I found it is much less than 1ms“.Yes, I agree with the following: “Nobody expect the chat to be a precise document. (IMO) is fine to have typos, and errors, (I am not even sure many people will read this)”And now I think that readers following this chat should automatically filter the typos as he read along. As I said earlier, I might try to make a summary after each milestone, and also brief project report on completion of project.BTW, I googled further but still have not found useful to guide me where to go next on serial bus servos. This is another abandoned project: GigaBrain Dynamixel and LX-16A Project – rpi.org.forums 2018sep19
raspberrypi.org/forums/…I am also updating my knowledge on logical level shifters. Here is an updated of the catalogs: (1) Logical Level Shifter Catalog – AdaFruit
(2) Logic Level Converter Catalog – SparkFun
sparkfun.com/categories/361It is too late for me to update (2) to following: (2) Logic Level Converter Catalog – SparkFun (***I always forgot that opto-isolaters are also level shifters***)
sparkfun.com/categories/361 5 hours later… tlfong013983Tue 16:03Yes, my test confirms your much less than 1ms is about 200us
The output has a little problem. The TXS0104’s 10k Or’ed 10k (Or’ed with LX-827 input) seems not strong enough, with the result the output could not be pulled down to a clear cut zero. I tried to parallel 4k7 to make the pull up stronger, but it seems not making any difference. Anyway, Rpi at the 3V3 side seeem to read the data OK.
I also now understand why you said that each LewanSoul byte is 10 bits, beginning with “10”. More precisely, the beginning “10” should be “stop bit/idle high bit/level (“1”) and “start bit” (“0”).Anyway, the TXS0104 circuit seems working, though not perfectly. So I will move on to tidy up my quick and dirty python program and show a complete listing here, perhaps some time after afternoon tea/jogging/supper. Cheers. 5 hours later… tlfong013983Tue 21:26I forgot that the TXS0204 5V side TxD ORed with RxD and LX-824 is shifted down to 3V3 and at 3V3 side RxD read by Rpi is between 1V (Low) and 3.2V (High) and therefore acceptable to Rpi.
tlfong013983Tue 21:47And this is the complete listing of the program to test the TXS0104 LX-824TV interface circuit.
# srv_util_01_v153.py # LX-824HV Testing v1.0 tlfong01 2020sep15hkt2133 # Contents # Serial UART LoopBack Program v0.62 (Minimal) # Serial UART LoopBack Program v0.98 (Multiple ports USB and on board UYART Ports) # HiWonder serial bus servo LX-824HV LewanSoul command testing (2020sep15) # Serial UART LoopBack Program v0.99 - https://penzu.com/p/f2cb232e # serial_loopback_test_v062.py tlfong01 2020jun03hkt1447 # Rpi4B buster (r2020feb13), python 3.7.3 (r2019dec20), thonny v3.2.7 (r2020jan22)
(see full text)The above program follows the recommendation style of StackOverflow – MCVE (Minimal, Comprehensive, Verifiable Example). Or CPR (Copy-Paste-Run) No external library is required to run it. 1 hour later… tlfong013983Tue 23:14I am going to write some more python programs to control the LewanSoul serial bus servo. I google a couple of forums and found quite a lot of discussions on Dynamixel and almost nothing on LewanSoul servos.Luckily we have the following two references: (1) LewanSoul Bus Servo Communication Protocol User Guide. (2) lewansoul_lx16a_terminal.py, Maxim Kulkin (maximkulkin), GitHub 2019feb27. One bad thing is that all things I found are based on LX-16A, nothing about LX-224HV and LX-824HV. Anyway, I think we have enough references to move on.I found the following two EE SE forum discussions on serial bus servo Dynamixel, but I found them not very useful. (3) Single wire two-way serial communication – hardware configuration （Dynamixel XL-320）- EESE 2015aug05
(4) How can I make a half-duplex UART to TTL converter for communicating to a servo (Dynamixel AX-12A) with a HC04 and a HC126? – EESE 2020jul20
electronics.stackexchange.com/……(see full text) 12 hours later… tlfong013983Wed 10:56I am using the following Arduino libraries for reference in writing my python code. This is the most up to date LewanSoul code based on LX-16A. Ihave given up searching for more updated libraries for LX-224HV and LX-824HV.LX-16A Arduino Libraries – Eicken & Harrington 2020aug14
arduinolibraries.info/…I found the LX-16A functions in the Arduino library a bit simple and straightforward. So I am now thinking of writing all python functions from scratch. I think if you are writing C++ coode for Cortex M4, you should find this C++ code a good reference.This is an example of the Arduino code for reading Vin of LX-16A
tlfong013983Wed 11:24I also found tons of user guides and tutorials for Dynamixel AX-12A. Here is an example for newbies to get started.
wiki.ros.org/…So though I have given up searching further for LX-16A/LX-224HV/LX824HV resources, I can easily find Dynamixel equivalents. One day when I get to know enough with Dynamixel servo, I will consider getting a couple of Dynamixel to play with.Or start DIYing my LX-224HV or AX-12A robot arm: wiki.ros.org/…. Cheers. tlfong013983Wed 11:53Earlier I cursed the lousy, badly written LewanSoul user guide. One reason is that the description and terms are very confusing. For example, the user guides says (a) there are two kinds of packets: Read and Write, And that both controller and servo sends “commands”. Saying that servo sends commands is very misleading, because they are “slaves”.I found Dynamixel tutorial on protocol very clear and newbie friendly: Dynamixel Protocol User Guide – Robotis
I am now using a modified form of Dynamixel for my python programming as summarized below:(1) Controller (eg. Arduino, Rpi) and serial bus servo (eg. AX12A, LX-224HV) communicate each other by sending and receiving data called Packet.
(2) There are two kinds of packets:
(a) Instruction (Control) Packet, which Main Controller sends to control (request status/data of) servo, and(see full text)tlfong013983Wed 12:46DynaMixel vs LewanSoul ServosNow that I have reviewed DynaMixel and LewanSoul bus servos, my quick conclusion is that the US$20 LewanSoul is for poor hobbyists like me, and US$80 DynaMixel is for my Crazy Rich Asian friends – youtube.com/….(1) AliExpress Hiwonder Lobot LX-824HV LX-224HV (17kg/20kg) 11.1V Intelligent Serial Bus Servo for DIY Bionic Robots – 2019 US$19
(2) AliExpress Robotis Dynamixel AX-12A 11.1V 15 kgCm Serial Bus Servo for Original Korean Robot – US$80
aliexpress.com/i/…. 1 hour later… tlfong013983Wed 14:00I bought my LX224HV from TaoBao/Tmall which is AliExpress in CN, both owned by owned by AliBaba) for US14 and so far so good.
TaoBao HiWonder LX-224HV 11.1V 20KG Serial Bus Intelligent Servo – ¥95 (US$14)
detail.tmall.com/…. 21 hours later… tlfong013983Thu 11:07So I am now writing a python program to request the servo for its Vin value, and read its reply and print it out. Then I found a big problem: The reply string read back at the Rpi side has funny characters. I think the problem is that the servo Vin value returned at the TXS0104 output OR’ed to input point is not within an acceptable logical range of 0.5V- for Low, and 2.8V+ for High.
In other words Logical level Low of around 1V is too high. Even after converted to 3V, the Low level is still around 1V, too high for Rpi to read as a Low every time. So there are intermittent errors reading the reply string. In short, the design of TXS0104 input and output ORed at the output side has intermittent errors and is therefore NOT ACCEPTABLE!(removed)(removed)
3 hours later… tlfong013983Thu 14:10Yet another try – this time using HC03 and CD4050
1 hour later… tlfong013983Thu 15:37Now that I have two servos setup, I am thinking of using two Rpi on board serial ports to separately control them. Perhaps I should use TxD #2 and RxD #2.
tlfong013983Thu 16:27@AdrianMaire I skimmed your question to SO and found it too advanced for me. (1) I forgot the the use of “auto” C/C++ keyword and I am not keen to refresh my memory on it, because I should not be using C/C++ even if I might try Cotrex M0 later for this bus motor project. (2) I have zero expereince in wiringPi and I heard that the author of WiringPi stopped supporting it for Rpi4B, so I am not motivated to start learning WiringPi now.The guys at SO suggested to use RTS/CTS which should not fit your situation. If you give them your HC160 cct schematic with enable/disable TxD/RxD, then they might understand and help more, because your “writeMode” control bit might confuse them. (3) The suggestion of “tcdrain()” passing fd given back by serialOpen() is too difficult for me. So I gave up reading on. Good luck. Cheers.I originally thought about suggesting you to try the TXS0104 method if you get stuck in the HX160 design and gave it up. But as you might have read my recent comments, I found the TXS0104 method problematic, because perhaps the LX-824HV output is not strong enough to drive the OR’ed TSX0104 open drain input/output pins low. So I have given up the TXS0104 method and started trying the new HC03 + CD4050 method. So far so good, but I have only 50% confidence that I won’t find trouble later.I have also searching other forums using keyword “Dynamixel” with the following results:
Rpi.org.forum = 61 matches
Robotics SE = 40 matches
SO = 27 matches
EE SE = 22 matches
Arduino SE = 12 matches
All About Circuits = 2 matches
Rpi SE = 1 matchIt appears that (1) Rpi.org.forum, (2) Robotics SE, (3) EE SE, and (4) SO are the most active forums in DyanMixel and serial bus servos. I am surprised that the Adruino guys seems not active, perhaps the Arduino platform is too weak to support Dynamixel A-12A or LewanSoul LX-224HV. LX-224HV is only two years old, perhaps we should wait a year or two to find more good references. Jogging time. See you later. 1 hour later… tlfong013983Thu 17:51LX-824HV Rpi Interface (HC03 + CD4050) Schematic v0.1 tlfong01 2020sep17hkt1759
19 hours later… tlfong01Fri 13:23I googled further and found the following very interesting: alibaba.com/product-detail/…. Cheers. 2 days later… tlfong01398314:43I have finalized the last version of HC03 x 1 based Half Duplex LX-824HV adaptor board. The program listing is given below.
# srv_util_01_v164.py # LX-824HV Testing v1.4 tlfong01 2020sep20hkt1159 # Contents # Serial UART LoopBack Program v0.62 (Minimal) # Serial UART LoopBack Program v0.98 (Multiple ports USB and on board UYART Ports) # HiWonder serial bus servo LX-824HV LewanSoul command testing (2020sep15) # Serial UART LoopBack Program v0.99 - https://penzu.com/p/f2cb232e # serial_loopback_test_v062.py tlfong01 2020jun03hkt1447 # Rpi4B buster (r2020feb13), python 3.7.3 (r2019dec20), thonny v3.2.7 (r2020jan22)
(see full text)Buggy HC03 based adaptor. Like the first version of using TXS0104, there is still intermittent reading errors as shown below:bytes read = b’UU\x01\x03\x1b\xe0UU\x01\x05***x1bJ\x14***\x80′The Vin value of two bytes \x1b\x14 has a random character “J” or other random characters after the first byte. tlfong0115:08