element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
EZ-EV Challenge
  • Challenges & Projects
  • Design Challenges
  • EZ-EV Challenge
  • More
  • Cancel
EZ-EV Challenge
Forum DockBot - Part 4 - Getting the Arduino Q to move the tank motors
  • News
  • Projects
  • Forum
  • DC
  • Leaderboard
  • Files
  • Members
  • More
  • Cancel
  • New
Join EZ-EV Challenge to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 5 replies
  • Subscribers 58 subscribers
  • Views 260 views
  • Users 0 members are here
  • design challenge
  • arduino uno q
  • drv8833
Related

DockBot - Part 4 - Getting the Arduino Q to move the tank motors

arvindsa
arvindsa 20 days ago

Recap

I am building a robotic system that identifies the charging port on an EV and automatically moves a charger arm to plug the charger in.

Past Forum Posts:

  • DockBot - Part 1 - The Concept
  • DockBot - Part 2 - Positioning with Aruco Markers
  • DockBot - Part 3 - New Plan, New Hardware for Better Sensing

This part is about turning the Devastator chassis from Part 3 into something that actually drives, and getting the Arduino UNO Q to be the one driving it.

The new motors and chassis mods

In the last post I mentioned that the Devastator Chassis motors were burnt out and I had ordered a All Gear Motors, I received my motors went ahead and installed the replacement all-metal BO motor and found two problems - one I'd anticipated, one I hadn't. The original Yellow BO motors were L-shaped; the replacement is straight. Before I even ordered it I had checked for collisions and found that a flange with a nut, which connects the roof of the platform to the side, would be in the way. Fix for that is to cut the flange and replace it's functionality with a 3D printed bracket.

Modding the chassis

Below is a  video of me modding the Chassis. Watch it only if you love watching such logs. Its a bore for others.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

The second problem was new: a little plastic stub that I think holds one of the gears in place looked mechanically identical to the original but wasn't quite. There was a minor location difference, Had to drill out the location hole to get it to fit.

Drilling locatr hole

Both motors installed, tracks back on, and I confirmed both spin the right way before moving on to electronics.

The electronics

The Arduino UNO Q becomes the brain of the whole platform. The Qualcomm Dragonwing QRB2210 side runs Linux and acts as the overall controller - it'll receive positioning data from the Radxa Q6A about where the robot and the car actually are. The STM32U585 side handles the real time motor control loop through a DRV8833 driver.

As a mechatronics engineer I know that manufacturing differences between motors - different inertia and friction in the gear train, different friction in the track and wheel system - mean the two motors won't turn at exactly the same speed for the same commanded voltage. Sometimes you get lucky and the mismatch is tiny, but I didn't want to bet on luck, so I planned ahead for an encoder on each motor shaft, which is why I bought motors with a shaft on both ends in the first place. I'll be using a TLE5012B as a non-contact magnetic encoder for that - not wired up yet, more on that below. I am using TLE5012B just because I have surplus of it from another project, But there are more easier to procure and easier to interface encoders available.

For power, I'm using a 3500mAh 2S 7.4V Li-ION battery. The Arduino Q gets powered through its VIN pin (official power spec). During testing I found it needs a minimum of 6.7V to run reliably - the official docs say 7V, but that's presumably for full-load conditions. The motors are rated at 6V, so a buck converter in parallel brings that down to 5.9V before it reaches the motors via the DRV8833.

I made a custom perfboard PCB to house the DRV8833, a screw terminal for battery in, the motor leads, and a 2.54mm JST-XH connector carrying the 6V rail into the driver. The one snag: the battery uses a female T-Deans connector, and I didn't have a matching male one on hand. I had to do a makeshift, admittedly dangerous workaround to get power flowing for bench testing. I would not recommend anyone do what I did - that battery has a high discharge rate and is a genuine fire hazard if shorted. I've ordered the correct connector; whether it arrives before the submission deadline is a different question.

Custom Perfboard with the Buck Converter
Perfboard driver PCB - DRV8833, screw terminals, JST-XH power in

image

The code

For Arduino UNO Q programming, I'm building on the work from the last design challenge - On the Line - where I disabled the bridge between the Dragonwing Linux side and the STM32, giving the STM32 full bare-metal control instead of going through the Arduino sketch layer. Same STM32CubeMX HAL project setup carried over, pins reassigned for this board.

For now I'm deliberately skipping the encoder and any PID control - the goal of this post is just getting the hardware moving, closed-loop speed control is a separate step.

The wire protocol between the Linux side and the STM32 is a tiny line-based ASCII format:

M <left> <right>   set track motor speeds, -255..255 each
S <id> <angle>     set servo <id> (0 or 1) to <angle> degrees, 0-180
H                  halt (motors only)

with a 500ms command-timeout fail safe in STM32 firmware - if no valid line shows up within that window it halts the motors on its own, so a crashed Linux-side process can't leave the tank driving into something:

void UartProtocol_Poll(void)
{
  if (s_line_ready) {
    s_line_buf[s_line_len] = '\0';
    handle_line(s_line_buf);
    s_line_len = 0;
    s_line_ready = 0;
  }

  if (HAL_GetTick() - s_last_command_ms > COMMAND_TIMEOUT_MS) {
    Motor_Stop();
  }
}

First bench test immediately turned up two bugs. One was the usual - the left motor's direction sense was wired backwards relative to the `M <left> <right>` sign, so a positive command drove it in reverse. Easy fix, just invert it in software rather than rewire anything.

The second one took longer to track down. With the DRV8833's DIR pin held HIGH, the driver alternates full-drive and brake every PWM cycle instead of the documented drive/coast behavior - so with DIR high, a small commanded duty was actually the fastest the motor would go, and a large duty stalled it. Completely backwards from what I expected. Once I figured that out, complementing the duty (`255 - magnitude`) whenever DIR is HIGH fixed it:

static uint32_t compute_duty(int16_t speed)
{
  uint32_t magnitude = (uint32_t)(speed < 0 ? -speed : speed);
  return speed < 0 ? 255U - magnitude : magnitude;
}

Both directions now scale proportionally from zero on the bench. There's still a small deadband near zero but that is due to the the PWM having too less duty to overcome the static friction. I'll deal with that later.

For actually driving the thing during bench testing, I have to credit the author of Hall W EV - Post 1 - The Wheels Are Turning (Mostly)  tamadillo and hambreros  for the idea of hosting a web UI directly on the UNO Q for manual control. I would have made a python tkinter GUI to tun on host computer. Only difference is I set mine up by hand instead of through App Lab - a plain Python http.server handler that serves a page with sliders and posts JSON to /api/drive, /api/servo, /api/halt, which get relayed straight down the serial link to the STM32:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Since the STM32 halts on a 500ms silence, the page has to keep resending the current slider values every 150ms while a slider is held - releasing it (or hitting Stop) sends H and stops the resend loop. I later added +/-1 and +/-5 bump buttons alongside the drag sliders, for the fine adjustments that are basically impossible to hit by dragging a slider with a mouse.

What's next

Encoder wiring and a basic speed-control loop are next on the STM32 side (Assuming the Diametrically polarized magnets come in time), then getting the Linux side actually talking guidance over the serial link instead of me driving it by hand with sliders with the Radxa showing the absolute positioning.

Final Notes

Devastator Chassis is a tank again. I feel I should some RGB lights, What do you say?

  • Sign in to reply
  • Cancel
  • tamadillo
    tamadillo 16 days ago

    good stuff - yeah the Web UI with the UNO Q really seems to work well

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • arvindsa
    arvindsa 20 days ago in reply to veluv01

    I am sorry, What i wanted to say is the website where i got the Battery just simply says - "Y" to BMS, just a plain Y. I have asked their customer care to confirm that. That website has given me incorrect specs in the past. and hence the Safer route.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • veluv01
    veluv01 20 days ago in reply to arvindsa

    If it has a BMS then it's safe, no issues even when shorted accidentally.V

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • arvindsa
    arvindsa 20 days ago in reply to veluv01

    Thanks veluv01 , the product listing page of the battery pack said it has a BMS but no more details on the protections available. So, taking the safer route. Ah, Neopixel ring is a good idea. Let me see if i can source it in time or maybe i will wrap the strip i have as a ring.

    next post will be up in around 3 days. Thank you for your support. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • veluv01
    veluv01 20 days ago

    Metal-geared BO motors are a great choice for torque and reliability! On the power side, a Li-ion pack with an integrated BMS is the safer route it handles cell balancing, over-discharge, and short-circuit protection. A NeoPixel ring would be a nice addition too, useful as a visual indicator for battery level, status, or operating mode.Smile

    Great Update! Looking forward to see how it turns out!Relieved

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube