PHY 235 Robotics Workshop Course Introduction Learning Objectives

PHY 235 Robotics Workshop Course Introduction

Learning Objectives • Understand 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. htm l • 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 Cards Team Leaders Choose Teams Choose Workstation Pick Up Course Kits (Boe-Bot, Legos, Tools)

Today • Introduction (General Background) • ZX 24 Programming (Z-Basic) • Boe-bot Construction

What is a Robot? 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 1960 s 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? 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 R 2 D 2

Robots in Education

Robotics Overview • 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/

What. Robots are robots good at? vs Humans • 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.

What makeup upa a Whatsubsystems make robot? • Robot Platform – Stationary base – Mobile – Actuators • Sensors • Control • Power Robert Stengel, Princeton Univ.

Robotic Actions do - Actuators Action – physically something. • Manipulators – Pneumatic (air) – Hydraulic (liquid) – Electric • Motors – Analog (continuous) – Stepping (discrete increments) • Gears, belts, screws, levers • Displays

Mobile Robots Mobility • • Legs Wheels Tracks Crawls

What sensors robots have? Robotmight Sensors • Optical – Laser / radar – Visible/Infrared Light • • Switch/Touch Temperature Motion & Accelerometer Acoustic – Ultrasonic Distance

Control - the Brain • 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?

Knowledge Base for Introduction to Robotics 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.

Week 1: Basic Robotics Principles using the Boe-Bot We will develop our knowledge base (electronics, sensing, control and programming) using the Boe-Bot. www. parallax. com

Today – Basic Programming • 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 “USBDriver. Installer. V 2. 04. 16”

Today – Basic Programming • Log into the workstations and start up the ZBasic IDE

Weeks 2 -4: Lego Robots with Boe-Bot brain • Build robot structure from Legos • Write programs for the ZX 24 A processor • Construct sensors • Develop Strategy for competition – Test, Test!


Boe-Bot -> Computer • 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 Power • We will use 5 Ni. MH 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 5 th 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 partiallyinstalled 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 -> Computer • In the IDE Choose “Options”-> “Device Options” • Click “Identify Device”. • On the 3 rd line you should see “Connected Device: ZX-24 a”

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.

Our First Program Const red. LED as Byte = 25 Const grn. LED as Byte = 26 Dim i as Integer ' define the pin for the red LED ' define the pin for the green LED 'define a variable i Sub Main() ' alternately blink the LEDs For i = 1 to 20 ' turn on the red LED for one half second Call Put. Pin(red. Led, 0) Call Delay(0. 5) Call Put. Pin(red. Led, 1) ' turn on the green LED for one half second Call Put. Pin(grn. Led, 0) Call Delay(0. 5) ' delay 0. 5 seconds Call Put. Pin(grn. Led, 1) Next End 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-24 a cpu on the Boebot board and then run the program. • You should see the Green and Red LED’s on the Zx-24 a chip blink on and off 10 times.

Our First Program • Now, Disconnect the usb cord from the Boebot 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.

Microcontrollers • “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.

ZBasic “Basics” • The ZX-24 a 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” - Subroutines • A subroutine is a block of code that begins with the keyword Sub and ends with the keywords End Sub Name(parameter list) statements End Sub • Example – Here is a subroutine to blink an LED Sub Blink(By. Val pin as Byte) ' turn on the LED connected to the specified pin for one half second Call Put. Pin(pin, 0) Call Delay(0. 5) Call Put. Pin(pin, 1) End Sub

Our First Program – Ver 2 Const red. LED as Byte = 25 ' define the pin for the red LED Const grn. LED as Byte = 26 ' define the pin for the green LED Dim i as Integer 'define a variable i Sub Main() ' alternately blink the LEDs For i = 1 to 20 ' turn on the red LED for one half second Call Blink(red. LED) ' turn on the green LED for one half second Call Blink(grn. LED) Next End Sub Blink(By. Val pin as Byte) ' turn on the LED connected to the specified pin for one half second Call Put. Pin(pin, 0) Call Delay(0. 5) Call Put. Pin(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.

ZBasic “Basics” - Definitions • 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” – I/O Pins • 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 24 a chip we see these pins labeled “P 0” through “P 15”.

ZBasic “Basics” – I/O Pin Numbering • The socket for the ZX-24 a 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 “P 0” is actually pin 5 on the socket. When programming, we use the actual pin number, not the label number. • P 0 -> Byte = 5, P 1 -> Byte = 6, …, P 15 ->Byte = 20

ZBasic “Basics” – I/O Pin Numbering • Example: Const p 12 as Byte = 17 Call Put. Pin(p 12, 1) • This code defines a constant labeled “p 12” as the byte value 17 and then calls a built-in subroutine named “Put. Pin” with two parameters: “p 12” and “ 1”. • “Put. Pin” outputs a value of 1 (high voltage) on the actual socket pin numbered 17. Note that this is IO pin labeled “P 12” on the ZX-24 a 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” – Reference • 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

Homework - Boe-Bot Construction • 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.

Boe-Bot Servo Example const p 12 as byte = 17 const p 13 as byte = 18 const servo. Stop as single = 0. 0015 const servo. Move as single = 0. 0020 Dim i as Integer Sub Main() for i = 1 To 40 call pulseout(p 12, servo. Stop, 1) call pulseout(p 13, servo. Move, 1) call delay(0. 02) next End Sub 'pin 12 reference 'pin 13 reference 'pulse width that should stop servo motor 'pulse width that should start servo motor 'define a variable i 'send out a pulse on pin 12 of length 1. 5 ms 'send out a pulse on pin 12 of length 2. 0 ms 'delay for 20 msec for servo to reset

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 Boebot 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 BX 24 chip, but also applies to our chip.

Team Tasks • Discuss the reading with your team. Make sure all members understand servo operation. • For your Boe-bot determine the value of the pulse-width (servo. Stop) that will make each servo completely stop. (Vary servo. Stop 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

Clean-up • 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.
- Slides: 58