Middle School
MS News & Info MS Grades MS Services

Computer Programming

Computer programs are a series of instructions that together produce a behavior. Computer programs are very intricate and detailed, usually they require some kind of information or input and even after finished there will be room for improvement. That is why programs usually get "upgraded".

When you are writing a program before you start you must:

  • clearly specify the task; what is it you need the program to achieve?
  • identify the kinds of inputs the robot will need to use, a way for the robot to "get" the information needed to achieve the task.
  • plan the behaviors needed to complete the task; what kinds of outputs will my robot need to produce.
  • device an algorithm, plan the instructions that will complete the task.
  • write the algorithm in computer language.

The Generic Problem Solving Process:

Identify “What’s the problem?”
Brainstorm solutions
Evaluate solutions
Try (implement) best solution
Evaluate results
In this case, the solution is expressed as an algorithm (sequence of instructions), then converted to a computer program

What’s an Algorithm?

• The term algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem. The word derives from the name of the mathematician, Mohammed ibn-Musa Al-Khowarizmi, who was part of the royal court in Baghdad and who lived from about 780 to 850. Al-Khowarizmi's work is the likely source for the word algebra as well

• A computer program can be viewed as an elaborate algorithm. In mathematics and computer science, an algorithm usually means a small procedure that solves a recurrent problem

 

Running programs with the RCX:

The RCX has 5 programming slots, the first two are locked, your programs will download in slots 3, 4 and 5.

Since the IR towers have a long range always make sure that your tower is facing the wall when you download our program to avoid problems.

 

The programming environment

ROBOLAB is based on LabVIEW, a programming environment created by National Instruments (Texas, USA). It was used by NASA in 1997, to monitor the Sojourner Rover's location and position.

Panel Window The window that holds the main menu for the Robolab program (file, edit, operate, etc)
Toolbox Window From this window you can change from the editing tool to selection tool or the connector tool.
Function Window in this window you will choose different functions and the actions that you want your robot to perform.
Diagram Window The area of the screen where you will write the algorithm (s) that you need for your robot to perform an specific task
   

 

RCX Commands

Ways to express algorithms

  • In the real programming world there are many ways to do this
  • In the Robolab world, probably the two best ways are:
    • Draw block diagrams (icons)
    • Literally act it out
  • Always talk it out and test it using a team member to walk through it acting like the robot.
  • Keep actions at simplest possible level

To program the RCX we create simple commands the same way we create simple sentences:

Command
ICON
Modifier
ICON

start program

Time modifier
turn motor on
Power modifier
stop motor
Port modifier
stop program
 

 

All ROBOLAB programs start with a green traffic light and end with a red one. You can see these in the programming window.

Programming icons are placed in between the traffic lights to indicate the task you want your robot to perform. All the icons that are part of the program must be linked together with the wiring tool which draws a pink line between the pieces. The arrow is used to select the programming icons. When a programming icon is placed in the program window, it will sometimes be automatically joined with a pink line to the nearest icon. This can speed up the process of linking the symbols together. Broken links can be erased by pressing ctrl B to clean up.

 

Sample Programs with parameters:

Start program

Motor A

Power level 5

When touch port 3

sensor press

Stop motor A
End program

 

Troubleshooting

Start program

Motor A

Wait 2 seconds

Stop motor A
End program

this program will not work because the wire is broken, press ctrl B to clean

 

Debugging and Analysis (Debugging is almost as important as being able to write your program, it means finding the mistake of fixing the program so that is solves your problem)

  • Literally walk through it
  • Ask lots of questions
    • What ifs
  • Do little pieces at a time
    • For example, get the robot to where it needs to be first, then work on getting it to do something
  • Use pieces that you know already work
    • For example, you know how to turn 90°
  • Feel confident in your algorithm before starting to code it.

 

ROBOLAB Help

Get help on any (and all) of the icons in ROBOLAB byright clicking on the icon and selecting help or selecting Show Context Help from the Help Menu in the Diagram Window. Then move the cursor over an icon to display the information in the Help window.