PBASIC

PBASIC

PBASIC is a microcontroller based version of BASIC created by Parallax, Inc. The language was created to bring ease of use to the microcontroller and embedded processor world. PBASIC 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.

Contents

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 used for special purposes that are not available in traditional BASIC (such as having the Basic Stamp ring a piezo-speaker, for example).

Programming

In PBASIC you have to select 1 of 7 different basic stamps, BS1, BS2, BS2E, BS2SX, BS2P, BS2PE, and BS2PX, and to that you have to select one of these commands:
' {$STAMP BS1}
' {$STAMP BS2}
' {$STAMP BS2e}
' {$STAMP BS2sx}
' {$STAMP BS2p}
' {$STAMP BS2pe}
' {$STAMP BS2px}
you also have to select a PBASIC version. To do that you have to select one of these commands:
' {$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 along with the DO...LOOP Would Be:

DO  
  HIGH 1               'turn LED in pin 1 on
  PAUSE 1000           'keep it on for 1 second
  LOW 1                'turn it off
  PAUSE 500            'keep it off for ½ second
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               'turn LED in pin 1 on
  PAUSE 1000           'keep it on for 1 second
  LOW 1                'turn it off
  PAUSE 500            'keep it off for ½ second                        
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:

HIGH 1                 'turn on LED on pin 1
PAUSE 1000             'pause for one second
LOW 1                  'turn off LED on pin 1
END                    'end program

Other Chips

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

External links


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • BASIC Stamp — 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 quite popular with electronics hobbyists since the early 1990s due to its low threshold of… …   Wikipedia

  • MetaComCo — Industry Software Founded 1981 Headquarters Bristol, England Key people Peter Mackeonis Products various Basic interpretators, AmigaDOS …   Wikipedia

  • NIB — or nib may refer to: N.I.B., a song by Black Sabbath Neodymium magnet or NIB, a powerful magnet made from neodymium, iron, and boron Nib, a type of variable in PBASIC which stores Nibble values in the range of 0 to 15 Nib, partially processed… …   Wikipedia

  • List of BASIC dialects by platform — List of BASIC dialects by platform: This is a list of dialects of the BASIC computer programming language, sorted into groups for better conceptual organization.There is also an alphabetical list of BASIC dialects. These two lists should contain… …   Wikipedia

  • List of BASIC dialects — This article gives an alphabetical list of BASIC dialects mdash;a flat list of interpreted and compiled variants of the BASIC programming language. The dialects platform(s) (that is, the computer models and operating systems) are given in… …   Wikipedia

  • Parallax, Inc. (company) — Infobox Company company name = Parallax, Inc. company company type = Private company slogan = foundation = 1987 Rocklin, California location = Rocklin, California key people = Chip Gracey, President industry = Technology products = Basic Stamp,… …   Wikipedia

  • Boe-Bot — Professor Chuck Schoeffler of the University of Idaho Industrial Technology Education program took his Board of Education programming board and mounted it on a robot chassis, known today as the Boe Bot robot. Dr. Scheoffler inspired the creation… …   Wikipedia

  • Parallax Propeller — chip The Parallax P8X32A Propeller chip, introduced in 2006, is a multi core architecture parallel microcontroller with eight 32 bit RISC CPU cores.[1] …   Wikipedia

  • Basicdialekt — Aufgrund der seit Jahrzehnten bestehenden Popularität von BASIC existieren zahlreiche BASIC Implementierungen auf einer Vielzahl von Plattformen. Entsprechend den sehr unterschiedlichen Umgebungen und Einsatzzwecken wurde eine hohe Zahl von… …   Deutsch Wikipedia

  • Basicdialekte — Aufgrund der seit Jahrzehnten bestehenden Popularität von BASIC existieren zahlreiche BASIC Implementierungen auf einer Vielzahl von Plattformen. Entsprechend den sehr unterschiedlichen Umgebungen und Einsatzzwecken wurde eine hohe Zahl von… …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”