That definitely is a start ...
Did you check the PM I sent you by the way ?

As much as I have read the info on the PULSIN command, it still leaves me somewhat confused.

I have seen many references to your code on the forum but I just can't seem to 'catch on' to the method

My blurred pseudo understanding of it is :

1.Wait for a certain pulse of specified duration (discard all other pulses we are not interested in)
2. Once the correct pulse is received then start counting pulses of a certain duration
3. Store each pulse as a bit. 8 pulses = a byte , 32 pulses = 4 bytes
4. Decipher the received/stored bits/bytes into a SYSTEM ID and a DEVICE ID.


So with reference to the diagram and the following quote:

http://www.sbprojects.com/knowledge/ir/rc5train.gif


The first two pulses are the start pulses, and are both logical "1". Please note that half a bit time is elapsed before the receiver will notice the real start of the message.
Extended RC-5 uses only one start bit. Bit S2 is transformed to command bit 6, providing for a total of 7 command bits. The value of S2 must be inverted to get the 7th command bit though!

The 3rd bit is a toggle bit. This bit is inverted every time a key is released and pressed again. This way the receiver can distinguish between a key that remains down, or is pressed repeatedly.
The next 5 bits represent the IR device address, which is sent with MSB first. The address is followed by a 6 bit command, again sent with MSB first.
A message consists of a total of 14 bits, which adds up to a total duration of 25 ms. Sometimes a message may appear to be shorter because the first half of the start bit S1 remains idle. And if the last bit of the message is a logic "0" the last half bit of the message is idle too.

As long as a key remains down the message will be repeated every 114ms. The toggle bit will retain the same logical level during all of these repeated messages. It is up to the receiver software to interpret this auto repeat feature.

PS: I had rather a big error on this page for quite some time. For some mysterious reason the LSB and MSB of the address and command were reversed. I can recall correcting this error before, but somehow an old version of the description must have sneaked its way up to the internet again.
And with reference to your code

Code:
If (stx<760) Then init
As soon as a pulse is received greater than 760 then INIT but what is the 760 ?
and
Code:
While GPIO.1=1:Wend			'wait space
This line is the same as
Code:
While GPIO.1=1
Wend			'wait space
So in other words keep looping while GPIO.1 is 1
and as soon as it goes to a 0 then continue to the next line(s)
On the next section of code (the pulse count/bit catcher) you REPEAT the same thing until i is > 31 (since 0 to 31 is 32 pulses(1 or 0 bits) right ?

Code:
Repeat
          PulsIn GPIO.1, 1, pulse
          If (pulse>100) Then
            IR.0(i)=1				'set bit
          EndIf
          i=i+1 
        Until (i>31)
OK for me there is a little confusion in the above stub of the code
Code:
If (pulse>100) Then
So do we disregard any pulse less than 100 here ?

and this line
[/code] IR.0(i)=1 [/code]

So the above begins to build the the array IR[4] (it's 4 since we need to catch 4 bytes (32 pulses/bits) not so ?)
The value "i" is the counter which is incremented evertime we loop through this section of code until the UNTIL condition is met (Ie. we have 32 bits or 4 bytes namely IR.0,IR.1IR.2and IR.3)
And finally to send what we have so far (the value of the 4 IR bytes to the PC serial port
Code:
For i = 0 To 3
          Debug IHEX2 IR[i] 
          
        Next
I notice you display the HEX value here, is that because if it were decimal you might overflow the WORD var ?

I also saw in another posting that there might be a reverse bit order sent through ... is that correct ?

In the meantime I will go through the link you sent and carefully examine the RC5 info and post what I have come up with albeit wrong.

Kind regards

Dennis





I hope you don't mind me asking a tally of questions to get a clearer understanding of the functions.