Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code Sample for Holonomic Drive (HO15 drive)
Uploaded code to the code area -

This is an example holonomic drive for an HO15 - it "just" adds the appropriate inputs together to get values to drive the wheels.

[Image: thumb_Sentry_Brain.jpg]
Arduino code for 4-wheel holonomic drive and 5 LED WS2811 lights
Some more details for that code might be good Smile It's intended for 4 Pololu simple motor controllers and 3 normal R/C inputs.

The motor controllers need to be assigned #s in the "simple motor control center", and configured for "Serial" input. I used 38400 baud because I'd done that before, it might be able to go higher.

I made these assignments (which are in the comments of the scriptSmile

#13 (decimal) is Front-Left
#14 is Front-Right
#15 is Rear-Right
#16 is Rear-Left

I use "Rotate" as the 'rudder' RC Channel 4, which I attach to Channel 1 of the Front-left (#13) controller
I use "Fwd/Back" as the 'elevator' RC Channel 3 - which I attach to Channel 1 of the rear-left (#16) controller
I use "sideways" as the 'aileron' RC Channel 2 - which I attach to Channel 2 of the Rear-Left (#16) controller
The other R/C channels/inputs are unused, but you could use them for other purposes.

Those 2 controllers (13/16) are the "first" ones on my chain the way I wired them, but they don't have to be. I used those two because they were closest to where I mounted the Arduino. They skip numbers because I #'d them in a different pattern than I ran the wires.
The Pololus can be “daisy chained”. You need GRD (signal reference), TX & RX. For a single simple motor controller the GRD on the Arduino goes to GRD on the motor controller. Tx goes to Rx and Rx goes to Tx. (They’re labeled a transmit and receive for the device they’re on).

For multiple controllers, they all “listen” for their # when the Arduino talks, so the Tx and ground from the Arduino just go to all of their GND and Rx pins. I used the Serial1 Tx/Rx for my Leonardo, but if you have a single serial you can rename that to Serial. Or if you have a Mega, you can assign the motors to unique serial lines.

When daisy chained, the controllers all have to talk to the single Arduino pin. You can’t just tie them all together because they non-talkers would pull the talking one’s pin the wrong way. They say you can use an AND gate, however they put that on the board (so why mention it?)

So, the TX from the LAST Pololu goes to TXin on the next to-last Pololu. Then that one’s TX pin goes to the txIn of the next-to-last one. Etc. They relay the signal through all of them.

Really, we only need to “listen” to the first two if you put the ones with the RC inputs first in the chain, so you only really have to do that once, but I added the other two just in case I wanted to query them later for some reason.

The R/C wires for the 3 channels we need then go to the R/C inputs of the 1st two controllers.

When the Arduino “talks”, everyone listens. The Arduino sends 0xAA to get their attention, then a byte with the motor’s controller #, then the rest of the command (it’s in their PDF docs). The command changes a tiny bit in this mode, normally the high bit is set (basically to get it’s attention) for one controller, but in this mode the commend has the high bit cleared. They list it in the docs both ways.

When the Arduino is queried for information (like the R/C input values), then we have to “wait” a little for the serial buffer to get full before we can read the answer. My understanding is that if the controllers all respond at the same time we’ll get garbage – but that’s tough to do because our command is 4 bytes and they only reply 2 bytes, so they should have plenty of time to reply while we’re sending the next command.
I used RC servo cable for my signal line, but I had to use different connectors on the ends. I installed my own .1" header pins. Each controller needs RX and GND to go to the next controller, so I each of those pins has two wires attached to it (at least for the first 3 controllers).

I made a "thing" on Thingiverse that provides a jig to hold the individual header pins at the right spacing. You could, of course, just use a 7 pin (housing). I had individual pins available though. I also made the housing because we've had problems with individual pins getting knocked loose on other droids and not knowing for sure where they were supposed to connect to - or being in a rush and having a hard time seeing in bad light and accidentally trying to attach them off-by-one.
We're using:
  • 4 Pololu 37D 30:1 motors,
  • 4 VEX 4" omniwheels,
  • 4 Pololu 18v7 Simple motor controllers,
  • a bad 12V LiFePO4 battery,
  • an Arduino (happens to be Leonardo), and
  • 5 Pololu addressable LEDs (program as WS2811)

Forum Jump:

Users browsing this thread: 1 Guest(s)