Saturday, February 13, 2010

Finding out IR signal timing using a Zephir

Thanks to John Sims from I recently learned an easy way to find out infrared signal timings for use with lets say an Arduino application.

The screenshot below shows the START-STOP signal of a Canon HF100 camcorder in the Zephir signal editor. The editor offers a graphical representation of the IR signal. Red bars are ON bursts where the IR LED is switched on and off repeatedly 38000 times per second. Blue bars represent pauses. The height of the bars is proportional to the length of each burst or pause.

If you select a bar the number of ON or OFF segments is shown in the lower left corner. The example above shows 44 segments. Since each cycle consists of two segments (one ON and one OFF state) the number of cycles repeating at 38 kHz is 22. To find out an entire burst length or pause length multiply the number of cycles with 26 microseconds, the length of a 38 kHz cycle. (1 / 38000 = 0.000026 seconds) e.g. 22 cycles times 26 microseconds equals 572 microseconds burst length.

Now comes the fun part. In the Zephir editor choose Edit > Select All followed by Edit > Copy. To get the number of cycles of each bar just copy the clipboard content into a text editor:

Below is an example how this can be used in an Arduino sketch. Note that all "044" numbers have been replaced with "44".

Arduino sketch for sending a START-STOP IR remote signal to a Canon HF100 camcorder
Code is based on an example at
2010, Martin Koch,
#define irLED 3
unsigned long START_STOP_Signal[68] = {684,351,44,130,44,130,44,44,44,44,44,44,44,44,44,44,44,130,44,130,44,130,44,44,44,44,44,44,44,130,44,130,44,130,44,130,44,130,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,130,44,130,44,130,44,130,44,130,44,130,44,3116};

void setup() {
pinMode(irLED, OUTPUT);
delay(3000); // record 3 * 1000 ms

void loop() {

void START_STOP() {
for (int i=0; i<68; i=i+2) {
unsigned long endBurst = micros() + START_STOP_Signal[i] * 13; // create the microseconds to pulse for
while(micros() < endBurst) {
digitalWrite(irLED, HIGH); // turn IR on
delayMicroseconds(13); // half the clock cycle for 38 Khz (26.32×10-6s)
digitalWrite(irLED, LOW); // turn IR off
delayMicroseconds(13); // delay for the other half of the cycle to generate oscillation
unsigned long endPause = micros() + START_STOP_Signal[i+1] * 13; // create the microseconds to delay for
while(micros() < endPause);

No comments:

Post a Comment