Before you read this section, please:
The Prop-1 controller (and the Basic Stamp 1 from which it was derived) communicates with the outside world through a set of eight wires ("pins"), marked on the board as P0 through P7. Any of these wires can be set up to serve as an input or output. By convention, P0-P5 are used for output and P6-P7 are used for input. Parallax even modified P6-P7 to make it easier to do input with them, and P0-P7 to make it easy to do output - but exactly how these pins are used is your choice.
In order to use a pin for input, you must:
The three-pin connector (white, red, black) is used in lot of Parallax products,
as well as RC servos.
Parallax sells a cable with the matching connector.
Parallax has modified P6-P7 to make it easier to do input with them.
Those two lines can be jumpered with pull-up or pull-down resistors.
These resistors can be used to shove a 0 ("pull-down" to ground)
or a 1 ("pull up" to +5 volts) into these pins.
By using these jumpers, you shove a 0 or 1 into the input,
which can be safely overpowered by the switch when it is activated.
You should use the jumper that does the opposite of what your switch will do when activated:
Since we prefer to use
positive logic,
activating the switch should send a 1 value into the controller.
So the other end of the switch should be connected to +5 Volts,
and when the switch is not active, we use a pull-down resistor to send in a 0.
Here is a normally open switch hooked up to a PROP-1:
Since we prefer to use
positive logic,
activating the switch should send a 1 value into the controller.
So the other end of the switch should be connected to ground,
and when the switch is active, we use a pull-up resistor to send in a 1.
Here is a normally closed switch hooked up to a PROP-1:
But what do you do if you want the Prop-1 to act on
signals from other types of sensors - things that send out a voltage when they have something to say?
The Prop-1 can indeed accept input signals from active devices,
but this is trickier and involves more risk than simply using a passive switch
(sometimes called "dry contacts").
If you inject the wrong type of signal, you can permanently damage the input pin
on the Prop-1.
If you have any doubts, please use a
mechanical relay
to take the input voltage and turn it into a contact closure that can be safely used
on the controller.
See
High Voltage Input.
If you know that your input produces a signal that is compatible with the Prop-1,
you can plug it straight into the
Pin Header:
You can use a
mechanical relay
to take the input voltage and turn it into a contact closure that can be safely used
on the controller.
You must select a relay with a "coil" specification that matches the input trigger voltage.
(This is not the same kind of relay as is used for
high voltage output.
That relay will probably use a 12 VDC coil.)
Here is a relay used to interface a high input voltage to a PROP-1:
Here are some common relays with 110 Volt AC coils [as of October 2005]:
PROP-1 Input Hardware
Pin Header
Any of the P0-P7 connections can be used for input.
They are located on a big array of pins:
The letters on the top say "W R B", and they mean:
The "W R B" pattern is repeated for all 8 pins.
14-inch LCD Extension Cable
Stock#: 805-00002,451-00303
Weight: .0068 lbs
Price: $1.29 each, $0.97 in quantities of 10 [May 2006]
Pull Up, Pull Down
As we learned in the
Input/Output Overview,
it is a bad idea to leave a controller input disconnected.
In order to always have a valid state,
pull-up or pull-down resistors
can be used.
You can choose whether to use:
Kinds Of Input
Normally Open Switch
A "normally open" switch takes two wires and leaves them dangling in space ("open") most of the time.
When you activate the switch, it connects the wires together, which completes the electrical circuit.
Use the pull-down option:
put the rectangular plug on the right two pins.
Normally Closed Switch
A "normally closed" switch takes two wires and connects them together ("closed") most of the time,
which completes the electrical circuit.
When you activate the switch, it disconnects the wires, leaving them dangling in space ("open").
Use the pull-up option:
put the rectangular plug on the left two pins.
Active Input
So far, we have illustrated the use of
switches, both
normally open
and
normally closed.
These are passive components that simply make or break a connection.
High Voltage Input
Sometimes, you need to take a high voltage signal,
like the line voltage switched by an
X-10
module.
Use the pull-down option:
put the rectangular plug on the right two pins.
| part number | description | contacts | coil | price |
|---|---|---|---|---|
| Radio Shack #275-217 | 125VAC/10A DPDT Plug-In Relay | DPDT 10A at 125VAC | 125VAC, 15mA, 4.5Ω | $8.39 |
Do not try to use a solid state relay for this.
Features:
Features:
In order to prepare for input and output, you need to tell the Prop-1 which of the eight pins
are used for input and which are for output.
[This isn't always necessary, as the Prop-1 has certain "default" values that
take effect until you decide to change them.
But when I write a program, I dislike making assumptions,
so I explicitly tell the Prop-1 what I want to do.]
This is done by setting "DIRS" equal to some value.
Another thing that I like to do in the front of the program is to clear all output bits.
You can set all the bits at once by assigning a value to PINS.
Example:
Here is a simple example using
positive logic
("1" means the the trigger is activated):
Here is a slightly more readable example:
Copy the following program from this web page, and paste it into the BASIC Stamp Editor's
program window.
Here's how to test it:
Specific Input Devices
Parallax PIR Sensor
Parallax sells a Passive Infrared (PIR) sensor that serves as a motion detector.
PIR Sensor
Stock#: 555-28027
Weight: 1 lb
Price: $7.95 [May 2006]
Parallax PROP-1 Trainer
Parallax sells a "PROP-1 Trainer" that attaches to the Prop-1 to provide output LEDs,
an input push-button, and an analog input knob.
It is unlikely that you will leave this gadget attached to the Prop-1 during normal operation,
but it can be very helpful in early testing and learning how to use the Prop-1.
Prop-1 Trainer Board
Stock#: 31199
Weight: 0.65
Price: $19.95 [October 2005]
Programming
Initialization
"Initialization" is the beginning of the program where things are set up
for later use.
Normally, the program only executes the initialization part once - when you turn it on.
The value that is assigned starts with "%".
This means that it is a binary value,
with each digit being a "0" or "1", and corresponding to an I/O pin.
When setting DIRS, "1" means the corresponding pin will be used for output and "0" means input.
' 76543210 ' bit positions
DIRS = %00111111 ' make P7-P6 inputs, P5-P0 outputs
PINS = %00000000 ' all outputs off
Testing Input
The input can be tested by using it in an "IF" statement.
These instructions will work, but they aren't very readable.
Some day you might need to come back to an old program and change it,
so I prefer to put in some comments
and refer to the pin and value it takes with symbols.
Main:
IF PIN6 = 0 THEN Main
What this does:
SYMBOL Trigger = 6 ' input trigger PIN6
SYMBOL IsOff = 0
TryAgain:
IF Trigger = IsOff THEN TryAgain ' wait until trigger is activated
The Prop-1 will "spin" around and around,
testing the trigger input again and again - until it finally sees the trigger become active.
Then the Prop-1 will break out of this "loop" and execute the rest of the program.
Example
Now, let's try a very simple program.
The goal of this program is to wait until it sees a switch pressed,
and then start blinking a LED.
' {$STAMP BS1}
' {$PBASIC 1.0}
SYMBOL TheLed = 0 ' LED is on P0
SYMBOL Trigger = PIN6 ' input trigger on P6
SYMBOL IsOff = 0
Reset:
DIRS = %00111111 ' make P7-P6 inputs, P5-P0 outputs
PINS = %00000000 ' all outputs off
Main:
TryAgain:
IF Trigger = IsOff THEN TryAgain ' wait until trigger is activated
HIGH TheLed
PAUSE 1000 ' wait 1 second
LOW TheLed
PAUSE 1000 ' wait 1 second
GOTO Main ' repeat forever
END