In robotics, it is usual to have to drive a few motors with the RBPi or Raspberry Pi. However, instead of letting the RBPi handle the low-level job of motor control, using a motor controller board is another option. This frees the RBPi for handling more of the high-level code, resulting in better utilization of the resources and improving the efficiency of the project.
For turning your RBPi into a proper motor controller, you can use the RasPiRobot Board. Apart from simply running your motors from an external supply, the RasPiRobot does a fantastic job of powering your RBPi as well. A switch-mode power supply on board the RasPiRobot ensures that your RBPi receives a well-filtered and regulated power supply.
To run two motors from the RBPi, you will need a few parts. These include a battery holder with a switch – capable of holding six batteries of the AA type, two 5V or 6V DC motors, a RasPiRobot Board v2 and an RBPi Model B+ with 512MB RAM. You will find the version 2 of the RasPiRobot Board perfectly matches the RBPi Model B+. The RasPiRobot Board fits directly over the RBPi, with its GPIO connector matching the GPIO pins of the RBPi.
The RasPiRobot Board uses the L293D motor driver chip in an H-bridge configuration to run two DC motors independently and bi-directionally. The switch-mode power supply on board allows you to drive low-voltage DC motors from a higher voltage battery supply. Additionally, the RasPiRobot Board can also supply the RBPi with over 2A of current. That means you need only a single power supply for driving both the motors and the RBPi.
You must connect the motors via the screw terminal pairs on the RasPiRobot Board. These terminals are marked as L and R on the board. Take care to connect leads from one motor to the L terminals and the leads from the other motor to the R terminals. Swapping the leads of a particular motor will make it spin in the reverse direction.
Now plug in the RasPiRobot Board on the RBPI, taking care to match the GPIO pins and connector correctly. After this, you may connect the flying leads from the battery pack to the screw terminals. Be careful to connect the positive lead (red/yellow color) to the screw terminal marked Vin and the negative lead (black/blue color) to the screw terminal marked GND. Reversing these leads could result in irreversible damage to your RasPiRobot Board.
Place the batteries in the holder (be careful of maintaining the sequence), and throw the switch to the on position. The RBPi starts to boot, which is evident from its LED lighting up. The two LEDs on the RasPiRobot Board should also light up. You will need to download and install the Python Library – follow the tutorial.
After the library has installed, you can get the motors running individually in forward or reverse directions for a definite interval or stop them. It is also possible to make your entire assembly mobile by mounting it on a robot chassis.