QZHU

Infrared (IR) Remote Communication on Multiple Protocols II

Posted on September 22, 2020

Hi everyone, here is another update on the topic of Infrared (IR) Remote Communication on Multiple Protocols. Previously we have gone through IR Communication Theory. And in this article, we will get to know IR protocols and using NEC protocol as an example.

Here are the topics I would like to note down in this article:

  • IR Communication Theory
  • IR NEC Protocol <– We are here!!
  • IR Transmit Raw Data
  • Useful Tool: Pulse View + Logic Analyzer
  • Useful Links

I will give a general background idea on what I understand about IR Communication Theory first, then gradually add in the remaining parts. Please stay tuned.

IR NEC Protocol

NEC, also known as Japanese Format, was developed by Now Renesas. The NEC protocol uses Pulse Distance Encoding of the message bits for data communication. As we described in the previous article, the carrier frequency is at 38kHz and each MARK (transmitter ON) is around 560µs in length.

It further forms the rules of NEC logic bits (figure below):

Logic bits of NEC

Figure 4: NEC Logic Bits Formation
  • Logical ‘0’: a 560µs MARK followed by a 560µs (= 1120 µs – 560 µs) SPACE, with a total transmit time of 1.125ms
  • Logical ‘1’: a 560µs MARK followed by a 1690µs (= 2250 µs – 560 µs) SPACE, with a total transmit time of 2.25ms

In conclusion, the features of NEC can be listed in the following bullet points:

NEC Features

  • 8-bit address and 8-bit command length.
  • Extended mode available, doubling the address size.
  • Address and command are transmitted twice for reliability.
  • Pulse distance modulation.
  • The carrier frequency of 38kHz.
  • Bit time of 1.125ms or 2.25ms.

Modulation

Since a total number of  32-bit data together with the header and the end-bit will be transferred (Figure 5). If we separate the data in the time-frame (in us), there will be ( 2 + 32 ) x 2 + 1 = 69 MARKs or SPACEs, which is 69 data in microseconds to be transmitted (Figure 6).

Figure 5: Example of a Full NEC Data (in logic1 or 0)

Figure 6: Sample of a Full NEC RAW Data (in us)

This part of the code can be modified by users as NEC RAW data. Details of how to obtain raw data code for your remote devices, you may refer to Ken Shirriff’s blog, where it provides multiple libraries provided online. It will also be explained in the later section of “IR Transmit Raw Data“.

Starting Bit

Figure 4 above shows a typical pulse train of the NEC protocol. With this protocol, the LSB is transmitted first. In this case, the first 9ms MARK and 4.5ms SPACE is indicating a Starting Bit, which was used to set the gain of the earlier IR Receivers. Then following by the Address and Command.

Address

The Address is transmitted twice, the 2nd time all the bits are inverted and can be used for validation and verification of the receiving message is correct.

Command

The Command is transmitted twice, the 2nd time all the bits are inverted and can be used for validation and verification of the receiving message is correct.

 

The total transmission time is constant because every bit is repeated with its inverted length. If you’re not interested in this reliability you can ignore the inverted values, or you can expand the Address and Command to 16 bits each! Keep in mind that one extra 560µs burst has to follow at the end of the message to be able to determine the value of the last bit. (Quoted from SB Projects: https://www.sbprojects.net/knowledge/ir/nec.php)

 

Here comes to the end of the story behind the NEC protocol, hope it could help you with your project development. Stay tuned and I will be soon finishing the uploading on the reset of the sections.

Share with:

FacebookTwitterLinkedIn