Motor Driver Library
The best way to get used to how to use this library is too look in the file->examples->examples->battleblimpsboard and give some examples a go. A particularly amusing example is musical motors which Cass wrote, if you connect a small speaker across the motor 1 connection it will play an entertaining ditty.
Serious silkscreen error
On the 12/7/2011 version of the board (all boards currently in existence) one of the power inputs on the Motor Driver Board is labeled back to front. See here. Connecting power wrong will kill your H-bridges, not right away maybe and perhaps not all of them especially, if your code isn't telling them to do anything. I did managed to kill one of my H-bridges this way so please be careful. I recommend scratching off or writing over the offending text.
Powering Your Boards
In general you will need 2 power supplies (probably batteries) to provide power to your boards. This is because in general it is a bad idea to connect the microcontroller and the motors to the same power source due to noise and microcontroller brownouts. As such the motor driver board power is not connected to the megamini power. If you know what you are doing, obviously they can be connected, however I suggest you start with two power supplies first.
Powering the Motor Driver Board
simply connect power (correct polarity) to GND and Vbatt+ (note silkscreen error above) either side will do. If you anticipate drawing lots of power, I suggest connecting to both connectors on the bottom of the board. If you are going to draw the max current from all 4 H bridges it might be prudent to run a wire from the Vbatt connectors to the + connectors on the middle of the board and a wire from the GND connector to the - connectors in the middle of the board. How big a deal this is we don't know yet, we will destructive test one of the motor driver boards to see how much current the traces can take. IF you want to draw lots of power, particularly from the FETS see here.
The maximum voltage the board can take is a bit hard to calculate as we used electrical engineering capacitors on the boards rather than the ones we actually purchased for the job, we don't know their voltage rating. It should be fine as the max voltage on the H-bridges is 15 volts. (12-13 is probably safest). For a bit more info on the motor driver chips see Pololu Motor driver based on the same chip
Powering the megamini
Caution, fi you have multiple power supplies make sure you placed the little diodes on the megamini board Initially we did not have the diodes and some folk used 0 ohm resistors in place of the diodes. The diodes protect the USB connection from higher than 5 volts on the vin pin (if you don't have anything connected to this pin it should be fine, though you will want to put power into this pin later)
For testing purposes it is ok to have the the motor driver board connected to a battery or power supply while the megamini is connected to USB. This makes debugging easy as you can SerialUSB.prints to see what is going on while you figure stuff out. To power the megamini independently of the USB is sadly a little awkward. You need to connect a voltage greater than 3.4 volts to the vin pin. Max voltage is 16 volts but I suggest less than this as the voltage regulator will get quite hot at 16 volts. For a more detailed explanation see here You need to connect the negative, or ground, of you battery/power supply to one of the GND pins. If you are using the motor drier board, it is actually easiest to connect the negative/ground to one of the screw terminals on that board as they share ground.
Connecting motors to the H bridges
Motors are connected accross the A1 A2 terminals or the B1 B2 terminals. The numbering in the library works like this:
- Motor 1 is connected between Motor Driver 1 A1 and A2
- Motor 2 is connected between Motor Driver 1 B1 and B2
- Motor 3 is connected between Motor Driver 2 A1 and A2
- Motor 4 is connected between Motor Driver 2 B1 and B2
Note that if you do need to more than 1 amp continuous you can get 2 amps continuous by ganging outputs. So connect a 2 amp motor to Motor Driver 1, one terminal to A1 AND B1 and the second terminal to A2 AND B2. In you code be very careful to ensure that you make both outputs do exactly the same thing. Ie, both go Forward at the same time, and both have the same speed set.
Things to take Care With
Remember each H bridge Channel (A1 A2 or B1 B2) is only rated to 1 amp continuous (it can take about 3 amps briefly) This is actually a fair bit but using an ammeter to check is recommended.
