bit array conversion
Archiver
Posts: 46,084
Hello,
Is there an easy way to convert a bit array into bits? I am turning
on loads based on a time loop. The times are stored in eeprom and
read during initialization using a FOR-NEXT loop. A second FOR-NEXT
loop check every second to see if its time to set load_on(n). This
REQUIRES (I think) a bit array. My problem is to send the bits out to
a shift register they have to be bits..not a bit array. I've tried
the obvious using load_on.bit0... but that gets a complier error.
Below is showing the conversion process I am now going through.
TIA, Paul
loads VAR Byte
load_on VAR Bit (8)
'would like to streamline this part
LOADS.BIT0 = load_on(0)
LOADS.BIT1 = load_on(1)
LOADS.BIT2 = load_on(2)
LOADS.BIT3 = load_on(3)
LOADS.BIT4 = load_on(4)
LOADS.BIT5 = load_on(5)
LOADS.BIT6 = load_on(6)
LOADS.BIT7 = load_on(7)
SHIFTOUT DataP,Clock,LSBFIRST,[noparse][[/noparse]LOADS\8]
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
Is there an easy way to convert a bit array into bits? I am turning
on loads based on a time loop. The times are stored in eeprom and
read during initialization using a FOR-NEXT loop. A second FOR-NEXT
loop check every second to see if its time to set load_on(n). This
REQUIRES (I think) a bit array. My problem is to send the bits out to
a shift register they have to be bits..not a bit array. I've tried
the obvious using load_on.bit0... but that gets a complier error.
Below is showing the conversion process I am now going through.
TIA, Paul
loads VAR Byte
load_on VAR Bit (8)
'would like to streamline this part
LOADS.BIT0 = load_on(0)
LOADS.BIT1 = load_on(1)
LOADS.BIT2 = load_on(2)
LOADS.BIT3 = load_on(3)
LOADS.BIT4 = load_on(4)
LOADS.BIT5 = load_on(5)
LOADS.BIT6 = load_on(6)
LOADS.BIT7 = load_on(7)
SHIFTOUT DataP,Clock,LSBFIRST,[noparse][[/noparse]LOADS\8]
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
Comments
simply need to "typecast" them. You can do this:
loads VAR Byte
loadOn VAR Bit(8)
idx VAR Nib
FOR idx = 0 TO 7
loads.LOWBIT(idx) = loadOn(idx)
NEXT
The thing is ... eight bits constitues one byte, so loadOn should be
defined as a byte to start with. I'm not sure how data is getting into
loadOn, but you can do this and still use an index:
loadOn VAR Byte
loadOn.LOWBIT(idx) = 1
By defining loadOn as a byte to start with, all the bits will be grouped
and you can send them with SHIFTOUT.
-- Jon Williams
-- Parallax
Original Message
From: P.R.Coy [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=MK5dyOB8orcDBxx76xfHpmwJS9rWfLegSj_PSwkvkWc5uBmWoztCzZwj7PTphyJum7GXH4lwvbKLHA]prcoy@y...[/url
Sent: Thursday, July 10, 2003 10:16 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] bit array conversion
Hello,
Is there an easy way to convert a bit array into bits? I am turning on
loads based on a time loop. The times are stored in eeprom and read
during initialization using a FOR-NEXT loop. A second FOR-NEXT loop
check every second to see if its time to set load_on(n). This REQUIRES
(I think) a bit array. My problem is to send the bits out to a shift
register they have to be bits..not a bit array. I've tried the obvious
using load_on.bit0... but that gets a complier error. Below is showing
the conversion process I am now going through. TIA, Paul
loads VAR Byte
load_on VAR Bit (8)
'would like to streamline this part
LOADS.BIT0 = load_on(0)
LOADS.BIT1 = load_on(1)
LOADS.BIT2 = load_on(2)
LOADS.BIT3 = load_on(3)
LOADS.BIT4 = load_on(4)
LOADS.BIT5 = load_on(5)
LOADS.BIT6 = load_on(6)
LOADS.BIT7 = load_on(7)
SHIFTOUT DataP,Clock,LSBFIRST,[noparse][[/noparse]LOADS\8]
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
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/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
loads VAR Byte
load_on VAR loads.bit0 ' alias name of bit 0
' implied array, load_on(n) refers to individual bits of loads
' load_on(3)=1
' if load_on(0)=0 then ...
' SHIFTOUT ,,,[noparse][[/noparse]loads]
>Hello,
>Is there an easy way to convert a bit array into bits? I am turning
>on loads based on a time loop. The times are stored in eeprom and
>read during initialization using a FOR-NEXT loop. A second FOR-NEXT
>loop check every second to see if its time to set load_on(n). This
>REQUIRES (I think) a bit array. My problem is to send the bits out to
>a shift register they have to be bits..not a bit array. I've tried
>the obvious using load_on.bit0... but that gets a complier error.
>Below is showing the conversion process I am now going through.
>TIA, Paul
>
>loads VAR Byte
>load_on VAR Bit (8)
>
>'would like to streamline this part
> LOADS.BIT0 = load_on(0)
> LOADS.BIT1 = load_on(1)
> LOADS.BIT2 = load_on(2)
> LOADS.BIT3 = load_on(3)
> LOADS.BIT4 = load_on(4)
> LOADS.BIT5 = load_on(5)
> LOADS.BIT6 = load_on(6)
> LOADS.BIT7 = load_on(7)
>
>SHIFTOUT DataP,Clock,LSBFIRST,[noparse][[/noparse]LOADS\8]
>