Group Pins
Archiver
Posts: 46,084
I am new to programing in Pbasic. How do I group pins together as a
group. I need to read five pins together so that I can read them as
a whole number. I know there must be a way.
Thanks,
Troy
group. I need to read five pins together so that I can read them as
a whole number. I know there must be a way.
Thanks,
Troy
Comments
pins (P0-P3) and IND has the last 4 pins. In addition INH and INL are the
two groups of 8 bits (P8-P15 and P0-P7, respectively).
To do what you propose you'd probably want to knock off the top part of an 8
bit group, so say:
V=INL & $1F
Something like that.
Regards,
Al Williams
AWC
*Kits!
http://www.awce.com/kits.htm
Original Message
From: Troy Bakken [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=wV1hrHAIGkZipQNLWtShiBmoOE1erI6jtUwYo3Qpq_ukBF2ZhtRzhdPtSYiQ0B6t8g7N7pvsC_9fttHD]troybakken@y...[/url
Sent: Monday, April 26, 2004 10:56 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Group Pins
I am new to programing in Pbasic. How do I group pins together as a
group. I need to read five pins together so that I can read them as
a whole number. I know there must be a way.
Thanks,
Troy
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Yahoo! Groups Links
groups of four (nibbles = INA, INB, INC, IND), in groups of eight (bytes
= INL, INH), or all 16 (INS) as a word.
With your example, you'll need to read as a group of eight (INL or INH)
and then mask out the unused pins. You may also need to shift the data,
depending on your input alignments in the group.
Let's say, for example, your inputs are P0 - P4. Easy.
myInputs = INL & %00011111
This reads the group INL (P0 - P7), then masks out the inputs on P5 -
P7. But what if your inputs are not aligned on the LSB as above? What
if your inputs are P2 - P6 and you want to read them as a number. Just
tweak your mask value and add a shift operation:
myInputs = INL & %01111100 >> 2
Note that this only works with contiguous groups of pins. If your
inputs are not contiguously grouped, you'll have to grunt it out. For
example:
myInputs.BIT0 = IN0
myInputs.BIT1 = IN2
myInputs.BIT2 = IN4
myInputs.BIT3 = IN6
myInputs.BIT4 = IN7
Section 4 of the manual covers this stuff.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: Troy Bakken [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=MxOWPty49PNJll_PUNmAkyrJ-0YdH34MMn_09yHEeLh78sAwv0HFR1P3hN9npRA0JoXWenebrU_GAVMgMg]troybakken@y...[/url
Sent: Monday, April 26, 2004 10:56 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Group Pins
I am new to programing in Pbasic. How do I group pins together as a
group. I need to read five pins together so that I can read them as
a whole number. I know there must be a way.
Thanks,
Troy