Assembling Initio using RoboHAT

Using RoboHAT with Initio

rh13

Click on any image to enlarge

 

You should already have followed the instructions for assembling the chassis here.

In this section we will add the RoboHAT controller, the obstacle sensors, line sensors and the pan/tilt assembly with ultrasonic sensor.

1. Fitting the RoboHAT to the Raspberry Pi

step01

Screw one of the support pillars to the underneath of the RoboHAT at the front (under the RoboHat logo). Then plug the RoboHAT onto the Raspberry Pi.

Push the RoboHAT carefully onto the GPIO pins of the Raspberry Pi, ensuring the pins are placed correctly as shown in the photo above

step02

Connect the motor wires as shown. Red – Black – Black – Red

It won’t damage it if you connect them differently, but the example programs won’t go the direction that you would expect

ultpi_23

Plug the Black/White cable with the DC Jack into the left-most pins on the switch PCB on Initio and the DC Jack end into the RoboHAT as shown above.

There will be a spare cable with Red and Black wires. This is not required for the Raspberry Pi build and should be removed so the ends don’t short.

Check all the wiring again very carefully, then now is a good time to see if the Pi powers up and you can control the motors.

Use 6xAA batteries. These should be good quality rechargeable batteries. We recommend Energizer Extremes or Eneloops

Connect a monitor, keyboard and mouse to the Raspberry Pi, plug in your SD card and switch on. The green light near the On/Off switch should turn on, the LEDs on the Pi should start flashing and the booting sequence should appear on the monitor. If not, switch off and double check the wiring.

Instead of using the batteries, you can plug a micro-USB cable directly into the connector on the Pi. This is an excellent way to get started and allows you to test everything (except the motors, which may turn but only slowly) without using batteries.

 

2. Mounting Obstacle Sensors

ultpi_02

Check that each sensor has 2 mounting collars. Screw one onto the body of the sensor, leaving room at the front for the second one

ultpi_03

Push the sensor through from the rear of the mounting bracket and screw on the second collar. Feed the wires up through the holes in the top plate

ultpi_04

Repeat for the second side

step03

Connect to the RoboHAT INPUTs

  • Left sensor to Pin 7 (marked x07 or #04)
  • Right sensor to Pin 11 (marked x11 or #17)

The wire colours from the obstacle sensor are:

  • Black: Gnd
  • Red:  5V
  • White or Yellow: Signal

Make sure you connect them to the correct pins on the RoboHAT

 

3. Mounting the Line Sensors

ultpi_07

First, take the 30cm female-female jumper strip of 10 wires and split it into three strips:

  • Brown, Red, Orange, Yellow (this is for the Ultrasonic Sensor)
  • Green, Blue, Purple (this is for the Left Line Sensor)
  • Grey, White, Black (this is for the Right Line Sensor)

ultpi_08

Next, prepare the two Line Sensors and 2 of the 3x8PB screws as shown

ultpi_09

Screw the line sensors in position as shown, using the screwhole in the middle of the circuit board

ultpi_10

Connect the Green, Blue, Purple wire to the Left Sensor and the Grey, White, Black cable to the Right Sensor

** Note some sensors have the pins in order 5V, Signal, Gnd; other have them in order Signal, 5V, Gnd – make sure you know which wire colour is connected to which.

step04

Connect the sensors to the RoboHAT

  • Left sensor to Pin 29 (marked x29 or #05)
  • Right sensor to Pin 13 (marked x13 or #27)

 

4. Connecting the Pan/Tilt Assembly

ultpi_12

This is now supplied fully assembled with the Initio Ultimate kit. If you have an unassembled one, then please visit the assembly instructions here (opens in new window)

Take 4 of the 2.0x6PB screws (these are the smallest ones in the packet and there are 6 of them)

ultpi_13

Screw the base of the pan/tilt assembly to the upper plate in the position shown

Rotate the pan/tilt carefully left and right to access the screw holes

step05

Connect the Pan servo (bottom servo) to Pin 22 (marked x22 or #25)

Connect the Tilt servo (upper servo) to Pin 18 (marked x18 or #24)

Note the colours of the servo wires and ensure they are connected correctly:

  • Black: Gnd
  • Red: 5V
  • Orange or White: Signal

 

5. Connecting the Ultrasonic Sensor

NOTE: More recent kits use a specially purchased ultrasonic sensor which has the connection pins at the front, instead of at the rear as shown below. If you have one of these, then simply use 2 small screws (included) to fit the sensor securely to the mounting plate. If your connection pins are at the back, please follow the instructions below. The wiring is the same in either case.

ultpi_15

For this you will need the mounting plate, saddle clamp and the final 2 of the 2.0x6PB screws used in step 4

ultpi_16

Push the 4-way 30cm female-female cable that you made in Step 3 onto the top of the ultrasonic sensor:

  • Brown: Gnd
  • Red: Echo
  • Orange: Trig or Ping
  • Yellow: 5V or VCC

ultpi_17

Screw the saddle clamp over the cable terminals as shown above

ultpi_18

Clip the whole assembly to the front of the Pan/Tilt assembly as shown above

Note that you can purchase additional clip-on mounts so you could mount a camera on one and simply clip it off to change from Ultrasonic to Camera

step06

Connect the other end of the cable into the ultrasonic pins located between the 2 motor terminals

Ensure that Brown is Gnd, and they are in the order as shown

 

The main build of your Ultimate Initio Kit for the Raspberry Pi is now complete.

 

6. Connecting the Wheel Sensors (Optional)

Note that the wheel sensors require additional code to operate properly that is not included in the python library.

It is recommended that you do not fit these until you are familiar with the operation of the rest of the robot.

If you want to fit them, use Pins 15 and 16 (marked x15, x16 or #22, #23)

For each Wheel Sensor, connect:

  • Black to Gnd
  • Red to 5V
  • Orange or Brown to the selected pin (in fact, each wheel has 2 sensors that are slightly out of phase so you can get direction of travel from them, but you will then need 2 pins for each sensor)
  • DO NOT connect the sensor wires directly to GPIO pins on the Raspberry Pi as they are 5V signals. Always use beffered inputs as on the RoboHAT

It is recommended to leave the wheel sensor cables unconnected to start with

RoboHAT – Robotics Controller for Raspberry Pi

Links for Various Resources for the 4tronix RoboHAT

rh09

 

See the bottom of this page for software library and downloads.

 Useful Links

Know your RoboHAT

rh12a

Clockwise from top left:

  • 2-way screw terminal for DC Motor 1 (left motor if using the Python library)
  • EEPROM containing the HAT information for the device tree
  • DRV8833 motor driver chip
  • 2-way screw terminal for DC Motor 2 (right motor)
  • 4-pin male connector for the Ultrasonic distance sensor (HC-SR04)
  • 6-pin female connector for the I2C breakout. This is the standard header used on all 4tronix controller boards
  • 4 x 3-way (GVS) inputs. These accept 3-5V input signals and are converted to the 3.3V logic required for the Raspberry Pi GPIO pins. They are labelled with both pin numbers and Broadcom GPIO numbers
  • Blue Power indicator LED
  • Jumper to select power input method for the motor driver. In most cases this should be to the left so that a single set of batteries can be used to power the Raspberry Pi and the motors. If you want a separate power supply for the motors, then move this jumper to the right and connect the separate motor power to the 2-pin screw terminal
  • 2-pin screw terminal for optional separate motor power
  • DC Jack for the main power input. This is the input from your (typically) 7.2V battery pack and is used to create the 5V for the Raspberry Pi and to drive the motors directly (if motor power jumper is to the left)
  • 6 x 3-way (GVS) outputs. These provide a 5V driven output from the Raspberry Pi GPIO pins. They are labelled with both pin numbers and Broadcom GPIO numbers

 

Pin Assignments

RoboHAT signals are mapped directly to individual GPIO pins as follows:

Description

In/Out

J5 Pin Number

Broadcom Number

1 Motor1 A

Out

36

16

2 Motor1 B

Out

35

19

3 Motor2 A

Out

33

13

4 Motor2 B

Out

32

12

5 Ultrasonic

In/Out

38

20

6 Input 0

In

7

4

7 Input 1

In

11

17

8 Input 2

In

29

5

9 Input 3

In

13

27

10 Input 4

In

15

22

11 Input 5

In

16

23

12 Output 0

Out

18

24

13 Output 1

Out

22

25

14 Output 2

Out

12

18

15 Output 3

Out

31

6

 

Python Software

To download the library and example programs from the internet, you can use the following commands from your Raspberry Pi in the home folder. (open LXTerminal from desktop):

  • wget http://4tronix.co.uk/robohat.sh -O robohat.sh
  • bash robohat.sh

 

Files included

  • robohat.py This is the python library module, see the first few lines of the library for listing of all the exposed functions for controlling motors, LEDs and reading sensors
  • motorTest.py – cycles through various motor directions
  • motorTest2.py – use the arrow keys on your keyboard to control the direction and speed of the motors
  • motorTestRaw.py – cycles through various motors, but doesn’t use the library
  • irTest.py – check the state of the IR line and obstacle sensors sensors (assumes you have the sensors connected as shown in the Initio build instructions)
  • sonarTest.py – prints the distance using the UltraSonic sensor
  • servo.py – a very simple servo test using the RPI.GPIO PWM commands
  • servoTest.py – a more sophisticated test that uses ServoBlaster (servod) to create the timing pulses