Page 126 - Robots Androids and Animatrons : 12 Incredible Projects You Can Build
P. 126

Software installation
                                       Install the compiler (PICBASIC) and programming (EPIC) software
                                       according to the directions provided in their manuals. I created a
                                       directory on my computer’s hard drive called APPLICS. I used the
                                       DOS path command so that I could run both the compiler and pro-
                                       gramming software from this directory. I wrote and saved all my
                                       programming text files in the APPLICS directory also. For complete
                                       software installation directions with a basic DOS commands tutor-
                                       ial, along with numerous PIC microcontroller applications, read my
                                       PIC Microcontroller Project Book (McGraw-Hill, New York, 2000).
                               Step 1: Writing the BASIC language program

                                       PICBASIC programs are written using any word processor that is
                                       able to save its text file as ASCII or DOS text. Every word processor
                                       I have worked with has this option. Use the Save As command and
                                       choose MS-DOS text, DOS text, or ASCII text. The finished text
                                       file is compiled into a program by the PICBASIC compiler. If you
                                       don’t own a word processor, you can use Windows Notepad, which is
                                       included with Windows 3.X, 95, and 98, to write the BASIC language
                                       source file. (In Windows, look under Accessories.) At the DOS level
                                       you can use the Edit program to write text files.
                                                                                                          105
                                       When you save the file, save it with a .bas suffix. So if you were
                                       saving a program named Wink, you would save it as wink.bas.

                               Step 2: Using the compiler
                                       The PICBASIC compiler program is started by entering the com-
                                       mand pbc followed by the name of the text file. For example, if the
                                       text file we created is named wink.bas, then at the DOS command
                                       prompt enter
                                       pbc wink.bas

                                       The BASIC compiler compiles the text file and creates two additional
                                       files, an .asm (assembly language) file and a .hex (hexadecimal) file.
                                       The wink.asm file is the assembly language equivalent to the BASIC
                                       program. The wink.hex file is the machine code of the program
                                       written in hexadecimal numbers. It is the .hex file that is loaded
                                       into the PIC chip.

                                       If  the  compiler  encounters  errors  when  compiling  the  BASIC
                                       source code, it will list each error it has found along with the line
                                       number where the error is located and terminate. The errors listed
                                       need to be corrected in the BASIC source code before it will suc-
                                       cessfully compile.
                                                       Team LRN                                      Intelligence
   121   122   123   124   125   126   127   128   129   130   131