This first lesson will show you how to assemble the PiBot. It will then show you how to configure and use the Raspberry Pi to control the PiBot with a simple Python program. Finally it will describe how the electronics work together to control the PiBot.
The parts below are required to complete this lesson. Note that all parts except the Raspberry Pi board and optional hardware are included in the OSOYOO kit that can be purchased on Amazon.
When handling any of the circuit boards make sure to wear your ESD wrist strap and have it connected to an earth ground point
When installing items with multiple screws or nuts, leave them loose until all are installed and then tighten to ensure that you can get them all inserted
When installing a board using the M2.5x5mm+6mm pillars, attach the pillars to the board with the screws and then install on the chassis with the nuts
Make sure the OSOYOO Model Pi motor driver module is installed in the correct direction as shown on the right below
If using brass pillars insert an M2.5 plastic washer between the Model Pi motor driver module and each pillar
Create loops in the wires by wrapping them around your finger to keep the wiring neat
Use the USB-A to USB-C cable for the Raspberry Pi 4. Use the USB-A to USB-micro B cable for the Raspberry Pi 3B.
Model Pi Motor Driver Board | PCA9685 Module | Raspberry Pi Board |
---|---|---|
ENA | PWM 0 | — |
IN1 | — | Pin 16 (GPIO 23) |
IN2 | — | Pin 18 (GPIO 24) |
IN3 | — | Pin 13 (GPIO 27) |
IN4 | — | Pin 15 (GPIO 22) |
ENB | PWM 1 | — |
Model Pi Motor Driver Board | Voltage Meter |
---|---|
VIN | VT |
5V | VCC |
GND | GND |
Select the appropriate link below for instructions to setup the software on the PiBot and an exploration of how it works.
The OSOYOO Model Pi motor driver board is the heart of the PiBot. It is an improved L298N module which can power the motors and the Raspberry Pi at the same time. This board supports all the features of the L298N DC motor drive and also has a USB 5V output port which provides a stable voltage to the Raspberry Pi board up to 2.4A. It is fully compatible with the L298N control input signals ENA, IN1, IN2, IN3, IN4, and ENB. Each channel has two output sockets, K1 and K2 for the right side motors and K3 and K4 for the left side motors. The input power source can be any voltage between 7.5V and 24V. Recommended battery configurations are 2pcs tandem 18650 batteries, 6pcs tandem AA batteries, or 2pcs parallel 9V batteries.
The ENA input to the Model Pi board gets a PWM signal from the PCA9685 compatible board which is controlled by the Raspberry Pi. This creates an analog current through the motor using the L298N H-bridge. The higher the PWM value from the Raspberry Pi, the more current will go through the motor, and the faster the motor will spin. The ENA input controls the K1 and K2 outputs which are connected to the right side motors.
The ENB input to the Model Pi board gets a separate PWM signal from the PCA9685 compatible board. This creates an analog current through the motor using the L298N H-bridge in the same way that the ENA input works. The ENB input controls the K3 and K4 outputs which are connected to the left side motors.
The IN1 and IN2 inputs to the Model Pi board get digital signals from the Raspberry Pi. These inputs control the L298N H-bridge to determine the direction that the motor rotates. When IN1=HIGH(1) and IN2=LOW(0) the motor moves forward. When IN1=LOW(0) and IN2=HIGH(1) the motor moves backward. The IN1 and IN2 inputs control the K1 and K2 outputs which are connected to the right side motors
The IN3 and IN4 inputs to the Model Pi board get separate digital signals from the Raspberry Pi. These inputs control the L298N H-bridge to determine the direction that the motor rotates in the same way that the IN1 and IN2 inputs work. The IN3 and IN4 inputs control the K3 and K4 outputs which are connected to the left side motors
The PCA9685 compatible board connects to the Raspberry Pi I2C bus. The Raspberry Pi can send commands to the PCA9685 compatible board to create the PWM signals used for the ENA and ENB signals to the Model Pi board. The PCA9685 compatible board has 16 PWM outputs, but the PiBot only use two of them, PWM0 and PWM1.
The Raspberry Pi is the brains of the PiBot. It runs the Python programs which send the commands to the Model Pi board in order to make the PiBot do what you want it to do. It also can receive status from sensors that tell it where it is and allow it to make decisions about what to do without you. This capability will be explored in the following lessons.