Robotics enthusiasts find the credit card sized single board computer, Raspberry Pi or RBPi – a versatile unit for controlling various functions. With several add-ons or HATs readily available in the market, the RBPi can be a formidable force to reckon with. With its latest Motor HAT from Adafruit, your RBPi can control up to four DC motors or two stepper motors using PWM to achieve full speed control.
Although the RBPi has several GPIO pins, not many of them work as PWM. That means, to control motor direction and speed, you require a fully dedicated PWM driver chip onboard. Such chips will handle all the motor and speed controls, while communicating with the RBPi on only two pins – SDA & SCL. These pins follow the I2C standard protocol for communication. Therefore, you can connect this Motor HAT to any other device working with the I2C protocol.
In case you need to control a larger number of motors, as it is often required in robotics, you can easily stack up several of these Motor HAT boards. A total number of 32 boards are allowed by the I2C standard. Therefore, you will be able to control simultaneously 64 stepper motors or 128 DC motors, or a mix of both. To do this, you will have to replace the header on the Motor HAT with a stacking header.
Typically, stepper motor drivers rely on L293D chips. However, the Adafruit Motor HAT uses TB6612 MOSFET drivers. These drivers have the flyback diodes built-in and provide a huge improvement over the L293D – you get 1.2A per channel with 3A as peak current capability. The Motor HAT board comes with a small prototyping area and a polarity protection FET on the power pins. Adafruit offers the Motor HAT fully assembled and tested. All that a user has to do is to solder on the included terminal blocks and the 2×20 plain headers. However, stacking headers are not included.
Looking at the specs of the Motor HAT, you will find four H-bridges with thermal shutdown protection and internal kickback protection diodes. The bridges are capable of driving motors operating from 4.5VDC to 13.5VDC. Each board is capable of driving up to four bi-directional DC motors with individual speed selection using 8-bits or 0.5% resolution. Alternately, you can drive up to two stepper motors – unipolar or bipolar. These could be of single coil or double coil type and the driving could be interleaved or micro stepping.
Motors require a good amount of current for producing the required torque. The huge terminal block connectors allow use or 18-26AWG wires for drive and power. External power can come from a 5-12VDC power supply; the two-pin terminal block connector on the board is polarity protected.
Adafruit Motor HAT board is best suited for RBPi models B+ and A+. For using with models A and B, you have to use an extra-tall 2×13 header in place of the 2×20 header supplied. Adafruit supplies the easy-to-use Python library that makes driving motors a breeze with the RBPi wearing the HAT.