I need a third drive-train motor. The X2 is set up for easy use with 2 drives via the VNH2SP30 drivers. Can I easily attach a 3rd driver to the auxiliary processor, or do I need to drive the third motor via PWM from the mega644?
It looks like the SPI.h provides PWM only via the at168. Is there another API that provides PWM? (sorry I haven’t examined the avr-libc too closely yet. RTFM me if necessary!)
I think you would need to generate PWM for the third motor driver from the ATMega644 directly. There’s no good way to connect to unused pins of the ATMega168, and beyond that it’s firmware wouldn’t support it.
Have you seen the T-Rex and T-Rex Jr motor controllers? They have some cool configurable mixed serial and RC control, and can run three motors (one in only one direction).
You would still need a separate microcontroller to run one of the T-Rexes, but you could pick up an original Orangutan and a T-Rex Jr for about the same price as an X2, and you would even get a little LCD screen to boot! Or if you need more current and don’t care for the LCD, maybe one of the Baby Orangutans (there are a few to choose from) and a big T-Rex. Mix and match! Come to think of it, the Orangutan and Baby Orangutan each have a dual H-Bridge built in to begin with. Crazy!
The ATmega168 has no free I/O pins, so getting another motor on there is a hardware limitation, not a firmware one (though that is full, too!). The TReX Adam mentioned is the easiest way to add more channels of motor drive to the X2, and since you can use it to read 5 RC channels, you can get the mixed RC/autonomous control on all 4 main channels (you would use the fifth channel to determine if you want autonomous control or RC control).
If you can spare the I/O lines and processing time, you could also connect an extra motor driver to the main controller (mega644). There isn’t some pre-set API since it’s up to how you connect the motor drivers, so you would just be writing normal AVR code. You can look at the examples for the Orangutan LV-168, which use hardware PWM for motor control, to see one way to do it.
Thanks for all the comments.
We want some uniformity in the motor control code, so we decided to use the Serial Servo Controller: pololu.com/catalog/product/207 to drive our motor controllers.