Using AnalysIR's batch export with IRLib

Everything related to protocols and IR codes
Post Reply
User avatar
AnalysIR
Site Admin
Posts: 776
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Using AnalysIR's batch export with IRLib

Post by AnalysIR »

A user from Singapore asked about including the automatically generated C code from AnalysIR for use with with IRLib.

The steps are simple:
- Download and install the latest version of IRLib library.
- First record the signals using AnalysIR
- Then use the batch export feature Menu->File->Batch Export->IRLib (IRremote, PSOC4 & LIRC also available.
- The C code is automatically placed in your clipboard for pasting.
- GO to your Arduino IDE and open the example IRsendDemo sketch provided with the IRLib library File->Examples->IRLib->IRsendDemo
- Edit the sketch and paste the code (CTRL+V) into the sketch to match the example provided below.
- Note we exported 3 RC6 signals and placed a 10 second gap between sending each signal. If the delau is too short it may confuse the system you are testing.

Code: Select all

#include <IRLib.h>

IRsend My_Sender;

void setup()
{
  Serial.begin(9600);
}

void loop() {
/*
Automatically Generated by AnalysIR - Batch Export Utility
Registered to: xxxxxxxx
Session History
Type : Key : Value : Bits
0 : RC6 :  : 03202 : 20
1 : RC6 :  : 00003202 : 20
2 : RC6 :  : 00003202 : 20
*/

// NB: Not all protocols are supported by IRremote or IRLib. You may need to edit the code below manually
// Automatically Generated by AnalysIR for xxxxxxxx, visit http://www.AnalysIR.com or email info@....... for further details
int khz=38; //NB Change this default value as neccessary to the correct modulation frequency
My_Sender.send(RC6,0x03202, 20); //AnalysIR Batch Export (IRLib) // AnalysIR IR Protocol: RC6, Key:  

delay(10000);
My_Sender.send(RC6,0x00003202, 20); //AnalysIR Batch Export (IRLib) // AnalysIR IR Protocol: RC6, Key:  
delay(10000);
My_Sender.send(RC6,0x00003202, 20); //AnalysIR Batch Export (IRLib) // AnalysIR IR Protocol: RC6, Key:  
delay(10000);
}
User avatar
AnalysIR
Site Admin
Posts: 776
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: Using AnalysIR's batch export with IRLib

Post by AnalysIR »

The example above used an inbuilt protocol supported by the IRLib library.

Here we show an example using the 'RAW' method. This can be useful for unsupported signal types, such as Air Conditioner signals which are not directly supported by the available libraries.(Note: We have used the same signals as above for convenience, but this time in RAW format)

Code: Select all

#include <IRLib.h>

IRsend My_Sender;

void setup()
{
  Serial.begin(9600);
}

void loop() {
/*
Automatically Generated by AnalysIR - Batch Export Utility
Registered to: xxxxxxxx
Session History
Type : Key : Value : Bits
0 : RAW :  :  : 20
1 : RAW :  :  : 20
2 : RAW :  :  : 20
*/

// NB: Not all protocols are supported by IRremote or IRLib. You may need to edit the code below manually
// Automatically Generated by AnalysIR for xxxxxxxx, visit http://www.AnalysIR.com or email info@....... for further details
int khz=36; //NB Change this default value as neccessary to the correct modulation frequency


unsigned int Signal_0_0[] = {2632,912,372,964,404,492,396,496,1292,1356,404,488,844,496,376,964,400,492,844,940,400,492,400,492,400,492,404,488,376,516,376,516,848,940,396,83988,2636,908,400,936,404,488,404,488,1296,1356,400,496,844,492,400,940,400,488,852,936,396,496,376,516,400,492,400,492,376,516,400,496,844,940,400}; //AnalysIR Batch Export - RAW

My_Sender.IRsendRaw::send(Signal_0_0, sizeof(Signal_0_0)/sizeof(int), khz); //AnalysIR Batch Export (IRLib) - RAW
 // AnalysIR IR Protocol: RAW, Key:  

delay(10000);
unsigned int Signal_1_1[] = {2604,912,428,912,428,464,428,464,424,916,816,492,376,516,844,496,400,940,376,516,844,936,404,492,372,520,376,516,400,492,400,492,400,492,848,940,372,84040,2604,912,428,912,424,468,424,468,424,912,820,492,400,492,820,520,400,940,400,492,844,936,404,488,400,496,372,520,376,516,400,492,400,492,848,940,372}; //AnalysIR Batch Export - RAW

My_Sender.IRsendRaw::send(Signal_1_1, sizeof(Signal_1_1)/sizeof(int), khz); //AnalysIR Batch Export (IRLib) - RAW
 // AnalysIR IR Protocol: RAW, Key:  
delay(10000);

unsigned int Signal_2_2[] = {2632,908,400,940,400,496,368,524,1260,1356,432,460,876,464,428,912,428,464,876,908,428,468,424,468,424,468,404,484,432,460,432,468,848,932,400,84016,2632,912,396,940,400,496,368,524,1260,1388,372,492,844,520,404,908,400,492,872,912,428,464,404,488,432,464,428,464,424,468,400,492,872,912,428}; //AnalysIR Batch Export - RAW

My_Sender.IRsendRaw::send(Signal_2_2, sizeof(Signal_2_2)/sizeof(int), khz); //AnalysIR Batch Export (IRLib) - RAW
 // AnalysIR IR Protocol: RAW, Key:  

delay(10000);
}
It is important to set the khz variable to the correct value for the IR protocol you are testing. Here we set it 36 (kHz) for the RC6 protocol. If you are unsure try each of the following values in order until it works (38,36,40,56,33,30 - ordered by ~popularity). AnalysIR always defaults to a value of 38.
User avatar
AnalysIR
Site Admin
Posts: 776
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: Using AnalysIR's batch export with IRLib

Post by AnalysIR »

If you prefer to use IRremote then just follow a similar process to the above, but this time using the IRremote library and it's IRsendDemo example sketch.

In general we suggest using IRLib rather than IRremote, particularly for Air Conditioner signals.

IRLib is a more modern/recent re-write of IRremote, with many additional features.
Post Reply