Está en la página 1de 52

ROBOLAB

QUE ES EL ROBOLAB?
Es

un lenguaje utilizado para programar los robots. Fotos, llamados iconos representan funciones diferentes para crear la lgica de su programa. Uso de la Torre de infrarrojos se puede descargar los programas que escriben en su RCX.

Introduccin

Haga doble clic en el acceso directo de ROBOLAB para iniciar la aplicacin.

Introduccin

Haga clic en el botn del programador

Introduccin

Haga doble clic en Inventor 4 para que aparezca una ventana de programa en blanco.

Un programa sencillo
Ahora

vamos a escribir un programa simple con ROBLAB Este programa girara a uno de los motores durante 2 segundos y luego se apagar.

Un programa sencillo
Blank Program Window

Functions Palette

Esta es una ventana de programa en blanco. La luz verde es el comienzo del programa. La luz roja es el final del programa. La paleta de funciones contiene todos los iconos que tendr que escribir el programa.

Un programa sencillo

The first icon is the motor. Select the icon with the A over the motor because the motor is connected to Port A. The arrow shows what direction the motor will run. Choose the one pointing to the right. Click the icon and place it in the program window. Click again over the spot where you want to place the icon. For information about each icon, click Help, then Show Help.

Help Window

Un programa sencillo

Motors can be programmed to run at different power levels, from 1(lowest) to 5(highest).

Un programa sencillo

Iconos del nivel de poder se encuentran los modificadores de los sub-paleta, situada en la paleta Functions. Haga clic en el icono de nivel 5 y colocarlo debajo del motor.

Un programa sencillo

A continuacin ponemos un retardo de tiempo para que el motor funcione durante 2 segundos. El icono se puede encontrar en la paleta de sub-con la imagen de un reloj.

Un programa sencillo

Ahora ponemos una seal de stop para apagar el motor. Asegrese de colocar la muestra de la parada con la letra correspondiente de su motor. Este es el que tiene la "A".

Un programa sencillo

Para enlazar todos los iconos juntos para hacer de la ejecucin del programa, ahora necesitamos la herramienta de alambre. Seleccione el men de Windows, a continuacin, Mostrar paleta de herramientas

Un programa sencillo

Here the wire tool has been selected


Wire Tool

Un programa sencillo

Click on the upper right corner of the first icon. Then click the upper left of the next. Continue this for each icon until they are all connected.

Un programa sencillo

Dont forget to connect the Power Level Modifier to the motor.

The RCX

This is the brain of your robot. The inputs (sensors) are connected to ports 1, 2, and 3 The outputs (motors, lamps) are connected to ports A, B, and C

RCX Buttons

On-Off turns the RCX on and off. The RCX shuts itself off after 15 minutes unless changed in setup Run starts and stops the program Prgm selects which program you want to run. You can store up to 5 at once. View lets you view the values at the ports. This is useful when looking at sensor values.

Downloading to the RCX

Turn on the RCX. Select a program number to store it. Place the InfraRed Tower 6 to 8 inches from the RCX. Make sure the receiver is facing the tower.

InfraRed Tower

Downloading

Select Run from the Operate menu. This starts downloading the program. The RCX will make a rising sweep sound if the download was successful.

Problems when downloading

If any of the icons are not connected properly you will see an error list describing what the problem is.

If you get an error

Make sure the InfraRed Towers serial cable is connected to the computer. Make sure the RCX is on. Try moving the RCX closer to the tower. Check the batteries (9V in tower and 6 AA in RCX).

Other Tools

Select

The Select tool lets you select icons so you can move them or delete them. The Text tool lets you put text in the program window.

Text

Other Tools

The replace tool lets you replace an icon without rewiring.

Replace Tool

Using the replace tool

Lets replace the 2 second delay with an 8 second delay.

Using the replace tool

Select the replace tool and left click the 2 second display icon. Select replace from the menu and a new functions palette Replace should appear.

New Functions Palette

Using the replace tool

Select the 8 second delay from the palette.

8 second Delay

Using the replace tool

The program has now been changed from a 2 second delay to an 8 second delay.

Loops

Loops allow you to repeat part of the program so you dont have to rewrite the same part over. These are the icons beginning and end of a loop.

Loops

You can specify the number of times you want the loop to repeat with a text box modifier. You can also use the random dice modifier to have the loop repeat a random number of times.

Jumps

These are the jump and land icons You can have more than one jump per program. Keep them separate by assigning a number or using a different color for each.

Examples using loops and jumps


Here

are some examples of a program that tells the RCX to beep every second. The first 2 are examples of finite loops. The 3rd implements an infinite loop.

Example 1

This program beeps every second. It does this for 10 loops.

Example 2

This program beeps every second. It does this for a random number of loops.

Example 3

This program beeps every second. It does this forever.

The Touch Sensor


Wait until pressed Wait until released

Touch Sensor Fork

Remember to specify the port that the sensor is connected to. The sensors are usually used to control motors and lights. The fork allows the program to run based on the position of the sensor.

The Rotational Sensor


Reset Wait for a number of counts Rotation This sensor waits a Sensor certain number of Fork

counts before doing something. 16 counts = 1 revolution. The fork runs a portion of the program depending on the sensor count.

The Light Sensor

These are used to detect light levels between 0 and 100. The top icon waits until the level is above the given value of 50. The bottom icon waits until the level is below the given value of 50.

The Light Sensor

The top icon waits until the light level is a certain percentage above the current level. The bottom waits until the light level is a certain percentage below the current level. In both cases, the percentage is 5%.

Timers

There are 3 timers. The program can wait for a certain amount of time. 1 sec = 10 timer counts. Make sure you reset the timer at the beginning of your program.

Example using a timer


This

program times how long it takes for someone to push in a touch sensor. If the sensor is pressed within 3 seconds of starting the program a descending sweep sound will be played. If more than 3 seconds pass a different rising sweep sound will be played.

Timer Example

Reset the red timer. Wait for touch sensor to be pressed. Play appropriate sound based on the time elapsed.

Containers

Another word for container is variable. Variables are a number you dont know until you run the program. Can have up to 3. You can zero a container, give it a number, or give it the value of a sensor.

Container Math Operations


Add 4 to the container value. Multiply container value by 2. Subtract 3 from the container value.

Divide container value by 1.

Containers

You can use the value of a container to set the power level for an output such as a light or motor.
Container Value

Example using a container


This

program starts out with the power level of the motor at 0. Every time the sensor is pressed the power level increases by 1. When the sensor has been pressed 6 time the motor shuts off.

Container Example

Zero the red container and loop forever. If the sensor is touched, make a sound and add one to the container. Otherwise turn motor A on at the level the container holds. If the red container value > 5 stop and exit. Repeat until value of container is > 5.

Multiple Tasks

This allows your program to do 2 or more things at the same time. Each task must end with a red stoplight. You can have up to 10 separate tasks in a program.

Example using tasks

This program has 3 tasks. The 1st turns on motor A for 45 seconds then turns it off. The 2nd plays a rising sweep then waits a random amount of time before repeating this happens 4 times. The 3rd turns motor C on for 1 second then turns it off and waits 2 seconds this happens a random number of times.

Task Example

Debugging
Even

if the program successfully downloads to the RCX, the program may not work the way you expect it to.

Debugging Hints

Have your program play a sound when it reaches a certain point if you hear the sound you know your program got to that point this is especially good for fork debugging. Sounds and lamps are a good way to see the value of a container. Add time delays to slow down the actions of your robot so that you have time to think about what is going on. Keep trying until your program works the way you want it to.