~derf / ir codes / nec protocol

The NEC IR protocol is commonly used for simple infrared remote controls. There's a detailed description at Altium: NEC Infrared Transmission Protocol.

In case that site goes down, the NEC protocol boils down to the following:

  • data is modulated on a 38kHz carriar for IR transmission
  • Logical 0: 562.5µs burst (demodulated as "1") + 562.5µs space (demodulated as "0")
  • Logical 1: 562.5µs burst + 1.6875ms space
  • Leader code: 9ms burst + 4.5ms space
  • Repeat code: 9ms burst + 2.25ms space
  • EOT code: 562.5µs burst

When a key is pressed, the following is transmitted:

  • Leader code
  • 8-bit device address (e.g. 0x00)
  • Logical inverse of device address (e.g. 0xff)
  • 8-bit command (e.g. 0x04)
  • Logical inverse of command (e.g. 0xfb2
  • EOT code

If the key is quickly released, no other transmissions will be sent. If it is kept pressed, the remote will issue periodic repeat codes:

  • Repeat code
  • EOT code