Comparing Bits with Inputs of String
Archiver
Posts: 46,084
Hi BS people
I am trying to do a Bit comparator with my BS2
I am having trouble trying to see Exactly which bits are what for my
string for each paritcular bits: bit 1, bit 2 ect and printing them
to the screen that way.(bit 1 has 0 bit 2 has 1 bit 3 has0 and bit 4
has 1) And then comparing that particular bit with an IN. My code
is a little rough on the edges but it think it will be ok...
user1 VAR Byte(6)
test VAR user1.HIGHNIB
IN1=0
IN2=1
loop
SERIN 16,16468,5000,nodata,[noparse][[/noparse]STR user1\4]
DEBUG "user1 ", STR user1,CR
DEBUG "test bit 1 ",STR test(2),CR
IF test=0 THEN new
nodata:
DEBUG "no data to display",CR
GOTO loop
new:
IN2=test
DEBUG " in2", BIN IN2, CR
STOP
thanks
I am trying to do a Bit comparator with my BS2
I am having trouble trying to see Exactly which bits are what for my
string for each paritcular bits: bit 1, bit 2 ect and printing them
to the screen that way.(bit 1 has 0 bit 2 has 1 bit 3 has0 and bit 4
has 1) And then comparing that particular bit with an IN. My code
is a little rough on the edges but it think it will be ok...
user1 VAR Byte(6)
test VAR user1.HIGHNIB
IN1=0
IN2=1
loop
SERIN 16,16468,5000,nodata,[noparse][[/noparse]STR user1\4]
DEBUG "user1 ", STR user1,CR
DEBUG "test bit 1 ",STR test(2),CR
IF test=0 THEN new
nodata:
DEBUG "no data to display",CR
GOTO loop
new:
IN2=test
DEBUG " in2", BIN IN2, CR
STOP
thanks
Comments
MaskBit0 CON %00000001
IF (User1(0) & MaskBit0) = 1 THEN
DEBUG "LSB is 1"
ENDIF
Best Wishes,
Frank
--- In basicstamps@yahoogroups.com, "princethepup"
<princethepup@y...> wrote:
> Hi BS people
> I am trying to do a Bit comparator with my BS2
> I am having trouble trying to see Exactly which bits are what for
my
> string for each paritcular bits: bit 1, bit 2 ect and printing
them
> to the screen that way.(bit 1 has 0 bit 2 has 1 bit 3 has0 and bit
4
> has 1) And then comparing that particular bit with an IN. My code
> is a little rough on the edges but it think it will be ok...
>
> user1 VAR Byte(6)
> test VAR user1.HIGHNIB
> IN1=0
> IN2=1
> loop
> SERIN 16,16468,5000,nodata,[noparse][[/noparse]STR user1\4]
> DEBUG "user1 ", STR user1,CR
> DEBUG "test bit 1 ",STR test(2),CR
> IF test=0 THEN new
> nodata:
> DEBUG "no data to display",CR
> GOTO loop
> new:
> IN2=test
> DEBUG " in2", BIN IN2, CR
> STOP
>
> thanks
-- don't use LOOP as a program label, it is now a keyword (PBASIC 2.5)
-- for more flexibility, manually declare arrays (see below)
-- you CANNOT assign input bits (INx) as you do in your code
On arrays ... the BASIC Stamp RAM space is an implicit array, so you can
give yourself some flexibility by doing this:
user1 VAR Byte
user1b VAR Byte
user1c VAR Byte
user1d VAR Byte
user1e VAR Byte
user1f VAR Byte
You can still access bytes with an index value (like user1(3)), but you
can now get to the bits of the individual elements in your array,
because you cannot use dot modifiers for variables after an array index.
Do this:
myVal = user1c.HIGHNIB
because
myVal = user1(2).HIGHNIB
will not compile.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: princethepup [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=d_kIoJ1wILbfxuUsv4w61FyzPM721lPtq6Rjw9EQ5Ty3CkMehAMDU_QLXaJkBp9WuhoQa6N5Wl3u9rUuCyfFV8Q]princethepup@y...[/url
Sent: Sunday, April 11, 2004 12:33 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Comparing Bits with Inputs of String
Hi BS people
I am trying to do a Bit comparator with my BS2
I am having trouble trying to see Exactly which bits are what for my
string for each paritcular bits: bit 1, bit 2 ect and printing them
to the screen that way.(bit 1 has 0 bit 2 has 1 bit 3 has0 and bit 4
has 1) And then comparing that particular bit with an IN. My code
is a little rough on the edges but it think it will be ok...
user1 VAR Byte(6)
test VAR user1.HIGHNIB
IN1=0
IN2=1
loop
SERIN 16,16468,5000,nodata,[noparse][[/noparse]STR user1\4]
DEBUG "user1 ", STR user1,CR
DEBUG "test bit 1 ",STR test(2),CR
IF test=0 THEN new
nodata:
DEBUG "no data to display",CR
GOTO loop
new:
IN2=test
DEBUG " in2", BIN IN2, CR
STOP
thanks