Statement equivelents
kingneb
Posts: 65
In the BASIC stamp PBasic language what are the equivilent statements to these in SX basic:
tris_b = %00000000 'portb all output
rb = 255 'make all outputs high
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
All my exes live in Texas
Oh yeah, all my exes are six feet under the ground!!!
One was a lineman who violated the one hand rule.
The·second put his tongue on 10 car batteries wired in series.
The third was involved in a tesla coil experiment gone bad.
tris_b = %00000000 'portb all output
rb = 255 'make all outputs high
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
All my exes live in Texas
Oh yeah, all my exes are six feet under the ground!!!
One was a lineman who violated the one hand rule.
The·second put his tongue on 10 car batteries wired in series.
The third was involved in a tesla coil experiment gone bad.
Comments
The closest you could come in PBasic would be OUTL or OUTH, which covers Stamp Pins 0 to 7 and 8 to 15.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester yet?
http://hometown.aol.com/newzed/index.html
·
· TRIS_B = %00000000
··RB = 255
... translate to PBASIC as:
· DIRL = %11111111
· OUTL = 255
What you'll notice is that the BASIC Stamp uses 1 to set a bit as an output, where the SX uses 0.· Why?· Well, this is an old convention where all BASIC Stamp RAM (and I/O is mapped into RAM) is cleared to zero.· Since we want reset the pins to inputs, that's what happens.· What you can correctly infer from this is that DIRL and OUTL are actually shadow registers, and the bits in DIRL are inverted before writing to the TRIS_B register.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
In PBASIC, you want to look at the following commands:
/code
DIRS = Direction register - 16 ports,· or 2 x 8, or·4 x 4;·0 = Input,·1·= Output
DIRS,·DIRL, DIRH, DIRA, DIRB, DIRC, DIRD
·ALL···Bot 8· Top 8·· 0-3··· 4-7··· 8-11·· 12-16
· 16
INS = Input pin port register - 16 ports, or 2 x 8, or 4 x 4
INS,· INL,··· INH,·· INA,· INB,· INC,·· IND
·ALL··Bot 8· Top 8· 0-3·· 4-7·· 8-11· 12-16
· 16
OUTS = Output pin port register - 16 ports, or 2 x 8, or 4 x 4
OUTS, OUTL, OUTH, OUTA, OUTB, OUTC, OUTD
·ALL··· Bot 8·· Top 8··· 0-3··· 4-7··· 8-11·· 12-16
· 16
code/
If one were to arbitrarily label Pin ports 0-7 as Port B, and Pin port 8-15 as Port A, you could effect the same settings as on the SX with the following PBASIC commands:
DIRL· = $00
OUTL = $FF
Regards,
Bruce Bates
Post Edited (Bruce Bates) : 10/19/2005 2:50:14 AM GMT
DIRH = %11111111
Will this statement make pins 14 and 15 inputs?
DIRL = %11111100
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
All my exes live in Texas
Oh yeah, all my exes are six feet under the ground!!!
One was a lineman who violated the one hand rule.
The·second put his tongue on 10 car batteries wired in series.
The third was involved in a tesla coil experiment gone bad.
Also, binary values are listed: MSB...LSB.· To make P0 - P7 outputs you would do this:
· DIRL = %11111111
Now, you don't have to set P14 and P15 to inputs at the beginning of the program, because that's their default state.·
Bruce has a typo in his post regarding the bits in the BASIC Stamp DIRS register.· In the BASIC Stamp, 1 = output, 0 = input -- this is just the opposite of program the SX in SX/B or assembly language.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 10/19/2005 2:47:15 AM GMT
for pins 14 & 15 to be used as output, not DIRL?
And
if pins 14 & 15 are to be used for inputs?
Well, at least according to the Help file, if I read it right, it does.
I think Bruce had it right. Just being a pick nitter again.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Rusty-
--
Rusty Haddock = KD4WLZ = rusty@fe2o3.lonestar.org
**Out yonder in the Van Alstyne (TX) Metropolitan Area**
Microsoft is to software what McDonalds is to gourmet cooking
Bruce's post incorrectly states that for the DIRS register, 1 = input and 0 = output. This is NOT the case with the BASIC Stamp.
From the help file:
To summarize: DIRS determines whether a pin's state is set by external circuitry (input, 0) or by the state of OUTS (output, 1). INS always matches the actual states of the I/O pins, whether they are inputs or outputs. OUTS holds bits that will only appear on pins whose DIRS bits are set to output.
(Emphasis mine)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 10/19/2005 2:52:15 AM GMT