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.
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
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
The following are some library functions commonly used:
int start_process(function-call(...), [TICKS], [STACK-SIZE] ) Returns integer which is the process ID number.
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);
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.
void sleep(float sec) Waits for an amount of time equal to or slightly greater than sec seconds.
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.
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.