IR blaster for an AC unit

Share here your ideas for new projects

Moderators: odroid, meveric, mdrjr

IR blaster for an AC unit

Unread postby mad_ady » Mon Apr 24, 2017 5:37 pm

I've been thinking of a way to use an Odroid (XU4 or C1) to control an air conditioning (AC) unit (LG). The AC unit comes with a standard IR remote control (it's not a "smart" unit with Wifi), so I'll need to build an IR emitter and somehow clone the remote. Preliminary searches led me to this guide: https://github.com/zeroflow/ESPAircon/w ... ngineering which basically tells you that the AC's remote control sends the whole state (temperature, power status, cooling type, on/off timer, etc) each time you press a key. So, when you power on the AC you tell it all the parameters - the same thing when you power it off. This probably means that lirc might be unable to learn these codes, since it believes that each key has a unique code.

I will try to use lirc to record the IR codes from the existing remote to see if they can be captured.

Otherwise, plan B is to use the XProtolab Plain Oscilloscope to capture raw waveforms from the IR receiver data pin and store them as "wave" files. Next step is to decode the wave file and convert it to binary and see if I can decode the output (figure out which is temperature, which is power status, which is timer, etc).

If/when I can do all this, it's time to start working on an emitter. Lucky for me, I already have a fairly long (3m) IR repeater from my Samsung TV (https://forum.samygo.tv/viewtopic.php?t=11030) which should be able to do the job. I'll just have to figure out what parameters are safe for it (what voltage can be applied on the IR diodes, what current) and wire something up. I don't have any data-sheets for the components, but from guesses and internet searches it looks like most IR diodes work with about 1.6V and have a maximum current of about 50mA. The plan is to hook it up to a XU4 which is in a 3m proximity to the AC, since all other devices are away from line of sight and might be behind closed doors.

To emit the IR data I could probably use the LIRC_ODROID module (like here viewtopic.php?f=24&t=2426 or http://odroid.com/dokuwiki/doku.php?id= ... io_blaster) or I'll have to do it "by hand" and replay the wave file recorded or turn on/off the gpio with the correct sequence and frequency - but this might be more tricky.

I started this thread as a place to ask for help when I get stuck and also document each step and most failures :).

Wish me luck!
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby rooted » Tue Apr 25, 2017 6:16 am

The Android application irplus has codes for most devices, you may be able to get what you need from it.

https://play.google.com/store/apps/deta ... oid.irplus

What is the exact model of your AC?
User avatar
rooted
 
Posts: 3652
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1
C1+
C2
XU3 Lite
XU4
VU7+
HiFi Shield 2
Smart Power (original)

Re: IR blaster for an AC unit

Unread postby mad_ady » Tue Apr 25, 2017 2:51 pm

Well, I can't seem to find the AC's manual or order information and I don't know the exact model. The remote however has the part number akb73456113 and is compatible with the following AC units:
P24EL, P18EL, P12RL, P09RL, P24RL, P18RL,
P24EL.NS2, P18EL.NS2, P12RL.NSB, P09RL.NSB,
P24RL.NSB, P18RL.NSB,
LG SILVERDEC09.SET, LG SILVERDEC12.SET,
LG SILVERDEC18.SET, LG SILVERDEC24.SET,
NEW SILVER DECO, SILVERDECO,
LG NEWSILVER12.SET, LG NEWSILVER09.SET,
LG NEWSILVER18.SET, LG NEWSILVER24.SET,


Unfortunately my phone doesn't have an IR blaster, so I can't install the app you suggested. But if you can install it, can you check if it supports any of the models above? I will try the LIRC approach and see if it can learn the codes.
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby rooted » Tue Apr 25, 2017 4:00 pm

Sure, looking now.

This is exported and contains lirc_raw codes

https://db.tt/WSelOZpCEK

This is the buttons it contains

http://i.imgur.com/8Xfxz19.png
User avatar
rooted
 
Posts: 3652
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1
C1+
C2
XU3 Lite
XU4
VU7+
HiFi Shield 2
Smart Power (original)

Re: IR blaster for an AC unit

Unread postby crazyquark » Tue Apr 25, 2017 6:30 pm

I used a usb irtoy2 to capture codes and replay them for my AC unit.
crazyquark
 
Posts: 133
Joined: Thu Jan 15, 2015 4:22 pm
languages_spoken: english, french, romanian
ODROIDs: C1,C1+,C2,XU4

Re: IR blaster for an AC unit

Unread postby rooted » Tue Apr 25, 2017 8:28 pm

I'm not sure you can capture these codes, at least I have never captured any this complex.

I have no experience with an irtoy2, checking it out now.

*edit*
The irtoy2 is cool, as long as the device is RC5 based it would likely work.

@mad_ady
This will allow you to install it and get the codes yourself.

https://play.google.com/store/apps/deta ... .irpluslan

It could also be a cool weekend project to setup.

This one is equally cool and could also be a nice weekend project, it uses audio and the headphone jack.

https://play.google.com/store/apps/deta ... irpluswave
User avatar
rooted
 
Posts: 3652
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1
C1+
C2
XU3 Lite
XU4
VU7+
HiFi Shield 2
Smart Power (original)

Re: IR blaster for an AC unit

Unread postby mad_ady » Tue Apr 25, 2017 9:08 pm

I appreciate your guys help, but you're doing all the work and leaving me without the fun :D

I managed to get lirc to capture the codes in raw mode, but the problem is the code sends the whole state, so, for instance if you want to send the AC the code to set temperature to 20C with fan set to max is going to be a different than the code to set the temperature to 20C with fan set to low. It would be nice to be able to generate the correct code based on one's needs.

Here is a basic lircd.conf file with the POWER key and KEY_F8 - KEY-F17 mapped to temperatures 23-30
Code: Select all

# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.0(default) on Tue Apr 25 14:51:10 2017
#
# contributed by
#
# brand:                       lg.conf
# model no. of remote control:
# devices being controlled by this remote:
#

begin remote

  name  lg.conf
  flags RAW_CODES
  eps            30
  aeps          100

  gap          16777215

      begin raw_codes

          name KEY_POWER
             8862    4178     461    1619     490     571
              489     569     442     558     467    1634
              467     558     467     585     465     577
              466     577     463     570     443     580
              463     590     443     591     443     614
              420     592     443    1631     445    1623
              444     592     443     613     437    1639
              445     606     443    1641     444     578
              463    1631     445    1623     445    1632
              445    1619     467    1625     441

          name BTN_MODE
             8823    4173     514    1564     503     553
              498     504     520     534     500    1565
              505     564     476     534     500     543
              500     542     499     543     496     547
              499     525     500    1601     501     507
              502     542     500     521     553     533
              477    1653     421    1584     501    1583
              509     541     502    1573     510     533
              501     534     500     562     486     517
              519    1590     500    1552     503

          name KEY_F8
             8849    4181     493    1576     494     592
              444     555     493     589     438    1600
              469     575     467     564     492     561
              466     568     466     575     468     557
              491     569     467    1608     468     573
              475     570     466     558     493    1596
              494     558     492     567     474     585
              442     577     467    1596     518     537
              466     576     466     565     517    1565
              519     566     444     567     467

          name KEY_F9
             8819    4191     463    1617     494     614
              420     582     498     529     505    1589
              445     573     485     539     491     593
              436     564     502     539     492     592
              459     567     476    1624     504     512
              491     562     467     656     377    1600
              470     567     466     582     451    1601
              468     604     430    1616     468     613
              444     583     476     558     443    1620
              503     524     504    1599     500

          name KEY_F10
             8787    4214     442    1646     469     572
              443     593     439     611     416    1659
              443     598     468     566     442     593
              468     577     489     557     443     601
              442     607     441    1642     418     632
              445     598     468     575     441    1625
              443     593     441     599     443     594
              438     595     438    1630     416     627
              440     593     440     619     415    1629
              441     592     441     600     443

          name KEY_F11
             8808    4215     502    1600     463     567
              472     587     443     555     492    1595
              468     576     465     558     491     564
              465     556     490     586     442     580
              454     568     466    1601     468     567
              467     590     444     591     443    1623
              468     577     466    1600     491     569
              466     583     468    1592     467     569
              466     590     442     579     457    1622
              469    1624     472     544     492

          name KEY_F12
             3803     295     252     370     334     450
              517     292     310     194    1422    4767
              436    1711     333     700     338     930
              154     605     387    1709     361     809
              207     807     258     648     361     681
              439     645     338     670     363     698
              363    1811     256     648     361     708
              352     647     386    1705     361     734
              308    1749     390     625     358     684
              362    1732     337     749     284     726
              308     647     282    1835     362    1723
              290     728     384

          name KEY_F13
             8846    4155     518    1558     514     542
              501     572     505     515     500    1563
              544     510     500     542     501     523
              549     511     498     533     518     551
              502     556     483    1555     531     523
              499     546     493     577     502    1535
              502    1587     503     563     471     588
              458     557     487    1560     522     542
              500     541     501    1721     376     553
              470     598     435     556     502

          name KEY_F14
             8789    4210     498    1589     512     533
              442     590     459     625     419    1622
              461     592     443     633     413     578
              460     584     458     602     447     620
              423     606     469    1590     468     609
              428     583     464     579     443    1631
              474    1621     442     590     476     572
              445     621     408    1622     466     611
              433     597     475    1619     427     621
              456     552     564     491     455

          name KEY_F15
             8779    4216     505    1531     494     597
              441     638     448     510     492    1597
              503     525     517     537     499     546
              501     529     500     532     518     539
              510     527     517    1580     504     531
              520     522     547     503     511    1565
              505    1572     503     523     519    1573
              503     540     503    1556     519     555
              479     534     551    1513     504     556
              477     565     502    1521     522

          name KEY_F16
             8791    4208     525    1546     465     574
              467     613     433     625     413    1612
              475     569     462     613     421     589
              472     573     443     612     440     620
              439     625     405    1639     456     576
              463     586     457     578     467    1624
              441    1629     447    1609     500     555
              446     625     417    1612     471     582
              446     598     443    1622     475     586
              447    1609     475     594     440

          name KEY_F17
             8866    4188     518    1542     520     567
              444     581     500     544     467    1596
              519     544     466     567     467     575
              467     558     516     567     444     555
              518     536     466    1624     469     574
              468     564     518     523     518    1567
              469    1607     470    1600     473    1593
              470     565     469    1614     470     570
              463     568     470    1584     521     535
              467    1598     470    1623     470

      end raw_codes

end remote



I'm not sure if I can convert the raw codes to a bitstring to try to see what fields are being sent (identify the fields based on the changes between them).
I think I'm going to hook up the oscilloscope to the IR pins and try to capture the waveform for the fun of it :D

The oscilloscope might not be needed. mode2 seems to do the job:
Code: Select all
root@kbd:~# mode2 -d /dev/lirc0
space 16777215
pulse 8879
space 4157
pulse 528
space 1588
pulse 482
space 522
pulse 519
space 534
pulse 501
space 566
pulse 477
space 1562
pulse 521
space 557
pulse 477
space 566
pulse 476
space 551
pulse 499
space 551
pulse 498
space 543
pulse 500
space 530
pulse 520
space 558
pulse 477
space 1562
pulse 521
space 542
pulse 500
space 543
pulse 499
space 522
pulse 519
space 535
pulse 500
space 1581
pulse 503
space 542
pulse 500
space 534
pulse 500
space 545
pulse 500
space 1563
pulse 502
space 543
pulse 499
space 1555
pulse 521
space 535
pulse 500
space 522
pulse 519
space 534
pulse 500
space 1585
pulse 500

I wonder if I can turn it into a waveform graph :) And also some hex. Need to read more on mode2...

Edit2: There was a project that did just that, but it seems to have dissapeared from the face of the internet: https://sourceforge.net/p/lirc/mailman/ ... /12852339/
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby rooted » Tue Apr 25, 2017 9:33 pm

Oddly enough the app can show the waveform, at least on a device with an IR blaster.

This is the left power button, see the graph at the bottom.

http://i.imgur.com/YAY2BL6.png
User avatar
rooted
 
Posts: 3652
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1
C1+
C2
XU3 Lite
XU4
VU7+
HiFi Shield 2
Smart Power (original)

Re: IR blaster for an AC unit

Unread postby mad_ady » Tue Apr 25, 2017 11:03 pm

I've stumbled over this: https://bbs.nextthing.co/t/installing-l ... i-p/2449/4

With the raw codes captured by lirc and sox (with that guy's script) I generated this waveform:

Image

The on/off data is modulated on top of a carrier frequency (I suspect I need to tweak this to be 38k instead of 192k as the script defaults):

Image

At least now I have a visualization and I can think about comparing signals.
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby mad_ady » Thu Apr 27, 2017 10:00 pm

Ok, I had a bit of time and I was able to hook up the Xprotolab-Plain to the IR GPIO input pin of the IR receiver of the C2 (it's the outer most pin, closest to the edge of the board). I had to learn how to set triggers and how to capture the signal, and ran a capture through lirc's "mode2" and the oscilloscope.
The signal looks like this:
Code: Select all
     8925     4111      502     1555      519      662
      384      526      518      545      497     1563
      521      580      450      599      456      519
      602      456      499      549      499      544
      499      533      517      543      497      546
      494      529      518      544      485     1573
      497      556      498      517      494     1563
      518      543      495     1588      495      563
      484      570      469     1789      294     1586
      489      576      487     1572      494

I captured the signal for the state "on, 24 degrees, maximum fan" both ways. I converted the output from mode2 (which lists raw lirc codes of pause and signal) into a wave file with the script in the above post and compared the wave file to the output of the oscilloscope.

Tada:

- recreated wavefile
Image

- oscilloscope reading at 5ms/div (screenshot is truncated, but the signal was readable on the scope:
Image

- oscilloscope reading at 10ms/div (sampling rate is too low and some symbols merge):
Image

A bit length is about 500us, so, for the whole signal (including the "silence" at the beginning) we would have about 50ms of "signal". That would mean about 100 bits of data, or if we exclude the silence period (which I doubt carries any information), we're left with 41ms or 82 bits of data.

I won't be using the oscilloscope to extract the waveform, but it was a nice tool to use to validate that the data that was recorded through mode2 looks "ok".
Next steps:
1. Record signals with mode2 for all the states that I want/need to use (all temperature/fan speed combinations)
2. Look for a gnu-radio tool to convert the waveform into bits/hex
3. Just for fun - compare the codes based on the known state that was sent to identify where the bits are stored in the IR signal
4. Think about how the emitter would look like/work.
5. Implement the hardware + test
6. Profit!
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby rooted » Thu Apr 27, 2017 10:17 pm

Good work mad_ady.

I've been meaning to look at the Xprotolab, what do you think about it?
User avatar
rooted
 
Posts: 3652
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1
C1+
C2
XU3 Lite
XU4
VU7+
HiFi Shield 2
Smart Power (original)

Re: IR blaster for an AC unit

Unread postby mad_ady » Thu Apr 27, 2017 10:37 pm

I think it's nice for a hobbyist. I certainly don't have the skills to push it to the limit. But I like the fact that it has UART (and other protocol) detection so I got it to find UART ports on other boards (e.g. hook up the relevant pins, reboot remote board, look for UART signals). It also comes with some clamps that you can use to latch to various pins (which is cool).

Image
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby rooted » Fri Apr 28, 2017 8:27 am

Thumbs up ^^^

I don't have much need for a full blown oscilloscope but I often find myself needing to measure PWM, it might fit the bill.
User avatar
rooted
 
Posts: 3652
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1
C1+
C2
XU3 Lite
XU4
VU7+
HiFi Shield 2
Smart Power (original)

Re: IR blaster for an AC unit

Unread postby mad_ady » Tue May 02, 2017 7:54 pm

Ok, I tried to make some more progress on two fronts:
1. I mapped the keys I needed (on/off, temperature 18-30, fan low/medium/high/cycle) and put them in this repository: https://github.com/mad-ady/lg-ac-remote-lirc. I was too lazy to map them by hand so I wrote a small script to ask me to put the remote in a state and press a key and it would record the mode to that file. Took less than a minute to map the 48 codes I needed. I will probably use these for replay, but I still want to see the waveform and map the protocol (for fun)
2. I found some tools to handle OOK decoding (On-Off-Keying) (https://github.com/Sc00bz/DemodulateOOK), but they require wave files where the ones are represented as a high volume section, not a sine waveform as it is now. So, I'm working with sox trying to generate a flat signal in the time spectrum instead of a sine wave: https://superuser.com/questions/1205200 ... ave-signal

I'll work on concatenating the codes in a lirc file and then I will look at the hardware part of the project. See what I have and what I'm missing.
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby mad_ady » Wed May 03, 2017 8:02 pm

Some more progress report. I managed to convince sox to generate a square wave and was able to convert the lirc raw-codes to wave files. Then, I took the wavefiles and ran them through an ook-demodulator and got a hex string back. I ran the hex string through bc and converted it to binary and put all codes in an easy to read CSV file (Excel FTW!). The results are on my git mentioned above.

And now, a case study - looking for the on/off bit. We are looking at two remote signals, one for ON in the state "24C, low fan", and one for OFF in the "24C, low fan" state. The purpose of the exercise is to identify which bit(s) changed:

  • off-24-low, hex: 008AA2A88AAAAAA28AA0, bin: 10001010 10100010 10101000 10001010 10101010 10101010 10100010 10001010 10100000
    Image
  • on-24-low, hex: 008AA2AAA8AA2A2AAA80, bin: 10001010 10100010 10101010 10101000 10101010 00101010 00101010 10101010 10000000
    Image
One thing to mention is that the hex-binary conversion is done with bc and leading zeros are lost. If you are to take a close look at the differences you'll notice that there are 6 bits which are different. Unfortunately, the bits are widespread throughout the message indicating they are not (all) part of a CRC. Possible causes:
1. wrong demodulation - maybe it isn't OOK
2. the remote also has a "current time" setting which might get sent to the AC on each key press. This means that part of the message will differ between all messages.
3. read errors?

I'll continue to scratch my head over the meaning of the bits. Maybe I should print them out and overlay them to see what the pattern means...
Image
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby mad_ady » Tue May 09, 2017 6:00 pm

Ok, summer is approaching, so I need to finish this project :)

I think I finished the software side (without decoding the actual codes - :( ), but I need to get started on the hardware side.
So, if I start with the standard schematic from here http://odroid.com/dokuwiki/doku.php?id= ... io_blaster and I modify it with my blaster configuration (which contains 5 leds in paralel) I end up with this schematic:
Image

The problem is - I don't have the specs of the IR diodes in my blaster, but I'd say they have to be close to regular IR diodes (https://cdn-shop.adafruit.com/datasheet ... asheet.pdf), so that would mean a peak current of ~100mA, usual current of 20mA and a voltage drop of ~1.2-1.5V.
So, I need to calculate the value of R2 and what actual current I will be needing - because the diodes are in paralel. So, R2 should support a current of 50mA*5 = 250mA. I'm not sure what the voltage drop on the NPN transistor (collector-emmitor) is, but - is R2 necessary for the XU4? If yes, what value (and power rating) should it have?
R1's role is to ensure a 0.6V drop on the base-emmitor of the transistor, so I guess I can use any value (e.g. 330ohm?) because the current is weak on the GPIO port.

I'll be using a KSP2222A transistor, which I think is appropriate for the job).

I'd like the input of somebody with hands-on knowledge (like @odroid or @phaseshifter), so that I can proceed further :)
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby odroid » Tue May 09, 2017 7:50 pm

Yes, R1 can be 270~1Kohm.
R2 can be 4.7ohm or less. Measure the voltage drop on R2 with a volt-meter when you tinkering the IR LEDs to find an optimal value.
User avatar
odroid
Site Admin
 
Posts: 22768
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: IR blaster for an AC unit

Unread postby mad_ady » Tue May 09, 2017 8:27 pm

Thank you for the feedback @odroid. I made an order for 4.7 ohm resistors (together with other stuff) and I'll build it early next week. Will keep you posted.
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby rooted » Wed May 10, 2017 3:43 am

mad_ady wrote:Thank you for the feedback @odroid. I made an order for 4.7 ohm resistors (together with other stuff) and I'll build it early next week. Will keep you posted.

Good luck, I have a feeling it will turn out great.
User avatar
rooted
 
Posts: 3652
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1
C1+
C2
XU3 Lite
XU4
VU7+
HiFi Shield 2
Smart Power (original)

Re: IR blaster for an AC unit

Unread postby mad_ady » Fri May 19, 2017 6:20 pm

Ok, this week has been the hardest - the physical build. I tried the original design with the 4.7 ohm resistor (which was actually 6 ohm built from 4 20ohm resistors in parallel) and an assortment of wires and connectors - and - it didn't work. My test plan was to flip the GPIO to 1 and see if the leds light up (when viewed through a camera). Turns out my 1.8 VDD pin on my test XU3 didn't output 1.8V. Don't know why. So, I changed the design a bit and connected to the 5V pin (PIN1) and replaced the R2 resistor with a 80 ohm resistor (made from 4 330 ohm resistors in parallel - from the tinkering kit). With this design one can use the same circuit on the C series as well (not tested yet). This time I built it on a breadboard and tested it, and eureka - it lit up! Next I rebuilt the hardware variant, but again - I got nothing. I replaced and measured various parts and it turns out that the audio jack connector I was using to connect to the IR leds (since they have an audio jack by design) was faulty/not reliable. So I changed that as well. Now when I manually turn the GPIO on, the leds light up. I'm really bad at this... :)

Next, the software part. I'm using kernel 4.9 on the XU3 and I compiled my own kernel with this commit cherry-picked: https://github.com/hardkernel/linux/com ... b6af56c6ff
I can manually insert the kernel module and it seems to load just fine:

Code: Select all
# modprobe lirc_dev
# modprobe lirc_odroid gpio_out_pin=24 softcarrier=1 invert=1
# dmesg
...
[   33.401581] lirc_dev: IR Remote Control driver registered, major 245
[   49.181104] lirc_odroid: module is from the staging directory, the quality is unknown, you have been warned.
[   49.192967] lirc_odroid lirc_odroid.0: lirc_dev: driver lirc_odroid registered at minor = 0
[   49.200118] lirc_odroid: driver registered!



Lirc starts without incident as well. But - when I try to send a key code I get a crash:
Code: Select all
root@odroid:~# irsend SEND_ONCE lg.conf on-24-min
root@odroid:~# dmesg
...
[   33.401581] lirc_dev: IR Remote Control driver registered, major 245
[   49.181104] lirc_odroid: module is from the staging directory, the quality is unknown, you have been warned.
[   49.192967] lirc_odroid lirc_odroid.0: lirc_dev: driver lirc_odroid registered at minor = 0
[   49.200118] lirc_odroid: driver registered!
[  300.431749] lirc_odroid is opened
[  300.433852] Unable to handle kernel NULL pointer dereference at virtual address 00000020
[  300.441926] pgd = ec544000
[  300.444571] [00000020] *pgd=b5ea8835
[  300.448166] Internal error: Oops: 17 [#1] PREEMPT SMP ARM
[  300.453356] Modules linked in: lirc_odroid(C) lirc_dev netconsole fuse cpufreq_conservative cpufreq_ondemand cpufreq_userspace cpufreq_powersave smsc95xx exynos_gpiomem ipv6
[  300.468792] CPU: 4 PID: 1582 Comm: lircd Tainted: G         C      4.9.28+ #1
[  300.475879] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
[  300.481951] task: ec529f40 task.stack: ed052000
[  300.486483] PC is at lirc_dev_fop_open+0xc4/0x18c [lirc_dev]
[  300.492106] LR is at set_use_inc+0x10/0x18 [lirc_odroid]
[  300.497384] pc : [<bf0b4bd8>]    lr : [<bf0ba088>]    psr: 600f0013
               sp : ed053df0  ip : 00000000  fp : 00000000
[  300.508810] r10: ed053f74  r9 : ed053ed0  r8 : 00000000
[  300.514012] r7 : edc8ac00  r6 : ec4c96f0  r5 : ed244480  r4 : 00000000
[  300.520513] r3 : 00000000  r2 : 00000000  r1 : eedb83a8  r0 : 00000000
[  300.527013] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[  300.534116] Control: 10c5387d  Table: 6c54406a  DAC: 00000051
[  300.539836] Process lircd (pid: 1582, stack limit = 0xed052210)
[  300.545725] Stack: (0xed053df0 to 0xed054000)
[  300.550070] 3de0:                                     bf0ba674 ed10d500 ec4c96f0 edc8ac00
[  300.558223] 3e00: 00000000 ed053ed0 ed053f74 c021c5d0 00000006 00000000 edc8ac00 ec4c96f0
[  300.566366] 3e20: edc8ac08 c021c52c 00000000 c0215644 00000000 ed053e94 00000002 00000000
[  300.574511] 3e40: 00000000 ed053ed0 ed053f74 c02254cc 00000000 c022172c ed053e80 00000006
[  300.582658] 3e60: edc8ac00 00000041 00000001 ed053f28 ed053f50 c0930154 00000000 c0226820
[  300.590799] 3e80: 00000000 00000000 00000000 00000002 ec4c96f0 c262fd90 ed737908 c2189550
[  300.598945] 3ea0: ec4c96f0 00000001 00000002 00000007 ed053f74 00000001 fffff000 c0107884
[  300.607094] 3ec0: ed052000 00000000 00000000 c02271a4 c262fd90 ed737908 5bc85782 00000005
[  300.615237] 3ee0: ed2f0015 00000001 00000000 c2189550 ec4c96f0 00000101 00000002 000019c0
[  300.623380] 3f00: 00000000 00000000 00000000 ed053f10 00000000 00000000 591eb6e3 239e60b6
[  300.631528] 3f20: 00000002 ed2f0000 00000007 c266f100 c266f118 00000000 00000400 c0235038
[  300.639671] 3f40: ed2f0000 00000000 ffffff9c 00000002 ffffff9c c0107884 00000007 ffffff9c
[  300.647818] 3f60: ed2f0000 c0216a58 0000002c 0f500000 00000000 00000002 591e0000 00000006
[  300.655968] 3f80: 00000100 00000001 591eb6e3 0004e1a4 00048138 0004814c 00000005 c0107884
[  300.664109] 3fa0: ed052000 c01076c0 0004e1a4 00048138 bee4cf6a 00000002 bee4c9e0 00002000
[  300.672257] 3fc0: 0004e1a4 00048138 0004814c 00000005 bee4cbc8 000463d0 00048138 00000000
[  300.680399] 3fe0: 00000000 bee4c9dc 00022807 b6d6be36 000f0030 bee4cf6a 00000000 00000000
[  300.688600] [<bf0b4bd8>] (lirc_dev_fop_open [lirc_dev]) from [<c021c5d0>] (chrdev_open+0xa4/0x178)
[  300.697497] [<c021c5d0>] (chrdev_open) from [<c0215644>] (do_dentry_open+0x1fc/0x2fc)
[  300.705288] [<c0215644>] (do_dentry_open) from [<c02254cc>] (path_openat+0x348/0xf14)
[  300.713086] [<c02254cc>] (path_openat) from [<c02271a4>] (do_filp_open+0x60/0xc4)
[  300.720537] [<c02271a4>] (do_filp_open) from [<c0216a58>] (do_sys_open+0x114/0x1c4)
[  300.728171] [<c0216a58>] (do_sys_open) from [<c01076c0>] (ret_fast_syscall+0x0/0x3c)
[  300.735867] Code: e12fff32 e2504000 1a000023 e595808c (e5984020)
[  300.742256] ---[ end trace be171f60b6608eab ]---


I'm guessing that the lirc_odroid patch will need adjusting for kernel 4.9, right?
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby mad_ady » Mon May 22, 2017 5:27 pm

Until the 4.9 lirc_odroid driver gets fixed, I'm working on alternatives.

Plan A: use a spare C2 to transmit IR. I've made the hardware adjustments and tested the IR diodes (they light up under a camera when toggling the GPIO manually). Next, I'm working on making lirc transmit with the built-in lirc_odroid module. Here I've had mixed results. I'm loading the module with:
Code: Select all
sudo service lirc stop
modprobe lirc_dev
modprobe lirc_odroid gpio_out_pin=249 softcarrier=1 invert=0
sudo service lirc restart


The /etc/lirc/hardware.conf file lists the following:
Code: Select all
# /etc/lirc/hardware.conf
#
#Chosen Remote Control
REMOTE="None"
REMOTE_MODULES="meson-ir"
REMOTE_DRIVER="default"
REMOTE_DEVICE="/dev/lirc0"
REMOTE_SOCKET=""
REMOTE_LIRCD_CONF=""
REMOTE_LIRCD_ARGS="--uinput"
#Chosen IR Transmitter
TRANSMITTER="odroid blaster"
TRANSMITTER_MODULES="lirc_odroid lirc_dev"
TRANSMITTER_DRIVER=""
TRANSMITTER_DEVICE="/dev/lirc0"
TRANSMITTER_SOCKET=""
TRANSMITTER_LIRCD_CONF=""
TRANSMITTER_LIRCD_ARGS=""
#Disable kernel support.
#Typically, lirc will disable in-kernel support for ir devices in order to
#handle them internally.  Set to false to prevent lirc from disabling this
#in-kernel support.
#DISABLE_KERNEL_SUPPORT="true"

#Enable lircd
START_#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD="false"

#Try to load appropriate kernel modules
LIRCD="true"
LOAD_MODULES="true"

# Default configuration files for your hardware if any
LIRCMD_CONF=""

#Forcing noninteractive reconfiguration
#If lirc is to be reconfigured by an external application
#that doesn't have a debconf frontend available, the noninteractive
#frontend can be invoked and set to parse REMOTE and TRANSMITTER
#It will then populate all other variables without any user input
#If you would like to configure lirc via standard methods, be sure
#to leave this set to "false"
FORCE_NONINTERACTIVE_RECONFIGURATION="false"
START_LIRCMD=""


dmesg lists the following (the first errors are from missing parameters for lirc_odroid at boot time:
Code: Select all
root@kbd:~# dmesg | grep lirc
[   23.929955] lirc_dev: IR Remote Control driver registered, major 230
[   23.939766] rc rc0: lirc_dev: driver ir-lirc-codec (meson-ir) registered at minor = 0
[   23.960382] lirc_odroid: module is from the staging directory, the quality is unknown, you have been warned.
[   23.961189] lirc_odroid: cant claim gpio pin 0
[   23.961201] lirc_odroid: init port fail!
[   23.961204] lirc_odroid[lirc_odroid_exit]
[   24.573147] lirc_odroid: module is from the staging directory, the quality is unknown, you have been warned.
[   24.574542] lirc_odroid: cant claim gpio pin 0
[   24.574557] lirc_odroid: init port fail!
[   24.574561] lirc_odroid[lirc_odroid_exit]
[  305.003140] lirc_odroid: module is from the staging directory, the quality is unknown, you have been warned.
[  305.004354] lirc_odroid lirc_odroid.0: lirc_dev: driver lirc_odroid registered at minor = 1
[  305.004369] lirc_odroid: driver registered!
[  305.198954] input: lircd as /devices/virtual/input/input5
[  430.014254] input: lircd as /devices/virtual/input/input6


irsend can list the configured key presses:
Code: Select all
root@kbd:~# irsend LIST lg.conf ""
irsend: 0000000000000001 on-21-low
irsend: 0000000000000002 on-19-high
irsend: 0000000000000003 on-23-high
irsend: 0000000000000004 on-27-med
irsend: 0000000000000005 on-26-high
irsend: 0000000000000006 on-22-high
irsend: 0000000000000007 on-30-low
irsend: 0000000000000008 on-24-low
irsend: 0000000000000009 on-27-high
irsend: 000000000000000a on-18-cycle
irsend: 000000000000000b on-29-med
irsend: 000000000000000c on-30-med
irsend: 000000000000000d on-20-cycle
irsend: 000000000000000e on-25-high
irsend: 000000000000000f on-26-cycle
irsend: 0000000000000010 on-29-high
irsend: 0000000000000011 on-28-low
irsend: 0000000000000012 on-24-cycle
irsend: 0000000000000013 on-20-med
irsend: 0000000000000014 on-28-high
irsend: 0000000000000015 on-20-high
irsend: 0000000000000016 off-24-min
irsend: 0000000000000017 on-26-low
irsend: 0000000000000018 on-22-low
irsend: 0000000000000019 on-29-low
irsend: 000000000000001a on-22-med
irsend: 000000000000001b on-25-low
irsend: 000000000000001c on-19-med
irsend: 000000000000001d on-21-med
irsend: 000000000000001e on-28-med
irsend: 000000000000001f on-24-med
irsend: 0000000000000020 on-28-cycle
irsend: 0000000000000021 on-24-high
irsend: 0000000000000022 on-25-cycle
irsend: 0000000000000023 on-19-cycle
irsend: 0000000000000024 on-30-high
irsend: 0000000000000025 on-18-low
irsend: 0000000000000026 on-23-cycle
irsend: 0000000000000027 on-27-cycle
irsend: 0000000000000028 on-27-low
irsend: 0000000000000029 on-19-low
irsend: 000000000000002a on-21-high
irsend: 000000000000002b on-18-med
irsend: 000000000000002c on-23-low
irsend: 000000000000002d on-29-cycle
irsend: 000000000000002e on-20-low
irsend: 000000000000002f on-21-cycle
irsend: 0000000000000030 on-23-med
irsend: 0000000000000031 on-26-med
irsend: 0000000000000032 on-18-high
irsend: 0000000000000033 on-22-cycle
irsend: 0000000000000034 on-25-med
irsend: 0000000000000035 on-30-cycle


But when I try to send I get this error:
Code: Select all
root@kbd:~# irsend SEND_ONCE lg.conf on-24-max
irsend: command failed: SEND_ONCE lg.conf on-24-max
irsend: hardware does not support sending


The thing is - I did get it to work once. The leds would even blink for a split second, but I was only able to send one message before lirc needed restarting. So - I might have messed up lirc config. I will restore the stock lirc configuration and try again.

Plan B: parse the lirc pulse-space data and toggle the gpio manually from user space. I'm not sure if I have enough accuracy from user-space to generate 500us pulses through GPIO on the XU4, but I think with affinity set to a big core and process priority set to high, I might have a chance.
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby odroid » Mon May 22, 2017 5:34 pm

We will try the IR blaster function on XU4 kernel 4.9 within a few days.
User avatar
odroid
Site Admin
 
Posts: 22768
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: IR blaster for an AC unit

Unread postby mad_ady » Mon May 22, 2017 5:54 pm

Ok, I redid the /etc/lirc/hardware.conf like this:
Code: Select all
# /etc/lirc/hardware.conf
#
#Chosen Remote Control
REMOTE="None"
REMOTE_MODULES=""
REMOTE_DRIVER=""
REMOTE_DEVICE=""
REMOTE_SOCKET=""
REMOTE_LIRCD_CONF=""
REMOTE_LIRCD_ARGS=""

#Chosen IR Transmitter
TRANSMITTER="odroid blaster"
TRANSMITTER_MODULES="lirc_odroid lirc_dev"
TRANSMITTER_DRIVER=""
TRANSMITTER_DEVICE="/dev/lirc0"
TRANSMITTER_SOCKET=""
TRANSMITTER_LIRCD_CONF=""
TRANSMITTER_LIRCD_ARGS=""

#Disable kernel support.
#Typically, lirc will disable in-kernel support for ir devices in order to
#handle them internally.  Set to false to prevent lirc from disabling this
#in-kernel support.
#DISABLE_KERNEL_SUPPORT="true"

#Enable lircd
START_LIRCD="true"

#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD="false"

#Try to load appropriate kernel modules
LOAD_MODULES="true"

# Default configuration files for your hardware if any
LIRCMD_CONF=""

#Forcing noninteractive reconfiguration
#If lirc is to be reconfigured by an external application
#that doesn't have a debconf frontend available, the noninteractive
#frontend can be invoked and set to parse REMOTE and TRANSMITTER
#It will then populate all other variables without any user input
#If you would like to configure lirc via standard methods, be sure
#to leave this set to "false"
FORCE_NONINTERACTIVE_RECONFIGURATION="false"
START_LIRCMD=""


Also, I made the modules load with the correct parameters at startup (@odroid, please add this step to the wiki as well):
Code: Select all
root@kbd:~# cat /etc/modprobe.d/lirc.conf
options lirc_odroid gpio_out_pin=249 softcarrier=1 invert=0


And now, after a reboot, I can send multiple commands without lirc locking up:
Code: Select all
root@kbd:~# dmesg | grep lirc
[   16.181978] lirc_dev: IR Remote Control driver registered, major 230
[   16.207962] lirc_odroid: module is from the staging directory, the quality is unknown, you have been warned.
[   16.209033] lirc_odroid lirc_odroid.0: lirc_dev: driver lirc_odroid registered at minor = 0
[   16.209040] lirc_odroid: driver registered!
[  286.513276] lirc_odroid is opened
[  286.514757] lirc_odroid is closed
[  307.536364] lirc_odroid is opened
[  307.543263] lirc_odroid is closed
[  310.813686] lirc_odroid is opened
[  310.823298] lirc_odroid is closed
[  324.470092] lirc_odroid is opened
[  324.470189] lirc_odroid - SET_SEND_CARRIER 38000
[  324.470204] lirc_odroid - SET_SEND_DUTY_CYCLE 50
[  324.523130] lirc_odroid is closed
[  464.108689] lirc_odroid is opened
[  464.109732] lirc_odroid - SET_SEND_CARRIER 38000
[  464.109752] lirc_odroid - SET_SEND_DUTY_CYCLE 50
[  464.161512] lirc_odroid is closed
[  585.147392] lirc_odroid is opened
[  585.149215] lirc_odroid - SET_SEND_CARRIER 38000
[  585.149282] lirc_odroid - SET_SEND_DUTY_CYCLE 50
[  585.202649] lirc_odroid is closed
[  626.154934] lirc_odroid is opened
[  626.157321] lirc_odroid - SET_SEND_CARRIER 38000
[  626.157407] lirc_odroid - SET_SEND_DUTY_CYCLE 50
[  626.212186] lirc_odroid is closed


The command I used (I had it wrong in my previous post):
Code: Select all
irsend SEND_ONCE lg.conf on-24-high


Now, this seems to work (it generates pulses), but I haven't tried it yet on my AC unit. I will try to do so in the following days/next week. But - I tried a dry run - generate the code and compare it with the remote's code with the oscilloscope. The codes look similar, but not identical (original code is further up):
Image

I'm guessing that the reason the codes are not identical is that my code is a replay of an older state which might include current date/time, while the remote has slightly different settings with regard to date/time. I'm hoping the relevant settings are correct (temperature, etc).

I'll let you guys know.

P.S. Thanks @odroid!
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby mad_ady » Mon May 22, 2017 6:07 pm

Hmm, I tried the same procedure on a different C2 and the module can't load because it can't claim gpio 249:
Code: Select all
adrianp@jumphost:~> dmesg | grep lirc
[   15.321395] lirc_dev: IR Remote Control driver registered, major 230
[   15.327452] lirc_odroid: module is from the staging directory, the quality is unknown, you have been warned.
[   15.328345] lirc_odroid: cant claim gpio pin 249
[   15.328365] lirc_odroid: init port fail!
[   15.328370] lirc_odroid[lirc_odroid_exit]
[   17.754356] Modules linked in: lirc_dev w1_gpio wire meson_gpiomem gxbb_wdt nfsd nfs_acl ipv6 autofs4 raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq raid1 raid0 multipath linear md_mod

How can I find which module keeps that GPIO busy? It's not critical - it seems gpio 238 is free:
Code: Select all
   
root@jumphost:~# cd /sys/class/gpio/
root@jumphost:/sys/class/gpio# echo 249 > export
-su: echo: write error: Device or resource busy
root@jumphost:/sys/class/gpio# echo 238 > export
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby joy » Wed May 24, 2017 6:17 pm

You can use the node, /sys/kernel/debug/gpio to get a list of the mapped gpios.

Code: Select all
root@odroid64:~# cat /sys/kernel/debug/gpio
GPIOs 122-135, platform/c1109880.pinmux, ao-bank:
 gpio-125 (amlsd               ) out lo   
 gpio-127 (?                   ) in  lo   
 gpio-135 (blue:heartbeat      ) out hi   

GPIOs 136-255, platform/c1109880.pinmux, banks:
 gpio-150 (rst_pin             ) in  hi   
 gpio-165 (amlsd               ) out hi   
 gpio-180 (amlsd               ) in  hi   
 gpio-223 (amlsd               ) out lo   
 gpio-224 (sysfs               ) in  hi   
 gpio-249 (sysfs               ) in  hi   
Last edited by joy on Wed May 24, 2017 6:34 pm, edited 2 times in total.
joy
 
Posts: 222
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: IR blaster for an AC unit

Unread postby mad_ady » Wed May 24, 2017 6:23 pm

Thanks! It was one-wire:
Code: Select all
adrianp@jumphost:~> sudo cat /sys/kernel/debug/gpio
GPIOs 122-135, platform/c1109880.pinmux, ao-bank:
 gpio-125 (amlsd               ) out lo   
 gpio-127 (?                   ) in  lo   
 gpio-135 (blue:heartbeat      ) out lo   

GPIOs 136-255, platform/c1109880.pinmux, banks:
 gpio-150 (rst_pin             ) in  hi   
 gpio-165 (amlsd               ) out hi   
 gpio-180 (amlsd               ) in  hi   
 gpio-223 (amlsd               ) out lo   
 gpio-238 (lirc_odroid ir/out  ) out lo   
 gpio-249 (w1                  ) in  hi
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2

Re: IR blaster for an AC unit

Unread postby joy » Wed May 24, 2017 6:35 pm

On C2, I confirmed the operation as the wiki describes so could you try it first?
http://odroid.com/dokuwiki/doku.php?id= ... io_blaster
And don't forget the IO voltage of C2 is 3.3V. ;)

And on XU4 4.9, I will check it.
Please give me a few days.
I got the same errors with XU4 4.9. :(
joy
 
Posts: 222
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: IR blaster for an AC unit

Unread postby mad_ady » Wed May 24, 2017 7:09 pm

For my C2 I had played with 1wire before, so my image is not stock.
The hardware I built works with both 1.8 and 3.3V because this voltage is used only for the transistor's base. The rest of the circuit plugs into 5V
User avatar
mad_ady
 
Posts: 1710
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU3, C1+, C2


Return to The Ideas

Who is online

Users browsing this forum: No registered users and 5 guests