1
\$\begingroup\$

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):

https://www.dropbox.com/sh/b3v81sb9nwir16q/AADXOwhdw7KLq5t5UM8ND3kwa/LX-15D%20Bus%20Servo?dl=0&subfolder_nav_tracking=1

Testing signal:

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:

schematic

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:

enter image description here

The result signal:

The resulting signal at the signal pin of the servo-motor is as follow:

enter image description here

There is no significant signal after this, which I interpret as the servo not responding for any reason.

The question:

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..

\$\endgroup\$
  • 1
    \$\begingroup\$ Note: I also tried other types of messages (rotate), without more success \$\endgroup\$ – Adrian Maire Aug 28 '20 at 15:20
  • 1
    \$\begingroup\$ I think the following document is more helpful: dropbox.com/sh/b3v81sb9nwir16q/AADXOwhdw7KLq5t5UM8ND3kwa/… Thank you \$\endgroup\$ – Adrian Maire Aug 28 '20 at 15:28
  • 2
    \$\begingroup\$ Multidrop 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... \$\endgroup\$ – Chris Stratton Aug 29 '20 at 0:33
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ – tlfong01 Aug 29 '20 at 4:20
  • 1
    \$\begingroup\$ (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. \$\endgroup\$ – Adrian Maire Aug 29 '20 at 10:49
1
\$\begingroup\$

After some time researching the topic together @tlfong01 and me(@adrian_maire), we managed to get the servo working through the Raspberry Pi (from now: RPI) without the need of the driver board.

For this purpose, several problems has been solved:

  1. Converting voltage level from 3.3V (RPI) to 5V (servo bus)
  2. Implementing the different UART messages for the RPI
  3. Converting full-duplex UART to half-duplex UART

Converting voltage level from 3.3V to 5V

Even if this could be a sub-optimal solution, considering that the 74HC126D allows level conversion, two of them has been used to manage both problems: enabling and disabling of Tx/Rx and level conversion at the same time.

schematic

simulate this circuit – Schematic created using CircuitLab

Implementing the different UART messages for the RPI

A project has been created (GPL3) to any of you to use it.

https://github.com/Escain/HiwonderRPI

(The code is unfortunately too large to include here.)

Converting full-duplex UART to half-duplex UART

For the conversion of full-duplex to half-duplex UART, the servo relay on the enabling and disabling of the full-duplex TX (transmission) and RX (reception) line:

  • When RPI transmit, it enable TX and disable RX
  • When RPI don't transmit, it disable TX and enable RX so the servo can answer.

The servo start answering UART request some 0.1ms after reception, this is below the OS scheduling time of any modern operating system, including Raspian. In consequence the first attempt to drive en-TX and en-RX by software was totally unsuccessful.

To solve this issue, the en-TX is implemented by hardware, through a retriggering monostate 555 timer of around 0.1 ms. The en-RX is just the negation of en-TX.

schematic

simulate this circuit

Connecting all together:

  1. Tx is connected to the RPI GPIO 14
  2. Rx is connected to the RPI GPIO 15
  3. enTx from both circuits are connected together
  4. Servo S is connected to the signal of the servo
  5. Gnd and VCC (3.3V, 5V and 9V) are connected to the circuits and to the servo. (This servo is HV and thus, support up to 12V, but others Hiwonver servos can NOT manage 12V, be careful).

enter image description here

\$\endgroup\$
0
\$\begingroup\$

Question

How can Rpi4B talk to duplex BUS UART servo LX-224HV?


Answer

Part B - Rpi4B UART to LX-224HV Simplex Serial Ciruit Design V0.1

lx-224 simplex cct design

Next step is to let Rpi to send commands to LX-224 and see if is replies back anything. The OP reports nothing comes back. So I will repeat his commands and see if I have better luck.

The Op is sending the following commands. I think I better read the servo command manual to make sure the commands are OK and will not fry the servo.

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

Part A - LX224HX Troubleshooting Using BusLink V2.4

I am using the HiWonder Bus Linker V2.4 to display the send receive signals when the LX-224 UART/Bus servo is set to motor mode and move continuously at about 700 rpm.


lx224 motor test 2


motor signal 1


motor signal 2


motor signal 3


References

(1) LewanSoul Bus Servo Communication Protocol

/ to continue, ...


Appendices

Appendix A - The OP's test setup

The OP's test setup


Appendix B - HiWonder LX-224 BusServoController setup

lx-224 controller


Appendix C - HiWonder LX-224 BusLink V2.4 Setup


enter image description here


Appendix D - TSX0104 Level Shifter for implementing LX224 Simplex UART/BUS Servo Bidirectional Control

tsx0102 1

/ to continue, ...


Not yet completed answer. Stay tuned, ...

\$\endgroup\$
  • 1
    \$\begingroup\$ Hello @tlfong01, thanks you for your great research :-) Looking at your oscilloscope output, it does not resemble to any of the message that I have in the documentation. My initial conclusion is that the protocol explained is either wrong or has been significantly changed. It would be interesting to have more samples of communication to reverse-engineer the protocol. The on of your picture is probably about querying the temperature/voltage or position. \$\endgroup\$ – Adrian Maire Sep 2 '20 at 9:26
  • 1
    \$\begingroup\$ Ah, I see. But I am not surprised, because I am using the Win10 Bus Servo Terminal GUI command to turn the motor non stop so I can easily us a scope to display something. There are other things that cause trouble: (1) I am using BusLink version 2.6, but I read the AliExpress and Amazon are selling old versions. So there might be outdated commands. The other thing is that I found HiWonder keeps saying that they cannot help users to develop software, because HiWonder is asking LeWanSoul to develop the LeWanSoul simplex uart servo protocol. So LeWanSoul might not the have motor turning commands. \$\endgroup\$ – tlfong01 Sep 2 '20 at 9:38
  • \$\begingroup\$ Ah, supper time, so see you late this evening or tomorrow. Cheers. \$\endgroup\$ – tlfong01 Sep 2 '20 at 9:39
  • 1
    \$\begingroup\$ In your circuit, I suggest you to add the pull-up resistor and also some 0.5k in-serie resistor between the bus and the servo. This will avoid any error to burn to quickly your devices. \$\endgroup\$ – Adrian Maire Sep 2 '20 at 9:40
  • \$\begingroup\$ Ah that is a good advice I carelessly forgot . I usually use 330R or 470R series resistor to limit the motor current. I am also using a very small 220VAc to 12VDC 1A (yes, 1A only) PSU then step down to LM2596 12V to 5V to supply the LX-224. So I think LX-224 should at most take 1A or a bit more, hopefully no to fry anything. And also that is why I am using the less expensive servo, not the most expensive one, just in case, ... Cheers \$\endgroup\$ – tlfong01 Sep 2 '20 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.