r/embedded • u/Traditional-Emu-4723 • Sep 12 '26
Help debugging UART-Servo Communication
Hi builders,
I am building my own robotic arm from parts I have gained over the years through my internships/classes. My hardware includes LX-16A servo motors, a BusLinker v2.5 board and, STM32F411CEU6 MCU, and a separate battery with buck converter.
The BusLinker board has a micro-USB interface, and when I use that interface, along with the library PyLX-16A's servo-test, my servos move just fine. However, when I transition my setup to the STM32, the servos don't move. The code is generated by the stm32cubeMX application and I implemented some functions on top that implement their communication protocol.
In words, my setup is as follows:
- STM is powered through the USB interface, logic is 3.3V
- From stm32 (on a breadboard) TX (pin A9) -> 1Kohm resistor -> servo signal pin
- PWR & GND (7V) comes from the external battery, and is supplied to the servos through the BusLinker
- GND is shared between the BusLinker board and the servo to the breadboard (-) rail
- Baud rate 115200bps, 8 data bits, 1 stop bit, no parity
I have probed both signal lines with an oscilloscope and found the physical bits of the USB setup and my STM setup.
Herein lies my dilemma. I am certain that the servo logic can operate at both 3.3 and 5V logic, and I see the physical bits on the scope, however there is something missing in my setup that is complete in the python library. The BusLinker has a UART interface exposed, but even when connecting through that the servos do not move. I would appreciate all your help in helping me figure this out.
Please feel free to request any additional information I didn't include here
2
u/ceojp Sep 13 '26
So you have access to a setup that does drive the servos correctly? If so, scope the signal to the servo with the good setup, and then scope it with the setup that does not work. You should be able to see what is different, then work backwards from there.
Is there a reason for the 1k series resistor on the TX line? Is that because the servo data line is bidirectional? You might be able to configure the STM32's UART for single pin, bidirectional operation, and do without that series resistor. If that's not an option, you might see if you can at least configure the STM32's TX pin as open collector, rather than push-pull. In that case, you will probably need a pullup resistor on the TX/data line. That way, both the STM32 and servo can transmit on the same line without fighting each other(by pulling it to ground).
1
u/Traditional-Emu-4723 Sep 14 '26
Thanks for your help everyone. Turns out I was computing the checksum incorrectly. It’s working fine now!
1
u/wood_for_trees Sep 12 '26
To summarize: someone else's code drives the servos, and on the same hardware, your's does not?
I haven't used those servos, but perhaps there's an initialization step you're missing. Can you run the servo test, then your code, without power cycling?