ebook img

Robotics at Home with Raspberry Pi Pico: Build autonomous robots with the versatile low-cost Raspberry Pi Pico controller and Python PDF

401 Pages·2023·35.892 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Robotics at Home with Raspberry Pi Pico: Build autonomous robots with the versatile low-cost Raspberry Pi Pico controller and Python

Robotics at Home with Raspberry Pi Pico Build autonomous robots with the versatile low-cost Raspberry Pi Pico controller and Python Danny Staple BIRMINGHAM—MUMBAI Robotics at Home with Raspberry Pi Pico Copyright © 2023 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Group Product Manager: Rahul Nair Publishing Product Manager: Rahul Nair Content Development Editor: Sujata Tripathi Technical Editor: Rajat Sharma Copy Editor: Safis Editing Project Coordinator: Sean Lobo Proofreader: Safis Editing Indexer: Pratik Shirodkar Production Designer: Nilesh Mohite Senior Marketing Coordinator: Nimisha Dua Marketing Coordinator: Gaurav Christian First published: March 2023 Production reference: 1170223 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-80324-607-9 www.packtpub.com To my amazing wife, Carol, who has supported all my robotics experiments with love, inspiration, and tolerance of a living room filled with robots. To my children, Helena and Jonathan, for all their ideas and enthusiasm and for encouraging me to take a break and play with them sometimes! – Danny Staple Contributors About the author Danny Staple is a robot builder and programmer. He has been a professional software engineer since 2000, uses Python professionally, and regularly contributes to open source projects. Danny has been building robots at home since 2004 and has a cupboard full of projects, including robots with wheels, cameras, tank tracks, legs, and arms, made from plastic, cardboard, metal, kits, lunchboxes, and modified toys. Danny authored Learn Robotics Programming, published in 2021 by Packt Publishing, and has written magazine articles for The MagPi. He runs the robotics YouTube channel Orionrobots and brings his robots to events such as Pi Wars and Arduino Day. Danny also mentors at CoderDojo KU, where he shows kids how to program in Python and has run Lego robotics clubs. I would like to thank the Pi Wars and Adafruit communities for answering my tricky questions, Mike Moncrieffe for checking diagrams for me, and my review team for the great feedback throughout this book. About the reviewer Leo White is a professional software engineer and a graduate of the University of Kent. His interests include electronics, 3D printing, and robotics. He first started programming on the Commodore 64 and later wrote several applications for the Acorn Archimedes. He currently programs set-top boxes for his day job. Utilizing the Raspberry Pi as a foundation, he has mechanized children’s toys and driven robot arms, blogging about his experiences and processes along the way. He has given presentations at Raspberry Jams and entered a variety of robots in the Pi Wars competition. Table of Contents Preface xv Part 1: The Basics – Preparing for Robotics with Raspberry Pi Pico 1 Planning a Robot with Raspberry Pi Pico 3 Technical requirements 3 Test fitting a Raspberry Pi What is Raspberry Pi Pico, and Pico robot 21 why is it suitable for robotics? 4 Creating your first test-fit part 21 A microcontroller that runs Python 4 Motors 22 Raspberry Pi Pico’s interfaces for Power systems 23 sensors and devices 7 Creating a rough chassis 24 Arranging the test-fit parts 25 What is CircuitPython? 10 A recommended shopping list Planning a Raspberry Pi Pico for robot basics 26 robot 11 Robot parts and where to find them 26 An overview of robot planning 12 The robot workshop and makerspaces 28 A note on trade-offs 14 Choosing a robot chassis 15 Summary 30 Choosing the power systems 16 Exercises 30 Pin usage 20 Further reading 30 viii Table of Contents 2 Preparing Raspberry Pi Pico 31 Technical requirements 31 Lighting the Pico LED with CircuitPython 35 Getting CircuitPython onto Blinking the LED with code 36 Raspberry Pi Pico 32 Soldering headers to Raspberry Preparing the CircuitPython Pi Pico 38 library for Pico 33 Summary 43 Coding on Pico – first steps 33 Exercises 43 Downloading the Mu editor 34 Further reading 44 3 Designing a Robot Chassis in FreeCAD 45 Technical requirements 45 Modeling chassis parts from Introducing FreeCAD 46 sketches 68 The FreeCAD screen 46 Modeling the chassis plate 68 Selecting workbenches 47 Modeling the other parts 70 FreeCAD settings 48 Troubleshooting the model 72 Modeling the caster in 3D 73 Making robot chassis sketches in FreeCAD 50 Making FreeCAD technical drawings 75 Preparing the document 51 Sketching the chassis outline 52 Setting up the page 75 Creating the upper parts main sketch 58 Adding parts to the drawing 76 Sketching the motor holes 63 Preparing the drawing for print 77 Designing the caster placement 67 Summary 79 Exercises 79 Further reading 80 4 Building a Robot around Pico 81 Technical requirements 81 Transferring CAD measurements to a plastic sheet 83 Cutting styrene parts 83 Cutting the plastic sheet 85 Finishing and sanding the chassis plate 87 Table of Contents ix Assembling a robot chassis 90 Adding the batteries 96 Attaching the caster and battery box 90 Wiring in the motors and encoders 97 Attaching the motors and wheels 92 Powering the robot up 99 Wiring a Raspberry Pi Pico robot 93 Summary 100 Wiring Pico and the motor controller Exercises 100 into the breadboard 93 Further reading 100 5 Driving Motors with Raspberry Pi Pico 101 Technical requirements 101 Turning while moving 114 Driving forward and back 102 Driving along a planned path 115 Testing each motor with CircuitPython 102 Putting line and turn moves together 115 Driving wheels in a straight line 106 The flaw with driving this way 117 Steering with two motors 108 Summary 118 An introduction to pulse width Exercises 118 modulation speed control 110 Further reading 118 Driving fast and slow 111 Part 2: Interfacing Raspberry Pi Pico with Simple Sensors and Outputs 6 Measuring Movement with Encoders on Raspberry Pi Pico 121 Technical requirements 121 Examining the wiring 125 About encoders and odometry 122 Programming Raspberry Pi Absolute and relative sensing 122 Pico PIO 126 Types of encoders 122 Introduction to PIO programming 126 Encoder pulse data 123 Introducing PIOASM 128 Wiring in encoders on a Detecting input with PIO 129 Raspberry Pi Pico robot 124 PIO instructions and registers 132 Making a counter with PIO 136 Examining the motors 124

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.