PHY 235 Robotics Workshop Course Introduction
Dec 25, 2015
PHY 235 Robotics Workshop
Course Introduction
Learning Objectives
• Understand and build autonomous robotic systems.• Apply concepts of computer science to robot system
programming.• Understand basics of electronic circuits used in
robot sensors.• Develop teamwork through robot competitions.• Develop an engineering attitude toward the solution
of robotic tasks.
Class Web Site - Syllabus
• All resources are located on the course web site http://www.gac.edu/~hvidsten/courses/robotics.html
• Course Syllabus – On Handouts and on web site– Discuss
Team Selection
• Teams should have members with the following skill sets: – Programming Experience– Electronics or Electrical Experience– Lego Experience (gearing, structure)
• Each team will have – Lab table and a computer– Boe-bot kit – Kit of Lego parts and other tools
Team Selection
Skills Inventory CardsTeam LeadersChoose Teams
Choose WorkstationPick Up Course Kits
(Boe-Bot, Legos, Tools)
Today
• Introduction (General Background)
• ZX24 Programming (Z-Basic)
• Boe-bot Construction
Any automatically operated machine that replaces human effort, though it may not look much like a human being or function in a humanlike manner.
The term comes from the play R.U.R. by Karel Capek (1920). Major developments in microelectronics and computer technology since the 1960s have led to significant advances in robotics. Advanced, high-performance robots are used today in automobile manufacturing and aircraft assembly, and electronics firms use robotic devices together with other computerized instruments to sort or test finished products.
© 2002 Encyclopedia Britannica, Inc.
What is a Robot?
What is a Robot?
A robot is a reprogrammable, multifunctional manipulator designed to move material, parts, tools, or specialized devices through variable programmed motions for the performance of a variety of tasks. (Robot Institute of America)
Alternate Definition: A robot is a one-armed, blind idiot with limited memory and which cannot speak, see, or hear !!
Robots for Hazardous Duty
Humanoid Robots
“Hollywood” Robots
“Hollywood” Robots
Robby – Forbidden Planet Terminator
R2D2
Robots in Education
•The next set of slides is from the John Hopkins University Engineering Innovation Center.
•They are used in the Center’s What is Engineering Course
•Web link - http://www.jhu.edu/virtlab/course-info/ei/
Robotics Overview
What are robots good at?• What is hard for humans is easy for robots.
– Doing repetitive tasks.– Being in continuous operation.– Doing complicated calculations.
• What is easy for a human is hard for robots. – Reasoning.– Adapting to new situations.– Integrating multiple sensors.– Resolving conflicting data.– Creativity.
Robots vs Humans
What subsystems make up a robot?
• Robot Platform– Stationary base– Mobile– Actuators
• Sensors• Control• Power
Robert Stengel, Princeton Univ.
What subsystems make up a robot?
Action – physically do something.
• Manipulators– Pneumatic (air)– Hydraulic (liquid)– Electric
• Motors– Analog (continuous)– Stepping (discrete increments)
• Gears, belts, screws, levers • Displays
Robotic Actions - Actuators
Mobility
• Legs• Wheels• Tracks• Crawls
Mobile Robots
What sensors might robots have?
• Optical– Laser / radar– Visible/Infrared Light
• Switch/Touch• Temperature• Motion & Accelerometer• Acoustic
– Ultrasonic Distance
Robot Sensors
• Open loop, i.e., no feedback, deterministic – Robot carries out preset Instructions– Robot obeys unchangeable Rules
• Closed loop, i.e., feedback from sensors– Robot can Learn – Robot can Adapt
• Here ends our brief overview of Robotics• Next: What will we need to create and run our
robots?
Control - the Brain
What do we need to know to build robots?
• Electronics – For sensors, drive and control systems.
• Programming – To instruct the robot what actions to take and how to respond to its environment.
• Mechanical – Construction of the chassis, drive train, mechanical actuators, sensors.
Knowledge Base for Introduction to Robotics
We will develop our knowledge base (electronics, sensing, control and programming) using the Boe-Bot.
www.parallax.com
Week 1: Basic Robotics Principles using the Boe-Bot
• If you are using your own laptop do the following: • Download the ZBasic IDE (Integrated Development
Environment) Software from the class website and install it at your lab station. (Windows Software)– File “zbasic-setup_3-1-2.exe: on your laptops
• Download and install the USB drivers (if needed)– File “USBDriverInstallerV2.04.16”
Today – Basic Programming
• Log into the workstations and start up the ZBasic IDE
Today – Basic Programming
• Build robot structure from Legos
• Write programs for the ZX24A processor
• Construct sensors
• Develop Strategy for competition – Test, Test, Test!
Weeks 2-4: Lego Robots with Boe-Bot brain
• Locate the usb to serial converter in your Boe-Bot box. • Plug the mini-usb end of the usb cable (from
your Boe-bot kit) into the converter.
Boe-Bot -> Computer
• Plug the serial (DB-9) metal end of the converter into the connector on the Boe-bot
board.
Boe-Bot -> Computer
• Plug the free end of the usb cord into one of your computer’s open usb ports.• In the ZBasic IDE window, Choose “Options”-> “Serial Port Options”
Boe-Bot -> Computer
• In the pull-down list, find the port for your usb connection• In the “Serial Port “Management” panel click “Open COM X” to open the port. (X is the port number)OR, just click “OK”
Boe-Bot -> Computer
• We will use 5 NiMH rechargeable AA batteries in the battery holder of the green Board of Education (BOE) board. You will need to use the Boe-boost module to add the 5th battery. This module should be in your Boe-bot kit.
• We need to use 5 batteries as each is 1.2 Volts and the Boe-bot runs best with a 6 volt supply. • Non-rechargeable batteries are 1.5 volts – we would need only 4 of them.
Boe-Bot Power
• Install a battery in the BOE-Boost battery holder with the polarity indicated in the holder:
• Install four batteries in the BOE-Bot battery holder: two of them all the way, and two only partially, with the positive terminals resting on the edge of the holder, as shown:
Boe-Bot Power
• Position the BOE-Boost tabs against the two partially-installed cells, as shown:
Boe-Bot Power
• Slide the BOE-Boost tabs behind the partially-installed batteries’ positive terminals and press them against the spring pressure until they can slide into the BOE-Bot’s battery holder. These tabs
should now slip into place between the battery terminals and the battery holder contacts. Push the BOE-Boost the rest of the way in until it snaps into place.
Boe-Bot Power
• On the BOE (Board of Education circuit board), place the power switch in programming mode 1. The green power light should come on.
Boe-Bot Power
• In the IDE Choose “Options”-> “Device Options” • Click “Identify Device”. • On the 3rd line you should see “Connected Device: ZX-24a”
Boe-Bot -> Computer
• We are now ready to write our first program. • To create a new project (program) choose
“Project->New” in the ZBasic IDE. • Name your project and save it somewhere in your
account. Note that the ZBasic IDE creates a “stub” for your code.
Boe-Bot -> Computer
• All ZBasic programs comprise, at a minimum, one subroutine. That one required subroutine must be named Main() and it must be defined as taking no parameters.
• For our first program, type in the code on the following slide. Note how the ZBasic IDE color codes keywords.
• This program blinks a pair of LED’s on the ZBasic cpu chip.
Boe-Bot -> Computer
Const redLED as Byte = 25 ' define the pin for the red LEDConst grnLED as Byte = 26 ' define the pin for the green LEDDim i as Integer 'define a variable i
Sub Main() ' alternately blink the LEDsFor i = 1 to 20
' turn on the red LED for one half secondCall PutPin(redLed, 0)Call Delay(0.5)Call PutPin(redLed, 1)' turn on the green LED for one half secondCall PutPin(grnLed, 0)Call Delay(0.5) ' delay 0.5 secondsCall PutPin(grnLed, 1)
NextEnd Sub
Our First Program
• Next, choose “Project->Go” in the ZBasic IDE. The IDE will download the program through the USB cable to the ZX-24a cpu on the Boe-bot board and then run the program.
• You should see the Green and Red LED’s on the Zx-24a chip blink on and off 10 times.
Our First Program
• Now, Disconnect the usb cord from the Boe-bot and hit the reset button. The Boe-bot will run the program in its memory – which is the one we just down-loaded.
• Note: Whenever the Boe-bot is powered on, or when the reset button is pressed, the microcontroller will run the program in its memory.
Our First Program
• “A microcontroller is a programmable device that can read inputs from external devices, analyze the input, and then output control signals to external devices.” (www.zbasic.net)
• Microcontrollers can be found in digital wristwatches, cell phones, calculators, microwaves, cars, etc.
Microcontrollers
• The ZX-24a microcontroller is programmed using ZBasic, a version of an old, but still very useful, computer language called BASIC.
• The fundamental structure in a ZBasic program is that of a subroutine.
ZBasic “Basics”
• A subroutine is a block of code that begins with the keyword Sub and ends with the keywords End Sub.
Sub Name(parameter list) statementsEnd Sub
• Example – Here is a subroutine to blink an LED Sub Blink(ByVal pin as Byte)
' turn on the LED connected to the specified pin for one half secondCall PutPin(pin, 0)Call Delay(0.5)Call PutPin(pin, 1)
End Sub
ZBasic “Basics” - Subroutines
Const redLED as Byte = 25 ' define the pin for the red LEDConst grnLED as Byte = 26 ' define the pin for the green LEDDim i as Integer 'define a variable i
Sub Main() ' alternately blink the LEDsFor i = 1 to 20
' turn on the red LED for one half secondCall Blink(redLED)' turn on the green LED for one half secondCall Blink(grnLED)
NextEnd Sub
Sub Blink(ByVal pin as Byte)' turn on the LED connected to the specified pin for one half secondCall PutPin(pin, 0)Call Delay(0.5)Call PutPin(pin, 1)End Sub
Our First Program – Ver 2
• Create a new project and type in this new version of our first program.
• Reconnect the Boe-bot board to the computer and download and run this new version.
• Note how the use of a subroutine makes our program simpler in structure.
• Now let’s look at specific parts of this code.
Our First Program – Ver 2
• The first part of our program includes a set of definitions. These include constants and variables. These two quantities can be any of the types described in the table below.
• Constants are defined using the Const keyword.• Variables are defined using the Dim keyword.
ZBasic “Basics” - Definitions
• A microcontroller reads input from external devices and sends output control signals via physical connections called I/O pins.
• On the socket for the ZX-24a chip we see these pins labeled “P0” through “P15”.
ZBasic “Basics” – I/O Pins
• The socket for the ZX-24a chip has its pins numbered with the pin labeled “Sout” being pin 1 and then increasing around the chip until the pin labeled “Vn” which is pin 24.
• The I/O pin labeled “P0” is actually pin 5 on the socket. When programming, we use the actual pin number, not the label number. • P0 -> Byte = 5, P1 -> Byte = 6, …, P15 ->Byte = 20
ZBasic “Basics” – I/O Pin Numbering
• Example: Const p12 as Byte = 17 Call PutPin(p12, 1)
• This code defines a constant labeled “p12” as the byte value 17 and then calls a built-in subroutine named “PutPin” with two parameters: “p12” and “1”.
• “PutPin” outputs a value of 1 (high voltage) on the actual socket pin numbered 17. Note that this is IO pin labeled “P12” on the ZX-24a socket.
• Note: There are two extra IO pins -- pins 25 and 26. These are connected to the on-board red and green LED’s.
ZBasic “Basics” – I/O Pin Numbering
• This is a very brief introduction to programming using ZBasic. As we progress to more and more complex code, it will be important to use two documents which you can download from the class website:– ZBasic Language Reference Manual
• Basic details, syntax of the language
– ZBasic System Library Reference Manual• Listing and functionality of all built-in subroutines
ZBasic “Basics” – Reference
• Access the Boe-bot reference manual from the class website. (Robotics with the Boe-Bot – Student Guide)
• Construct the Boe-bot chassis and drive wheels as described in Chapter 3, Activity 1 (pp. 91-101).
• Create a new Project and type in the sample program on the next slide.
Homework - Boe-Bot Construction
const p12 as byte = 17 'pin 12 referenceconst p13 as byte = 18 'pin 13 referenceconst servoStop as single = 0.0015 'pulse width that should stop servo motorconst servoMove as single = 0.0020 'pulse width that should start servo motorDim i as Integer 'define a variable i
Sub Main() for i = 1 To 40 call pulseout(p12, servoStop, 1) 'send out a pulse on pin12 of length 1.5 ms call pulseout(p13, servoMove, 1) 'send out a pulse on pin12 of length 2.0ms call delay(0.02) 'delay for 20 msec for servo to reset nextEnd Sub
Boe-Bot Servo Example
• Next, put the switch on the Boe-Bot into programming position 2 (engages power to servos) and choose “Project->Go”. (Hold the Boe-bot so it will not run off the table)
• One of the Boe-bot servos should be stopped (or nearly stopped)and one should be moving.
• Read sections 11.8 and 11.9 in the text Introduction to Servomotor Programming on the class website. This is written for the BX24 chip, but also applies to our chip.
Boe-Bot Servo Example
• Discuss the reading with your team. Make sure all members understand servo operation.
• For your Boe-bot determine the value of the pulse-width (servoStop) that will make each servo completely stop. (Vary servoStop by a small amount – e.g. change the value to .00148 or .00151). If the values for the left and right servos are not the same, you will need two variables – one for each servo.
Team Tasks
• Find pulse-width values for the two servos that can be used to move the Boe-bot forward. (Be careful to hold the Boe-bot up when you test so that the usb connection is not damaged)
• Create two sub-routines, called “forward” and “reverse” that will cause the Boe-bot to move forward and backward. Test your code.
Team Tasks
• Create new sub-routines “turn-right” and “turn-left” that cause the Boe-bot to turn as described.
• Create new projects that will:– Have Boe-bot drive in a circle– Have Boe-bot drive in a square– Have Boe-bot follow some other path
• Note: It may be helpful to look at the sections following 11.9 in Introduction to Servomotor Programming
Team Tasks
• When you are done, it is important to: – Turn the programming switch to 0 (off) on the
Boe-bot. – Disconnect the USB cord from the computer.– Remove your batteries and place them in the
chargers.
• It will be helpful for your team to come to the lab this afternoon to further experiment with basic Boe-bot programming.
Clean-up