240 likes | 644 Views
The BASIC Stamp Editor. Programming Unit, Lecture 2. The BASIC Stamp Editor. Parallax, Inc. provides the BASIC Stamp Editor free of charge. CD’s containing the software and documentation are available. Download from www.parallax.com. Versions are available for DOS Windows Linux Macintosh.
E N D
The BASIC Stamp Editor Programming Unit, Lecture 2 BASIC Stamp Editor
The BASIC Stamp Editor Parallax, Inc. provides the BASIC Stamp Editor free of charge. CD’s containing the software and documentation are available. Download from www.parallax.com. Versions are available for DOS Windows Linux Macintosh BASIC Stamp Editor
BASIC Stamp Development What you need to design, develop and test BASIC Stamp systems BASIC Stamp Editor software A suitable host PC Almost any PC can run the parallax software A serial port is required to download programs to the BASIC Stamp For machines without a serial port, a USB-to-Serial Adapter BASIC Stamp controller (for example, the BS2P24 module) Carrier board for the BASIC Stamp Development boards are available from Parallax and other vendors. A custom designed carrier/prototyping board such as BalloonSat. Programming cable (typically a standard 9-pin straight-thru serial cable. BASIC Stamp Editor
Installation of BASIC Stamp Software Installation of the BASIC Stamp Editor is straight forward. Follow simple instructions on Parallax website. For PC’s not connected to the internet, A CD is available from Parallax, Inc. The only difficulties usually encountered involve configuring the PC’s serial port. Make sure there is an available serial port or use a USB-to-Serial adapter. BASIC Stamp Editor
Running the BASIC Stamp Editor Running the BASIC Stamp Editor should yield a screen like this. The area to the left allows you to explore files on the PC. The large window on the right is where you will enter your BASIC Stamp program for editing, checking and downloading to the BASIC Stamp hardware BASIC Stamp Editor
Configuring the BASIC Stamp Editor The Editor can be configured but the default settings will usually work fine. Pull down the Editor tab and select Preferences to access the configurable options. The software will usually default to the AUTO option for the COM port, shown at right. BASIC Stamp Editor
Configuring the COM Port The COM port can be set to any of the PC’s available COM ports. If a COM port does not appear in the list of known ports it is likely assigned to another device or is not configured properly in the PC’s BIOS. BASIC Stamp Editor
Configuring the Stamp Type Parallax makes a number of different BASIC Stamp micro-controllers. The BASIC Stamp Editor should be configured for the particular type of controller being used, for example a BS2p. Mouse-over the stamp icons chose then click. BASIC Stamp Editor
Configuring the Stamp Type The Stamp mode can also be set by using the Directive pull-down menu. The $STAMP Directive is automatically inserted in the source file. There is also a $PORT Directive available from the pull-down menu for selecting the COM port. BASIC Stamp Editor
PBASIC Help Access HELP from the menu bar or press F1 Learn to use the Syntax Guide and PBASIC Command Reference. BASIC Stamp Editor
Checking and Running a PBASIC Program A PBASIC program can be checked for errors from the Run pull down menu. Select Check Syntax. A BASIC Stamp does not have to be connected. When any syntax errors have been corrected, selecting Run downloads and executes the program on the attached BASIC Stamp hardware. BASIC Stamp Editor
Number Systems Micro-controllers operate with digital logic that has two states (0V for logic 0 and +5 for logic 1). It is natural then to use a binary number system (base 2) consisting of only two digits, 0 and 1. Binary numbers are represented by collections of bits (binary digits). Leading 0’s can be added without changing the value. 00000101 = 101 or decimal 5 BASIC Stamp Editor
Bits and Bytes The bit is the smallest unit of data. Numerically it can be either 0 or 1 but can represent other useful quantities such as TRUE or FALSE, ON or OFF, RED or GREEN, etc. A byte consists of eight bits and is convenient for representing numerical quantities (0 to 255) or characters. Bit 0 is the least-significant-bit. These are the bit numbers and weighted values: BASIC Stamp Editor
Other Number Systems • Hexadecimal (base 16) numbers are commonly used in the world of micro-controllers. • Hex numbers are compact: each hex digit represents 4 bits. • Easy to convert binary to hex and hex to binary. BASIC Stamp Editor
Other data types - the nibble The nibble is a collection of four bits. It is useful for representing BCD (binary coded decimal) and hexadecimal (base 16) numbers. BASIC Stamp Editor
Word data type The word is a collection of sixteen bits. The individual bits are numbered from 0 (least significant bit) to 15 (most significant bit) and the bits have weighted values from 20 to 215 (or 32,768 decimal). A word can also be viewed as two bytes. Bits 0 through 7 form the low order byte, bits 8 through 15 form the high order byte. A word sized number value can represent an unsigned value from 0 to 65535 -or- a signed valued from -32,768 to 32,767 BASIC Stamp Editor
Variables A variable is a memory location for storage and retrieval of a number. In PBASIC a variable has a fixed size depending upon the desired range of values needed for a given application. The BASIC Stamp has limited memory. Use the smallest variable type necessary for the application to conserve memory. BASIC Stamp Editor
Declaring and Naming Variables In PBASIC a variable is declared by assigning a name for the variable and by defining the type (size). For example, for the BS2 a variable declaration might look like ageYrs var byte ageYrs is the name of the variable which might refer to the age of a person in years. The keyword var is used to declare a variable. In this instance the size of the variable is 1 byte which can take on values of 0 to 255 which is a reasonable size and range of values for the intended application (age of a person). The value of a variable can change as the result of program execution. BASIC Stamp Editor
Constants Constants do not change values. The value is assigned when the program is written but does not change during program execution. Constants are named in a manner similar to variables, for example NumButtons CON 5 A constant named NumButtons is declared by the keyword CON with a value of 5. This constant might hold the number of buttons on a control panel or it could be the number of buttons on a shirt. In any case, we name the constant to reflect its meaning in a program. BASIC Stamp Editor
Naming Conventions Notice that in the examples for declaring variables and constants we name them using the following convention: Variable names start with a lowercase letter, for example ageYrs. Constant names start with uppercase letters, for example NumButtons. Words within a name are capitalized for improved readability. The PBASIC language does not care about these conventions. They are used only for aiding in the documentation and troubleshooting of programs. Perhaps most importantly, use meaningful names that help to explain program logic and operation. BASIC Stamp Editor
Activities Students will correct any soldering defects found their Stage 1 BalloonSat boards. The BASIC Stamp Editor will be installed on the lab computer. Students will become familiar with running the software and become proficient in using the PBASIC Help utility. Students will establish a communications link between BalloonSat and the lab computer. BASIC Stamp Editor