robotics demo chris odom [email protected] george school, newtown, pa

48
Robotics Demo Chris Odom www.basicxandrobotics.com [email protected] George School, Newtown, PA

Upload: cameron-alexander

Post on 17-Dec-2015

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Robotics DemoChris Odom

www.basicxandrobotics.com

[email protected]

George School, Newtown, PA

Page 2: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

The BX-24 microcontroller• The BX-24 is a 24-pin

microcontroller made by NetMedia

• Small and Fast

• Floating-point math

• 16 I/O pins (8 built-in A-to-D converters)

• EEPROM storage• About $45• Programmed with BasicX, a high-level language

compatible with Visual Basic. BasicX is free.

Page 3: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Exciting TechnologyThe BX-24 can be used to:

• Autonomously control nearly any mechanical device such as robots, vehicles, airplanes, vacuum cleaners, etc.

• Output electrical signals to (thereby controlling) motors, speakers, LCD panels, lights, LEDs, etc.

• Read data such as temperature, light intensity, magnetic field strength, force, distance, flame (IR), conductivity, etc.

• Record data in space, underwater, your back yard

Page 4: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Personal Computer vs BX-24

The PC:

• Is faster

• Has more computing power

• Is larger, heavier and therefore more stationary

• Is more expensive

• Is dependent on AC power

• Is better suited for gaming and desktop programming

Page 5: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Why BX-24?

The BX24:

• Is smaller and therefore transportable

• Is cheaper

• Has no moving parts: data a programs are burned in to the chip. Can be removed from power

• Runs on a 9V battery

• Is better suited for remote and mobile applications

• Students love it!

Page 6: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

The Robodyssey Motherboard• Robodyssey Systems in

Trenton, NJ designed and sells the RAMB

• Makes programming the BX-24 easy

• About $45

• Could do it yourself:

Page 7: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Walking RobotsWheeled Robots (My students use the Mouse)

Expressive Robots

(ESRA)Kits

Page 8: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Just Toys?• Fun but not a toy• Learn a real computer language• Learn logic skills• Learn electronics• Research universities are now using the BX-24 to

teach computer science• Microcontrollers allow the average person to do

what only NASA could do just a few years ago• Springboards into other “serious” fields such as

electronics, aerospace engineering, manufacturing, automotive and medical applications, etc.

Page 9: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

“Computers never do what you want them to do, only what you tell them to do.”

Brian Patton

Vice President, Robodyssey Systems

Page 10: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

BasicX and Robotics• Textbook written for novices and

beginners ages 12 and up (especially for high school and college)

• Only one of its kind• A teacher by your side to walk you

through material• Over 300 problems and 400 full

color images. 365 pages.• A complete curriculum• $44.95 textbook• Who has it?

Page 11: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

A Quick Tutorial• Rather than just a Show-and-Tell,

let me explain some of the basics of computer and microcontroller programming

• Very abbreviated tour of the book• Let’s start by learning how the

BX-24 outputs data…

Page 12: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Creating a Program• The program is written on the PC

in the BasicX language • BasicX can be downloaded for free

at www.basicx.com• The code is saved as a simple text

file. (New programs start with a blank page.)

• When the program is ready to run, simply press one button to compile the program into a language the BX-24 can understand

• The compiled program is sent to the BX-24 via a serial cable

Page 13: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

OUTPUT:Printing data to the PC

Let’s write a short program that will display a simple message to the computer screen. The text message will be sent back to the PC via the serial cable. Here’s the code:

Debug.Print "Hello, my name is Chris."

Page 14: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

OUTPUT:Printing data to the PC

Here’s what the program’s output looks like on the PC’s monitor:

Page 15: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

OUTPUT:Printing data to the LCD

With a small LCD screen, we can print messages and data without the need of a computer monitor. This allows us to be mobile! The code to do this is easy, too:

Call InitLCDCall Display2Line("Hello", "My name is Chris")

Page 16: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

OUTPUT:Printing data to the LCD

Here’s what the program’s output looks like on the LCD screen:

Page 17: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Loops

• Almost all computer problems use structures called “loops” to repeatedly perform a task or tasks.

• Do-Loops can run forever.• For-to-Next loops run for a finite

number of times.

Page 18: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Do-Loops

DoDebug.Print "I can't stop!!!"

Loop

Page 19: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

For-To-Next Loops

Dim i as IntegerDebug.Print "I can count fast!"For i = 1 to 5

Debug.Print CStr(i)Next

Page 20: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Delays

Sometimes, the computer performs its tasks too quickly. We can use a Delay command to slow it down:

Dim i as IntegerDebug.Print "Countdown...."For i = 5 to 1 Step -1

Debug.Print CStr(i)Call Delay(1.0)

NextDebug.Print "Lift Off!"

Page 21: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Computer Logic

• First, check to see if the door is open. • If the door is open, then walk right

through.• Else (computerese for “otherwise”), if the

door is unlocked, then turn the handle and walk through.

• Else, unlock the door with a key, turn the handle, and walk through.

The computer is only as smart as the person

who programmed it!

The computer can be programmed to think using the “If-Then” logic statement. Here’s how we humans employ logic statements:

Page 22: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

An If-Then Logic StatementFor i = 1 to 5

If (i <= 3) ThenDebug.Print "I am happy to be here!"

ElseIf (i = 4) ThenDebug.Print "BasicX rocks!"

ElseDebug.Print "Let's get started!"

End IfNext

Page 23: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

OUTPUT Using PutPin

• BasicX has a command named PutPin that can be used to turn on and off external devices such as lights, LEDs, motors, buzzers, etc.

• All you have to do is tell the BX-24 which pin the device is connected to and whether to turn it on or off:

Call PutPin(5, 1)

1 = Turn it ONThe device is connected to pin 5

Page 24: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

OUTPUT: Onboard LEDs• The BX-24 has two built-in LEDs.

One red (pin 25), one green (pin 26).• Think about how to make a light blink.

What we take for granted must be painstakingly programmed into the computer line by line:

– Turn on the light

– Leave it on for some time

– Turn off the light

– Leave it off for some time

– Repeat

DoCall PutPin(26,1)Call Delay(0.3)Call PutPin(26,0)Call Delay(0.3)

Loop

Page 25: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

OUTPUT: External LEDs• External LED’s can also be easily controlled with

the BX-24 using the PutPin command. (Here, the LED is connected to pin 5.)

• This code simulates a flickering candle by using random delay times between 0.0s and 0.1s:

DoCall PutPin(5,1)Call Delay(Rnd * 0.1)Call PutPin(5,0)Call Delay(Rnd * 0.1)

Loop

Page 26: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

OUTPUT: Piezo Buzzers• Loud, obnoxious buzzers can

also be controlled with the BX-24• A class of buzzers can be driven

by simply connecting them to a battery

• Connect and disconnect the battery (loops!) and you can turn the buzzer into a siren

• Use the PutPin command to turn the buzzer on and off

Page 27: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

OUTPUT: Speakers

• The BX-24 can also control speakers and audio transducers

• These devices cannot simply be connected to a battery. They must be turned on and off to make a sound.

• There are two more commands that can be used to turn the output voltage on and off: the PulseOut and FreqOut commands.

Page 28: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

OUTPUT Using PulseOut

Dim i as IntegerFor i = 1 to 100

Call PulseOut(12, 0.500, 1) Call PulseOut(12, 0.001, 0) Next

1 = Turn it ON

The speaker is connected to pin 12

Duration = 0.5s

0 = Turn it OFF

Duration = 0.001s

Page 29: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

OUTPUT Using FreqOut

Musical notes have a particular frequency. Using the FreqOut command, the BX-24 can output these frequencies to a speaker.

Call FreqOut(12, 512, 0, 2.0)

The speaker is connected to pin 12 Duration = 2s

Frequency #1 = 512 Hz Frequency #2 = 0 Hz

Page 30: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Robot MusicThe BX-24 can be programmed to play familiar tunes.

Or build your own piano and make the music yourself.

Page 31: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Beats

From Section 9.3 in BasicX and Robotics

When two notes of similar frequencies are added together, a beat is created.

Call FreqOut(12, 512, 514, 5.0)

The speaker is connected to pin 12 Duration = 5s

Frequency #1 = 512 Hz Frequency #2 = 514 Hz

Here, the beat frequency is 2Hz. (514Hz – 512Hz = 2Hz)

Page 32: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

OUTPUT: Servomotors• Electric motors spin when a voltage is applied to it.• Servomotors (or servos) are special motors

commonly used in R/C planes, cars, and boats. Roboticists also use them.

Page 33: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

• Servos are controlled with the PulseOut command.• A 1-ms pulse turns the servo clockwise• A 2-ms rotates it counterclockwise• The speed can be controlled with pulse width

modulation (PWM)

OUTPUT: Servomotors

Page 34: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

OUTPUT: Grippers• Grippers use servo motors to

open and close their jaws• Loops and the PulseOut

command is used to control its movement

• To hold an object, the jaws must continually be pulsed

Page 35: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

INPUT: Voltmeter

• Digital signal 0 = 0V• Digital Signal 1023 = 5V (10-bit value)

• Therefore, a signal of 512 is ~2.5V. What does a AA battery read?

• Not only can the BX-24 output voltages, it can read them, too

• This is easy to do with the GetADC command• The analog voltage from a battery, for example,

must be converted into a digital signal before it can be read by the computer

• The BX-24 has eight built-in A-to-D converters!

Page 36: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

INPUT: Light meter

• Ambient light can be read using GetADC and an inexpensive photoresistor

• As the light intensity increases, its resistance drops and the voltage to the BX-24 increases

• This signal can be put to music with the FreqOut command

• Some “light” music anyone?

Page 37: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Light Meter Data

From Section 17.4 in BasicX and Robotics

A night watchman was “observed” checking the classroom.

Page 38: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

INPUT: Infrared Range Finder

• The range (or distance) to any object can be determined using GetADC and an IR sensor

• A transmitter sends out an invisible (to the human eye) beam of infrared light

• The amount of light picked up by the receiver is an indication of the distance to the object

• Section 16.9 in my book shows how to convert the digital signal to an actual range

• Have you seen these? Yes!

Page 39: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

INPUT: Temperature Sensor

• The ambient temperature be determined using GetADC and an inexpensive thermistor

• As the temperature increases, the thermistor’s resistance increases and the voltage to the BX-24 decreases

• The temperature can be calibrated and displayed in Fahrenheit, Celsius, and Kelvin scales. (See Section 17.7 of my book.)

Page 40: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

INPUT: Flame Sensor

• Raw infrared light (heat) can be measured and displayed using an infrared transistor and the GetADC command

• This sensor is also used in line- following robots and soccer-playing robots

• What light/heat sources are detected?

Page 41: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

It can be rocket science!• In 2003, NASA, Penn State, and Clemson

University launched a Terrier-Orion rocket from Wallops Island, Virginia. The rocket, part of the SPIRT II campaign, was in space for about 10 minutes and experienced nearly 20-G’s during liftoff.

Page 42: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

SPIRIT II Results

• High school students (at George School) in my physics and computer science classes designed an experiment that flew onboard that rocket.

• A BX-24 and RAMB motherboard were used to measure the forces of liftoff and any changes in temperature within the payload.

• The experiment cost less than $100 (the force sensors cost 4¢ each) and returned excellent data.

Page 43: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Robots in Action

• Follow Me– Not so smart

• Line Following Mouse– A bit smarter, but still constrained

• Battle Bot Hack– H-bridge technology

• The Crawler– Another H-Bridge application– Stays on tabletop

• ESRA Expressive robot– Used in psychological research

labs across the country including Yale

– Autistic research in high school?

• Robot Soccer Junior– 2050 Challenge

• Clean Sweep– Smart and useful (sort-of)

• RoboSapien Hack– Brain surgery

Let’s take a look at a few robots and how they utilize these basic microcontroller principles. Each robot is controlled by the BX-24. Can you picture how the commands are put together to obtain these results?

Page 44: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Future Work

• Inner planetary exploration especially on the Moon and Mars

• More rocket launches• Balloon research• Salt run-off experiment• A DIY science classroom laboratory• DARPA Challenge

– 2015 (1/3 of all military vehicles must be autonomous)

• Understanding robotics to make intelligent, ethical decisions

This is only the beginning. In the field of robotics, we are (now) limited only by our imaginations. Here are some other applications that my students are interested in and/or working on:

Page 45: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Thank you for coming!

Also, if you would like to purchase my book, the cost is $44.95. Please make the check out to Robodyssey. I would be delighted to sign it for you.

www.basicxandrobotics.com

[email protected]

If you would like to receive updates on what is happening with my students and our robots, please enter your name and email address in my notebook.

Page 46: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Thank you for coming!

Also, if you would like to purchase my book, the cost is $44.95. Please make the check out to Robodyssey. I would be delighted to sign it for you.

www.basicxandrobotics.com

[email protected]

If you would like to receive updates on what is happening with my students and our robots, please enter your name and email address in my notebook.

Page 47: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA
Page 48: Robotics Demo Chris Odom  chris_odom@georgeschool.org George School, Newtown, PA

Follow Me[to be added at a later time]

This simple robot application is a fairly unintelligent one. The Mouse, equipped with an infrared range-finding sensor, will continually spin around until something comes close to it. Then, the robot will move toward the object, stopping just prior to hitting it. If the object is removed, the process is repeated.

Can you imagine which commands and logic structures are used for this application? What would the If-Then statement look like?