Although Infrared (IR) technology might seem outdated in today’s world of smart homes and wireless everything, it’s far from obsolete. In fact, IR is still widely used in many household devices—most notably, televisions. Even with the growing presence of Android-based smart TVs, IR remains an inevitable part of device control.

Most IR receivers are designed to detect signals modulated at 38 kHz. To be detected by the receiver, the IR signal must be modulated at (or very close to) 38 kHz.

Interestingly, this particular IR sender transmits a modulated signal at 40 kHz, slightly above the more common 38 kHz. Using the formula T = 1 / f, we can calculate the period of the signal:

T = 1 / 40,000 Hz = 25 microseconds (µs)

This means each cycle consists of 12.5 µs ON and 12.5 µs OFF, forming the standard square wave used for modulation.

Now, if you want to send a 4.5 ms burst at this frequency, you’d need to repeat this 25 µs signal 180 times:

4.5 ms / 25 µs = 180 cycles

4.5 ms = 4500 µs
4500/25 = 180

for (i = 0; i <= (duration / 25.0) ; i++){
  Set IR LED HIGH;
  delay  12.5 µs
  SET IR LED LOW
  delay  12.5 µs
}

The IR sender that I built for Samsung TV . It has some similarities with NEC protocol but not exactly. It uses following pattern;

  • 9 ms. START Bit (4.5 milisecond ON , 4.5 milisecond OFF)
  • 16 bit device code (0x0707)
  • A 16-bit command code typically consists of an 8-bit command followed by its 8-bit inverse (bitwise NOT). Example: If the command is 0xA2, the inverse would be ~0xA2 = 0x5D, so the full 16-bit command becomes 0xA25D.
  • ON IR Led for 560 µs and then OFF

Logic 1 (ON)- 560 µs HIGH, 1690 µs LOW

Logic 0(OFF) – 560 µs HIGH, 560 µs LOW

I am sharing you the schematic for IR Sender.

Schematic

You can find my C code for IR sender in my GitHub repo.

You can also find the Logic Analyzer capture in the same GitHub repo. In order to view the capture, you need a program, which you can download from Saleae.

The model I captured the traffic from IR remote control model: BN59-01198Q

Written by

yilgo

Scribbles of a Platform Engineer