EasyManua.ls Logo

Parallax BASIC Stamp 2e - User Manual

Default Icon
353 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
Loading...
BASIC Stamp
Programming Manual
Version 2.0c

Table of Contents

Question and Answer IconNeed help?

Do you have a question about the Parallax BASIC Stamp 2e and is the answer not in the manual?

Overview

The BASIC Stamp is a microcontroller development system designed for a wide array of embedded applications. It integrates a BASIC Interpreter chip, internal RAM and EEPROM, a 5-volt regulator, and general-purpose I/O pins. The system supports a simplified, customized form of the BASIC programming language called PBASIC.

Function Description:

The BASIC Stamp microcontrollers are designed to run PBASIC programs, performing various I/O pin operations and mathematical calculations. They are capable of executing a few thousand instructions per second. The system includes built-in commands for I/O pin control, math, and communication protocols.

Important Technical Specifications:

Memory:

  • RAM: The BASIC Stamp has two types of memory: RAM for variables and EEPROM for program storage and long-term data. RAM contents are cleared to 0 upon power loss, while EEPROM retains data even without power.
    • BS1: 16 bytes (8 words) of RAM. The first word, PORT, is used for I/O pin control (PINS and DIRS). PINS bits correspond to I/O pin states, and DIRS bits control pin direction (1 for output, 0 for input). The remaining words (W0-W6) are for general-purpose use, with B0 and B1 being bit-addressable.
    • BS2, BS2e, BS2sx, BS2p: 32 bytes of Variable RAM. The first six bytes are reserved for I/O pin control (INS, OUTS, DIRS). INS is read-only, reflecting actual I/O pin states. OUTS holds output latch states. DIRS controls pin direction. The remaining 26 bytes are for general-purpose variables (W0-W12, B0-B25). All registers are word, byte, nibble, and bit addressable.
  • Scratch Pad RAM:
    • BS2e, BS2sx: 64 bytes (0-63), byte-organized. Location 63 is read-only and contains the current program slot number.
    • BS2p: 128 bytes (0-127), byte-organized. Location 127 is read-only, with the lowest nibble containing the current program slot number and the highest nibble containing the current read/write slot number.
  • EEPROM: Used for program storage (downloaded from highest address downwards) and data storage (from lowest address upwards). EEPROM is written in 16-byte sections during download if any location within that section needs writing.
    • Write Cycles: 10 million for BS1/BS2, 100,000 for BS2e/BS2sx/BS2p.

I/O Pins:

  • BS1: 8 general-purpose I/O pins (P0-P7). Each can sink 25 mA and source 20 mA. Total current should not exceed 50 mA (sink) and 40 mA (source).
  • BS2, BS2e, BS2sx: 16 general-purpose I/O pins (P0-P15). Each can sink 25 mA and source 20 mA. Total per 8-pin group (P0-P7 or P8-P15) should not exceed 50 mA (sink) and 40 mA (source) with internal 5V regulator, or 100 mA (source or sink) with external 5V regulator.
  • BS2p: 16 general-purpose I/O pins (P0-P15) on BS2p24, or 32 I/O pins (P0-P15 and X0-X15) on BS2p40. Each can source and sink 30 mA. Total per 8-pin group should not exceed 75 mA (source or sink) with internal 5V regulator, or 100 mA (source or sink) with external 5V regulator.

Power Supply:

  • BS1: VIN accepts 5.5-15 VDC (6-40 VDC on BS1-IC rev. b), internally regulated to 5V. VDD is 5V DC input/output.
  • BS2, BS2e, BS2sx: VIN accepts 5.5-15 VDC (6-40 VDC on BS2-IC rev. e), internally regulated to 5V. VDD is 5V DC input/output.
  • BS2p: VIN accepts 5.5-12 VDC (7.5V recommended), internally regulated to 5V. VDD is 5V DC input/output.
  • Current Draw (approximate, no loads):
    • BS1: 2 mA (run), 20 µA (END).
    • BS2: 8 mA (run), 40 µA (END).
    • BS2e: 25 mA (run), 60 µA (END).
    • BS2sx: 60 mA (run), 60 µA (END).
    • BS2p: 40 mA (run), 60 µA (END).

Communication:

  • Serial Programming:
    • BS1: Uses PC parallel port (PCO, PCI, VSS).
    • BS2, BS2e, BS2sx, BS2p: Uses PC serial port (SOUT, SIN, ATN, VSS).
  • 1-Wire Protocol (OWIN/OWOUT): Approximately 20 kbits/sec (low speed). Requires a 4.7 KΩ pull-up resistor on the DQ pin.
  • I2C Protocol (I2CIN/I2COUT): Approximately 81 kbits/sec. Requires 4.7 KΩ pull-up resistors on SDA and SCL pins. Does not support multiple masters or slave operation.
  • Asynchronous Serial (SERIN/SEROUT):
    • BS1: 300, 600, 1200, 2400 baud. 8-data bits/no-parity, 1-stop bit.
    • BS2, BS2e, BS2sx, BS2p: 243 to 115.2K baud. Flexible 1-stop bit, 8-data bits/no-parity or 7-data bits/even-parity. Flow control supported.
  • Synchronous Serial (SHIFTIN/SHIFTOUT): ~16 kbits/sec (BS2/BS2e), ~42 kbits/sec (BS2sx/BS2p).

Timing:

  • PAUSE: 1 ms resolution, ±1% accuracy.
  • NAP: (2^Period) * 18 ms duration (Period 0-7). Accuracy -50% to +100% (±10% @ 75°F with stable power supply).
  • SLEEP: 2.304 seconds resolution. Length from 2.3 seconds to over 18 hours. Accuracy ±1%.
  • PULSIN: 10 µs (BS1), 2 µs (BS2/BS2e), 0.8 µs (BS2sx), 0.75 µs (BS2p) resolution.
  • PULSOUT: 10 µs (BS1), 2 µs (BS2/BS2e), 0.8 µs (BS2sx), 1.18 µs (BS2p) resolution.
  • COUNT: 1 ms (BS1/BS2/BS2e), 400 µs (BS2sx), 287 µs (BS2p) resolution. Max frequency 120 kHz (BS1/BS2/BS2e), 300 kHz (BS2sx), 416.7 kHz (BS2p).
  • RCTIME: 2 µs (BS2/BS2e), 0.8 µs (BS2sx), 0.9 µs (BS2p) resolution.

Usage Features:

  • PBASIC Language: A simple, easy-to-learn language with standard BASIC instructions (GOTO, FOR...NEXT, IF...THEN) and specialized I/O instructions (SERIN, PWM, BUTTON, COUNT, DTMFOUT).
  • Variables: Declared using SYMBOL (BS1) or VAR (other Stamps). Supports BIT, NIB, BYTE, and WORD sizes. Aliases and variable modifiers (LOWBYTE, HIGHBYTE, LOWNIB, HIGHNIB, BIT0-BIT15) allow flexible memory access.
  • Constants and Expressions: Numbers can be represented in decimal, binary (% prefix), or hexadecimal ($ prefix). Named constants improve code clarity and simplify updates. Compile-time expressions allow the editor to evaluate math/logic operations before download.
  • Operators: Supports unary (ABS, COS, DCD, ~, -, NCD, SIN, SQR) and binary (+, -, *, **, */, /, //, MIN, MAX, DIG, <<, >>, REV, &, |, ^, &/, |/, ^/) operators. Integer math rules apply (whole numbers only). Parentheses are supported on BS2/BS2e/BS2sx/BS2p for order of operations.
  • Development Boards: Various carrier boards (Stamp 1 Carrier Board, Stamp 2 Carrier Board, Super Carrier Board, Board of Education, BASIC Stamp Activity Board) provide prototyping space, programming connectors, and power sources.
  • Editor Software: Available for Windows and DOS. Windows editor supports multiple BASIC Stamp models and files. DOS editor supports one model and one file at a time.
    • STAMP Directive: Used to specify the target BASIC Stamp model (' { $STAMP BS2 }).
    • Project Download Modes (BS2e/BS2sx/BS2p): "Modified" (default, downloads only changed files), "All" (downloads all files), "Current" (downloads only current file).
    • Memory Map: Displays PBASIC program layout, DATA usage, and RAM register usage.
    • Identify Function: Checks firmware version and verifies PC connection.
  • Commands:
    • AUXIO/MAINIO/IOTERM (BS2p40 only): Switch control between main and auxiliary I/O pin groups.
    • BRANCH: Conditional branching to a specified address.
    • BUTTON: Debounces button input, performs auto-repeat, and branches based on button state.
    • COUNT: Counts cycles on a pin for a specified period.
    • DATA/EEPROM: Store data in EEPROM during program download. Supports sequential, addressed, and block data storage.
    • DEBUG: Displays information on the PC screen for debugging. Supports various formatters (DEC, SDEC, HEX, SHEX, IHEX, ISHEX, BIN, SBIN, IBIN, ISBIN, STR, REP) and control characters (CR, CLS, HOME, Move To, Cursor Left/Right/Up/Down, Bell, Backspace, Tab, Line Feed, Clear Right/Down).
    • DTMFOUT: Generates dual-tone, multifrequency (DTMF) telephone tones.
    • END: Stops program execution and enters low-power mode.
    • FOR...NEXT: Creates repeating loops with optional step values.
    • FREQOUT: Generates one or two sine-wave tones for a specified period.
    • GET/PUT: Read/write byte-sized values from/to Scratch Pad RAM.
    • GOSUB/RETURN: Subroutine calls and returns.
    • GOTO: Unconditional jump to a specified address. HIGH/LOW/INPUT/OUTPUT/REVERSE/TOGGLE: Control I/O pin states and directions.
    • I2CIN/I2COUT: Receive/send data using the I2C protocol.
    • LOOKDOWN/LOOKUP: Search for values in lists and retrieve corresponding indices or values.
    • NAP: Enters low-power sleep mode for short periods.
    • OWIN/OWOUT: Receive/send data using the 1-wire protocol.
    • PAUSE: Delays program execution for a specified duration.
    • POLLIN/POLLMODE/POLLOUT/POLLRUN/POLLWAIT (BS2p only): Configure polled-input pins, polled-output pins, and actions in response to polled events.
    • POT: Reads variable resistance (e.g., potentiometer, thermistor).
    • PULSIN/PULSOUT: Measures/generates pulses.
    • PWM: Generates analog output via pulse-width modulation.
    • RANDOM: Generates pseudo-random numbers.
    • RCTIME: Measures RC charge/discharge time.
    • READ/WRITE: Read/write data from/to EEPROM.
    • RUN: Switches execution to another program slot (BS2e/BS2sx/BS2p).
    • SERIN/SEROUT: Receive/send asynchronous serial data.
    • SHIFTIN/SHIFTOUT: Receive/send synchronous serial data.
    • SLEEP: Enters low-power sleep mode for specified periods.
    • SOUND: Generates square-wave tones.
    • STOP: Stops program execution.
    • STORE (BS2p only): Designates a program slot for READ/WRITE instructions.
    • XOUT: Sends X-10 power-line control commands.

Maintenance Features:

  • Warranty: 90-day warranty against defects in materials and workmanship.
  • Money-Back Guarantee: 14-day money-back guarantee if the product does not suit needs (excluding shipping/handling).
  • Internet Access: Parallax website (www.parallaxinc.com) and stampsinclass.com for software, examples, and support.
  • Discussion List: Internet discussion list for BASIC Stamp users.
  • Guidelines and Precautions:
    • Static Sensitive Devices: Use grounding straps and anti-static mats when handling.
    • Power: Verify power is off before connecting/disconnecting.
    • Orientation: Verify correct IC orientation before connection to prevent damage. Pin 1 indicators (dot, half-circle, or number 1) are present on modules and sockets.
    • Programming Connections: Use provided cables or ensure custom cables follow diagrams closely. Verify pin numbering with a meter.
    • Serial Communication: Build projects in steps, pay attention to timing and wiring, and verify port settings. Avoid connecting output pins directly to external power sources.
    • EEPROM Writes: Be aware of the finite number of write cycles per EEPROM location. Check memory map to prevent overwriting program code.

Parallax BASIC Stamp 2e Specifications

General IconGeneral
BrandParallax
ModelBASIC Stamp 2e
CategoryMicrocontrollers
LanguageEnglish

Related product manuals