BS1 Help - Manipulating Individual Bits
Hi. Well, after all these years of working with the BS2/BS2SX I've built a
tiny micro size bot that uses a BS1. Talk about taking a step backwards.
Anway, I'm wanting to control my two motors. Using the BS2 is simple...I
use OUTA=%0011, etc.
Question:
I can't use OUTA on the BS1. Is there a way to set/change the bits on only
four of the pins (P0-P3) without changing the state or value of the other
four (since they are used for IR input, etc.)? I think it is possible using
PINS and a bitwise operator but I'm not sure which one or how to code it.
Could someone please show me how with an example?
Here is what I'm trying to replace:
********************
forward: ' Move Forward
low 0
low 1
high 2
high 3
return
********************
But the other four bits (P4-7) cannot be modified or have their state
changed.
Pages 73 through 76 of the Stamp Manual contain information on this but I
just can't seem to get it. It's really simple... right???
Thanks,
Brice D. Hornback
Educational & Personal Robots
http://www.cyberbound.com
tiny micro size bot that uses a BS1. Talk about taking a step backwards.
Anway, I'm wanting to control my two motors. Using the BS2 is simple...I
use OUTA=%0011, etc.
Question:
I can't use OUTA on the BS1. Is there a way to set/change the bits on only
four of the pins (P0-P3) without changing the state or value of the other
four (since they are used for IR input, etc.)? I think it is possible using
PINS and a bitwise operator but I'm not sure which one or how to code it.
Could someone please show me how with an example?
Here is what I'm trying to replace:
********************
forward: ' Move Forward
low 0
low 1
high 2
high 3
return
********************
But the other four bits (P4-7) cannot be modified or have their state
changed.
Pages 73 through 76 of the Stamp Manual contain information on this but I
just can't seem to get it. It's really simple... right???
Thanks,
Brice D. Hornback
Educational & Personal Robots
http://www.cyberbound.com
Comments
Original Message
> Hi. Well, after all these years of working with the BS2/BS2SX I've built
a
> tiny micro size bot that uses a BS1. Talk about taking a step backwards.
> Anway, I'm wanting to control my two motors. Using the BS2 is simple...I
> use OUTA=%0011, etc.
>
> Question:
>
> I can't use OUTA on the BS1. Is there a way to set/change the bits on
only
> four of the pins (P0-P3) without changing the state or value of the other
> four (since they are used for IR input, etc.)? I think it is possible
using
> PINS and a bitwise operator but I'm not sure which one or how to code it.
> Could someone please show me how with an example?
>
> Here is what I'm trying to replace:
>
> ********************
> forward: ' Move Forward
> low 0
> low 1
> high 2
> high 3
> return
> ********************
>
> But the other four bits (P4-7) cannot be modified or have their state
> changed.
>
> Pages 73 through 76 of the Stamp Manual contain information on this but I
> just can't seem to get it. It's really simple... right???
Original Message
From: Rodent <daweasel@s...>
To: <basicstamps@yahoogroups.com>
Sent: Tuesday, July 03, 2001 6:03 PM
Subject: Re: [noparse][[/noparse]basicstamps] BS1 Help - Manipulating Individual Bits
So read in the whole word, modify the bits you want and write it back.
Original Message
> Hi. Well, after all these years of working with the BS2/BS2SX I've built
a
> tiny micro size bot that uses a BS1. Talk about taking a step backwards.
> Anway, I'm wanting to control my two motors. Using the BS2 is simple...I
> use OUTA=%0011, etc.
>
> Question:
>
> I can't use OUTA on the BS1. Is there a way to set/change the bits on
only
> four of the pins (P0-P3) without changing the state or value of the other
> four (since they are used for IR input, etc.)? I think it is possible
using
> PINS and a bitwise operator but I'm not sure which one or how to code it.
> Could someone please show me how with an example?
>
> Here is what I'm trying to replace:
>
> ********************
> forward: ' Move Forward
> low 0
> low 1
> high 2
> high 3
> return
> ********************
>
> But the other four bits (P4-7) cannot be modified or have their state
> changed.
>
> Pages 73 through 76 of the Stamp Manual contain information on this but I
> just can't seem to get it. It's really simple... right???
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.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
represents individual ports.
This code snippet should work...
SYMBOL My_Var = W0 'the whole word
SYMBOL My_Var_Low = B0 'the low byte of the word W0
SYMBOL My_Var_High = B1 'the high byte of the word W0 (if you need to
modify this part)
My_Var = PINS 'read the pin values in
My_Var_Low = %1001 'change the value of the low byte to
whatever
PINS = My_Var 'set the new pin values
Original Message
> How?
> So read in the whole word, modify the bits you want and write it back.
>
>
Original Message
>
> > Hi. Well, after all these years of working with the BS2/BS2SX I've
built
> a
> > tiny micro size bot that uses a BS1. Talk about taking a step
backwards.
> > Anway, I'm wanting to control my two motors. Using the BS2 is
simple...I
> > use OUTA=%0011, etc.
> >
> > Question:
> >
> > I can't use OUTA on the BS1. Is there a way to set/change the bits on
> only
> > four of the pins (P0-P3) without changing the state or value of the
other
> > four (since they are used for IR input, etc.)? I think it is possible
> using
> > PINS and a bitwise operator but I'm not sure which one or how to code
it.
> > Could someone please show me how with an example?
> >
> > Here is what I'm trying to replace:
> >
> > ********************
> > forward: ' Move Forward
> > low 0
> > low 1
> > high 2
> > high 3
> > return
> > ********************
> >
> > But the other four bits (P4-7) cannot be modified or have their state
> > changed.
> >
> > Pages 73 through 76 of the Stamp Manual contain information on this but
I
> > just can't seem to get it. It's really simple... right???
doesn't allow parenthesis like the BS2 does. What you want to do is this:
Pins = Pins & %11110000 | newOutData
The "& %11110000" part protects pins P3 - P7 and clears the lower bits, the
OR operator enables the bits that are set in the variable called "newOutData."
HTH.
-- Jon Williams
-- Dallas, TX
In a message dated 7/3/01 6:04:58 PM Central Daylight Time,
bdh@c... writes:
> Hi. Well, after all these years of working with the BS2/BS2SX I've built a
> tiny micro size bot that uses a BS1. Talk about taking a step backwards.
> Anway, I'm wanting to control my two motors. Using the BS2 is simple...I
> use OUTA=%0011, etc.
>
> Question:
>
> I can't use OUTA on the BS1. Is there a way to set/change the bits on only
> four of the pins (P0-P3) without changing the state or value of the other
> four (since they are used for IR input, etc.)? I think it is possible using
> PINS and a bitwise operator but I'm not sure which one or how to code it.
> Could someone please show me how with an example?
>
> Here is what I'm trying to replace:
>
> ********************
> forward: ' Move Forward
> low 0
> low 1
> high 2
> high 3
> return
> ********************
>
> But the other four bits (P4-7) cannot be modified or have their state
> changed.
>
> Pages 73 through 76 of the Stamp Manual contain information on this but I
> just can't seem to get it. It's really simple... right???
>
[noparse][[/noparse]Non-text portions of this message have been removed]
Original Message
> It's not too tough. Remember that the Stamp 1 evaluates left-to-right and
> doesn't allow parenthesis like the BS2 does. What you want to do is this:
>
> Pins = Pins & %11110000 | newOutData
>
> The "& %11110000" part protects pins P3 - P7 and clears the lower bits,
the
> OR operator enables the bits that are set in the variable called
"newOutData."
> > Hi. Well, after all these years of working with the BS2/BS2SX I've
built a
> > tiny micro size bot that uses a BS1. Talk about taking a step
backwards.
> > Anway, I'm wanting to control my two motors. Using the BS2 is
simple...I
> > use OUTA=%0011, etc.
dropped over half the lines of code I originally had and this runs so much
more efficiently. I thought it could be done with the bitwise OR but I
wasn't sure how to protect the other bits. This helps me understand the
bitwise stuff a "bit" more and I really appreciate the help.
THANK YOU!
Best regards,
Brice
Educational & Personal Robots
http://www.cyberbound.com
Original Message
From: <jonwms@a...>
To: <basicstamps@yahoogroups.com>
Sent: Tuesday, July 03, 2001 7:41 PM
Subject: Re: [noparse][[/noparse]basicstamps] BS1 Help - Manipulating Individual Bits
It's not too tough. Remember that the Stamp 1 evaluates left-to-right and
doesn't allow parenthesis like the BS2 does. What you want to do is this:
Pins = Pins & %11110000 | newOutData
The "& %11110000" part protects pins P3 - P7 and clears the lower bits, the
OR operator enables the bits that are set in the variable called
"newOutData."
HTH.
-- Jon Williams
-- Dallas, TX
In a message dated 7/3/01 6:04:58 PM Central Daylight Time,
bdh@c... writes:
> Hi. Well, after all these years of working with the BS2/BS2SX I've built
a
> tiny micro size bot that uses a BS1. Talk about taking a step backwards.
> Anway, I'm wanting to control my two motors. Using the BS2 is simple...I
> use OUTA=%0011, etc.
>
> Question:
>
> I can't use OUTA on the BS1. Is there a way to set/change the bits on
only
> four of the pins (P0-P3) without changing the state or value of the other
> four (since they are used for IR input, etc.)? I think it is possible
using
> PINS and a bitwise operator but I'm not sure which one or how to code it.
> Could someone please show me how with an example?
>
> Here is what I'm trying to replace:
>
> ********************
> forward: ' Move Forward
> low 0
> low 1
> high 2
> high 3
> return
> ********************
>
> But the other four bits (P4-7) cannot be modified or have their state
> changed.
>
> Pages 73 through 76 of the Stamp Manual contain information on this but I
> just can't seem to get it. It's really simple... right???
>
[noparse][[/noparse]Non-text portions of this message have been removed]
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.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/