BASIC Stamp II - egr.msu.edu

4
1 ME456: Mechatronics Systems Design Lecture 2 WAM Chapter 1: Getting Started Chapter 2: Lights On –Lights Off Prof. Clark J. Radcliffe Mechanical Engineering Michigan State University http://www.egr.msu.edu/classes/me456/radcliff BASIC Stamp II An integrated microcontroller system Postage Stamp Size, Programmed in BASIC 2k byte EEPROM 5 volt Regulator Interpreter Chip PIC16C57 w/ 26 bytes RAM 20 MHz Resonator Serial Interface I/O Pins 0-7 I/O Pins 8-15 The Basic Stamp Introduced them in 1992. As of July 2000, > 200,000 BASIC Stamp modules into use. Each BASIC Stamp includes: a BASIC Interpreter chip internal memory (RAM and EEPROM) a 5-volt regulator 16 general-purpose I/O pins (TTL-level, 0-5 volts) built-in commands for math and I/O pin operations. 5 models: BS1, BS2, BS2e, BS2sx & BS2p. BASIC Stamp I The original Basic Stamp 8 i/o pins 16 bytes of RAM 256 bytes of program storage Fewer programming functions 2000 PBASIC statements/sec 2 ma running power requirement Parallel port interface BASIC Stamp II • Specifications – 4000 BASIC Statements per second – 16 Digital I/O pins Source 20 mA, Sink 25 mA – Special purpose control routines – 5v power supply (50 mA) – Low power (8 mA, sleep at 0.1mA) – RS232 serial programming interface – 2k bytes program token storage Basic Stamp 2 IC

Transcript of BASIC Stamp II - egr.msu.edu

1

ME456: Mechatronics Systems Design

Lecture 2 WAM Chapter 1: Getting Started Chapter 2: Lights On –Lights Off

Prof. Clark J. Radcliffe Mechanical Engineering

Michigan State University

http://www.egr.msu.edu/classes/me456/radcliff

BASIC Stamp II •  An integrated microcontroller system •  Postage Stamp Size, Programmed in BASIC

2k byte EEPROM

5 volt Regulator

Interpreter Chip

PIC16C57 w/ 26 bytes RAM

20 MHz Resonator

Serial Interface

I/O Pins 0-7

I/O Pins 8-15

The Basic Stamp

•  Introduced them in 1992. •  As of July 2000, > 200,000 BASIC Stamp

modules into use. •  Each BASIC Stamp includes:

–  a BASIC Interpreter chip –  internal memory (RAM and EEPROM) –  a 5-volt regulator –  16 general-purpose I/O pins (TTL-level, 0-5 volts) –  built-in commands for math and I/O pin operations. –  5 models: BS1, BS2, BS2e, BS2sx & BS2p.

BASIC Stamp I

•  The original Basic Stamp •  8 i/o pins •  16 bytes of RAM •  256 bytes of program storage •  Fewer programming functions •  2000 PBASIC statements/sec •  2 ma running power requirement •  Parallel port interface

BASIC Stamp II •  Specifications

–  4000 BASIC Statements per second –  16 Digital I/O pins

•  Source 20 mA, Sink 25 mA – Special purpose control routines –  5v power supply (50 mA) – Low power (8 mA, sleep at 0.1mA) – RS232 serial programming interface –  2k bytes program token storage

Basic Stamp 2 IC

2

Other BS2

•  BS2e: –  64 bytes scratch pad RAM –  30 mA i/o pin current

•  BS2sx: –  39 PBASIC Commands –  10,000 instructions/sec

•  BS2p24: –  12,000 instructions/sec –  55 PBASIC Commands

•  BSp40, BS2pe - more features

Board of Education Allows easy prototyping with BSII

5 volt 1.5A Regulator

9 volt Battery Connector

USB / Serial Interface

To PC

BASIC Stamp II

Microcontroller

Circuit Prototyping

Area

Digital I/O

Connector

5v Power Supply

Connection

Wall Transformer Connection

Reset Button

On-Off Switch

RC Servo Connections

BS2 RAM Organization Word Name Byte Name Nibble Name Bit Name Note

INS INL INH

INA, INB INC, IND

IN0-IN7, IN8-IN15

Input pins

OUTS OUTL, OUTH

OUTA, OUTB, OUTC, OUTD

OUT0 – OUT7 OUT8 – OUT15

Output pins

DIRS DIRL, DIRH

DIRA, DIRB, DIRC, DIRD

DIR0 – DIR7 DIR8 – DIR15

Direction bits 0 = input 1=output

W0 B0 B1

N0 N1

Bit names are not typically used (See Memory and Variables Help)

General Purpose word, byte, nibble and bit addressable

.

.

.

.

.

.

.

.

. W12 B24

B25 N48 N49

Chapter 2: Lights On –Lights Off

Indicator Lights

•  First external device •  An Output to human operator

–  Indicates binary condition •  On/Off, True/False, OK/Fault, etc.

•  Your Indicator Light – the LED –  “Light Emitting Diode”

•  Makes other outputs possible

LED

•  Electrical Properties – Constant “diode drop” of 0.7-1.4 volts

•  Depends on color (semiconductor) used

– Current: Max about 15 ma, Min about 5 ma •  Get light anywhere in that range

– Too much of either… •  SMOKE!!!

3

Current Limiting Resistor

•  Assume 5 volt supply – Resistance, Ohm = Potential/current

•  But there is no 500 Ohm Resistor … – Use 470 Ohm (Closest to 500)

( ) ( ) ( )310*105105 !=== milliampvoltIVR

OhmIVR 500==

Wrong Current Limit?

•  With 5 volt supply and 1 volt diode drop – R = 220: I = V/R = (5-1)/220 = 18.2 mA – R = 470: I = V/R = (5-1)/470 = 8.5 mA – R = 690: I = V/R = (5-1)/690 = 5.8 mA

•  Either 220 or 470 are commonly used

The Board of Education

•  Has connections directly to BS2 pins •  No current protection for I/O pins

– Too much current (over 20-25 mA) burns out I/O pin

•  Be Careful… – The BS2 you save may be yours…

Basic Stamp I/O Pins

•  Two Operating Conditions –  “Input” or “High Impedance”

•  Used to sense level –  Near 5 volts (above 3.5 volts) = “True”, “1” –  Near 0 volts (below 1.5 volts) = “False”, “0”

•  Input impedance is about 10M Ohm (very high) –  I = 5 volts/10x106 Ohm = 5x10-7 Amp (very small)

–  “Output” or “Low Impedance” •  Used to set level… “1” = 5 volts, “0” = 0 volts •  No change in potential with current

–  UNTIL you overload pin

BS2 I/O pin Overload

•  Set I/O pin to “output”, then – Pin = 0 connected to 5 volts => OVERLOAD – Pin = 1 connected to 0 volts => OVERLOAD

•  In either case, I/O pin is competing with power supply and one will lose – Usually the I/O pin

•  Power supply = 1.5 A, pin = 25 mA max

Turning LEDs On/Off

•  Two Methods… •  Active High (what the book does)

LED goes on when P14 is High

4

Turning LED’s On/Off

•  Active Low (Often Recommended)

LED goes on when P14 is Low

Many microcontroller pins work best as sinks

!470

Vdd (5v)

P14 (0v)

+

-

Current !470

Bi-Color LED

•  A Red and Green LED packaged as one Pin 1 = “+”, Pin 2 = “-” yields Red Pin 1 = “-”, Pin 2 = “+” yields Green

Look for the clear LED… in your package

Basic Stamp Commands •  HIGH pin

–  sets a pin to output and 5v •  LOW pin

–  sets a pin to output and 0v •  PAUSE count

–  pauses count milliseconds •  FOR … NEXT

–  Allows for a fixed number of repeats •  DO … LOOP (new in PBASIC 2.5)

–  Allows for an infinite number of repeats

Solid State Relays

•  Your ticket to real POWER –  3.5volt @ 2 mA “ON” gives 0-30 volts @40 A

I/O pin

+5v Vdd Load AC or DC

Power

PBASIC Examples

'{$STAMP BS2} '{$PBASIC 2.5} ‘Define symbols LED PIN 14 'LED control pin Time CON 15 'Pause time (ms) ‘Flash LED’s (pins connected “low”) DO ‘loop forever HIGH LED ‘Turn LED off PAUSE Time LOW LED ‘Turn LED on PAUSE Time LOOP