Dynalloy Muscle Wires FrankenSerial Interface Quick Start Manual - Page 4
Browse online or download pdf Quick Start Manual for Accessories Dynalloy Muscle Wires FrankenSerial Interface. Dynalloy Muscle Wires FrankenSerial Interface 5 pages. Moving electronics kit
6.0 FrankenSerial Interface Input/Output Commands
FrankenSerial
Command
Syntax
High
H [0-15]
Low
L [0-15]
Toggle
T [0-15]
Bit
B [0-15]
Analog
A
Input
I [0-15]
Output
O [0-15]
Direction,
DB
Both
Direction
DL
Lower
Direction
DH
Higher
Read Both
RB
Read Lower
RL
Read Higher
RH
F2893
1-089 V3.0 ©MMVII Muscle Wires®
and Flexinol® are registered trademarks of Dynalloy
Action, Stamp Syntax Example
Turns the selected pin to an output and writes a 1 to it.
SEROUT 0, N2400,("H",9)
' Sets Interface pin 9
Turns the selected pin to an output and writes a 0 to it.
SEROUT 0, N2400,("L",b2) ' Clears Interface pin
' whose number is contained in b2.
Turns the selected pin to an output and toggles (inverts) it.
SEROUT 0, N2400,("T",9)
' Toggles Interface pin 9.
Returns the state (0 or1) of the specified bit. Does not affect
the pins' data direction settings (input or output).
SEROUT 0, N2400,("B",15)
' Request status of bit 15.
SERIN 0, N2400, b2
' Get bit status in b2.
Returns a reading (0 to 255) from the ADC.
SEROUT 0, N2400,("A")
' Request ADC reading.
SERIN 0, N2400, b2
' Get ADC data in b2.
Makes the specified pin number an input.
SEROUT 0, N2400,("I",b2)
' Makes the pin whose number
' is stored in b2, an input.
Makes the specifies pin number an output. Whatever state was
Last written to the pin (high or low) will be output when this occurs.
If the pin must be in a particular state, use High or Low to make it
an output.
SEROUT 0, N2400,("O",3)
' Makes pin 3 an output.
Writes the data direction registers of both of the Interface's I/O
ports. A binary 1 in the data-direction register makes the
corresponding pin an output; a 0 makes it an input. The Interface
expects the lower port's data direction first.
SEROUT 0, N2400,("DB",%00001111,%11111111)
' Make pins 0-3 outputs, 4-7 inputs. Make all of the
' upper port pins outputs.
Writes the data direction register of the Interface's lower I/O port as
in DB above.
SEROUT 0, N2400,("DL",255)
' Make all of lower port outputs (255 = %11111111).
Writes the data direction register of the Interface's higher I/O port
as in DB above.
SEROUT 0, N2400,("DH",255)
' Make all of higher port outputs (255 = %11111111).
Reads both of the Interfaces I/O ports. Does not affect
the pins' data direction settings (input or output). Interface returns
data as two bytes, lower byte first.
SEROUT 0, N2400,("RB")
' Request read of port.
SERIN 0, N2400, b2,b3
' Get Interface data.
Reads the Interface's lower I/O port (pins 0-7) as in RB above.
SEROUT 0, N2400,("RL")
' Request read of port.
SERIN 0, N2400, b2
' Get Interface data.
Reads the Interface's higher I/O port (pins 8-15) as in RB above.
SEROUT 0, N2400,("RH")
' Request read of port.
SERIN 0, N2400, b2
' Get Interface data.
FrankenSerial
Command
Syntax
Write Both
WB
Write Lower
WL
Write Higher
WH
Sleep
S
Reset
*
Converting the program examples for use with the BASIC Stamp 2
The BASIC Stamp 2 (BS2) has Serin and Serout instructions that are similar to those of the BS1, but offer
more options. First of all, you can send and receive data at arbitrary data rates up to 50,000 bps, so it's up to
you to calculate the bit time and other communication parameters, called "baudmodes" in PBASIC. Here are
the baudmodes that apply to communication with the FrankenSerial Interface.
$418d
$4054
We won't duplicate the entire instruction table here, just a couple of examples. Suppose you wanted to toggle
pin 10 of the Interface, and that the Interface's serial pin is connected to BS2 pin 0. Assuming the Interface is
set for 9600 bps (jumper installed on the posts marked BPS), the instruction would be:
serout 0,$4054,["T",10]
The same pattern applies to all of the other output-only instructions.
To issue an instruction that expects a serial response (B for bit and A for Analog), you perform Serout to send
the instruction followed by Serin to get the response. For instance, to read the state of Interface bit 15,
assuming BS2 pin 0 for serial communication, 2400 baud (no jumper at BPS), and the existence of a byte
variable named "result," your instructions would be:
serout 0,$418d,["B",15]
Serin 0, $418d, [result]
The BS2 flavors of Serin and Serout have many other options. See the Parallax documentation for details.
Action, Stamp Syntax Example
Writes both of the Interface's I/O ports. Does not affect the pins'
data direction settings (input or output). If a pin is set to input at the
time of a write, it will not be affected until I is made an output.
SEROUT 0, N2400,("WB", b2, b3)
' Write contents of
' variable b2 to lower port, b3 to higher.
Writes the interface's lower I/O port (pins 0-7) as in WB above.
SEROUT 0, N2400,("WL", 255)
' Write 1s to all pins
' of the lower port.
Writes the interface's higher I/O port (pins 8-15) as in WB above.
SEROUT 0, N2400,("WH", 255)
' Write 1s to all pins
' of the higher port.
Puts the Interface to sleep. At intervals of 18 ms to 2.3 seconds,
the Interface will check its serial line for a high, signaling it to wake
up.
SEROUT 0, N2400,("S", 0)
' Sleep. Look for
' wakeup every 18 ms.
Returns the Interface's I/O pins to their power-up configuration;
All inputs, and all internal latches cleared to 0s. Useful during
Programming to set the interface to a know state. However, if the
Stamp is interrupted in the middle of a multipart command, it may
take as may as three resets to finish the interrupted command and
actually reset the interface.
SEROUT 0, N2400,("*")
' Reset all pins/directions.
'Inverted, 2400 baud.
'Inverted, 9600 baud.
'Toggle pin 10.
'Request state of bit 15.
'get the response