Hexaringapod rotate code

Reading Time: 2 minutes

MEETERS  (MITERS end of term showcase) today! ’twas awesome, lots of people came (both MIT students and people from the area and people from artist’s asylum).

Anyway, I fixed the servo horn that a kid broke @ Cambridge Mini Maker Faire (10 minutes), then I scratched my head a lot over rotating my hexapod. In the end, trial and error code and fellow MITERians ftw.

Still KISS code that I’m embarrassed to publish, but I know I’ll find this useful in the future.
I rewrote the coxa in terms of rotating CW or CCW around the body, instead of backward and forward. Backward and forward were useful for the rectangular body, making it clear that moving coxa in the +J direction, “forward”, meant moving CW for servos on the left “half” of the body and CCW for servos on the right half. But now that I have a circular body, it just confused me (I couldn’t figure out how rotating was different walking forward, hah).

I don’t think I can get it to strife left / right with my current setup, where I’m pairing servos with Y splitter cables to get down to 12 channels, the max that the Arduino servo library supports.

(As it turns out, it is entirely possible to get more PWM outputs. David Lawrence, after I spammed everyone on MITERS asking for guidance, informed me that


Essentially, because the PWM waveform is output at 1000 Hz, it’s necessary to use the hardware timers, which only connect to a subset of the output pins.  However, servos are quite happy to be driven by a 50 Hz PWM, in which case you can use one timer to control a whole bunch more of the GPIO pins.  The higher frequency is only really necessary for interfacing with analog hardware.  




and as always, pics:

social medialulz