Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendSony once again #1018

Closed
tomash opened this issue Jan 19, 2020 · 22 comments · Fixed by #1029
Closed

sendSony once again #1018

tomash opened this issue Jan 19, 2020 · 22 comments · Fixed by #1029
Assignees
Labels
help wanted Pending Confirmation Waiting for confirmation from user

Comments

@tomash
Copy link

tomash commented Jan 19, 2020

Library version 2.7, ESP32-Dev module.

I'm building my own web-to-ir to control both TV and Soundbar via phone in local network. The IRMQTTSample seems to compile, upload but not run, and I got pretty far with my setup anyway.

Baseline: the TV works with it all, it's a pretty old Toshiba 42" LCD using NEC protocol. So I've got it confirmed that my wiring (with transistor for amplifying the IR LED etc.) is working.

The problem: Sony soundbar (HT-CT380, to be exact) does not react to any sendSony() attempts I throw at it. I've recorded-and-decoded all the signals from original remote buttons:

  Sony soundbar
   power: 540C
   vol+:  240C = 9228
   vol-:  640C
   input: 4B0D
   menu:  770D
   back:  BE110
   enter: 180C
   up:    F0D
   down:  4F0D
   sw+:   1D0C
   sw-:   5D0C
   mute:  140C
   clear audio+: F4116
   sound field: 3B0D
   pairing: EE114

In my Arduino sketch code, whenever I call:

irsend.sendSony(code, 15);

with or without third repeat argument, the soundbar does not react. Yes, I'm passing the codes as integers, so that volume up, 0x240C, is passed to sendSony() as 9228.

The fun part, and a bit of silver lining which might help in debugging what happens, is that the raw data works properly (!).

      // Example of data captured by IRrecvDumpV2.ino
      // Protocol  : SONY
      // Code      : 0x240C (15 Bits)
      // 0x240C = 9228,  (Volume Up)
      uint16_t rawData[127] = {2448, 550,  648, 544,  1250, 546,  648, 548,  648, 550,  1272, 524,  648, 550,  644, 550,  674, 524,  648, 550,  648, 544,  674, 524,  1270, 524,  1246, 550,  674, 524,  648, 22404,  2474, 524,  674, 520,  1250, 548,  648, 544,  674, 524,  1270, 524,  648, 550,  648, 546,  674, 524,  648, 546,  652, 546,  674, 524,  1270, 524,  1272, 522,  674, 520,  648, 22404,  2452, 544,  674, 524,  1270, 524,  674, 518,  674, 522,  1246, 550,  674, 524,  648, 544,  674, 524,  648, 546,  674, 524,  674, 518,  1276, 518,  1276, 524,  648, 546,  674, 22380,  2474, 520,  674, 524,  1250, 544,  674, 524,  674, 518,  1276, 520,  674, 522,  674, 524,  674, 520,  674, 524,  674, 524,  674, 518,  1276, 518,  1276, 524,  672, 524,  648};  // SONY 240C
      irsend.sendRaw(rawData, 127, 38); // works like a charm, volume goes up

Which means I'm probably one-two parameters of sendSony() away from getting it to work. Is that the delays (22404?)? Is that something else?

And even if not, I can record raw dumps of all the original remote buttons and just use them.

Thanks for this library, it makes working with IR signals a breeze.

@crankyoldgit
Copy link
Owner

crankyoldgit commented Jan 20, 2020

Thanks for the excellent issue report. Full of details! Just what I like.

I'll try simulating a few things in a few minutes, but I'd like you to do a few things for me in parallel.

  1. Can you give me model numbers of your Toshiba TV and remote, so I can add them to the supported list?
  2. sendSony uses the traditional 40kHz modulation. Can you please try sending your rawData above, but using irsend.sendRaw(rawData, 127, 40); // Use 40kHz instead of 38kHz. That should tell us if that might be the problem. i.e. You sending it at 38kHz it seems to work. Wondering if newer Sony stuff expects 38kHz now.
  3. Note that your 5-hex-digit codes won't fit into the Sony 15-bit protocol (e.g. "back" etc), so you'll need a different bit size for those (see the IRrecvDumpV2 output for that bit size).

In theory, it should work as you've used it. I'll do some tests while I wait for your results to see if I can see what could be causing the issue.

Looking forward to your response/feedback.

@crankyoldgit
Copy link
Owner

crankyoldgit commented Jan 20, 2020

On first examination of your rawData you provided. I see there are a total of 4 messages in it. i.e. Original plus 3 repeats.
sendSony() defaults to 2 repeats (a total of 3 messages) sent. So, try calling it with 3 repeats:

irsend.sendSony(code, 15, 3);

@crankyoldgit
Copy link
Owner

More detailed analysis indicates that your captured data is just a little off spec.
It should be well within expected tolerance ranges of devices, so it's unlikely to be the culprit.
My guess is you only need the extra repeat (i.e. sendSony(data, 15, 3)) to get the physical device to see it.

IF and ONLY IF that doesn't work, then I would suggest you tweak the library values as following:

const uint16_t kSonySpace = 550;  // or 540 (was 600)
const uint16_t kSonyOneMark = 1250;  // or 1270 (was 1200)
const uint16_t kSonyZeroMark = 650;  // or 675 (was 600)

Other than that, I can't see any problems.
I'll upload the tests I carried out in a sec.

crankyoldgit added a commit that referenced this issue Jan 20, 2020
* To help debug what is going on in #1018
* No library impacting changes involved.

FYI @tomash
@crankyoldgit crankyoldgit self-assigned this Jan 20, 2020
crankyoldgit added a commit that referenced this issue Jan 20, 2020
* To help debug what is going on in #1018
* No library impacting changes involved.

FYI @tomash
@crankyoldgit
Copy link
Owner

crankyoldgit commented Jan 20, 2020

The IRMQTTSample seems to compile, upload but not run

I just noticed this line.

What exactly do you mean by "not run"? IRMQTTServer doesn't produce any useful serial output by default.

@tomash
Copy link
Author

tomash commented Jan 20, 2020

Thanks for the quick and substantial reply. I'll try the 38KHz modulation and repeat=3. I've tried up to repeat=5 but with the default modulation. By the way, the dumps were made with Vishay's TSOP4838, but according to specs it works for signals from 38 to 40 KHz base.

Here are raw dumps of all the commands from Sony soundbar remote:
https://github.com/tomash/esp32-web-ir-remote/blob/master/irrecvdump.txt

Most are 15bit but some are 20 bit, regarding your reply re: code sizes.

The TV is Toshiba 42TL838.

What exactly do you mean by "not run"? IRMQTTServer doesn't produce any useful serial output by default.

No serial output and not seeing the wifi network to connect to for initial configuration.

@crankyoldgit
Copy link
Owner

No serial output and not seeing the wifi network to connect to for initial configuration.

Sounds like you need to do a full reset/clear of the ESP device. A Google search should tell you how to do it with tools like esptool.py etc

crankyoldgit added a commit that referenced this issue Jan 21, 2020
@crankyoldgit
Copy link
Owner

I'll try the 38KHz modulation and repeat=3.

I think you mean 40kHz, when sending raw.
If you want to change Sony's modulation, you need to change 40 to 38 here.

I've tried up to repeat=5 but with the default modulation. By the way, the dumps were made with Vishay's TSOP4838, but according to specs it works for signals from 38 to 40 KHz base.

Yep. You signal was captured fine. No issues with you captures. They look fine to me.

Here are raw dumps of all the commands from Sony soundbar remote:
https://github.com/tomash/esp32-web-ir-remote/blob/master/irrecvdump.txt

Ta.

If changing the timings don't work, or the modulation, the only thing left to try really changing the duty cycle (33 on that same code line) to the default 50.

Alternatively, can you capture with another ESP device the signal your ESP32 is producing when sending via sendSony?

@crankyoldgit
Copy link
Owner

FYI, to full erase the flash, here are some instructions:

It's likely IRMQTTServer is picking up previous wifi config info. Erasing the chip fully should get you into a clean new state. Also, you could enable serial debugging in https://github.com/crankyoldgit/IRremoteESP8266/blob/master/examples/IRMQTTServer/IRMQTTServer.h#L231-L237 to get more info on what might be going wrong.

@crankyoldgit
Copy link
Owner

@tomash Friendly ping/follow up to see how your tweaking/testing went.

@tomash
Copy link
Author

tomash commented Jan 23, 2020

Thanks for the ping. I was out of town for the last three days, I'll resume work on this today or friday.

@crankyoldgit
Copy link
Owner

Any luck?

@tomash
Copy link
Author

tomash commented Jan 26, 2020

I finally have some time for hacking!
Your suspicions were correct: irsend.sendRaw(x240crawData, 127, 40);, i.e. changing carrier frequency to 40KHz, resulted in the soundbar not picking it up. Trying to make sendSony use 38KHz and 4-times message multiplier, will get back to you in a minute...

@tomash
Copy link
Author

tomash commented Jan 26, 2020

All right, great success: after editing ir_Sony.cpp in the library dir:

void IRsend::sendSony(uint64_t data, uint16_t nbits, uint16_t repeat) {
  sendGeneric(kSonyHdrMark, kSonySpace, kSonyOneMark, kSonySpace, kSonyZeroMark,
              kSonySpace,
              0,  // No Footer mark.
              kSonyMinGap, kSonyRptLength, data, nbits, 38, true, repeat, 33);
}

in the library, irsend.sendSony(code, bits, 3); codes finally get picked up by the soundbar. IT WORKS! 👏

@tomash
Copy link
Author

tomash commented Jan 26, 2020

Now, how do I implement the "sendSony but 38 Khz" function in a cleaner way, other than editing directly in the library's folder? I can't add a method to IRsend that wasn't declared in the header file, the used symbols aren't visible either. A pull request adding yet another parameter, base frequency, after repeat?

@tomash
Copy link
Author

tomash commented Jan 26, 2020

As for IRMQTTServer -- I'll try your suggestions and if something's broken for me I'll open a separate issue to avoid mixups. Thanks 👌

@crankyoldgit
Copy link
Owner

Now, how do I implement the "sendSony but 38 Khz" function

I'll code something up shortly.

crankyoldgit added a commit that referenced this issue Jan 26, 2020
- Add new protocol: `SONY_38K` & `sendSony38()`
- SONY_38K uses 3 repeats it seems, so default to that.
- There is no way to reliably tell if an incoming message is using 40kHz 
or 38kHz, so assume the SONY standard (40kHz).
- Unit tests for the above.
- Add supported model info.

Fixes #1018
@crankyoldgit crankyoldgit added Pending Confirmation Waiting for confirmation from user and removed more info labels Jan 26, 2020
@crankyoldgit
Copy link
Owner

@tomash Can you please download/test PR #1029 / branch https://github.com/crankyoldgit/IRremoteESP8266/tree/Sony38kHz and let me know if sendSony38() solves your problem?

Thanks in advance.

Btw. Thanks for doing the testing and confirming my theory, because otherwise, I was stumped for reasons why it was failing. ;-)

crankyoldgit added a commit that referenced this issue Jan 29, 2020
- Add new protocol: `SONY_38K` & `sendSony38()`
- SONY_38K uses 3 repeats it seems, so default to that.
- There is no way to reliably tell if an incoming message is using 40kHz 
or 38kHz, so assume the SONY standard (40kHz).
- Unit tests for the above.
- Add supported model info.

Fixes #1018
@crankyoldgit
Copy link
Owner

@tomash I haven't heard back from you testing the new branch/PR etc. I'm assuming it will work fine, merged it, and closing this issue. Please re-open if it doesn't work, or open a new issue and reference this one.

;-)

crankyoldgit added a commit that referenced this issue Jan 30, 2020
_v2.7.3 (20200130)_

**[Features]**
- Allow protocols to be enabled or disabled with compiler flags. (#1013, #1012)
- Panasonic AC: Add Ion Filter support for DKE models. (#1025, #1024)
- Add support for sending Sony at 38Khz (#1029, #1018, #1019)
- auto_analyse_raw_data.py: Handle analysing messages with no headers. (#1017)

**[Misc]**
- Fix Coolix unit test errors when using Apple c++ compiler. (#1030, #1028)
- Fix Apple clang c++ compiler error in unit tests. (#1027, #1026)
- Improve/fix scraping of supported devices (#1022)
- Panasonic PKR series A/C uses DKE protocol. (#1020, #1021)
- Update NEC supported devices. (#1018)
- Add note to avoid GPIO16 on the ESP8266 for receiving. (#1016, #1015)
crankyoldgit added a commit that referenced this issue Jan 30, 2020
_v2.7.3 (20200130)_

**[Features]**
- Allow protocols to be enabled or disabled with compiler flags. (#1013, #1012)
- Panasonic AC: Add Ion Filter support for DKE models. (#1025, #1024)
- Add support for sending Sony at 38Khz (#1029, #1018, #1019)
- auto_analyse_raw_data.py: Handle analysing messages with no headers. (#1017)

**[Misc]**
- Fix Coolix unit test errors when using Apple c++ compiler. (#1030, #1028)
- Fix Apple clang c++ compiler error in unit tests. (#1027, #1026)
- Improve/fix scraping of supported devices (#1022)
- Panasonic PKR series A/C uses DKE protocol. (#1020, #1021)
- Update NEC supported devices. (#1018)
- Add note to avoid GPIO16 on the ESP8266 for receiving. (#1016, #1015)
@crankyoldgit
Copy link
Owner

The code changes referenced above have been included in the v2.7.3 release of the library.

@tomash
Copy link
Author

tomash commented Jan 30, 2020

Thanks! I do it in my spare time which I don't have much of this week so I'll test it around saturday and get back to you here :)

@AptemCat
Copy link

AptemCat commented Sep 5, 2022

This helped me fix my Sony HT-SF150 soundbar. It worked with sendSony38(value,kSony15Bits,3);
Library version 2.8.2

@AptemCat
Copy link

AptemCat commented Sep 5, 2022

Also, Samsung UE40K5510AUXRU TV worked with sendSAMSUNG(value), an old BBK SP550S 5.1 sound system worked with sendNEC(value), and a TX 3 mini Android TV Box worked with sendNEC(value).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Pending Confirmation Waiting for confirmation from user
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants