Product Code: 48

Buying Links:          

Description

The RasPiRobot Board V3 is an expansion board designed to turn your Raspberry Pi into a robot controller! This board comes fully assembled and includes a switched-mode power supply so you can supply your Raspberry Pi from a variety of battery packs.

labelled

 

The board fits right on top of your Pi’s GPIO socket and allows for bi-directional control of both motors with an H-Bridge motor driver chip. It also allows for control of both motor’s speed independently. The board can also supply the Raspberry Pi with power using a cool and efficient switch mode power supply, allowing you to run a fully-loaded Pi and the robot from 6xAA batteries (not included!)

Features

The main features of version 3 are listed below.

  • Compatible with Raspberry Pi models 3, 2, 1, Zero, A, A+, B and B+
  • Extensive Open Source Python library with examples – download from Github
  • Supplied fully assembled – no soldering
  • Bi-directional control of two motors
  • Variable (PWM) power control. This allows you to both control the speed of the motors independently and the use of lower voltage motors than the battery pack.
  • Supplies the Raspberry Pi with power – run a fully loaded Pi and the Robot from 6 x AA batteries
  • Rangefinder header socket directly compatible with cheap HC-SR-04 ultrasonic range finders. Just plug them in
  • 5V I2C header, pin compatible with Adafruit displays
  • Two buffered open collector outputs capable of 2A each
  • Two LEDs
  • Two switch inputs
  • Screw terminals for motors and battery
  • Through headers allowing access to all GPIO pins (although the RRB3 uses many of them)

 

finished_kit copy

The RRB3 is powered from a battery pack that needs to be between 6 and 12V DC. Although using 4 x AA batteries can in theory provide 6V, actually the battery voltage will usually quickly fall below that, so it it better to use at least 6 x AA batteries, either rechargeable or regular heavy duty batteries. A 7.2V LiPo battery pack will also work just fine.

Note that you don’t need a separate power supply for the Raspberry Pi. The RRB3 will provide enough power with ease to the Raspberry Pi. However, it is perfectly OK to power your Pi over USB even while the batteries to the RRB3 are connected.

The RRB3 provides power to the motors direct from the battery pack.

 

Getting Started

On your Raspberry Pi, issue the following commands in a Terminal window:

$ cd ~
$ git clone https://github.com/simonmonk/raspirobotboard3.git
$ cd raspirobotboard3/python
$ sudo python setup.py install

Attach the RRB3 to your Raspberry Pi. You do not need to attach batteries, motors or anything else to the RRB3 just yet. For now you can just power it through the Pi’s normal USB power connector.

Lets run some tests from the Python Console now that everything is installed. We can experiment with the RRB3, even without any motors

Open a Python console (Python2 not 3) by typing the following into a Terminal window:

$ sudo python

Then, within the python console, type the following, one line at a time:

from rrb3 import *
rr = RRB3(9, 6)
rr.set_led1(1)
rr.set_led1(0)
rr.set_led2(1)
rr.set_led2(0)
rr.sw1_closed()

The last step should display the answer “False” because no switch is attached.

If you prefer, you can use True and False in place of 1 and 0 in the examples above.

 

Documentation

The library implements a class called RRB3. This is only available for Python 2 and any Python programs that you write that use the library must be run as a super user.

To import the library and create an instance of the class, put this at the top of your Python program.

from rrb3 import *
rr = RRB3(9, 6)

The first parameter ‘9’ is the battery voltage (6 x 1.5V AA batteries). The second parameter (‘6’) is the motor voltage (6V for most low cost robot chassis motors). It is important to set these values correctly, as the library will manage the voltage supplied to the motors, to prevent them burning out or running too fast.

The rest is pretty straightforward, there are just a load of useful methods on the class that you can use.

LEDs

There are two LEDs built-in to the RaspiRobotBoard, called LED1 and LED2. Both of these can be turned on and off using the following methods:

To turn LED1 on just do:

rr.set_led1(1)

To turn it off again do:

rr.set_led1(0)

To control LED2 just do the same thing but using set_led2.

Switch Inputs

The sw1_closed() and sw2_closed() functions return true if the contacts for that switch are closed. By default, the switches are open. You can test out closing the switch by shorting the two contacts with a screwdriver.

The following test program will show you the state of each of the switch contacts.

from rrb3 import *

rr = RRB3()

while True:
    print("SW1=" + str(rr.sw1_closed()) + " SW2=" + str(rr.sw2_closed()))
    raw_input("check again")

Open Collector Outputs

The RRB3 has two high-power open collector outputs. These can each provide up to 2A and so are suitable for driving loads at the battery voltage, such as high power LEDS, IR senders, alarm bells, relays etc.

Each OC output has a pair of screw terminals. Once screw terminal is marked + and this is connected to the positive power input from the batteries. The other connection is the open collector output.

This means that you can just connect your load (say a 12V siren) across the two screw terminals and then control it as described below. If the load you are using has a positive terminal then this needs to be connected to the screw terminal marked +.

To turn the Open Collector OC1 output on just do:

rr.set_oc1(1)

To turn it off again do:

rr.set_oc1(0)

To control OC2, substitute set_oc2 in place of set_oc1 in the examples above

Motor (High Level Interface)

There are two levels of command for controlling the motors. There is a high level interface that assumes that the motors are connected to wheels on a rover. These commands are forward, reverse, left, right and stop.

rr.forward()

… will start both motors running in the same direction to move the robot rover forwards. They will continue in this direction until another command is issued.

If you want to move forward for a certain amount of time, you can specify a number of seconds as an optional first argument. If you supply a second parameter between 0 and 1 this will control the speed of the motor. This is set to 0.5 as a defaut. If you want the motors to run indefinately, but also want to control the speed, then use 0 as the first patrameter.

Some examples:

rr.forward()       # forward half speed indefinately
rr.forward(5)      # forward for 5 seconds at half speed
rr.forward(5, 1)   # forward for 5 seconds at full speed

The commands left, right and reverse all work in the same way.

The stop command stops all the motors.

Stepper Motor Interface

There RRB3 can be used to drive a single bipolar stepper motor with one coil connected to the L motor driver and the other to the R terminals.

Two commands are available to make the motor step in one direction or the other:

rr.step_forward(5, 200)  # step in one direction for 200 steps with a 5ms delay between each phase change
rr.set_reverse(5, 200)   # other direction

Motor (Low Level Interface)

The low level interface is intended for control of the motors directly. It allows you to control the speed of each motor and its direction independently.

The method for this (set_motors) takes four arguments: the left speed, left motor direction, right spped and direction.

So to set both motors going forward at full speed, you would just use the following:

rr.set_motors(1, 0, 1, 0)

.. and half speed would be:

rr.set_motors(0.5, 0, 0.5, 0)

to send the motors both at half speed in opposite directions is:

rr.set_motors(0.5, 1, 0.5, 0)

Range Finder

If you fit the RRB3 with an SR-04 ultrasonic rangefinder, then you can use the following call to measure the distance to the enarest obstacle in cm.

rr.get_distance()

Schematic

You can download the schematic here.

Absolute Maximum Ratings

Input Voltage: 6-12V (9 recommended when driving motors)

Motor Current total average: 1.2A Motor Current total peak: 3.2A (built-in thermal shutdown)

OC1 and OC2 output currents: 2A at battery voltage (unprotected)

Max current supplied to Pi (excluding motor current): 1.5A

Using I2C Displays

The I2C socket is pin compatible with these Adafruit displays:

To use these you will need to download Adafruit’s Python library for the Pi from here.

Make sure that you plug the display in the right way around. The socket pins are labelled on the RRB3, make sure they match up with the labels on the display. You can use male to female jumper wires if you wish to put the display further away or its too big.

Troubleshooting

If one of the motor channels doesn’t work.

* Try swapping the polarity of the motor leads over on the same L or R channel. Is it now the forward command that works?
* Try the motor connected directly to a a battery. Does it rotate in both directions when you swap the polarity of the leads.
* Does the Pi reset when you do ‘forward’? This could indicate a power source that’s too weak.
* Do you have a multimeter to test the outputs?
* Make sure that NONE of the motor leads are connected to GND.
* Make sure that no other software is using the GPIO pins. If this isn’t a ‘fresh from the box’ pi there is every likelihood that something else is using one of the GPIO pins you need so if you re-install Raspbian it should clear this up.

 

 

27 thoughts on “RasPiRobot Board V3

  1. admin Post author

    The board uses this driver chip: https://www.sparkfun.com/datasheets/Robotics/TB6612FNG.pdf

    The problem will be the inrush current dropping the supply voltage and crashing your Pi, unless you use very short thick leads to batteries with low internal resistance. So you would probably need to supply the Pi from a separate battery.

  2. Demian Clements

    I picked up the RasPiRobot Rover Kit recently and after rebuilding it from scratch 3 times, reformatting with a fresh OS 3 times, and testing all motors and outputs I am at a total loss as to why it isn’t driving the motors. I’ve played with the code, but I assume all git sources should work without modification assuming directions are followed.

    LEDs work, the rangefinder works, nothing seems to be awry with the Pi itself.

    None of the searches or forums I scoured through have provided me any progress on this.

    Is it possible the outputs are not functioning correctly despite registering a change in resistance when the code for engaging the motors is run?

    This is my first foray into actual electronics despite decades of computer use.

  3. admin Post author

    Hi Demian,
    The first thing to note is that the motors will only be active if the RRB3 has a battery pack attached. That is powering the RRB3 from the Pi’s USB power will allow all functions to work except the motors.

    Could this be your problem?

    Si.

  4. otto-mated

    Greetings,

    You have spec’d upto a 12v input. Can this be higher?
    From the schematic, I see you use an MP1496 step down converter. MPS spec sheet, https://www.monolithicpower.com/DesktopModules/DocumentManage/API/Document/GetDocument?id=449, shows an input range of 4.5-16v input range.

    So if one connected this to a 12v power system, such as a car, or other mobile platform, that is then recharged, then it should be able to run during recharging? Charging of such items such as lead acid, run at about 13.8v, and could peak as high as 16v.

    I’m going to speculate that MPS designed the chip for the mobile market and should be able to handle the higher recharge voltage.

    Is there anything on the board that would prevent this from being used in the 12v mobile environment?

    Another question, the MPS spec suggests this is 2A. The Raspberry Pi 3 spec, https://www.raspberrypi.org/help/faqs/#powerReqs, suggests a recommended power of 2.5A. So if you are driving motors and proximity sensor, is this driver a bit under powered for continuous operation?

    Best regards,

    ..Otto

  5. admin Post author

    Hi Otto,
    While, as you say, the switching PSU can cope with an input up to 16V, the maximum input voltage for the motor controller IC (TB6612FNG) is 15V. The large electrolytics are rated at 16V – so in short – yes you should be fine at 13-14V.
    As for the supply current to the Pi, a Pi B+ to Pi3 rarely draws more than 1A and the power to the motor comes from the unregulated side.
    Hope this helps.
    Simon.

  6. Demian Clements

    Unfortunately not, I am powering the board from the 6 batteries from the battery pack. They are fully charged and the outputs appear to be producing a sustained voltage. To limit power draw I have made sure to have nothing else connected (including the rangefinder) and am using SSH to interact with the device.

  7. Demian Clements

    Would email be better? Inclusion of photos and such?

  8. Steve MacDougall

    Which of the GPIO pins connected via the GPIO passthrough are spare and available to be used for other things. Also, is it possible to use the I2C header for other devices such as the Adafruit servo module 815.

  9. Lyle

    After entering git clone……. In terminal it asks for username for ‘https: //GitHub.com’: then a password??
    Is this normal? If so what is the username and password?

  10. Demian Clements

    Should I just junk this board as faulty or ineffective support? I have patience but this is kind of boggling.

  11. Imran

    Quick question, does the kit include an odometer?

  12. jONATHAN

    Help
    hit a snag on the first line

    SERVER CERTIFICATION FAILED

  13. Linda Taylor

    Hi Jonathan, first line of what please?

  14. jim kski

    I am using the raspirobot v3f board to control a sm-42byg011-25 1.8 degree stepper motor. It works but…
    rr.step_forward(5, 200) . yields 1 step every 5 seconds – 200 steps takes a long time. Changed 5 to .05.
    Also despite being a 1.8 per step motor, 50 steps makes a full 360 – so it’s actually moving the equivalent of 4 steps per ‘step’. Have reversed polarity, clean install etc with no change in behavior. Any hints would be most appreciated.

  15. Vic

    I’m running into the same issue as Demian. I’ve tested the motors directly, they pass. I’m able to power the Pi via the Raspirobot. I’m also able to get my the LEDs to turn on and off on the Raspirobot hat. I’m also able to get data off the ultrasonic sensor. I have not only reinstalled the IS twice, I’ve also tried a different MicroSD card and tried direct command to the board rr.forward() – all to no avail. The board will simply not respond to any code that relates to motor movement. Do I have a defective board? What was Demian’s resolution? Please help.

  16. Linda Taylor

    @Vic, its possible you have a defective board. You do have batteries fitted and the right way around? Does the Pi boot up just from battery power? I ask because the RRB3 features all work except the motors when the Pi is powered by USB. The motors will only work if there are batteries installed.

  17. Vic

    @Linda. Yes, I do have the batteries fitted and oriented properly. They are Amazon 1.2V NiMh rechargeable batteries in an 8 battery holder producing 9.6V. It powers the Pi adequately through the Raspirobot. Im hoping its not defective as it will take a while to get a replacement.

  18. Linda Taylor

    @vic does the Pi reset itself when you issue a motor command like forward?

  19. c0d3r

    Can the board be stacked on a Raspi B2+ with the Sense HAT? Either by directly stacking on the connector or by bypassing/soldering a certain few connectors?

  20. Tom Ferguson

    Hello folks:

    My robot’s neural network libs are only compatible with Python 3. The RaspiRobot v3 libs are apparently only compatible with Python 2. The RaspiRobot board provides so many advantages over the likes of L298N boards and I’d hate to take a step backward… Any chance you’re working on Python 3 libs for the RaspiRobot board?

  21. Linda Taylor

    @Tom – its a while since I looked at it and I must admit I thought it did work on Python 3. Have you tried installing it with:

    $ python3 setup.py install

    Then using it from Python 3.

  22. Graham

    Having similar problems with Python 3. I’m trying to combine
    https://github.com/nassir-malik/IOT-Pi3-Alexa-Automation

    with your excellent linear actuator tutorial from MagPi with no luck. Essentially I want to use an Echo Dot to extend or retract the linear actuator with voice commands. My code is falling over because the RRBv3 libraries dont seem compatible with Python3. I am new to Python but any tips of guidance to get this working would be really appreciated.

  23. Linda Taylor

    Hi,
    The library itself should be ok under Python3. You need to install it using:

    $ python3 setup.py install

    But you will get errors if you try and run the programs in the examples folder that use “raw_input”. I’ve made a new folder “examples_python3” with raw_input replaced with “input”.

    If you are getting any other errors running the library under Python3, please let us know.

  24. TROC

    Received my RaspiRover with the RaspiRobot V3- Everything assembled OK, great all around. Two things:

    1) In the rev I received the battery pack wedges against the motor housing and causes the wheels to ‘toe-in’, you might want to move the motor mounts out 2mm, also with the bolts in the housing the batteries on the end get pushed up slightly and might be prone to fall out if jarred.

    2) All the Python examples worked great, but I’m trying motor functions in C, and am having a hard time with it. Do you (or anyone) have a very simple motor control example in C/C++?

    Nice Rover all around, thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *