Building a Raspberry Pi based Robot

Building a robot with raspberry pi? We need to have in depth knowledge about raspberry pi for successful operation of our robot. We will be presenting raspberry pi’s technical specifications, parts and accessories with compatible devices so that, you are aware of raspberry pi before getting started.

Introduction of Raspberry Pi

raspberry-pi-logoRaspberry pi is the revolutionary series of credit card-sized development board for all users especially developers, researchers and technical students. It was invented primarily for sparking interest in children towards computer programming. Its development first started in United Kingdom by the raspberry pi foundation. The Foundation’s major objective is to educate computer fundamentals in schools, colleges and developing countries.

Raspberry pi is introduced in several board configurations which were actually a series of successor boards that had better hardware muscle as compared to its Predecessors. Newark element 14 (Premier Farnell), RS Components and Egoman were the organizations who had the license for manufacturing and selling online or directly through nearby electronic stores. Additionally, Egoman created a version and distributed exclusively in Taiwan distinguishing it by applying red colour and lack of FCC/CE marks except the hardware which remains identical by all manufactures.

 Technical Specifications of Raspberry Pi:

  • SoC:Broadcom BCM2835(CPU, GPU, DSP, SDRAM,one USB port).
  • CPU:700 MHz single core ARM1176JZF-S.
  • GPU : Broadcom VideoCore IV @ 250 MHz.
  • Memory (SDRAM) : 256 MB (shared with GPU).
  • USB 2.0 ports : 1 (direct from BCM2835 chip).
  • Power Rating : 300mA (1.5 W ).
  • Power Source: 5 V via Micro USB or GPIO header.
  • Size : 85.60 mm × 56.5 mm (3.370 in × 2.224 in) – not including protrude connectors.
  • Weight : 45 g (1.6 oz).

Raspberry Pi Models:

Raspberry pi foundation created raspberry pi model A, A+, B, B+ and raspberry pi 2 model B. Each version is a bit similar but modified gradually according to their technical specifications performing variety of applications.

raspberrypi

Raspberry Pi Motor Control:

Raspberry pi is an essential development board that easily runs a motor. All robots, conveyors, wheels and other parts move through using simple raspberry pi code. The hardware requires few wires, old power supplies means from some old circuit boards.

Parts requisite for Raspberry Pi motor drive control:

  • Controller: 5 PCS dual H bridge DC stepper motor drive controller board module arduino L298N
  • Double H bridge drive chip-L298N
  • Logical voltage:5volt
  • Drive voltage:5volt-35volt
  • Logical current: 0mA-36mA
  • Drive current:2A (MAX single bridge)storage
  • Temperature: -20 to +135
  • Max power: 25W
  • Operating voltage: 3V-12V DC (recommended 6-8V)
  • Maximum torque: 800gf
  • No load speed:1.48
  • Load current:70mA
  • Size: 7×2.2×1.8cm (approx)

Step 1: Extra DC power supply dedicated for motor :

Power Supply in the circuit is required from any old electronic device alternatively a new one will also do as long as it is a 5V supply to a maximum of 6 volt for better compatibility. Batteries can also be used to run your motor but it won’t supply enough juice for driving ‘em for log. Raspberry pi does not have enough power to drive motors directly from the GPIO pins. Match your power drive according to your motor’s requirements and their drive voltages and also their power dissipation needs. If you have less power than the motor needs then they will be under-powered and may not turn the way you want or might even burn out your power supply. You see people hack their kids toy race cars with bigger batteries, the cars go fast and have a ton more power than the default design. These tricks always come at a cost for safety, reliability, and component breaking (melting, fires etc).raspberrypi-motor-driver-board

Step 2: Connector wires for driving the direction on the motor:

 The GPIO pins on the Raspberry PI will be used to trigger the L298N direction. There are TWO pins on each motor from which one lead receives the power when pin gets activated. For raspberry pi 2 models B +is appropriate or the older one model B can also be used. Wrong pins may crash or reboot or cause the poor thing to burn out and nobody likes a burnt pi for sure. Throughout the process I’ll talk more about the GPIO numbers over the physical pin numbering nomenclature. Check pins and the connections through LED which detects whether the parts are wired properly.

Step 3: Breadboard for simplifying wire connections:

For easy connections, we’ve used a breadboard.  A cheap bread board will work perfect for jamming the wires together. Plus they boards hold them in place from moving around and possibly shorting out. Fasten your Raspberry USB micro charger up to your standard PI input. Secondly, hook your 2nd power supply for your DC motor up to the +/- on the bread board.

Step 4: Code Snippet Python sample make motor turn one way then other:

motor-driver-boardCode snippets for python:

I assume that you have enough knowledge of python to know it’s a programming language that’s human readable and typed into a text file. Some experience with copy and paste will be required. Read the error messages and happy hacking your python motor codes.

GPIO vs Physical Pin Nomenclature:

There are virtual GPIO names for certain pins that are digital output pins, this overlay on top of or in lieu of the actual PIN numbering from the board layout. When writing your code you’ll need to indicate which one of the pin numbering systems that you’re using. The board pin number or the GPIO.

Simple Code Snippet:

Here’s the basic python code snippet for turning pins on/ off:

motor.py

Run the motor from the raspberry pi command line like this:

Troubleshooting Add Print Statement to Gauge Progress:

raspberry-pi-robot

Step 5:Troubleshooting:

Tools & Tricks:

  • Volt Meter is requisite for troubleshooting.
  • Code snippets are helpful too.

Debugging Items:

  • Does the motor work if you put power directly to it from the 2nd power supply?
  • Does the 2nd power supply have a voltage near or about the rated level of the motor when read with meter?
  • Are the screws properly tightened on the wires?
  • Did you connect {-} or “ground” between the controller module and Raspberry PI?
  • Are the Raspberry PI GPIO pins properly connected to the controller board?
  • Are the Raspberry PI GPIO pins correct?
  • Is the Code referencing the right pin numbers for HIGH & LOW (GPIO vs actual nomenclature?)
  • Do you have the controller wires connected to the right set of pins left side are left 2, right side are right 2? (Idiot question I know, but stupider things have failed the space shuttle.)
  • Did you use the “sudo” command before typing your python motor.py?
  • Did you spell any of the commands with capital letters or mix case? Linux is case specific.
  • How far in the code does the print “code got this far before error” lines occur to debug your code?

So with all the basic information on the little Raspberry pi and the Mighty robot and the configurations and all the robot is easy to build and also very interesting too… The possibilities with the raspberry pi is endless and the applications is limitless. Explore for yourself and leave your reviews and comments in the section below.