User Tools

Site Tools


pibot:lesson1

Objective

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.

Parts Required

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.

  1. Raspberry Pi 4 or 3B board
  2. OSOYOO Top & Bottom Chassis Plates
  3. OSOYOO Motors and wheel x2
  4. OSOYOO universal wheel
  5. OSOYOO Model Pi motor driver board
  6. OSOYOO PCA9685 compatible module
  7. OSOYOO Voltage Meter
  8. 18650 Battery box
  9. 18650 batteries x2
  10. Jumper wires & Hardware
  11. Optional Hardware
    1. M2.5x5mm Hex Cap Screws
    2. M2.5 Plastic Washers
    3. M2.5x5mm+6mm Hex Brass Pillars
    4. M2.5 Hex Nuts

Hardware Assembly

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

  1. Remove the protective film on the top and bottom car chassis plates

    Each chassis plate has only one protective film

    Remove protective film

  2. Install the Metal Motor Holders from the hardware kit on the motors as shown below

    Install motor holders

  3. Install the motors on bottom car chassis with M3x10mm screws from the hardware kit as shown below

    The M3x10mm screws are in the metal motor holder bag

    Install motors

  4. Install the OSOYOO Model Pi motor driver module on bottom car chassis with with 4pcs M2.5x5mm screws, M2.5x5mm+6mm pillars, and M2.5 nuts from the hardware kit as shown below

    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

    Install Model Pi

  5. Install the PCA9685 compatible board on the bottom chassis with 4pcs M2.5x5mm screws, M2.5x5mm+6mm pillars, and M2.5 nuts from the hardware kit as shown below

    If using brass pillars insert an M2.5 plastic washer between the PCA9685 compatible board and each pillar

    Install PCA9685

  6. Install the voltage meter board on the bottom chassis with 2pcs M2.5x5mm screws, M2.5x5mm+6mm pillars, and M2.5 nuts from the hardware kit as shown below

    If using brass pillars insert an M2.5 plastic washer between the voltage meter board and each pillar

    Install voltage meter

  7. Install the universal wheel on the bottom chassis with 2pcs M3x10mm screws and M3 nuts from the hardware kit as shown below

    Install universal wheel

  8. Install 4pcs M3x45mm brass pillars from the hardware kit on the bottom chassis with 4pcs M3x10mm screws and M3 plastic washers from the hardware kit as shown below

    Install brass pillars

  9. Connect the wires between the boards on the bottom chassis as described below
    1. Connect the 2pin 20cm and 3pin 20cm female to female cables to the PCA9685 compatible board as shown below
    2. Connect the 6pin flying lead cable between the Model Pi motor driver board and the PCA9685 compatible board as shown below
    3. Connect the motors to the Model Pi motor driver board as shown below
    4. Connect the 3pin 15cm female to female between the voltage meter and the Model Pi motor driver board as shown below
    5. Connect the USB cable to the Model Pi motor driver board as shown below

      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.

      Install Cables

      PCA9685 wires

      Model Pi control wires

      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 wires

      Voltage Meter wires

      Model Pi Motor Driver Board Voltage Meter
      VIN VT
      5V VCC
      GND GND

      USB power cable

  10. Install the Raspberry Pi board on the top chassis with 4pcs M2.5x5mm screws, M2.5x5mm+6mm pillars, and M2.5 nuts from the hardware kit as shown below

    If using brass pillars insert an M2.5 plastic washer between the Raspberry Pi board and each pillar

    Install Raspberry Pi

  11. Install the 18650 battery box on the top chassis with 4pcs M3x10mm flat screws and M3 nuts from the hardware kit as shown below

    Install 18650 battery box

  12. Install the top chassis on the bottom chassis with 4pcs M3x10mm screws and M3 plastic washers as shown below

    Feed the wires from the bottom chassis through the holes on the top chassis before screwing it down

    Install top chassis

  13. Connect the 18650 battery box to the Model Pi board as shown below

    18650 Battery wires

  14. Connect the PCA9685 compatible board to the Raspberry Pi board as shown below

    Create loops in the wires by wrapping them around your finger to keep the wiring neat

    PCA9685 wires

    PCA9685 Module Raspberry Pi Board
    V+ Pin 2 (5V)
    VCC Pin 4 (5V)
    SDA Pin 3 (GPIO 2)
    SCL Pin 5 (GPIO 3)
    OE
    GND Pin 9 (GND)
  15. Connect the Model Pi board flying leads to the Raspberry Pi board as shown below

    Model Pi control wires

    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
  16. Connect the Model Pi board USB to the Raspberry Pi board as shown below

    USB power cable

  17. Install the wheels on the motors with 2pcs M2.2x22mm self-tapping screws as shown below

    The wheels are very snug fitting to the motor shafts and may require significant force. Brace the opposite side of the motor shaft when pushing them on.

    Install wheels

Software

Select the appropriate link below for instructions to setup the software on the PiBot and an exploration of how it works.

Electrical Description

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.

Return to Main PiBot page

"Then God said, “Let us make man in our image, after our likeness. And let them have dominion over the fish of the sea and over the birds of the heavens and over the livestock and over all the earth and over every creeping thing that creeps on the earth.” - Genesis 1:26"
pibot/lesson1.txt · Last modified: 2022/10/20 21:53 by 127.0.0.1