Reader small image

You're reading from  Learn Robotics Programming - Second Edition

Product typeBook
Published inFeb 2021
PublisherPackt
ISBN-139781839218804
Edition2nd Edition
Concepts
Right arrow
Author (1)
Danny Staple
Danny Staple
author image
Danny Staple

Danny Staple builds robots and gadgets as a hobbyist, makes videos about his work with robots, and attends community events such as PiWars and Arduino Day. He has been a professional Python programmer, later moving into DevOps, since 2009, and a software engineer since 2000. He has worked with embedded systems, including embedded Linux systems, throughout the majority of his career. He has been a mentor at a local CoderDojo, where he taught how to code with Python. He has run Lego Robotics clubs with Mindstorms. He has also developed Bounce!, a visual programming language targeted at teaching code using the NodeMCU IoT platform. The robots he has built with his children include TankBot, SkittleBot (now the Pi Wars robot), ArmBot, and SpiderBot.
Read more about Danny Staple

Right arrow

Chapter 6: Building Robot Basics – Wheels, Power, and Wiring

In this chapter, we will start building the robot. We will choose a robot chassis kit with wheels and motors, a motor controller, and some power for the robot, talking through the trade-offs and things to avoid. We'll see how to ensure that everything fits and then build the robot. By the end of the chapter, you will have your basic robot structure ready.

Getting the trade-offs and plan right now gives you a robot you can build upon and experiment with, ensuring you know components are suitable before buying them.

In this chapter, you will learn about the following:

  • Choosing a robot chassis kit
  • Choosing a motor controller board
  • Powering the robot
  • Test fitting the robot
  • Assembling the base
  • Connecting the motors to the Raspberry Pi

Technical requirements

For this chapter, you will require the following:

  • A computer with access to the internet.
  • The Raspberry Pi and an SD card.
  • A set of screwdrivers: M2.5, M3 Phillips, and some jeweler's screwdrivers.
  • A pair of long-nose pliers. Optionally, a set of miniature metric spanners.
  • Some electrical tape.
  • Hook and loop or Velcro tape.
  • Drawing software such as app.diagrams.net, Inkscape, Visio, or similar software.
  • Nylon standoff kits for M2.5 and M3 threads.
  • Some insulation tape.
  • Four AA batteries, charged.

    Important note

    You will be choosing and purchasing a chassis, motor controller, and battery compartment in this chapter, but do not buy them yet.

Check out the following video to see the Code in Action: https://bit.ly/3oLofCg

Choosing a robot chassis kit

The chassis, like the controller, is a fundamental decision when making a robot. Although these can be self-made using 3D printing or toy hacking, the simplest place to start is with a chassis kit. These kits contain sets of parts to start your robot build. A chassis can be changed, but it would mean rebuilding the robot.

The internet has plenty of chassis kits around – too many. So how do you choose one?

Size

Getting the size of a robot right matters too. Make too small a robot and you will need miniaturization skills for electronics; too large and you will need far more serious power handling. These are both things to avoid for a beginner:

Figure 6.1 – Robot chassis sizes compared

We can compare different robot sizes from the chassis photos in Figure 6.1:

  • Chassis 1 has a diameter of 11 cm and just about fits a controller in but is too tiny. Being so small makes it hard to build your robot. Squeezing...

Choosing a motor controller board

The next important part you'll need is a motor controller. You cannot connect a Raspberry Pi directly to DC motors, as they require different voltages and high currents that would destroy GPIO pins. Motor controller boards can also add interfaces to other devices like sensors and other motor types.

It is a vital robot component that will guide many later decisions. Much like the motors, there are some trade-offs and considerations before buying one:

Figure 6.8 – A selection of motor control boards

Figure 6.8 shows a small sample group of motor controller boards. As we compare the requirements of our motor board, we refer to the boards pictured there as examples.

Integration level

Motor controllers may only control a motor (usually 2) like the L298N, containing the barest minimum to run this chip safely. They are not designed to sit on a Raspberry Pi and must be wired into the Pi's I/O output.

Controllers...

Powering the robot

The robot needs power for all its parts. We must consider two major power systems: the power for all the digital parts, such as the Raspberry Pi and sensors, and then the power for the motors.

Motors need a separate power system for a few reasons. First, they consume far more electrical power than most other components on the robot. They may require different voltages; I've seen low-voltage, high-current motor supplies and high-voltage supplies too. The other reason that they need their own power system is that they can cause interference. They can pull enough power that other circuitry has brownouts. A brownout is when circuitry has a voltage drop that is low or long enough to get into an inconsistent or reset state. Resets can lead to SD card corruption on a Pi. Motors can also introduce electrical noise to a power line as they are used, which could cause digital parts to misbehave.

There are two primary strategies for powering a robot with motors:

...

Test fitting the robot

I recommend test fitting before actually ordering parts. The test fit helps a builder be more confident that components fit, and you'll know roughly where these parts go. This step saves you time and money later.

You can use paper and a pen for test fitting, or an app such as diagrams.net. First, I find the dimensions for all the parts. Figure 6.15 has a screenshot from Amazon showing how to spot product dimensions:

Figure 6.15 – Finding product specifications

Some information-digging is needed to find these for your parts. For each, first find a shop you can buy them at, such as Amazon, several online shops, or eBay. You can then search for or ask for information about the dimensions of each board or item. Make sure you are looking at the dimensions of the part and not its packaging:

Figure 6.16 – A battery box product drawing with dimensions

You can find diagrams like the battery box in...

Assembling the base

Assuming you bought a chassis similar to mine, you can assemble it with these steps. For a completely different chassis, I strongly recommend consulting the documentation for assembly instructions. A chassis that is very different from the recommendations here may make it harder to follow the next few chapters.

Some parts may be covered in a layer of paper (shown in Figure 6.19). This layer prevents the plastic from getting scratches and can be safely removed. You can do this by getting a nail under it or using a craft knife. It's not essential to remove it, but a robot looks better without it:

Figure 6.19 – Removing the protective backing from robot parts

With the laser-cut kits that use the yellow motors, there are two main ways the motors are attached. One type has plastic brackets, and the other has metal motor brackets. Given that you may buy kits of either style, let's look at how the kits could differ. The difference...

Connecting the motors to the Raspberry Pi

In this section, we will connect the motors to the Raspberry Pi. Once we have connected them, we can use code on the Raspberry Pi to control the motors and make the robot move. Figure 6.33 is the block diagram for the robot that we are building in this chapter. We will be using the Full Function Stepper Motor HAT as the controller board, calling it the Motor HAT for short.

This block diagram is similar to the type shown in Chapter 3, Exploring the Raspberry Pi. First, it starts with the Raspberry Pi, here in gray, as we've chosen that as our controller. Connected to the Pi is the Motor HAT, with instructions flowing from the Raspberry Pi to this board. The Motor HAT and its connections are highlighted as we are adding these parts in this chapter. As we build on this block diagram in later chapters, existing components will be in the color gray. Added components will be highlighted with red to show what is new. Finally, the two motors...

Summary

In this chapter, you've now learned how to choose the parts for a robot by reasoning and making some important design decisions. You used a simple tool to test fit these parts and see what works before buying anything. Finally, you bought the parts and built your starting robot platform.

By considering the trade-offs and test fitting again, you have gained skills for planning any hardware project, including finding dimensions on the datasheets/vendor websites, making a simple test-fit sketch, and considering how the parts will interact together. You've learned how the size of a robot affects motor and controller decisions. You've seen how to make parts easy to remove using hook and loop tape and considered other options for this.

By hooking up independent power, and connecting the motors, the robot has the hardware it will need to drive itself around without being tethered to a wall. What it doesn't yet have is any code to move with. In the next chapter...

Exercises

  • In Chapter 2, Exploring Robot Building Blocks – Code and Electronics, you created block diagrams for a different robot. Consider what chassis, power, and parts it needs. Use online vendors to find suitable parts.
  • Consider whether there is a suitable combination of Raspberry Pi hats or bonnets that fit your design. Use resources such as https://pinout.xyz to check their pin usage is compatible.
  • What power systems might be suitable for the Raspberry Pi and the output devices in your new design?
  • Are there components that may need to be removed easily? How could you approach that? Can you come up with alternatives to hook and loop tape? Keep it simple.
  • Make a test-fitting sketch for your new robot parts, checking that they fit using part dimensions.

Further reading

Please refer to the following for more information:

  • For further reading on chassis designs, consider Raspberry Pi Robotic Blueprints, Dr. Richard Grimmett, Packt Publishing. This includes modifying an RC car into a robot.
  • For more robot chassis types, the community sharing website https://www.instructables.com has many buildable examples. Some of these are very interesting and more advanced than our robot.
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Learn Robotics Programming - Second Edition
Published in: Feb 2021Publisher: PacktISBN-13: 9781839218804
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Danny Staple

Danny Staple builds robots and gadgets as a hobbyist, makes videos about his work with robots, and attends community events such as PiWars and Arduino Day. He has been a professional Python programmer, later moving into DevOps, since 2009, and a software engineer since 2000. He has worked with embedded systems, including embedded Linux systems, throughout the majority of his career. He has been a mentor at a local CoderDojo, where he taught how to code with Python. He has run Lego Robotics clubs with Mindstorms. He has also developed Bounce!, a visual programming language targeted at teaching code using the NodeMCU IoT platform. The robots he has built with his children include TankBot, SkittleBot (now the Pi Wars robot), ArmBot, and SpiderBot.
Read more about Danny Staple