IC and You!
The Robot Boards can be programmed with a language called Interactive C, or IC for short. IC is an implementation of the C programming language that has a command line interpreter that can be used to issue C commands directly to the board. C programs can also be loaded directly to the board using the IC interface. IC runs on a Macintosh and the Robot Board needs to be connected to the Mac via the printer port in order to recive commands and programs. Once a program is loaded onto the board, it can be disconnected from the Mac and run alone.
To start up IC, connect the interface cable to the printer port on the back of the PowerMac and plug the other end into the phone plug on the board. The board needs to be connected to the batteries and turned on to start recieving information. The AA batteries provide the power for the processor on the board and must be plugged in for IC to be used. The D-cells power the motor and do not need to be connected while programming the board. However, since the D-cells provide the power for the motors, programs that use the motors will need to have the D-cells plugged in also.
Once the physical connection is made and the board is turned on, on the PowerMac click on the 'Init Board (printer)' icon. This will load the programms necessary to understand the IC code onto the board. Once this is accomplished, click on the 'IC v.XXX (printer)' icon to start IC.
The IC interface is a simple command driven program. To send a C command to the board, simply type it in. For example, if you wish to find the sum of 4 and 5, simply type:
C> 4 + 5;The interpreter will return the result of the evaluation from the board. Since these are C commands, don't forget to put the semicolon at the end of the line. Any C command can be executed this way. Extending the example, say we had variables a and b that we wanted to take on the values of 4 and 5, repectively, and that we then wanted the sum of a and b. The following sequence of IC commands would produce the desired result:
C> int a = 4; C> int b = 5; C> a + b;This example would be quicker if the commands could all be put on the same line. Well, IC has a method of doing just that! Simply enclose the commands in a set of curly braces and press return at the end of the line (again, don't forget the semicolons):
C> {int a = 4; int b = 5; a + b;}
While typing in commands one at a time is great for quick tasks,
larger projects should be written as programs and loaded up into the
board. A simple C program to compute the product of a and b and print
it to the display on the board would look like this:
void main()
{
int a = 4;
int b = 5;
printf("%d", a + b);
}
Programs can be written in any text editor. SimpleText on the
PowerMac is the most basic and the default Mac text editor. The
programs should be saved in the same folder that IC is in or in a sub
folder of it. This way, IC can find them when you try to load them
into the processor. To load the program onto the board (say we saved
it as add.c), type:
C> load add.cThis will load it and report any problems that it had. If the program was loaded successfully, pressing the red button will exectute the main() function. A few other useful file commands are:
These can all be type in from the IC command line.