Pages: [1] 2   Go Down
Author Topic: Solved: LG air conditioning codes  (Read 19896 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 49
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I'm working on an arduino remote control for LG air conditioner that should assemble mode, temp, fan speed (and any other parameters) and emulate the original remote control.
Can anybody point me to some resources about LG air conditioning codes?
Many thanks,
Adi
« Last Edit: January 04, 2012, 02:18:19 pm by adis » Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 95
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

https://github.com/shirriff/Arduino-IRremote

That library will allow you to record the IR codes, store them and send them. There isn't an LG protocol in the library but you can send the raw codes.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


If that doesn't work, see how I solved this:

http://arduino.cc/forum/index.php/topic,85056.0.html

Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13742
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Nice hack Martin smiley-wink
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 49
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

https://github.com/shirriff/Arduino-IRremote

That library will allow you to record the IR codes, store them and send them. There isn't an LG protocol in the library but you can send the raw codes.
Thanks Targettio
Your hint worked. Used the library to decode on/off times then gave 0/1 for each pulse duration. I obtained a 28 byte stream. Using slightly different commands (for example set temp with a degree difference) I managed to map each command inside the stream. The stream has a 4 bit CRC that sums each 4 bit group.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13742
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you post the command codes?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 49
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the output for the IR library
8250h   4300l = header
next
450h   1700l = 1
450h   700l = 0

first byte after header: 1 0 0 0 1 0 0 0 (i will not repeat this below)
power on: 0 0 0 0 0 1 0 0 1 1 1 1 0 1 0 0 + CRC 0 1 1 1 ( = 1 0 0 0 + 1 0 0 0 + 0 0 0 0 + 0 1 0 0 + 1 1 1 1 + 0 1 0 0; I will not repeat CRC below)
(this power on includes mode, temp and fan speed)
power off:1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 ( dont't see here any info about mode, temp and fan speed)
change temp/fan / mode:
0 0 0 0 1 1 0 0 1 1 1 0 0 1 0 0 = heating 29 C Fan4
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
1-5 always the same except for timer set, or jet mode (or other SF I was not interested)
6-8 heating 4, auto 3, dehumidification 1, cooling 0
9-12 = temp -15
13 = 0
14-16 = fan1 1, fan2 0 (strange), fan3 2, fan4 4

Make sure you add the header, the first byte and the CRC.
The code was tested with 38kHz modulation and it worked
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 134
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you also share how you convert the pulses to byte data? I am poking my eyes on a WAV file I recorded with my sound card and am able to read the data by eye, but it is tedious...



My Daikin has apparently aound 35 byte frame from what I see in the WAV file, broken in two transmissions (one short and one double that)

here is the WAV file itself:
http://dl.dropbox.com/u/18771283/daikin.wav

it has been quite a challenge so far, you have motivated me again.

My previous solution with emulating the keys clicks is HIGHLY unsatisfying since the arduino doesn't know the current readings on it, neither can get feedback..

also, if you may share the code, it will give the rest of us directions.

Thanks smiley
« Last Edit: January 05, 2012, 06:48:14 am by martin_bg » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 49
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Martin,

Your ir is modulated with aprox 38 khz, so using the sound card is the wrong way to start.
From your picture I don't understand how you captured it, but lets start the way I did it:

My advice is to spend 2€ on a 38khz ir receiver with digital output and a ir led and install the library from the second post.
You should be able to see the byte stream and play it back. If your air conditioner responds to it you have a solution using certain preconfigured commands.

Decoding is another story:
The library will give you the streams in a numeric format that can be converted into a 1/0 stream (with ms excel)
You set the temp to 29 and then to 28 and look for the differences in the stream...
Let me know when you have the hardware tested with the library and give me the  output from ir library, I'll fill in the excel and post it.

One word of caution: the remote is the state machine memory, if you use another remote in parallel your arduino is quite lost.

The code I have until now are some undocumented test, but the main is irsend.sendRaw(codesArray,buffer_size,38);

Regards,
Adi
« Last Edit: January 05, 2012, 03:02:39 pm by adis » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Adi,
I installed the IR library for Arduino, and used it to record the signal sent by my remote control to my Elco airconditioner.
However, when using the IRecvDump sketch, the output is in a form such as
Code:
Raw (76): 21114 1400 -1450 500 -500 500 -500 450 -1000 450 -500 500 -500 950 -550 450 -1000 950 -550 450 -950 500 -500 950 -550 450 -500 450 -550 450 -500 450 -550 450 -500 450 -550 450 -550 450 -550 400 -550 450 -550 450 -500 450 -550 450 -500 450 -550 450 -550 400 -550 450 -550 400 -1000 950 -550 1400 -1500 450 -550 400 -550 450 -1000 450 -550 400 -550 950

and I have no idea how to convert this to hex.
Can you please give me a hand?

Thanks!
-Ethan
Logged

Rome
Offline Offline
God Member
*****
Karma: 1
Posts: 987
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have a nice surf on my blog! :-)
http://jumpjack.wordpress.com/2008/05/20/worlds-cheapest-remote-control-replicator-just-1/
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice work, thanks!
Logged

Cosenza, Calabria - Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

dear Adis,

 may post code to clone the LG remote control, and the code to send commands acquired??

PS: I am using the examples of Ken Shirriff (IRrecvDemo.ino or IRrecvDump.ino) I get a 16-bit code (the original code is 24-bit.) These are the first 16 bits of the command.

thank you very much :-)
(sorry for my bad english)

Alessandro

* IRrecvDump.ino (2.03 KB - downloaded 92 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 49
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Below is the test program and a library I wrote in january.
I did my best to make it as clear as possible.

Regards,
Adi

Code:
#include <LG.h>
#include <IRremote.h>

// the LG code generator object

// the IR emitter object
IRsend irsend;

void setup()
{
Serial.begin(9600);
Serial.println("Start");


// wait 5 seconds
//delay(5000);
//LG LG(mode_heating,fan_4,30,state_on);
//LG LG(mode_heating,fan_4,30,state_off);
LG LG(mode_cooling,fan_1,18 ,state_on);


LG.debug();
// change the state
//LG.setState(STATE_off);
// send the code

irsend.sendRaw(LG.codes,LG_buffer_size,38);
//
Serial.println("End");



// wait 10 seconds
//delay(10000);

// change the state
//LG.setState(STATE_on);
// send the code
//irsend.sendRaw(LG.codes,LG_buffer_size,38);
}

void loop() {}

LG.h
Code:
#ifndef LG_h
#define LG_h
#include <WProgram.h>

#define first_byte 136 //b10001000

#define state_on 0
#define state_off 24 //b11000
#define state_change_mode 1

#define mode_heating 4 //b100
#define mode_auto 3 //b011
#define mode_dehuidification 1 //b001
#define mode_cooling 0
#define mode_none 0

#define temperature_offset 15

#define fan_1 1
#define fan_2 0
#define fan_3 2
#define fan_4 4 //b100
#define fan_none 5 //b101

#define first_high 8271
#define first_low 4298
#define zero_and_one_high 439
#define zero_low 647
#define one_low 1709

#define LG_buffer_size 59

class LG
{
public:
// fields
unsigned int codes[LG_buffer_size];
// methods
// setter
LG(int _mode,
int _fan,
int _temperature,
int _state);
// getter
// debugging
void debug();
private:
// fields
byte crc;
// methods
void FillBuffer(byte _pos, byte _bit, byte _value);
};

#endif;
LG.cpp
Code:
#include "LG.h"
LG::LG(int _mode,
int _fan,
int _temperature,
int _state)
{
// set sync
codes[0] = first_high;
codes[1] = first_low;
crc = 0;
FillBuffer(0,8,first_byte);
FillBuffer(8,5,_state);
if(_state==state_off)
FillBuffer(13,3,mode_none);
else
FillBuffer(13,3,_mode);
if(_state==state_off)
FillBuffer(16,4,0);
else
FillBuffer(16,4,(byte)_temperature-temperature_offset);
FillBuffer(20,1,0); //jet
if(_state==state_off)
FillBuffer(21,3,fan_none);
else
FillBuffer(21,3,_fan);
FillBuffer(24,4,crc);
codes[LG_buffer_size-1] = zero_and_one_high;
}

void LG::FillBuffer(byte _pos, byte _bits, byte _value){
for (int i=_bits;i>0;i--){
codes[2+2*(_pos+_bits-i)] = zero_and_one_high;
codes[2+2*(_pos+_bits-i)+1] = (bitRead(_value,i-1)==1?one_low:zero_low);
if(bitRead(_value,i-1)==1){
byte bitset = 0;
bitSet(bitset,(128+i-_pos-_bits-1)%4);
crc = crc + bitset;
}
}
}
void LG::debug()
{
for(byte i=0;i<LG_buffer_size;i++){
Serial.print(codes[i],DEC);
Serial.print(",");
}
}
Logged

Cosenza, Calabria - Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Another HELP!!??? smiley-lol   smiley-grin

I use Arduino 1.0.1
in the verification phase of the first code posted by Adis:

[ERROR]
Programmi\arduino-1.0.1\libraries\LG/LG.h:49: error: 'byte' does not name a type
Programmi\arduino-1.0.1\libraries\LG/LG.h:51: error: 'byte' does not name a type
Programmi\arduino-1.0.1\libraries\LG/LG.h:51: error: 'byte' does not name a type
Programmi\arduino-1.0.1\libraries\LG/LG.h:51: error: 'byte' does not name a type

[Possible solution] in 'LG.h' I changed the code to "unsigned char"................ but appears a new error:

sketch_LG_ino.cpp.o: In function `setup':
C:\Users\ALESSA~1\AppData\Local\Temp\build6352010931496577367.tmp/sketch_LG_ino.cpp:22: undefined reference to `LG::LG(int, int, int, int)'
C:\Users\ALESSA~1\AppData\Local\Temp\build6352010931496577367.tmp/sketch_LG_ino.cpp:25: undefined reference to `LG::debug()'
Logged

Pages: [1] 2   Go Up
Jump to: