crankyoldgit / IRremoteESP8266

Infrared remote library for ESP8266/ESP32: send and receive infrared signals with multiple protocols. Based on: https://github.com/shirriff/Arduino-IRremote/
GNU Lesser General Public License v2.1
2.98k stars 832 forks source link

LG AC control #285

Closed xpokor02 closed 7 years ago

xpokor02 commented 7 years ago

Version/revison of the library used v2.1

Expected behavior

Should control AC unit

Actual behavior

I used similar code from ardruino example (works fine with nano), unfortunately doesn't work with ‎WEMOS D1 mini

Output of raw data from IRrecvDumpV2.ino (if applicable)

I am going to test it.

Steps to reproduce the behavior

I am trying to turn on AC, It doesn't work. I am using suggested schematic and tested that led is blinking with mobile camera

Example code used

it is based on IRremote example https://github.com/z3t0/Arduino-IRremote/blob/master/examples/LGACSendDemo/LGACSendDemo.ino

Circuit diagram and hardware used (if applicable)

suggested one in wiki

I (have/have not) followed the steps in the Troubleshooting Guide

I did, but not all of them yet, connection is fine.

Other useful information

More information is always welcome. Be verbose. It would be great if someone could adjusted LG AC example from original library to b working

xpokor02 commented 7 years ago

Hi, dump from remote control: Encoding : LG Code : 88C0051 (28 bits) Timing[59]: +8400, -4150 + 550, -1550 + 550, - 450 + 600, - 450

dump from WEMOS D1 mini: Encoding : LG Code : 88C0051 (28 bits) Timing[59]: +7850, -3800 + 650, -1600 + 600, - 500 + 650, - 450

Hope it helps solve it. Thanks

crankyoldgit commented 7 years ago

The codes are very similar/the same. Only slight timing differences. You could try adjusting/tweaking the values at the top of ir_LG.cpp if I recall correctly. That should allow you to tune it closer to your actual remote. Let us know what values you end up with.

xpokor02 commented 7 years ago

Sure I will try it, but I don't know logic behind it. Can I change LG_TICK to something small like 50 and adjust all multipliers to higher number? Thanks

crankyoldgit commented 7 years ago

You can do anything you like. It's only code. ;-) Changing LG_TICK up or down should make subtle adjustments. It's probably all it will take to make it work for you.

xpokor02 commented 7 years ago

ok so I changed values to following ones and it works:

define LG_TICK 50U

define LG_HDR_MARK_TICKS 160U

define LG_HDR_MARK (LG_HDR_MARK_TICKS * LG_TICK)

define LG_HDR_SPACE_TICKS 80U

define LG_HDR_SPACE (LG_HDR_SPACE_TICKS * LG_TICK)

define LG_BIT_MARK_TICKS 12U

define LG_BIT_MARK (LG_BIT_MARK_TICKS * LG_TICK)

define LG_ONE_SPACE_TICKS 32U

define LG_ONE_SPACE (LG_ONE_SPACE_TICKS * LG_TICK)

define LG_ZERO_SPACE_TICKS 11U

define LG_ZERO_SPACE (LG_ZERO_SPACE_TICKS * LG_TICK)

define LG_RPT_SPACE_TICKS 45U

define LG_RPT_SPACE (LG_RPT_SPACE_TICKS * LG_TICK)

define LG_MIN_GAP_TICKS 795U

define LG_MIN_GAP (LG_MIN_GAP_TICKS * LG_TICK)

define LG_MIN_MESSAGE_LENGTH_TICKS 2161U

define LG_MIN_MESSAGE_LENGTH (LG_MIN_MESSAGE_LENGTH_TICKS * LG_TICK)

define LG32_HDR_MARK_TICKS 90U

define LG32_HDR_MARK (LG32_HDR_MARK_TICKS * LG_TICK)

define LG32_HDR_SPACE_TICKS 89U

define LG32_HDR_SPACE (LG32_HDR_SPACE_TICKS * LG_TICK)

define LG32_RPT_HDR_MARK_TICKS 179U

define LG32_RPT_HDR_MARK (LG32_RPT_HDR_MARK_TICKS * LG_TICK)

Thanks

baegopooh commented 6 years ago

I'm trying to do same thing-using this library on esp8266 to control lg ac- and this timing does not work(version 2.4). or, it works on transmit side(sendLG funtion), but does not work on receiver side.

I looked along, and found more strict timing based on oscciloscope, it says " The transmission starts with a pulse of 9 ms followed by 4.5ms space. Since the IR receiver is actively high, a 9ms pulse from a transmitter got translated into a 9 ms ‘dip’ in the receiver. A logical ‘1’ is started by a 562.5us pulse followed by 1.6875ms space (3 times 562.5us). A logical ‘0’ is represented by a 562.5us pulse followed by a 562.5us space." So i Changed code based on above timing. and it works much better on transmitting signal and receiving signal.

#define LG_TICK                       56U
#define LG_HDR_MARK_TICKS            161U
#define LG_HDR_MARK                  (LG_HDR_MARK_TICKS * LG_TICK)
//9016us. close to 9ms
#define LG_HDR_SPACE_TICKS            80U
#define LG_HDR_SPACE                 (LG_HDR_SPACE_TICKS * LG_TICK)
//4480us. close to 4.5ms
#define LG_BIT_MARK_TICKS             10U
#define LG_BIT_MARK                  (LG_BIT_MARK_TICKS * LG_TICK)
//560us. close to 562.5us
#define LG_ONE_SPACE_TICKS            30U
//1680us. close to 1687.5us.
#define LG_ONE_SPACE                 (LG_ONE_SPACE_TICKS * LG_TICK)
#define LG_ZERO_SPACE_TICKS           10U
#define LG_ZERO_SPACE                (LG_ZERO_SPACE_TICKS * LG_TICK)
crankyoldgit commented 6 years ago

I think you are describing a subtly different (new) protocol than what the library has coded. e.g. The HDR mark for the LG protocols is: either ~8000us or ~4500us depending on the variant. Not the 9000us you are suggesting.

I'm happy to add this new variant, but I'll need the full raw captures from the as-is IRrecvDumpV2.ino example code in the current master branch, or at least v2.4.1.

Note: The up-to-date master branch has some fixes for transmission timing issues.

Also, can you please do this in a new issue, as this one is closed.