Sei sulla pagina 1di 18

Reli Net Pte Ltd

Tel:62200300
Fax:62200400

Advanced Robotics Training

Page 1 of 18

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

Introduction
Advanced Robotics training will guide you into the various aspect of
programming using Robolab. You will learn how to task split, looping,
use of containers, RCX to RCX transmission and many more.

Chapter 1: LOOPS
We use loops to do the same thing any times. Unlike the command
Jump, You can specify the number of repetition you want.

Click on this submenu to


look for the loop icon.

STEP 1

Page 2 of 18

Click this to go
into the loop
sub-menu

STEP 2

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

Start of loop

End of loop

STEP 3
When you open up the loops sub-menu, you will notice that there are
a lot of commands for loops. On the left, you will see loops use for
different kind of sensors, even camera. On the right, will see two icons
for loop command. The first one is start of loop and the other is end of
loop.
How do we go about executing the command? Look at the diagram
below. How many loops are there? The answer is 2. Probably your
robot will do rectangle formation. Check the turn timing and you will
get a perfect rectangle.

Notice you have to specify the number of loops. Use the numeric
constant to attach the value to the start-of-loop icon.
Exercise
1) Create a program that plays musical C note for 1 sec for 5 times.
Download into your RCX and try it out.

Page 3 of 18

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

2) What is the different between the loop command and Jump


command?

While Do loop
This command literally means while this has not happen do that. So
there is a condition set here. This command is very useful if you want
your robot to do a set of actions first, then execute another set later.
Take for example the loop while timer is less than command. A set
of commands will be executed within the time of the loop until it is
more than that, it will jump out of it.

Drag out
the loop
while timer
is less
than icon

From the diagram above you will see how this command has been
used. You may be wondering where is the timer attached to, it is

Page 4 of 18

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

actually a built in clock. You will notice that the number given to the
timer is 400. This does not mean 400 sec. Rather the clock is counted
in tenths of seconds. What you get is 4 sec. The icon that appears to
be like a clock and a zero in it, is actually resetting the clock to zero.
This is important to really get the correct timing for the clock.

Chapter 2: Task Split


Ever heard your mum scream at you not to do two things at one time
but to concentrate on one? Where is something to break the rules.
Task split.

Task split

This command is given when you want to do another task


simultaneously apart from the main task. For example, take a look at
the diagram below:

Page 5 of 18

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

The program has been split into two tasks. The above line of command
is the main one and the below line is the simultaneous task. Note that
there should be two end icons for task split. The program above will
play musical notes C, D, E, F, G for 1 sec and at the same time runs
Motor A. Once you press touch sensor on port 1 it will stop Motor A.
Exercise
1) Create a program that will control the speed of your robot. Every
time you press the touch sensor on port 1 it will start changing speed
for power level 2 to 5. When you press the touch sensor on port 2, it
will stop.
2) Create a program that uses two touch sensors to control the
movement of the tankbot. When touch sensor on port 1 is depressed,
the tankbot will move to the right. When touch sensor on port 2 is
depressed, it will go to the left.
Sample program: If you notice, this program only run once. Try
making run repeatedly.

Page 6 of 18

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

Sample program 2: Try to decipher this program

Chapter 3: Containers
No, we are not talking about the containers that your mom uses to
hold your favorite biscuits. Container is used as a form of memory for
the RCX. It contains value and then manipulate the value to produce
certain results or actions. Containers can be quite confusing at times,
but with a bit of practice you will get the hang of it.

Value of
containers
Containers:
blue, red and
yellow

Page 7 of 18

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

As you can see from the diagram, under the modifier sub-menu, we
can see that there are basically two types of icons to be used. There
are the blue, yellow and red containers; the value of these containers.
Another important menu to take a look at is the
container menu. Usually we will use the add value
icon to add value into the container. The rest of the
icons is to subtract, plus, divide,
multiply, and, or, XOR the value in Add value
the container.
The best way to learn is by example. Please take a
look at the example on the next page.

Look at the diagram. In this program, the container is set to zero first.
Wait for 1 sec. When touch sensor is pressed, 1 will be added into the
container. The program will compare the container value with the
value 5. If it is less than 5, it will jump back to the beginning of the
program.

Set
container
to zero

Page 8 of 18

Add 1 to container

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

The important icons to take note is the yellow container and add-tocontainer. Notice how the yellow container, the reset container and
add-to-container is linked. Look at the picture and try to explain the
program.

The container will get the value from the light sensor and the value is
divided by ten. The value is then given to the motor to determine the
power level of it.

Exercise
1) Try out the program that you see from the picture( container 5)
from the previous page.
Make changes and improve it.
2) From the picture below, make changes to make your Robot follow
the light source and repel when there is no light.

Page 9 of 18

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

Page 10 of 18

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

Chapter 4: Mail
RCX can communicate with one another by using the function mail.

RCX
communication

Fill
mailbox
Send mail

Wait for
mail
Reset
mailbox
Page 11 of 18

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

How do we use the mail function in the functions palette?


Lets look at a simple program whereby we will set up 2 rcxes to
communicate with one another. One rcx will perform a series of
functions and then send across a mail value to another rcx which will
be waiting for the mail after which it will perform some new tasks.
Things to take note of :
1. Make sure the two rcxes are facing one another
2. Rcx A will be the one sending the mail across whereas Rcx B will
be on the receiving end.
3. Download the two programs into the two separate rcxes.
4. When you are downloading into one rcx make sure you switch
off the other rcx . This is to prevent your programs from being
downloaded into the wrong rcx.
5. Switch on both rcxes + the run buttons when you are ready to
activate rcx a.
Diagram of Program A (to send mail)

Diagram of Program B (to receive mail)

For program B you will notice that there is a reset mailbox icon before
the receive mail icon. This is to reset / clear your mailbox to null value

Page 12 of 18

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

before receiving any mail. After it has received mail it will perform
some non-essential tasks to indicate the programs continuity.
Take a look at a slightly more complex mail program. In this instance
we will allow both rcxes to send and receive mail continuosly in an
infinite loop from one another.
Diagram of Program A :

Diagram of Program B :

This program will continue indefinitely until you manually switch the
rcxes off.
Mail Program Exercise :
Create a program whereby you allow two rcxes to do a
forward/backward dance indefinitely. Each rcx has to take turns to
move backward and then forward again to the original starting
position. The rcxes should be initially placed this way (you must use
the mail icon in this program):

Page 13 of 18

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

IR panels

Rcx A

Page 14 of 18

Rcx B

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

Chapter 5: Timer

Use this icon to wait until the clock reaches a certain time (measured
in tenths of seconds) before moving on to the next command. Always
use a zero timer command prior to this command. It is rather simple
to use. Take for example this:

This program zeros the red timer and turns on motor A. Then it waits
for the red timer to reach 1 second (the default), after which it stops
motor A.
Look at another example:

This program will cause the RCX to beep until clock is more then 50,
then it will wait for 8 sec and play c# sound. You can use a
combination of fork, jump and land commands for your programming.
Exercise

Page 15 of 18

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

Create a program using the timer function, when you press the touch
sensor, it will run forward. The timer will time whether it is 400 counts
already, if not it will keep running. When it is 400 it will turn right and
beep sound 6. Use the timer fork to help you.

Page 16 of 18

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

Chapter 6: Subroutine
Subroutine is used to organize your program and to save on your
working time. If you need to use the same command again and again,
all you need to do is to create a subroutine and call it out again and
again.

Use this to define a subroutine. This does NOT start the subroutine.
Each subroutine needs its own end (stoplight) icon. The main task will
continue running by itself until a Run Sub command is reached.

Use this to start a subroutine. You must define the subroutine before
using this command.
Look at the example below:

This piece of code turns on motor A. After 4 seconds it plays 3 notes


and then turns off the motor.

Page 17 of 18

Reli Net Pte Ltd


Tel:62200300
Fax:62200400

Looking at the example above, you will noticed that the subroutine has
been declared as 1. The program is a line tracking program, using the
timer loop it runs the subroutine until the time runs out and jump into
the next action.
Exercise
1) Create a program that runs the robot at a square formation, using
the subroutine.
2) Now use the loop program to run the subroutine, making the robot
runs in square formation.

Page 18 of 18

Potrebbero piacerti anche