PBASIC

Last updated

PBASIC is a microcontroller-based version of BASIC created by Parallax, Inc. in 1992. [1]

Contents

PBASIC was created to bring ease of use to the microcontroller and embedded processor world. It is used for writing code for the BASIC Stamp microcontrollers. After the code is written, it is tokenized and loaded into an EEPROM on the microcontroller. These tokens are fetched by the microcontroller and used to generate instructions for the processor.

Syntax

When starting a PBASIC file, the programmer defines the version of the BASIC Stamp and the version of PBASIC that will be used. Variables and constants are usually declared first thing in a program. The DO LOOP, FOR NEXT loop, IF and ENDIF, and some standard BASIC commands are part of the language, but many commands like PULSOUT, HIGH, LOW, DEBUG, and FREQOUT are native to PBASIC and are used for special purposes that are not available in traditional BASIC (such as having the Basic Stamp ring a piezoelectric speaker, for example).

Programming

In the Stamp Editor, the PBASIC integrated development environment (IDE) running on a (Windows) PC, the programmer has to select 1 of 7 different basic stamps, BS1, BS2, BS2E, BS2SX, BS2P, BS2PE, and BS2PX, which is done by using one of these commands:

' {$STAMP BS1} ' {$STAMP BS2} ' {$STAMP BS2e} ' {$STAMP BS2sx} ' {$STAMP BS2p} ' {$STAMP BS2pe} ' {$STAMP BS2px} 

The programmer must also select which PBASIC version to use, which he or she may express with commands such as these:

' {$PBASIC 1.0}           ' use version 1.0 syntax (BS1 only) ' {$PBASIC 2.0}           ' use version 2.0 syntax ' {$PBASIC 2.5}           ' use version 2.5 syntax 

An example of a program using HIGH and LOW to make an LED blink, along with a DO...LOOP would be:

DO     HIGH 1               'turn LED on I/O pin 1 on   PAUSE 1000           'keep it on for 1 second   LOW 1                'turn it off   PAUSE 500            'keep it off for 500 msec LOOP                   'repeat forever

An example of a program using HIGH and LOW along with the FOR NEXT loop would be:

counter VAR Byte       'sets variable "counter  FOR counter = 1 to 5    HIGH 1               'make pin 1 logic level high (5 V)   PAUSE 1000           'keep it on for 1000 msec   LOW 1                'turn it off   PAUSE 500            'keep it off for 500 msec NEXT                   'redirects to beginning four more times END                    'end program                                             

Comments in the code are preceded by an apostrophe ('). The microcontroller ignores the rest of the line and continues to the next each time it encounters a comment. PBASIC codes can be simply a list of statements:

HIGH1'turn on LED on pin 1PAUSE1000'pause for one secondLOW1'turn off LED on pin 1END'end program

If the programmer selects 'Run' from the IDE's menu, the program is tokenized and uploaded to the Basic Stamp through an RS232 or USB cable and stored in the stamp's EEPROM as Huffman compressed non-byte-aligned variable-length tokens, and immediately executed. [2] For example, a GOSUB statement uses 20 bits, including 11 bit-oriented addressing bits for the subroutine address. Because statements are non-byte-aligned, a subroutine can start on any bit in any byte in the EEPROM. [3]

Other chips

The PICAXE microcontroller uses a version of Basic similar to the version used to program the Basic Stamp I.

Related Research Articles

<span class="mw-page-title-main">Microcontroller</span> Small computer on a single integrated circuit

A microcontroller or microcontroller unit (MCU) is a small computer on a single integrated circuit. A microcontroller contains one or more CPUs along with memory and programmable input/output peripherals. Program memory in the form of ferroelectric RAM, NOR flash or OTP ROM is also often included on chip, as well as a small amount of RAM. Microcontrollers are designed for embedded applications, in contrast to the microprocessors used in personal computers or other general purpose applications consisting of various discrete chips.

<span class="mw-page-title-main">MCS-51</span> Single chip microcontroller series by Intel

The Intel MCS-51 is a single chip microcontroller (MCU) series developed by Intel in 1980 for use in embedded systems. The architect of the Intel MCS-51 instruction set was John H. Wharton. Intel's original versions were popular in the 1980s and early 1990s, and enhanced binary compatible derivatives remain popular today. It is a complex instruction set computer, but also has some of the features of RISC architectures, such as a large register set and register windows, and has separate memory spaces for program instructions and data.

<span class="mw-page-title-main">AVR microcontrollers</span> Family of microcontrollers

AVR is a family of microcontrollers developed since 1996 by Atmel, acquired by Microchip Technology in 2016. These are modified Harvard architecture 8-bit RISC single-chip microcontrollers. AVR was one of the first microcontroller families to use on-chip flash memory for program storage, as opposed to one-time programmable ROM, EPROM, or EEPROM used by other microcontrollers at the time.

<span class="mw-page-title-main">Atari BASIC</span> Dialect of the BASIC programming language

Atari BASIC is an interpreter for the BASIC programming language that shipped with the Atari 8-bit family of 6502-based home computers. Unlike most American BASICs of the home computer era, Atari BASIC is not a derivative of Microsoft BASIC and differs in significant ways. It includes keywords for Atari-specific features and lacks support for string arrays.

<span class="mw-page-title-main">PIC microcontrollers</span> Line of single-chip microprocessors from Microchip Technology

PIC is a family of microcontrollers made by Microchip Technology, derived from the PIC1650 originally developed by General Instrument's Microelectronics Division. The name PIC initially referred to Peripheral Interface Controller, and is currently expanded as Programmable Intelligent Computer. The first parts of the family were available in 1976; by 2013 the company had shipped more than twelve billion individual parts, used in a wide variety of embedded systems.

<span class="mw-page-title-main">PIC16x84</span>

The PIC16C84, PIC16F84 and PIC16F84A are 8-bit microcontrollers of which the PIC16C84 was the first introduced in 1993 and hailed as the first PIC microcontroller to feature a serial programming algorithm and EEPROM memory. It is a member of the PIC family of controllers, produced by Microchip Technology. The memory architecture makes use of bank switching. Software tools for assembler, debug and programming were only available for the Microsoft Windows operating system.

<span class="mw-page-title-main">BASIC Stamp</span> Microcontrollers

The BASIC Stamp is a microcontroller with a small, specialized BASIC interpreter (PBASIC) built into ROM. It is made by Parallax, Inc. and has been popular with electronics hobbyists since the early 1990s.

The National Semiconductor COP8 is an 8-bit CISC core microcontroller. COP8 is an enhancement to the earlier COP400 4-bit microcontroller family. COP8 main features are:

MBASIC is the Microsoft BASIC implementation of BASIC for the CP/M operating system. MBASIC is a descendant of the original Altair BASIC interpreters that were among Microsoft's first products. MBASIC was one of the two versions of BASIC bundled with the Osborne 1 computer. The name "MBASIC" is derived from the disk file name MBASIC.COM of the BASIC interpreter.

<span class="mw-page-title-main">National Semiconductor SC/MP</span> 8-bit microprocessor

National Semiconductor's SC/MP for Simple Cost-effective Micro Processor, is an early 8-bit microprocessor which became available in April 1976. It was designed to allow systems to be implemented with the minimum number of additional support chips. SC/MP included a daisy-chained control pin that allowed up to three SC/MP's share a single main memory to produce a multiprocessor system, or to act as controllers in a system with another main central processing unit (CPU). Three versions were released over its lifetime, SCMP-1 through 3, the latter two also known as INS8060 and INS8070.

<span class="mw-page-title-main">PICAXE</span>

PICAXE is a microcontroller system based on a range of Microchip PIC microcontrollers. PICAXE devices are Microchip PIC devices with pre-programmed firmware that enables bootloading of code directly from a PC, simplifying hobbyist embedded development. PICAXE devices have been produced by Revolution Education (Rev-Ed) since 1999.

JAL (Just Another Language) is a Pascal-like programming language and compiler that generates executable code for PIC microcontrollers. It is a free-format language with a compiler that runs on Linux, MS-Windows and MS-DOS (OSX support). It is configurable and extendable through the use of libraries and can even be combined with PIC assembly language.

<span class="mw-page-title-main">In-system programming</span> Embedded system programming technique

In-system programming (ISP), or also called in-circuit serial programming (ICSP), is the ability of some programmable logic devices, microcontrollers, chipsets and other embedded devices to be programmed while installed in a complete system, rather than requiring the chip to be programmed prior to installing it into the system. It also allows firmware updates to be delivered to the on-chip memory of microcontrollers and related processors without requiring specialist programming circuitry on the circuit board, and simplifies design work.

<span class="mw-page-title-main">Boe-Bot</span>

BOE–Bot is short for Board of Education robot. It is the trade name of a robot kit that is used in junior high, high school and college robotics classes. It consists of a main circuit board and breadboard, a plug–in BASIC Stamp microcontroller, two servo motors to drive the wheels, and an aluminum chassis that the parts bolt onto. Students can use Erector set parts, Lego blocks, and additional servos to build custom projects. The BOE-bot has been manufactured and sold by Parallax Inc since 1998.

<span class="mw-page-title-main">Parallax Propeller</span> Multi-core microcontroller

The Parallax P8X32A Propeller is a multi-core processor parallel computer architecture microcontroller chip with eight 32-bit reduced instruction set computer (RISC) central processing unit (CPU) cores. Introduced in 2006, it is designed and sold by Parallax, Inc.

Parallax SX is a discontinued line of microcontrollers that was marketed by Parallax, from a design by Ubicom. Designed to be architecturally similar to the PIC microcontrollers used in the original versions of the BASIC Stamp, SX microcontrollers replaced the PIC in several subsequent versions of that product.

<span class="mw-page-title-main">Single-board microcontroller</span> Microcontroller built onto a single printed circuit board

A single-board microcontroller is a microcontroller built onto a single printed circuit board. This board provides all of the circuitry necessary for a useful control task: a microprocessor, I/O circuits, a clock generator, RAM, stored program memory and any necessary support ICs. The intention is that the board is immediately useful to an application developer, without requiring them to spend time and effort to develop controller hardware.

<span class="mw-page-title-main">ATmega328</span> 8-bit microcontroller

The ATmega328 is a single-chip microcontroller created by Atmel in the megaAVR family. It has a modified Harvard architecture 8-bit RISC processor core.

RL78 Family is a 16-bit CPU core for embedded microcontrollers of Renesas Electronics introduced in 2010.

The Mostek MK5065 was an 8-bit microprocessor introduced by Mostek in early 1974. The design was originally developed by Motorola for use in an Olivetti electronic calculator, and was licensed to Mostek for use in non-calculator roles. It featured three sets of processor registers, allowing it to switch to an interrupt handler in a single cycle, and a wait-for-data mode that aided direct memory access.

References

  1. What's a Microcontroller, ver. 1.9 (for first "experiment"), Student Guide for Experiments #1 through #6, Parallax, Inc, Page 3(Preface) ...The business grew slowly until 1992 when Parallax released the first BASIC Stamp...
  2. Scott Edwards, "Exploring the BS1 EEPROM". The Nuts and Volts of BASIC Stamps (Volume 1), July 1996.
  3. Chuck McManis, "Decoding the BASIC Stamp" Archived 2013-04-15 at archive.today , 1994.