About the Basic Stamp

Download Report

Transcript About the Basic Stamp

Basic Stamp II
is kinda cool.
- 2048 Bytes of EEPROM(non-volatile)
- Clock speed of 20 MHz.
- Holds 600 lines of code in EEPROM
- executes an average of 4000 instructions/sec
- 32 Bytes of Ram(16 of it for variable storage)
- 16 I/O pins, plus two synchronous serial pins
- Programmable with a PC/Mac through a serial connection with PBasic.
Micro-controllers and Single-board Computers:
A Micro-controller is an integrated circuit that contains many
of the same items that a desktop computer has, such as
CPU, memory, etc., but does not include any “human
interface” devices like a monitor, keyboard, or mouse. Microcontrollers are mostly designed for machine control
applications, rather than human interaction.
Micro-controllers paired with all the peripherals they need to
be self-sufficient, such as the Basic Stamp II IC, are
sometimes called “single-board computers.”
The Board of Education
• BSII micro-controller
• bread-board
• power supply
• 9 volt connection
• serial cable
BSII Carrier Board
Prototyping or “bread” board
Breadboard connections:
The horizontal black lines show how the
“sockets” are connected underneath the
breadboard. This means you don’t have to
plug two wires into one socket since the
socket to the right or left is connected.
I/O Pin connections are along left
power connections are along the top
“Vdd” is +5 volts
“Vss” is ground
Sensing
Basic Sensing Schemes
1) detect ON/OFF (switches)
2) determine resistance using a resistor/capacitor timing circuit
(RCTime)
3) read the frequency of a pulse given off by a device or
circuit (PulseIn)
4) use analog to digital converter (A/D) to convert voltage
value to number understood by micro-controller
RCTime Circuits
RCTIME
RCTIME pin, state, resultVariable
Count time while pin remains in state—usually to measure the charge/
discharge time of resistor/capacitor (RC) circuit.
• Pin
is a variable/constant (0–15) that specifies the I/O pin to use.
This pin will be placed into input mode and left in that state when
the instruction finishes.
• State
is a variable or constant (1 or 0) that will end the RCtime
period.
• ResultVariable
is a variable in which the time measurement (0 to
65535 in 2µs units) will be stored.
Essentials
Comments
‘ this is a comment
Declarations
foo var
byte
Value assignments
foo = foo + 1
Integer Math
Labels
Label:
Goto, gosub, return
Ins and Outs (pins)
Variable and Constant Declarations
Save memory by using the smallest size variable necessary to hold your
values
‘ Declare variables.
mouse var
bit
cat
var
nib
dog
var
byte
rhino var
word
‘ Declare constants.
cheers
con
3
‘
‘
‘
‘
Value
Value
Value
Value
can be 0
in range
in range
in range
or 1.
0 to 15.
0 to 255.
0 to 65535.
LOOPS
The first thing you should do is make your program into a loop so it is
always running. In basic you make a loop by labeling the top of the the loop and
using the GOTO command at the bottom of the loop
MYLABLE:
HIGH 2
PAUSE 1000
LOW 2
PAUSE 1000
GOTO MYLABLE
'This sets the label (note :)
'Turn pin 2 on.
'Pause for about 1 sec.
'Turn pin 2 of
'Pause for about 1 sec.
‘Sends it back up to top of loop
To make a loop you first have to understand labels. You can label a part of
your program just by putting the label name followed by a colon. The first line in
the example set the label MYLABLE. You can call your labels anything you like.
Anything following the single quote mark is considered a comment, which BASIC
ignores. The lines between the label and the goto are repeated. The last line
sends the program back up to the label MYLABLE and starts the loop over.
Serial and Analog I/O
SERIAL
SERIN
Serial input
SEROUT
Send data serially (will use for MIDI output)
ANALOG I/O
RCTIME
Measure an RC charge/discharge time.
PULSIN
To measure pulsewidth of incoming signals; useful
for some commercial sensors with builtin A/Ds.
RCTime Circuits