In looking at it again, it actually seems like leaving the following typo from the original snippet should do just fine...

Rx_Byte = Rx_Byte << 1
Rx_Byte.0 = Rx_bit


Here's what I'm thinking...

x = don't know/don't care.

Say we're shifting in the 6 data bits 111111

Rx_Byte = xxxx xxxx before loop begins...

First pass through a 'W' loop, a '0' will be shifted into Rx_Byte, so Rx_Byte will = xxxx xxx0
Then Rx_Byte.0 will be set to Rx_Bit (1, our first data bit in), and Rx_Byte will = xxxx xxx1


On the second 'W' loop, a '0' gets shifted into Rx_Byte, and Rx_Byte = xxxx xx10
Then Rx_Byte.0 is set to the second data bit in, and now Rx_Byte = xxxx xx11

And so on through the remaining four 'W' loops.

On the last 'W' loop, a '0' gets shifted into Rx_Byte, and Rx_Byte = xx11 1110
Then Rx_Byte.0 is set to the sixth data bit in, and now Rx_Byte = xx11 1111


Step by step through a simplified version...


FOR w = 0 TO 5 ;six loops to get data bits

PULSIN Rx_Pin, 0, Pulse ;get pulse length value

If Pulse > 80 and Pulse < 120 THEN Rx_Bit = 0 ;set or clear Rx_Bit as needed

IF Pulse > 180 AND Pulse < 220 Then Rx_Bit = 1

Rx_Byte = Rx_Byte << 1 ;shift a zero into Rx_Byte bit 0

Rx_Byte.0 = Rx_bit ;place new 'Rx_Bit' value into Rx_Byte bit 0

NEXT w

At the end of each 'W' loop, Rx_Byte.0 will = the new Rx_Bit, rather than shifting the new Rx_Bit over to Rx_Byte.1
The first "Rx_Byte = Rx_Byte << 1" command just shifts in a placeholder '0', which ends up in the unused position Rx_Byte.6

Now I'm wondering what happens to Rx_bit if Pulse = 120 to 180 ???
Or if Pulse is less than 80 or more than 220 ???