- Sussex University Home Page - COGS Home Page - EASy Home Page -
HOME
- Home - Resources - Robot Gallery - Projects - Links -
Hardware: -
Software: -
Examples: -

LEGO Robot Resources
Compiling and Uploading


1: Compiling
To use the compiler we need the CYGWIN environment. You can start this in Start > Software > Programming >cygwin

CYGWIN is a UNIX environment for windows so you can use unix commands to navigate through directories and find your programe.

Once you are in the directory containing your programe you can use the command:

compileCode -o output.s19

This will compile any file in the current directory that has a .c file extension so make sure you only have one .c file in the directory (this should be the file you want to compile) The argument output.s19 will be the name of the compiled file. You can call it anything you want so long as it has the extension .s19

Below: Finding a file in CYGWIN and successfully compiling code.


2: Connecting the robot to the PC
To programe the robot computer we need to connect it to the serial port of the PC. Each PC in the lab should have a cable already attached to the serial port with a four pin socket on the end.

The robot controller has a row of three pins (actually four pins but one of them is missing) called RS232 as shown in the picture below. The programming cable should plug into these pins. The cable socket is polarized which means you can only plug it in one way round so if you have trouble plugging it in then try it the other way.



3: Downloading
In order to download our programe we need to communicate with the robot controller and to do this we use a terminal emulator application called PTerm which can be found in Start > Software > Comms and Security > PTerm.

Before we can connect to the robot we need to change some settings in PTerm. The settings can be found in the Target menu or by clicking on the settings button.


The programming cable should be already plugged into the COM2 serial port so in the settings dialogue box change the port to COM2 using the pull down menu.

Now we need to change the communication speed or Baud Rate from 9600 to 57600.


Once you have changed the settings you can then connect the terminal. We can connect the terminal by clicking connect in the Target menu, or click on the connect button (The little lightning fork).

Nothing will happen when you click connect until you switch on the robot controller. **Remember to connect the battery first**

When you switch on the controller it will start to boot up and communicate with the PC. The first thing you will see in the terminal window will look like random garbage. This appears because the controller initially boots up with a slower com port speed and sends some data to the terminal, once it has done this it switches to the faster com port speed that we are using.

You should see the following in your terminal window:

The controller will wait for a few seconds before it starts to run whatever software has been downloaded into its memory. During this pause you can press the ENTER key and the controller will run its supervisor programe called CPU32Bug which allows you to download new software.

Once you have switched on the controller, and pressed enter, you should see the CPU32Bug prompt in the terminal window and you are now able to use the command lo to load your software. BUT FIRST!! we have to tell PTerm where the file that we want to download is located.


To select a file to download click on the select file button or go into the Target menu and select Choose File. A dialogue box will appear where you can select the file you want. The file should be the one that the compiler generated and should have the .s19 file extension.

Now type lo in the terminal window and press enter, this tells the controller that you are going to download a file and so the controller will wait for you to send the data. You can then click on the download button (or use the Target > Download file menu)


Copyright Sussex University 2002
Maintained by wb23@sussex.ac.uk