Sie sind auf Seite 1von 48

Robotics Demo

Chris Odom
www.basicxandrobotics.com 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.

Exciting Technology
The 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

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

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!

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:

Wheeled Robots (My students use the Mouse)

Walking Robots

Expressive Robots (ESRA)

Kits

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.

Computers never do what you want them to do, only what you tell them to do.
Brian Patton Vice President, Robodyssey Systems

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?

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 Lets start by learning how the BX-24 outputs data

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

OUTPUT: Printing data to the PC


Lets 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. Heres the code:
Debug.Print "Hello, my name is Chris."

OUTPUT: Printing data to the PC


Heres what the programs output looks like on the PCs monitor:

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 InitLCD Call Display2Line("Hello", "My name is Chris")

OUTPUT: Printing data to the LCD


Heres what the programs output looks like on the LCD screen:

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.

Do-Loops
Do

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


Loop

For-To-Next Loops
Dim i as Integer Debug.Print "I can count fast!" For i = 1 to 5 Debug.Print CStr(i) Next

Delays
Sometimes, the computer performs its tasks too quickly. We can use a Delay command to slow it down: Dim i as Integer Debug.Print "Countdown...." For i = 5 to 1 Step -1 Debug.Print CStr(i) Call Delay(1.0) Next Debug.Print "Lift Off!"

Computer Logic
The computer can be programmed to think using the If-Then logic statement. Heres how we humans employ logic statements:
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!

An If-Then Logic Statement


For i = 1 to 5 If (i <= 3) Then Debug.Print "I am happy to be here!" ElseIf (i = 4) Then Debug.Print "BasicX rocks!" Else Debug.Print "Let's get started!" End If Next

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)
The device is connected to pin 5 1 = Turn it ON

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: Do Turn on the light Call PutPin(26,1) Leave it on for some time Call Delay(0.3) Turn off the light Call PutPin(26,0) Leave it off for some time Call Delay(0.3) Repeat Loop

OUTPUT: External LEDs


External LEDs 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:

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

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

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.

OUTPUT Using PulseOut


Duration = 0.5s

Dim i as Integer For i = 1 to 100 Call PulseOut(12, 0.500, 1) Call PulseOut(12, 0.001, 0) Next

1 = Turn it ON

0 = Turn it OFF

The speaker is connected to pin 12

Duration = 0.001s

OUTPUT Using FreqOut


Musical notes have a particular frequency. Using the FreqOut command, the BX-24 can output these frequencies to a speaker.
The speaker is connected to pin 12
Duration = 2s

Call FreqOut(12, 512, 0, 2.0)


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

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

Or build your own piano and make the music yourself.

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

From Section 9.3 in BasicX and Robotics

The speaker is connected to pin 12

Duration = 5s

Call FreqOut(12, 512, 514, 5.0)


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

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

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.

OUTPUT: Servomotors
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: 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

INPUT: Voltmeter
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! 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?

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?

Light Meter Data


A night watchman was observed checking the classroom.

From Section 17.4 in BasicX and Robotics

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!

INPUT: Temperature Sensor


The ambient temperature be determined using GetADC and an inexpensive thermistor As the temperature increases, the thermistors 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.)

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 linefollowing robots and soccerplaying robots What light/heat sources are detected?

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-Gs during liftoff.

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.

Robots in Action
Lets 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?
Follow Me
Not so smart

ESRA Expressive robot


Used in psychological research labs across the country including Yale Autistic research in high school?

Line Following Mouse


A bit smarter, but still constrained

Battle Bot Hack


H-bridge technology

Robot Soccer Junior


2050 Challenge

The Crawler
Another H-Bridge application Stays on tabletop

Clean Sweep
Smart and useful (sort-of)

RoboSapien Hack
Brain surgery

Future Work
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:
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

Thank you for coming!


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. 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 chris_odom@georgeschool.org

Thank you for coming!


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. 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 chris_odom@georgeschool.org

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?

Das könnte Ihnen auch gefallen