Multiple inputs to Byte

Marcwolf

Senior Member
Hi there.
I know this must have been done before but there are so many combinations of search words I have given up.

Ok - I have an 20M with 8 inputs. I need a FAST way to convert 7 of those inputs into a Byte.

I could do it using read pin 1 + (pin 2 * 2) + (pic 3 * 4) etc but is there a FASTER (and less code intensive) way.

The concept being that I am reading the output of a HM2007 board. This board puts out via a 74ls373 the value of a recognised word. If the value is 55,66,77 then it is invalid and should not be processed.

The actual HM2007 chip sends a low pulse to the 74ls373 to output the value of the word onto the bus so I will be using that on Input 8 of the 20M as an interrupt.

I can then program the 20M to check the values to see if it is a correct word and then send it to another board via the serial bus.

Many thanks for any inspirations

Dave
Many thanks

Dave
 

andrew_qld

Senior Member
Whats wrong with:

let b1=pins ?

That will read the status of all 8 input pins into b1
If you only need 7 bits you can mask one of the pins with the:

let b1 = pins & %01111111

This lets reads the value of pins 0 through 6 into b1

This is all in the manual. Or are you trying to do something different?

Cheers,
Andrew
 

Marcwolf

Senior Member
Thanks Andrew

Hi Andrew.

Thanks - that is what I was looking for. However - PIN's is not the first choice of words I would look for when searching for that operation :>

Many thanks

Take Care
Dave
 
Top