Quick Tutorial on Interactive C

The Handyboard Web page contains more information


Connecting the battery pack

Getting Started

Here are the steps to getting started with the Handy Board and Interactive C:

1. Connect the Handy Board to the serial port of the host computer, using the separate Serial Interface board. The Serial Interface board connects to the host computer using a standard modem cable; the Handy Board connects to the Serial Interface using a standard 4-wire telephone cable.

2. Put the Handy Board into bootstrap download mode, by holding down the STOP button while turning on system power. The pair of LED's by the two push buttons should light up, and then turn off. When power is on and both of the LED's are off, the Handy Board is in download mode.

3. Start up Interactive C (under Start->programs). You may get a dialog box upon starting Interactive C that states the board is not found. Turn the Handyboard on and select "OK".

4. Download the Interactive C library file to the Handy Board by choosing Board on the menu, and then selecting Reload PCode. A new window should appear and you can choose to download the file 'Handy_Board_1.2.icd'. Choose Load to start downloading the file.

5. Once the library file is download, you can now use the library functions in the Handy Board manual.


How to download and unload a C file to/from the Handy Board

Loading Files

Loading a file into the Handy Board is simple. You can simply choose Load in the main menu and then select Download Window or Download File to download a program. The Download Window function will download what the code in the active window where you are writing the code and the Download File function will allow you to browse through the directory to download an existing C file in the computer.

Another way to download a file is by entering

load <filename>.c

in the interactive window.

Multiple files can be downloaded at a time by entering

load <filename1>.c <filename2>.c

in the interactive window.

If the files to be loaded contain dependencies (for example, if one file has a function that references a variable or function defined in the other file), then multiple file names should be entered in one command.

Unloading Files

When files are loaded into IC, they stay loaded until they are explicitly unloaded. However, suppose the file test.c is loaded, which contains a definition for the function main. Then another file IC1.c is loaded, which happens to also contain a definition for main. There will be an error message, because both files contain a main. The solution is to first unload the file containing the main that is not desired, and then load the file that contains the new main:

unload test.c

load IC1.c

IC commands

 
list functions : displays the names of presently defined C function 
list files : displays the names of all files presently loaded into IC
list globals : displays the names of all currently defined global variables
kill_all : kills all currently running processes
ps : prints the status of currently funning processes
help : displays a help screen of IC commands

Library Functions

The following are some library functions commonly used:

Processes

int start_process(function-call(...), [TICKS], [STACK-SIZE] )
	Returns integer which is the process ID number.

DC Motors

void fd(int m)
	Turns motor m on in the forward direction. Ex: fd(3);
void bk(int m)

	Turns motor m on in the backward direction. Ex: bk(1);

void off(int m)
	Turns off motor m. Ex: off(1);


Sensor Input

int digital(int p)
	Returns the value of the sensor in sensor port p,
    as a true/false value(1 for true and0 for false)

Sensors are expected to be active low, meaning that they are valued at zero volts in the active, or true, state. Thus the library function returns the inverse of the actual reading from the digital hardware: if the reading is zero volts or logic zero, the digital() function will return true.

Time Commands

void sleep(float sec)

	Waits for an amount of time equal to or slightly greater than sec seconds. 

Memory Access Function

int peek(int loc)
	returns the byte located at address loc

int peekword(int loc)
	returns the 16 bit value located at address loc and loc+1. loc had
	the most significant byte, in keeping with the
   68HC11 16 bit addressing standard.

void poke(int loc, int byte)
	stores the 8 bit value byte at memory address loc

void pokeword(int loc, int word)
	stores the 16 bit value word at memory addresses loc and loc+1

void bit_set(int loc, int mask)
	sets bits that are set in mask at memory address loc

void bit_clear(int loc, int mask)
	clears bits that are set in mask at memory address loc

Note: The above functions are used to examine and modify memory contents directly. They should be used with care as it would be easy to corrupt memory and crash the system using these funtions.


Battery Maintenance

The Handy Board has a 9.6 V, 600 mA battery pack consisting of eight AA-cell nickel-cadmium rechargeable batteries.

Battery Charging

There are three ways to charge the internal battery: When using one of the trickle-charge modes, the HB itself should be turned off so that the charge current goes toward charging the battery and not simply running the board. In ZAP CHARGE, there is enough charge current to operate the board and charge the batteries at the same time (assuming that the board is not driving motors or other external loads).

Adapter Specifications

The specifications of the HB's DC adapter are as follows: Most "universal" type adapters will work properly at one of their settings. Look for the yellow charge LED to light up indicating proper charge (make sure the Charge Rate switch is set to "Normal" mode).

Please be careful not to get an adapter that is overpowered. Problems have been reported using adapters that are rated for 1 to 2 amps.

Also, do not use an adapter that is underpowered or undervoltage. A 9 volt adapter will appear to work (the charge LED will light) but it won't be able to charge the battery for more than a few minutes' worth of power.