RC-6 is a very robust and well defined IR protocol created by Philips. This was introduced to overcome the limitations of RC-5 protocol.
Specifications : Address → 8 Bit
Command → 8 Bit
Modulation → Bi-Phase
Carrier → 36 kHz
Modulation: In RC-6 protocol all bit width (time) is not same. There are three different type of bits.
1. Leader Bit:
The leader bit is 4 times longer than normal bit. ¾ of this bit filled with burst of IR pulse and rest ¼ is idle.
2. Toggle Bit:
Toggle bit is 2 times longer than normal bit. A logical One is represented by first half (889 microsecond) filled with burst of carrier and being idle at another half. Logical Zero is represented by reversing the pattern. Note that this pattern is opposite pattern of RC5 protocol.
3. Normal Bits:
Normal bit is 888μs long,half of the bit is filled with IR burst and another half idle. Logical One and Zero pattern is same as toggle bit.
Protocol: There are multiple modes for RC6 protocol. Here we will consider mode 0 only which is reserved for Philips Consumer Electronic device. The figure below is typical example of RC6 protocol and it transmits 02H as address and 07H as command
Header Field: Header field is consists of 3 different component
- Start Bit → 1 Leader Bit. This bit not only indicates the first bit but also helps to adjust gain of receiver.
2. Mode Bit →3 Normal Bit. This bits used to determine the mode. In our case all three bits are 0
3. Toggle Bit →1 Toggle Bit. Every time a key released this bit get changed. This bit helps to understand if user has pressed and hold the button.
Address Field: Address field has one byte or 8 bits. MSB transmitted first and LSB at last.
Command Field: Command field also has one byte or 8 bits. MSB transmitted first and LSB at last similar to address field.
Scope View: Here is TSOP output (inverted) scope view of key 4
Decoding Using Microcontroller: To use RC6 remote in our electronics project we need decode the protocol and get the command from there. We may need the address and flip bit also depending the functionality of the project. So here I am going to show how we can decode RC6 using Arduino and 8051 Microcontroller.
RC6 Decoding Using Arduino: Decoding RC6 using Arduino is very easy as there are plenty of libraries are available. One of the most famous is KS Library. Click Here for Github location.
RC6 Decoding Using 8051: 8051 is another popular and cheap general purpose microcontroller used today. In case of decoding any IR protocol the timing is crucial factor. I have used 11.0592Mhz crystal so that we can use UART properly if we need it in future. The exact time frame can be created using Assembly language by calculating machine cycle. But I have seen in my experience that assembly code is very difficult to maintain. For this reason I have written the code in C. We can generate hex code by compiling the C code. But different compiler generates different hex code. I have used SDCC which is a free compiler. If you are using different compiler then you might have to adjust delayRC6.
Flowchart:
Source code:
// Bootloader and Library Fnctions Starts Here // #include <8051.h> void setup(); void loop(); void main(){ setup(); while(1)loop(); } // Bootloader and Library Fnctions Ends Here // #define IR_PIN P3_7 void delayRC6(unsigned char p); void processIR(unsigned char command); __bit flipBit = 0; __bit prevFlipBit = 0; void setup(){ //Initial setup } void loop(){ unsigned char address = 0x00; unsigned char command = 0x00; unsigned char count=0x00; while(IR_PIN==1); //Wait for first bit delayRC6(39); //Delay for 8.424ms flipBit=IR_PIN; //Reading flip bit for(count=0;count<8;count++){ delayRC6(4); //Delay for 0.864ms address = address << 1; if(IR_PIN==1) address = address | 0x01; } for(count=0;count<8;count++){ delayRC6(4); //Delay for 0.864ms command = command << 1; if(IR_PIN==1) command = command | 0x01; } //P1 = address; if(address==0x04){ //Cheking for valid address processIR(command); } } void processIR(unsigned char command){ P1 = command; //Custom code here } //delay for 216uS. For 8.424ms call 39 times and fro 0.864ms call 4 times void delayRC6(unsigned char r){ unsigned char p; unsigned int q; for(p=0;p<r;p++) for(q=0;q<27;q++); }