ESP32 + DXL Shield MKR Mashup in ARDUINO

Although the ESP32 and the DXL MKR Shield are not “purposedly” made for each other, they are well supported within the ARDUINO environment. Just looking at their respective schematics, it looked like that there was a possibility that they could be hooked up together. My experiment setup is shown below:

  • Two 2XL-430s are used and they are powered at 12V via the DXL MKR Shield.

  • My ESP32 board is a Feather ESP32 V2 from Adafruit. It is powered via the USB-C Port by my PC.

  • Both boards are grounded together via a Jumper Wire.

  • Pin TX on ESP32 is connected to Pin TX on DXL MKR Shield, while Pin RX on ESP32 is connected to Pin RX on DXL MKR Shield. In this experiment, the DXL MKR Shield is not considered as an external UART device, so the usual “cross-wiring” between TX and RX is not implemented.

  • On the ESP32, Pin A5 is used as the Flow Control Pin, and it is connected to Pin A6 on the DXL MKR Shield.

The usual PING test was used to test this mashup experiment (see picture below):

  • Broadcast Ping returned 3 servos instead of the actual 4, and specific ping to ID=1 failed.

I reduced the length of the jumper wires as much as possible (see picture below).

STILL the PING test would fail exactly as before.

I repeated this experiment with a Portenta H7 Lite and the same DXL MKR Shield, using the same jumper wires, and of course this time it is just a matter of “corresponding” direct Pin to Pin connections (see picture below):

The Ping test failed for Portenta H7 in the same way as for ESP32, see picture below:

Now, these particular Portenta and DXL MKR shield boards had been used together extensively before without any problem. Thus I put them back together via direct header to header connections, and ran a Sync Read/Write sketch. And the results are fine!

So it looks like that using Jumper Wires for Full-to-Half Duplex conversion via Serial1does not quite work the same way as direct header-to-header connections, for the same task. Does anyone encounter a similar situation?

Also, it looks like that ESP32 users would have to wait for an ESP32-compatible DXL Shield from ROBOTIS?

BTW, the same Sync Read Write sketch was appropriately modified to compile and download OK on the Feather ESP32, but at run time, absolutely no output (not even simple Serial.println() statements).

UPDATE: Feb. 4 2023.

Today, I took a second look at this project and figured out my previous errors which were to trust the Functions ping() and scan() of the Dynamixel2Arduino library :face_with_open_eyes_and_hand_over_mouth:.

First, I tried the sample sketches position_mode and position_velocity for this setup and they worked fine for me - see screen captures below:

Next, I went back to my SyncReadWrite sketch, and found that I forgot to initialize my Serial Port properly. OOPS! Once that was fixed, my SyncReadWrite sketch WORKED FINE PHYSICALLY on my DXLs, however I kept getting PACKET ERROR 128 - see screen capture below:

If @willson sees this post, may be he can help us understand what is going on.

Thus my conclusions at this time are:

  1. It is OK to use Adafruit Feather ESP32 V.2 with the MKR DXL Shield with the proper jumper wires used as described in my Post 1.

  2. The Dynamixel2Arduino Library seemed to work with this setup, but do not use/trust Functions ping() and scan().

  3. Although the DXLs seemed to respond properly to Goal Velocity and Goal Position commands (regular mode or in sync read/write mode). They always reported Packet Error 128, so the user must exercise vigilance!

Update 2/7/2023

When this setup was applied to a CarBot, see picture below

A major issue was revealed: lots of random loss of packets so the CarBot could not be controlled reliably. It looks like packet flow control cannot be done reliably “enough” via “jumper wires”.

Too bad, I was really looking forward to do Dual Core programming with the ESP32 :frowning_face: for my robots.

Update 2/13/2023
I finally got some 20 AWG Solid Core wires coming in today, and that I can use for Jumper Wires.
I am glad to report that these 20 AWG wires are providing much better mechanical fit than the standard DuPont connectors. As a result I do not get random packet losses any more!!!

Update 2/14/2023

Today, I had found that the built-in Classic Bluetooth on the Feather ESP32 V2 worked very well for me:

  1. Windows 10 paired to it as a “Hand-held PC” with SPP support.

  1. This time, as BT-210/410 are not used as for OpenRB-150 or MKR ZERO, I could build RC-100 Protocol on top of SerialBT() at 115.2 Kbps easily. Previously, when using BT-210/410, I was “restricted” to 57.6 Kbps.

The ESP32’s RC100 code was easily obtained by modifying the one provided for Serial4/Serial5 (OpenRB-150) in the free Kindle sample of my recent Arduino book:

  1. Time-of-Flight sensors from Pololu worked fine with the Feather ESP32 V2, and if they are used in non-blocking mode, they can be used together with SerialBT() and RC100 protocol.

  1. Both Pixy2 and HuskyLens cameras worked fine with the Feather ESP32 V2.

Update 2/17/2023

I settled on a “wire-wrapping” solution, but I previously made the mistake of cutting the header pins on my ESP32 board TOO SHORT, so it was such a chore to perform the needed wire wrapping tasks. At the end, I had to JUMP the RX Pins using a 20 AWG wire from the TOP SIDE of my COMBO MODULE. See picture below:

If any reader wants to repeat this project, please keep the header pins at their regular lengths, so that you can feed them through a pre-perforated PCB and this will result in a better MODULE than mine :grimacing:. With this “wire-wrapping” approach, I do not get random DXL packet losses anymore.

So next, I set out to modify my previous single-core SyncReadWrite code into an “independent-core” code based on simple FreeRTOS TASKs. Essentially, let Core 0 do SyncReadWrite on DXLs 1 and 2 set in Position Control mode, and let Core 1 do SyncReadWrite on DXLs 11 and 12 set in Velocity Control mode. And WOW, it was so easy to use in ESP32: KUDOS to FreeRTOS. See my picture below and note the interleaving of the TASKs.

Although “physically” all 4 DXLs did their jobs as programmed, but Packet Error=128 always showed up. Maybe @willson or @Jonathon have some ideas on this issue.

If you already read my recent Arduino book or ran across my old post regarding Portenta H7 Lite, where I did not have such successes with Core M4 regarding SyncRead:

In conclusion, I have a suggestion for ROBOTIS to consider ( @Aaron ). On the next OpenRB Arduino variant board (may be OpenRB-200?), please combine an ESP32 and the DXL Shield Hardware into a single module with the MKR format (or may be a slightly bigger format). So far my “hacking” progresses have shown that this is a very feasible project! :grinning:

Update 2/24/2023

I got some PCB and made my 100% wire-wrap “carrier” board for the ESP32 and DXL MKR shield - all the wire-wrappings are hidden beneath the PCB:

And interestingly, no more “128” Packet Error Message >> must have been due to some mechanical connection issues with my first wire-wrap solution.

So we found that although the D2A Library had never been written for Dual Core Programming, but thanks to the good job of the FreeRTOS folks in writing the ESP32 Scheduler, Dual Core multitasking can now be done for D2A with the Feather ESP32 V2 board, at least, as I have not tested other ESP32 based boards yet.