Arduino Forum

Using Arduino => Project Guidance => Topic started by: juntao65 on Mar 23, 2014, 08:49 am

Title: Trouble sending IR command to rc curtains
Post by: juntao65 on Mar 23, 2014, 08:49 am
Hey guys,

So this has had me stumped for the past few days.

Cliffs:
- want to control remote control curtains via arduino
- have this identical setup https://learn.sparkfun.com/tutorials/ir-communication/all
- using shirriff's library to read from the provided remote control

And... that's where things go wrong. Every time I press a particular button from the remote control, I get different values. I understand some protocols allow for a few different codes for the same button press, but I'm literally getting a different value 90% of the time. Occasionally a few values will show up again.

Fortunately the manufacturer has listed some codes so one can program them into home automation devices... so I thought maybe I can bypass the whole receiving/decode and just go to outright sending.

Quote
Is an infrared blaster compatible with erod™ motorized drapery hardware in order to integrate with my home automation system?
Yes, erod™ can be integrated. Use these wavelengths to program the blaster.
Close- 110100100000, Open- 110100010000, Stop- 110100001000
Hex code: Open- D10, Close- D20, Stop- D08


I tried using the following but with no luck:
Code: [Select]
#include <IRremote.h>

IRsend irsend;

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

void loop() {
 
    for (int i = 0; i < 3; i++) {
      irsend.sendNEC(0xd10, 12); // Sony TV power code
      delay(40);
    }
 
}


Also tried sendRC5/RC6, and for the hell of it send sony. Not even sure what protocol it is. Could the remote be using some unsupported protocol? Or am I making some total newbie mistake?

Some other notes
1) The circuit is hooked up correctly, because when I rant he sendPanasonicJVC script I was able to toggle my tv on/off just fine.
2) The IR led is flashing when shining phone camera at it
3) curtain rod manufacturer site : http://myerod.com/faqs/#eighteen
4) I coudln't ever get the raw dump feature to work even for supported remotes such as the panasonic. Like raw dump -> sendRaw. I really don't care about decoding it; my end project has no reads just sends. So if raw can work that'd be swell.
Title: Re: Trouble sending IR command to rc curtains
Post by: johnwasser on Mar 23, 2014, 01:48 pm
Your curtain controller might be like some air conditioners and use a MUCH longer code than the typical IR remote.  This causes problems with the IRremote library because it has a relatively small buffer.  Go into /Arduino/libraries/IRremote/IRremote.h and change:
Code: [Select]
#define RAWBUF 76 // Length of raw duration buffer
to a higher number like 300.  Then you have to go into IRremoteInt.h and change:
Code: [Select]
  uint8_t rawlen;         // counter of entries in rawbuf
to
Code: [Select]
  uint16_t rawlen;         // counter of entries in rawbuf
Title: Re: Trouble sending IR command to rc curtains
Post by: AnalysIR on Mar 23, 2014, 03:20 pm
Quote
I coudln't ever get the raw dump feature to work even for supported remotes such as the panasonic

Well you really need to be able to get the raw dump working with standard TV remote & if you can't then you just have a basic issue with your setup or understanding. I presume you were trying the IRrecvDump example sketch!

I suggest you first try working through all of the examples provided with the IRremote library. You will then be able to understand things better.

(Judging from the signals you provided, you are 'unlikely' to be exceeding the default value for RAWBUF as each code appears to be only 12 bits long)

If you posted the sketch you were using to record the signal and the output you get, it might help.


Code: [Select]
irsend.sendNEC(0xd10, 12); // Sony TV power code
Unlikely this will work, because NEC is almost always 32 bits not 12. Plus you dont know what format is used to send the signal.
(Could be worth a shot just changing the 12 to 32) = long shot!
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Mar 23, 2014, 07:12 pm

Your curtain controller might be like some air conditioners and use a MUCH longer code than the typical IR remote.  This causes problems with the IRremote library because it has a relatively small buffer.  Go into /Arduino/libraries/IRremote/IRremote.h and change:
Code: [Select]
#define RAWBUF 76 // Length of raw duration buffer
to a higher number like 300.  Then you have to go into IRremoteInt.h and change:
Code: [Select]
  uint8_t rawlen;         // counter of entries in rawbuf
to
Code: [Select]
  uint16_t rawlen;         // counter of entries in rawbuf


I don't think for this particular remote the buffer is an issue, but for the sake of leaving no stone unturned I attempted this anyways. Nothing much has changed.

Although to note, I tried with my panasonic remote and it seems like the raw output still caps at 100 (the value it was before). I made those 2 changes that you recommended and then restarted the arduino program but it still seems to stop at 100.

Code: [Select]
Decoded PANASONIC - Address: 4004 Value: 100BCBD (48 bits)
Raw (100): 27500 3450 -1650 500 -400 500 -1200 500 -350 500 -400 500 -350 500 -350 500 -350 500 -400 500 -350 500 -350 500 -350 500 -350 500 -400 500 -1200 500 -350 500 -400 500 -350 500 -350 500 -350 500 -400 450 -400 500 -350 500 -350 500 -1250 500 -350 500 -350 500 -350 500 -400 500 -350 500 -350 500 -350 500 -400 500 -1200 500 -350 500 -1250 500 -1200 500 -1250 500 -1200 500 -350 500 -400 500 -1200 500 -350 500 -1250 500 -1200 500 -1250 500 -1200 500 -350 500 -1250 500
F61E2A57
Unknown encoding: F61E2A57 (32 bits)
Raw (100): -5754 3400 -1750 450 -400 450 -1250 450 -450 450 -400 450 -400 450 -400 450 -450 400 -450 450 -400 450 -400 450 -400 450 -450 450 -400 450 -1250 450 -450 400 -450 450 -400 450 -400 450 -450 450 -400 450 -400 450 -400 450 -400 450 -1300 450 -400 450 -400 450 -450 450 -400 450 -400 450 -400 450 -450 400 -450 450 -1250 450 -400 450 -1300 450 -1250 450 -1300 500 -1200 500 -400 450 -400 450 -1250 500 -400 450 -1250 500 -1200 500 -1250 500 -1200 500 -400 450 -1250 500
100BCBD
Decoded PANASONIC - Address: 4004 Value: 100BCBD (48 bits)
Raw (100): -8414 3500 -1650 500 -350 500 -1250 500 -350 500 -350 500 -350 500 -400 450 -400 500 -350 500 -350 500 -400 450 -400 500 -350 500 -350 500 -1250 500 -350 500 -350 500 -350 500 -400 500 -350 500 -350 500 -350 500 -400 450 -400 500 -1200 500 -350 500 -400 500 -350 500 -350 500 -350 500 -400 450 -400 500 -350 500 -1250 450 -400 500 -1200 500 -1250 500 -1200 500 -1250 500 -350 500 -350 500 -1250 500 -350 500 -1200 500 -1250 500 -1200 500 -1250 500 -350 500 -1200 500


Here's some random codes from my curtain with the raw dump... does this mean it's 32 bit?

Code: [Select]
Unknown encoding: 3E84FD4 (32 bits)
Raw (14): 6486 250 -3100 250 -2000 350 -3000 350 -900 250 -750 350 -750 350
285083F4
Unknown encoding: 285083F4 (32 bits)
Raw (12): -24250 250 -3100 250 -2000 350 -3000 350 -750 400 -2000 250
E9E70E8C
Unknown encoding: E9E70E8C (32 bits)
Raw (8): -28800 250 -3100 300 -1950 350 -3000 350
7686B868
Unknown encoding: 7686B868 (32 bits)
Raw (12): 3186 400 -3000 300 -1900 250 -900 250 -2000 200 -3150 350
FABBA044
Unknown encoding: FABBA044 (32 bits)
Raw (18): -23200 300 -3100 250 -1950 250 -1000 800 -200 400 -700 350 -800 350 -750 350 -750 400
7C8E0E54
Unknown encoding: 7C8E0E54 (32 bits)
Raw (12): 6336 950 -200 950 -150 400 -700 950 -200 400 -700 200
E6E709D5
Unknown encoding: E6E709D5 (32 bits)
Raw (8): -6450 250 -3100 250 -900 200 -900 250
46172D8F
Unknown encoding: 46172D8F (32 bits)
Raw (8): 6336 1000 -150 950 -200 350 -700 350
FECB4123
Unknown encoding: FECB4123 (32 bits)
Raw (8): 6486 950 -200 900 -250 350 -700 250
801C88CB
Unknown encoding: 801C88CB (32 bits)
Raw (10): -6500 250 -2000 200 -900 250 -900 200 -900 250
Title: Re: Trouble sending IR command to rc curtains
Post by: AnalysIR on Mar 23, 2014, 08:40 pm
I had a look at your 'curtain' signals and you are right, they are random-ish, although some look similar but are not obviously a match for the  'erod' codes provided.

What type of IR receiver are you using  (ie model no & modulation frequency)?

How far way from the receiver do you have the remote when capturing?
Make sure you have nothing around your IR receiver (or behind) that could be reflecting the signal & causing interference.

You signals ar not 32 bits....IRremote seems to default to that when it cant figure out the signal. (not sure)


Given that the manufacturer published the codes, maybe you should email them to see if they would give you more info (like modulation frequency & pulse timings and/or IR protocol used - not just the Hex codes).


BTW: Your panasonic signals decode on my system as the 'Japanese Code' protocol which is not so common. It has 48 bits (96 mark/spaces), plus 4 other mark/spaces (lead-in, header & trailer), which coincidently matches the max setting for RAWBUF of 100. what type of device is this Panasonic (TV ?).
Title: Re: Trouble sending IR command to rc curtains
Post by: johnwasser on Mar 23, 2014, 08:43 pm
It might be time to find someone with a storage oscilloscope so you can check the raw signal for modulation frequency and pulse widths.
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Mar 23, 2014, 10:06 pm

I had a look at your 'curtain' signals and you are right, they are random-ish, although some look similar but are not obviously a match for the  'erod' codes provided.

What type of IR receiver are you using  (ie model no & modulation frequency)?

How far way from the receiver do you have the remote when capturing?
Make sure you have nothing around your IR receiver (or behind) that could be reflecting the signal & causing interference.

You signals ar not 32 bits....IRremote seems to default to that when it cant figure out the signal. (not sure)


Given that the manufacturer published the codes, maybe you should email them to see if they would give you more info (like modulation frequency & pulse timings and/or IR protocol used - not just the Hex codes).


BTW: Your panasonic signals decode on my system as the 'Japanese Code' protocol which is not so common. It has 48 bits (96 mark/spaces), plus 4 other mark/spaces (lead-in, header & trailer), which coincidently matches the max setting for RAWBUF of 100. what type of device is this Panasonic (TV ?).


This is the receiver: http://www.rpelectronics.com/tsop38238-ir-receiver-module-38khz-carrier-freq.html
38khz, unsure of model?

Distance from receiver... Less than 5cm. I also tried using bigger distances like a meter or 2 away. Still get different numbers on each press.

The IR receiver seems to work fine when using other remotes, I've tested it with a Toshiba TV and a motorolla cable box and it works swell. Pioneer dvd player.. it reads the same hex code consistently but when using IRrecord to send a signal it doesn't seem to work. I've made sure there were no wires or anything blocking the line of sight from remote --> receiver.

I've sent the manufacturer an email already and still waiting on response. Though I only asked them which protocol they're using, I guess if they respond I'll follow up with the stuff you added.

The panasonic is a vierra TV.

Right now I'm attempting to get sendRaw to work with devices that work with IRrecord so I can understand it better.
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Mar 24, 2014, 07:09 am

It might be time to find someone with a storage oscilloscope so you can check the raw signal for modulation frequency and pulse widths.


Man I was hoping to avoid this but it might be my last resort eh? is there some cheap pc ghetto version I can get?

So some update. I dissected the IRrecord sketch to use raw outputs all the time, and they work well with most of my home theatre devices... excluding my panasonic TV.

What works: Yamaha receiver, both motorolla cable boxes, toshiba tv.
Doesn't work: Panasonic TV ( but works if I use the sendPanasonic command from the JVCPanasonicSendDemo sketch), pioneer dvd player, bose sound dock, and regrettably the only thing I care about working ... the electric curtains.

AnalysisIR - that's quite coincidental that the marks/spaces line up to 100, I thought my buffer changes had no effect. Anyways I am now attempting to use the advice from your blog and use the IRLib library. I will continue to update. Let me know if there's more I should try.
Title: Re: Trouble sending IR command to rc curtains
Post by: AnalysIR on Mar 24, 2014, 02:22 pm
That IR receiver is classed as legacy in the datasheet. It may be that the modulated bursts are too short for it to lock on reliably or could be that its a 56kHz signal???

If you are confident opening up the receiver in the curtain unit, you could tap into the output signal, provided it is 3->5V, with your arduino and use the following  sketch to record the times.
CAUTION: use at your own risk and beware of any mains voltage.
http://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino/ (http://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino/)
download link at bottom of page

Now that I think about it, your could use this sketch to get better timings than IRrremote, from your existing receiver- so why not  try that first before messing with the curtain unit and post the output.


Regarding your Panasonic TV....this signal will work if you resend using sendRAW. You could also update the library to handle the actual codes.
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Mar 24, 2014, 08:42 pm

That IR receiver is classed as legacy in the datasheet. It may be that the modulated bursts are too short for it to lock on reliably or could be that its a 56kHz signal???

If you are confident opening up the receiver in the curtain unit, you could tap into the output signal, provided it is 3->5V, with your arduino and use the following  sketch to record the times.
CAUTION: use at your own risk and beware of any mains voltage.
http://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino/ (http://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino/)
download link at bottom of page

Now that I think about it, your could use this sketch to get better timings than IRrremote, from your existing receiver- so why not  try that first before messing with the curtain unit and post the output.


Regarding your Panasonic TV....this signal will work if you resend using sendRAW. You could also update the library to handle the actual codes.


I tried your sketch but I keep getting gibberish output. I'm supposed to connect the IR receiver to pin 2 right vs pin 11 for IRremote right?

Example output:
Code: [Select]
Gþß2¦ï2½"ýq²2¦,ï2¦ïÓ¥Ú?íé6¦÷q²íé7Vþ?oû7Vó?oû2¦,ïò0þþßÇhÈq²ìéM" XÞ?ÿ?q4â2½"ý

EDIT: I changed the serial begin to 9600 and that seemed to have fixed it. panasonic returned this:

Code: [Select]
Raw: (586) 3496, -1700, 480, -388, 484, -1256, 476, -396, 476, -392, 480, -392, 480, -392, 480, -388, 476, -396, 476, -392, 480, -392, 480, -388, 484, -388, 484, -384, 484, -1256, 480, -392, 480, -392, 480, -388, 484, -388, 484, -384, 476, -396, 476, -392, 480, -392, 480, -392, 480, -1260, 484, -384, 476, -396, 476, -392, 480, -392, 480, -392, 480, -388, 484, -388, 476, -392, 480, -1260, 484, -388, 480, -1260, 476, -1264, 480, -1260, 484, -1256, 476, -396, 476, -396, 476, -1264, 480, -388, 484, -1260, 472, -1268, 476, -1264, 472, -1268, 476, -392, 480, -1264, 476, -9108, 3492, -1700, 480, -392, 480, -1260, 472, -396, 476, -396, 476, -392, 480, -392, 480, -392, 468, -400, 472, -400, 472, -396, 476, -396, 476, -392, 480, -392, 472, -1268, 476, -396, 476, -392, 480, -392, 480, -388, 484, -388, 472, -396, 476, -396, 476, -396, 476, -392, 480, -1260, 484, -388, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 480, -388, 472, -400, 472, -1268, 476, -396, 476, -1264, 480, -1260, 476, -1264, 480, -1260, 484, -388, 472, -396, 476, -1264, 480, -392, 480, -1260, 472, -1268, 476, -1264, 480, -1260, 484, -388, 472, -1268, 476, -9132, 3496, -1700, 468, -400, 472, -1268, 476, -396, 476, -396, 476, -392, 472, -400, 472, -396, 476, -396, 476, -392, 480, -392, 480, -388, 484, -388, 472, -396, 476, -1268, 476, -392, 480, -392, 480, -388, 472, -400, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 480, -1260, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 480, -388, 476, -396, 476, -392, 480, -1260, 480, -392, 484, -1256, 476, -1264, 480, -1260, 484, -1260, 472, -396, 476, -396, 476, -1264, 480, -388, 484, -1256, 476, -1268, 476, -1264, 480, -1260, 476, -392, 480, -1264, 480, -15636, 3500, -1696, 444, -424, 480, -1260, 452, -420, 480, -392, 472, -396, 476, -396, 476, -392, 480, -392, 480, -388, 484, -388, 484, -388, 472, -396, 476, -396, 476, -1264, 480, -388, 484, -388, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 480, -388, 476, -396, 476, -1264, 480, -392, 480, -388, 484, -388, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 480, -1260, 472, -396, 476, -1264, 480, -1260, 484, -1256, 480, -1264, 476, -392, 480, -392, 472, -1268, 476, -392, 480, -1260, 484, -1260, 472, -1268, 476, -1264, 480, -392, 472, -1268, 472, -9112, 3496, -1696, 484, -388, 476, -1264, 476, -392, 480, -392, 480, -392, 480, -388, 476, -396, 476, -392, 480, -392, 480, -388, 484, -388, 484, -388, 472, -396, 476, -1264, 480, -392, 480, -388, 484, -388, 472, -400, 472, -396, 476, -396, 476, -392, 480, -392, 480, -388, 476, -1264, 480, -392, 480, -392, 480, -388, 480, -392, 472, -396, 476, -396, 476, -396, 476, -392, 480, -1260, 484, -388, 472, -1268, 476, -1264, 480, -1260, 472, -1268, 476, -396, 476, -396, 476, -1260, 476, -396, 476, -1264, 480, -1260, 472, -1268, 476, -1264, 480, -392, 480, -1260, 472, -9136, 3492, -1704, 476, -392, 480, -1260, 484, -388, 476, -396, 476, -392, 480, -392, 484, -384, 484, -388, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 480, -1260, 472, -396, 476, -396, 476, -392, 480, -392, 480, -392, 472, -396, 476, -396, 476, -392, 476, -396, 476, -1264, 484, -388, 472, -396, 476, -396, 476, -392, 480, -392, 480, -388, 472, -400, 472, -400, 472, -1268, 476, -392, 480, -1260, 472, -1268, 476, -1264, 480, -1264, 472, -396, 476, -396, 472, -1268, 476, -392,



But for the curtain remote I got differnet outputs for same key press:

Code: [Select]
Raw: (33) 220, -3176, 196, -32600, 220, -3172, 200, -2064, 200, -4324, 200, -62000, 240, -6560, 208, -5432, 200, -23548, 292, -3120, 204, -2040, 220, -912, 240, -2020, 244, -904, 384, -732, 368, -760, 372,

Press the button on the remote now - once only

Raw: (21) 224, -3168, 208, -3188, 204, -2056, 208, -2060, 200, -24680, 220, -11088, 224, -60848, 216, -11092, 224, -24660, 216, -11092, 220,

Press the button on the remote now - once only

Raw: (79) 952, -180, 948, -184, 380, -752, 948, -160, 400, -752, 380, -752, 940, -172, 224, -2040, 200, -932, 200, -24696, 948, -184, 948, -184, 376, -752, 952, -180, 380, -752, 380, -752, 948, -160, 400, -752, 384, -748, 380, -752, 380, -748, 384, -59556, 948, -164, 968, -184, 376, -736, 968, -184, 376, -732, 400, -732, 968, -164, 400, -732, 396, -732, 224, -912, 200, -24676, 968, -164, 968, -164, 396, -736, 220, -912, 208, -2052, 212, -2052, 196,

Press the button on the remote now - once only


I'm going to try sending the raw panasonic signal and see what happens
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Mar 24, 2014, 09:06 pm
Okay update.

Once I put the raw array I got from AnaylsisIR's script into my sendraw script, the output on the serial monitor goes to gibberish. If I press a button on a remote, or press the button hooked upto my arduino, things output but it's complete gibberish.

Here's the script:

Code: [Select]
#include <IRremote.h>

int RECV_PIN = 11;
int BUTTON_PIN = 12;
int STATUS_PIN = 13;

IRrecv irrecv(RECV_PIN);
IRsend irsend;

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(BUTTON_PIN, INPUT);
  pinMode(STATUS_PIN, OUTPUT);
}

// Storage for the recorded code
int codeType = -1; // The type of code
unsigned long codeValue; // The code value if not raw
unsigned int rawCodes[RAWBUF]; // The durations if raw
int codeLen; // The length of the code
int toggle = 0; // The RC5/6 toggle state

void storeCode(decode_results *results) {
  codeType = results->decode_type;
  int count = results->rawlen;
 
  Serial.print(count);
  Serial.println(" is the count.");

    Serial.println("Received unknown code, saving as raw");
    codeLen = results->rawlen - 1;
    for (int i = 1; i <= codeLen; i++) {
      if (i % 2) {
        // Mark
        rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS;
        Serial.print(" m");
      }
      else {
        // Space
        rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS;
        Serial.print(" s");
      }
      Serial.print(rawCodes[i - 1], DEC);
    }
    Serial.println("");
   
    // print array, just wnated to see if negatives get stored
    for (int i = 1; i <= codeLen; i++) {
      Serial.print(rawCodes[i - 1], DEC);
      Serial.print(" " );
    }
}

// the panasonic array
unsigned int rawCodesb[] = {1692, 480, 388, 480, 1260, 476, 396, 476, 392, 480, 392, 480, 392, 480, 388, 484, 388, 472, 396, 476, 396, 476, 392, 480, 392, 480, 392, 480, 1260, 472, 396, 476, 396, 476, 396, 476, 392, 480, 392, 480, 388, 484, 388, 472, 396, 476, 396, 476, 1264, 480, 388, 484, 388, 484, 388, 472, 396, 476, 396, 476, 392, 480, 392, 480, 392, 480, 1260, 472, 396, 476, 1268, 476, 1260, 484, 1260, 476, 1264, 476, 392, 480, 392, 480, 1260, 476, 396, 476, 1264, 476, 1264, 480, 1260, 476, 1264, 480, 392, 476, 1264, 480, 9104, 3468, 1728, 472, 396, 448, 1292, 480, 392, 448, 420, 488, 384, 484, 388, 452, 416, 448, 424, 448, 420, 452, 420, 452, 420, 452, 416, 452, 420, 444, 1296, 476, 392, 452, 420, 452, 416, 456, 416, 476, 396, 476, 392, 480, 392, 480, 388, 484, 388, 484, 1256, 476, 392, 448, 424, 448, 424, 480, 388, 484, 388, 452, 420, 452, 416, 444, 424, 448, 1296, 480, 388, 484, 1256, 476, 1264, 480, 1264, 480, 1260, 472, 396, 448, 424, 476, 1264, 480, 392, 448, 1292, 476, 1264, 476, 1264, 480, 1260, 476, 396, 484, 1256, 476, 9132, 3472, 1724, 476, 392, 480, 1260, 484, 388, 476, 392, 456, 416, 444, 428, 444, 424, 448, 424, 448, 420, 452, 420, 484, 384, 448, 424, 448, 420, 448, 1296, 480, 388, 484, 388, 472, 396, 476, 396, 476, 396, 476, 392, 480, 392, 480, 388, 484, 388, 476, 1264, 480, 392, 476, 392, 480, 392, 480, 388, 476, 396, 476, 392, 480, 392, 480, 388, 484, 1260, 480, 388, 476, 1264, 480, 1260, 484, 1260, 472, 1268, 476, 392, 480, 392, 480, 1260, 484, 388, 452, 1288, 476, 1264, 480, 1260, 484, 1256, 476, 396, 444, 1296, 480};

void sendCode(int repeat) {
  // Assume 38 KHz
  //irsend.sendRaw(rawCodes, codeLen, 38);
  irsend.sendRaw(rawCodesb, 298, 38);
  Serial.println("Sent raw");
 
}

int lastButtonState;

void loop() {
  // If button pressed, send the code.
  int buttonState = digitalRead(BUTTON_PIN);
  if (lastButtonState == HIGH && buttonState == LOW) {
    Serial.println("Released");
    irrecv.enableIRIn(); // Re-enable receiver
  }

  if (buttonState) {
    Serial.println("Pressed, sending");
    digitalWrite(STATUS_PIN, HIGH);
    sendCode(lastButtonState == buttonState);
    digitalWrite(STATUS_PIN, LOW);
    delay(50); // Wait a bit between retransmissions
  }
  else if (irrecv.decode(&results)) {
    digitalWrite(STATUS_PIN, HIGH);
    storeCode(&results);
    irrecv.resume(); // resume receiver
    digitalWrite(STATUS_PIN, LOW);
  }
 
  lastButtonState = buttonState;
 
}


After couple key presses on remote:
Code: [Select]
1?1?1?1010101?141?1010Pr%APr%ÿPrPrP?PrP²PrPr

When I press the button the output is too big to put here but it's complete gibberish. I'm guessing the problem is the unsigned int rawCodesb[] = can't handle that big of an array? Not sure...
Title: Re: Trouble sending IR command to rc curtains
Post by: AnalysIR on Mar 24, 2014, 09:22 pm
See attached screen shot for a visual of your erod signals. The second green burst seems to be the closest to a real signal which matches one of the codes exactly, although the timings may be a bit out.

I have imported the raw signal dumps into AnalysIR & exported the useful codes for sendRAW with IRremote below, one for the panasonic and the best version of the erod captured.
If you look at the erod signals in the screenshot, the top centre one matches one of your codes (Close- 110100100000) and the others seem to be degraded version of the same signal.

So try sending both signals (not in the same sketch)
Code: [Select]
/*
Automatically Generated by AnalysIR - Batch Export Utility
Registered to: xxxxxxxx
Session History
Type : Key : Value : Bits
0 : JAPANESE : Pana1 : 40040100BCBD : 48
2 : RAW : erod1 :  : 0
*/

// 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


unsigned int Signal_Pana1_0[] = {3496,1700,480,388,484,1256,476,396,476,392,480,392,480,392,480,388,476,396,476,392,480,392,480,388,484,388,484,384,484,1256,480,392,480,392,480,388,484,388,484,384,476,396,476,392,480,392,480,392,480,1260,484,384,476,396,476,392,480,392,480,392,480,388,484,388,476,392,480,1260,484,388,480,1260,476,1264,480,1260,484,1256,476,396,476,396,476,1264,480,388,484,1260,472,1268,476,1264,472,1268,476,392,480,1264,476}; //AnalysIR Batch Export - RAW

irsend.sendRaw(Signal_Pana1_0, sizeof(Signal_Pana1_0)/sizeof(int), khz); //AnalysIR Batch Export - RAW
// AnalysIR IR Protocol: JAPANESE, Key:  Pana1




unsigned int Signal_erod1_2[] = {,948,184,948,184,376,752,952,180,380,752,380,752,948,160,400,752,384,748,380,752,380,748,384}; //AnalysIR Batch Export - RAW

irsend.sendRaw(Signal_erod1_2, sizeof(Signal_erod1_2)/sizeof(int), khz); //AnalysIR Batch Export - RAW
// AnalysIR IR Protocol: RAW, Key:  erod1


Tip: if the erod one doesn't work try changing the khz value to 56, 40, and 36 instead of 38 (My bet is on 56kHz)

If all else fails I can look into re-constructing the timings for the erod, for more accuracy
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Mar 24, 2014, 10:28 pm
I may have messed up the pansonic output due to interference. Here is some more consistent output:

Code: [Select]
Press the button on the remote now - once only

Raw: (299) 3496, -1696, 472, -404, 468, -1268, 476, -396, 476, -392, 480, -392, 468, -400, 472, -400, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 480, -388, 476, -1264, 480, -392, 476, -392, 480, -392, 480, -392, 472, -400, 472, -396, 476, -392, 476, -396, 476, -396, 476, -1264, 472, -396, 476, -396, 476, -392, 480, -392, 476, -392, 480, -392, 480, -392, 472, -396, 476, -1264, 480, -392, 480, -1260, 484, -1256, 476, -1264, 480, -1264, 480, -388, 472, -400, 472, -1268, 476, -392, 480, -1260, 484, -1256, 476, -1268, 476, -1264, 480, -388, 484, -1256, 476, -9112, 3492, -1700, 480, -392, 476, -1264, 480, -392, 472, -396, 476, -396, 476, -392, 480, -392, 480, -388, 472, -400, 472, -400, 472, -396, 476, -396, 476, -396, 476, -1260, 484, -388, 472, -400, 472, -396, 476, -396, 476, -392, 480, -392, 480, -388, 484, -388, 472, -400, 472, -1268, 476, -392, 480, -392, 480, -392, 480, -388, 472, -400, 472, -396, 476, -396, 476, -392, 480, -1260, 484, -388, 472, -1268, 476, -1264, 480, -1260, 484, -1256, 476, -396, 476, -396, 476, -1264, 480, -388, 472, -1268, 476, -1268, 476, -1264, 480, -1260, 472, -396, 476, -1264, 480, -9132, 3488, -1704, 476, -396, 476, -1264, 480, -392, 468, -400, 472, -400, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 468, -400, 472, -400, 472, -396, 476, -1264, 480, -392, 480, -392, 480, -388, 472, -400, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 472, -1268, 476, -396, 472, -396, 476, -396, 476, -392, 480, -392, 472, -396, 476, -396, 476, -396, 476, -1260, 484, -388, 484, -1256, 476, -1264, 480, -1260, 480, -1264, 472, -396, 476, -396, 476, -1264, 480, -392, 476, -1260, 476, -1268, 476, -1264, 480, -1260, 484, -388, 472, -1268, 476,

Press the button on the remote now - once only

Raw: (299) 3492, -1704, 476, -396, 476, -1264, 480, -392, 468, -400, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 480, -388, 476, -396, 476, -392, 480, -392, 476, -1264, 480, -392, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 480, -388, 480, -392, 472, -396, 476, -1264, 480, -392, 480, -392, 480, -388, 484, -388, 472, -396, 476, -396, 476, -392, 480, -392, 480, -1260, 484, -388, 472, -1268, 476, -1264, 480, -1260, 484, -1256, 476, -396, 476, -396, 476, -1260, 484, -388, 472, -1268, 476, -1264, 480, -1260, 484, -1260, 472, -396, 476, -1264, 480, -9104, 3492, -1704, 476, -396, 476, -1264, 480, -388, 476, -396, 476, -392, 476, -396, 476, -396, 476, -392, 472, -400, 472, -396, 476, -396, 476, -392, 480, -392, 480, -1260, 480, -392, 472, -396, 476, -396, 476, -392, 480, -392, 480, -392, 480, -388, 484, -388, 472, -396, 476, -1264, 480, -392, 480, -388, 484, -388, 472, -400, 472, -396, 476, -396, 476, -392, 480, -392, 480, -1260, 472, -400, 472, -1268, 476, -1264, 480, -1260, 472, -1268, 476, -396, 476, -392, 480, -1260, 484, -388, 472, -1268, 476, -1264, 480, -1260, 484, -1256, 476, -396, 476, -1264, 480, -9128, 3492, -1704, 476, -396, 476, -1264, 480, -388, 472, -400, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 468, -400, 472, -400, 472, -396, 476, -396, 476, -1264, 480, -392, 472, -396, 472, -400, 472, -396, 476, -396, 476, -392, 480, -392, 480, -392, 472, -396, 472, -1268, 476, -396, 476, -392, 480, -392, 480, -392, 472, -396, 476, -396, 476, -392, 476, -396, 476, -1264, 480, -392, 472, -1268, 476, -1264, 480, -1260, 484, -1256, 476, -396, 476, -392, 480, -1260, 484, -388, 472, -1268, 476, -1264, 480, -1260, 484, -1256, 476, -396, 476, -1264, 480,

Press the button on the remote now - once only

Raw: (299) 3496, -1700, 468, -400, 472, -1268, 476, -396, 476, -392, 480, -392, 468, -404, 468, -400, 472, -400, 472, -396, 476, -396, 476, -396, 476, -392, 472, -400, 472, -1268, 476, -392, 476, -396, 476, -392, 480, -392, 472, -400, 472, -396, 476, -396, 472, -396, 476, -396, 476, -1264, 480, -392, 472, -396, 476, -396, 476, -392, 480, -392, 476, -392, 480, -392, 480, -392, 472, -1268, 476, -392, 476, -1264, 480, -1260, 476, -1268, 476, -1264, 476, -392, 480, -392, 480, -1260, 476, -396, 476, -1264, 480, -1260, 480, -1260, 472, -1268, 476, -396, 476, -1264, 480, -9104, 3496, -1700, 476, -396, 468, -1268, 476, -396, 476, -396, 476, -392, 480, -392, 480, -388, 472, -400, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 480, -1260, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 480, -388, 484, -388, 472, -396, 476, -396, 476, -1264, 480, -392, 480, -388, 472, -400, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 480, -1260, 472, -396, 476, -1264, 480, -1264, 480, -1260, 472, -1268, 476, -392, 480, -392, 480, -1260, 472, -400, 472, -1268, 476, -1264, 480, -1260, 472, -1268, 476, -396, 476, -1264, 480, -9128, 3492, -1704, 472, -396, 476, -1264, 480, -392, 480, -392, 472, -396, 476, -396, 472, -396, 476, -396, 476, -396, 476, -392, 480, -392, 472, -396, 476, -396, 476, -1264, 476, -396, 476, -392, 480, -392, 472, -396, 476, -396, 476, -392, 480, -392, 480, -392, 476, -392, 480, -1260, 476, -396, 476, -396, 476, -392, 480, -392, 476, -392, 480, -392, 472, -396, 476, -396, 476, -1264, 480, -392, 480, -1260, 472, -1268, 476, -1264, 480, -1260, 480, -392, 472, -396, 476, -1264, 480, -392, 480, -1260, 480, -1260, 476, -1264, 480, -1260, 484, -388, 480, -1260, 476,

Press the button on the remote now - once only


I am testing your code out right now anyways though. will update
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Mar 24, 2014, 10:48 pm
Okay we're getting somewhere!!

Signal_Pana1_0 turned on my panasonic TV! I used 38 khz.

Unfortunately I couldn't get my electric blinds to move. I used both Signal_Pana1_0 and Signal_erod1_2, as well as each of the suggested frequencies : 36, 38, 40, 56.

I feel we're so close man! I really appreciate you taking the time to help me out AnalysisIR. Let me know what you need from me to make more accurate measurements.

Anyways here's the code I used in case of silly mistakes:

Code: [Select]
#include <IRremote.h>

int RECV_PIN = 11;
int BUTTON_PIN = 12;
int STATUS_PIN = 13;

IRrecv irrecv(RECV_PIN);
IRsend irsend;

decode_results results;

void setup()
{
 Serial.begin(9600);
 irrecv.enableIRIn(); // Start the receiver
 pinMode(BUTTON_PIN, INPUT);
 pinMode(STATUS_PIN, OUTPUT);
}

// Storage for the recorded code
int codeType = -1; // The type of code
unsigned long codeValue; // The code value if not raw
unsigned int rawCodes[RAWBUF]; // The durations if raw
int codeLen; // The length of the code
int toggle = 0; // The RC5/6 toggle state

void storeCode(decode_results *results) {
 codeType = results->decode_type;
 int count = results->rawlen;
 
 Serial.print(count);
 Serial.println(" is the count.");

   Serial.println("Received unknown code, saving as raw");
   codeLen = results->rawlen - 1;
   for (int i = 1; i <= codeLen; i++) {
     if (i % 2) {
       // Mark
       rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS;
       Serial.print(" m");
     }
     else {
       // Space
       rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS;
       Serial.print(" s");
     }
     Serial.print(rawCodes[i - 1], DEC);
   }
   Serial.println("");
   
   // print array, just wnated to see if negatives get stored
   for (int i = 1; i <= codeLen; i++) {
     Serial.print(rawCodes[i - 1], DEC);
     Serial.print(" " );
   }
}

// the panasonic array
//unsigned int rawCodesb[] = {1692, 480, 388, 480, 1260, 476, 396, 476, 392, 480, 392, 480, 392, 480, 388, 484, 388, 472, 396, 476, 396, 476, 392, 480, 392, 480, 392, 480, 1260, 472, 396, 476, 396, 476, 396, 476, 392, 480, 392, 480, 388, 484, 388, 472, 396, 476, 396, 476, 1264, 480, 388, 484, 388, 484, 388, 472, 396, 476, 396, 476, 392, 480, 392, 480, 392, 480, 1260, 472, 396, 476, 1268, 476, 1260, 484, 1260, 476, 1264, 476, 392, 480, 392, 480, 1260, 476, 396, 476, 1264, 476, 1264, 480, 1260, 476, 1264, 480, 392, 476, 1264, 480, 9104, 3468, 1728, 472, 396, 448, 1292, 480, 392, 448, 420, 488, 384, 484, 388, 452, 416, 448, 424, 448, 420, 452, 420, 452, 420, 452, 416, 452, 420, 444, 1296, 476, 392, 452, 420, 452, 416, 456, 416, 476, 396, 476, 392, 480, 392, 480, 388, 484, 388, 484, 1256, 476, 392, 448, 424, 448, 424, 480, 388, 484, 388, 452, 420, 452, 416, 444, 424, 448, 1296, 480, 388, 484, 1256, 476, 1264, 480, 1264, 480, 1260, 472, 396, 448, 424, 476, 1264, 480, 392, 448, 1292, 476, 1264, 476, 1264, 480, 1260, 476, 396, 484, 1256, 476, 9132, 3472, 1724, 476, 392, 480, 1260, 484, 388, 476, 392, 456, 416, 444, 428, 444, 424, 448, 424, 448, 420, 452, 420, 484, 384, 448, 424, 448, 420, 448, 1296, 480, 388, 484, 388, 472, 396, 476, 396, 476, 396, 476, 392, 480, 392, 480, 388, 484, 388, 476, 1264, 480, 392, 476, 392, 480, 392, 480, 388, 476, 396, 476, 392, 480, 392, 480, 388, 484, 1260, 480, 388, 476, 1264, 480, 1260, 484, 1260, 472, 1268, 476, 392, 480, 392, 480, 1260, 484, 388, 452, 1288, 476, 1264, 480, 1260, 484, 1256, 476, 396, 444, 1296, 480};
//unsigned int Signal_erod1_2[] = {948,184,948,184,376,752,952,180,380,752,380,752,948,160,400,752,384,748,380,752,380,748,384}; //AnalysIR Batch Export - RAW
unsigned int Signal_Pana1_0[] = {3496,1700,480,388,484,1256,476,396,476,392,480,392,480,392,480,388,476,396,476,392,480,392,480,388,484,388,484,384,484,1256,480,392,480,392,480,388,484,388,484,384,476,396,476,392,480,392,480,392,480,1260,484,384,476,396,476,392,480,392,480,392,480,388,484,388,476,392,480,1260,484,388,480,1260,476,1264,480,1260,484,1256,476,396,476,396,476,1264,480,388,484,1260,472,1268,476,1264,472,1268,476,392,480,1264,476}; //AnalysIR Batch Export - RAW

void sendCode(int repeat) {
 // Assume 38 KHz
 //irsend.sendRaw(rawCodes, codeLen, 38);
 //irsend.sendRaw(Signal_erod1_2, sizeof(Signal_erod1_2)/sizeof(int), 38);
 irsend.sendRaw(Signal_Pana1_0, sizeof(Signal_Pana1_0)/sizeof(int), 38);
 Serial.println("Sent raw");
 
}

int lastButtonState;

void loop() {
 // If button pressed, send the code.
 int buttonState = digitalRead(BUTTON_PIN);
 if (lastButtonState == HIGH && buttonState == LOW) {
   Serial.println("Released");
   irrecv.enableIRIn(); // Re-enable receiver
 }

 if (buttonState) {
   Serial.println("Pressed, sending");
   digitalWrite(STATUS_PIN, HIGH);
   sendCode(lastButtonState == buttonState);
   digitalWrite(STATUS_PIN, LOW);
   delay(50); // Wait a bit between retransmissions
 }
 else if (irrecv.decode(&results)) {
   digitalWrite(STATUS_PIN, HIGH);
   storeCode(&results);
   irrecv.resume(); // resume receiver
   digitalWrite(STATUS_PIN, LOW);
 }
 
 lastButtonState = buttonState;
 
}
Title: Re: Trouble sending IR command to rc curtains
Post by: AnalysIR on Mar 24, 2014, 11:45 pm
OK, I did some extra analysis on the signal and came up with the following 'extrapolated' timings.

Replace the timings in the erod signal as follows:
(replace the first value with the second, such that the only timings are 850 and 290 in the signal)
Code: [Select]
948 --> 850
184 290
948 850
184 290
376 290
752 850
952 850
180 290
380 290
752 850
380 290
752 850
948 850
160 290
400 290
752 850
384 290
748 850
380 290
752 850
380 290
748 850
384 --> 290

Again try all of the frequencies.
If that doesn't work, then I suggest you get a 56kHz IRreceiver, which is my best guess,for you,  at this stage.

PS: it looks like I left a comma at the start of the erod signal last time (but you seem to have removed it which was correct)
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Mar 25, 2014, 12:58 am
I will test out your script once I get home and update.

I just wanted to share some good news. The manufacturer just got back to me!!

Code: [Select]
Thank you for contacting us. Below are additional codes you can try. I am not certain if these codes are compatible with your device, but they have worked for other customers. Please let us know if you have any other questions.

OPEN:

0000 006D 0000 0030 002C 0010 0030 0010 0010 0030 0030 0010 0010 0030 0010 0030 0010 0030 0030 0010 0010 0030 0010 0030 0010 0030 0010 052F 0030 0010 0030 0010 0010 0030 0030 0010 0010 0030 0010 0030 0010 0030 0030 0010 0010 0030 0010 0030 0010 0030 0010 0D2E 0030 0010 0030 0010 0010 0030 0030 0010 0010 0030 0010 0030 0010 0030 0030 0010 0010 0030 0010 0030 0010 0030 0010 052F 0030 0010 0030 0010 0010 0030 0030 0010 0010 0030 0010 0030 0010 0030 0030 0010 0010 0030 0010 0030 0010 0030 0010 0ED8

CLOSE:

0000 006D 0000 0030 002F 0010 0030 0010 0010 0030 0030 0010 0010 0030 0010 0030 0030 0010 0010 0030 0010 0030 0010 0030 0010 0030 0010 052F 0030 0010 0030 0010 0010 0030 0030 0010 0010 0030 0010 0030 0022 001E 0004 003F 0010 0030 0010 0030 0010 0030 0010 0D2E 0030 0010 0030 0010 0010 0030 0030 0010 0010 0030 0010 0030 0025 001B 0004 003F 0010 0030 0010 0030 0010 0030 0010 052F 0030 0010 0030 0010 0010 0030 0030 0010 0010 0030 0010 0030 0010 0030 0010 0030 0010 0030 0010 0030 0010 0030 0010 0ED8

STOP:

0000 006A 0000 0030 002E 0010 0030 0010 0010 0031 0030 0010 0010 0031 0010 0031 0010 0031 0010 0031 0030 0010 0010 0031 0010 0031 0010 0549 0030 0010 0030 0010 0010 0031 0030 0010 0010 0031 0010 0031 0010 0031 0010 0031 0030 0010 0010 0031 0010 0031 0010 0D6F 0030 0010 0030 0010 0010 0031 0030 0010 0010 0031 0010 0031 0010 0031 0010 0031 0030 0010 0010 0031 0010 0031 0010 0549 0030 0010 0030 0010 0010 0031 0010 0031 0010 0031 0010 0031 0010 0031 0010 0031 0010 0031 0010 0031 0010 0031 0010 0F22


Does this help? I'm not even sure how to convert this to an array that I can use with sendRaw... What follow up question should I ask?
Title: Re: Trouble sending IR command to rc curtains
Post by: AnalysIR on Mar 25, 2014, 01:32 am
Great - these are in PRONTO format.

IRremote code below (Automatically imported into AnalysIR & exported as below)
Code: [Select]
/*
Automatically Generated by AnalysIR - Batch Export Utility
Registered to: xxxxxxxx
Session History
Type : Key : Value : Bits
0 : RAW : Open :  : 0
1 : RAW : Stop :  : 0
2 : RAW : Close :  : 0
*/

// 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


unsigned int Signal_Open_0[] = {1144,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,16383,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,16383,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,16383,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,16383}; //AnalysIR Batch Export - RAW

irsend.sendRaw(Signal_Open_0, sizeof(Signal_Open_0)/sizeof(int), khz); //AnalysIR Batch Export - RAW
// AnalysIR IR Protocol: RAW, Key:  Open


unsigned int Signal_Stop_1[] = {1222,416,1248,416,416,1248,1248,416,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,1248,416,16383,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,884,780,104,1638,416,1248,416,1248,416,1248,416,16383,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,962,702,104,1638,416,1248,416,1248,416,1248,416,16383,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,416,1248,416,1248,416,1248,416,1248,416,16383}; //AnalysIR Batch Export - RAW

irsend.sendRaw(Signal_Stop_1, sizeof(Signal_Stop_1)/sizeof(int), khz); //AnalysIR Batch Export - RAW
// AnalysIR IR Protocol: RAW, Key:  Stop


unsigned int Signal_Close_2[] = {1196,416,1248,416,416,1274,1248,416,416,1274,416,1274,416,1274,416,1274,1248,416,416,1274,416,1274,416,16383,1248,416,1248,416,416,1274,1248,416,416,1274,416,1274,416,1274,416,1274,1248,416,416,1274,416,1274,416,16383,1248,416,1248,416,416,1274,1248,416,416,1274,416,1274,416,1274,416,1274,1248,416,416,1274,416,1274,416,16383,1248,416,1248,416,416,1274,416,1274,416,1274,416,1274,416,1274,416,1274,416,1274,416,1274,416,1274,416,16383}; //AnalysIR Batch Export - RAW

irsend.sendRaw(Signal_Close_2, sizeof(Signal_Close_2)/sizeof(int), khz); //AnalysIR Batch Export - RAW
// AnalysIR IR Protocol: RAW, Key:  Close

Note if they dont work as is, just truncate each signal just before the first 16383.
The modulation frequency comes up as 38 kHz (but again try them all if things dont work).

It looks like your IR receiver didnt like that signal for some reason? strange. (you could check/verify the model number which should be on the top surface, but very small)

PS KUDOS to the erod for being so responsive and open. Great customer support!
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Mar 25, 2014, 05:28 am
IT WORKS!!! Thank you so much AnalysisIR!!

How did you convert the signal from Pronto to array? Like do you just copy it into your software as-is?
Title: Re: Trouble sending IR command to rc curtains
Post by: AnalysIR on Mar 25, 2014, 12:08 pm
Great!
...glad to be of help.

Now you can open/close the curtains when you are not at home.... :)

Quote
How did you convert the signal from Pronto to array? Like do you just copy it into your software as-is?
Yes, AnalysIR can import/export  from/to a range of industry formats and also generates C code for IRremote & IRLib.
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Mar 29, 2014, 08:44 pm
Wasn't sure if I should create separate thread with this issue I'm having with IR again.

So my project is 95% done, only thing is that the transmission for only ONE of the three commands is unreliable.

Open curtain and stop curtain work perfectly, and I have like 12ft + range, and don't even need to point the LED right at the curtain. Never any issues with signal not going through except when I'm outright standing inbetween the IR LED and the receiver.

Close curtain sometimes works at like 3-4 feet. Even with a clear line of sight at 3-4 feet it only sometimes works.

I'm guessing the close curtain's raw array may have more noise the rest?

What I've tried:
- using lower resistance band. 33 ohm, with 5v voltage so driving LED's max 100mA
- amplify via transistor ( well I was already doing this )
- Fire code only once or multiple times (like 50)

Here's the code
Code: [Select]
PROGMEM unsigned int Signal_Open[] = {1144,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,16383,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,16383,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,16383,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,16383}; //AnalysIR Batch Export - RAW
PROGMEM unsigned int Signal_Stop[] = {1196,416,1248,416,416,1274,1248,416,416,1274,416,1274,416,1274,416,1274,1248,416,416,1274,416,1274,416,16383,1248,416,1248,416,416,1274,1248,416,416,1274,416,1274,416,1274,416,1274,1248,416,416,1274,416,1274,416,16383,1248,416,1248,416,416,1274,1248,416,416,1274,416,1274,416,1274,416,1274,1248,416,416,1274,416,1274,416,16383,1248,416,1248,416,416,1274,416,1274,416,1274,416,1274,416,1274,416,1274,416,1274,416,1274,416,1274,416,16383}; //AnalysIR Batch Export - RAW
PROGMEM unsigned int Signal_Close[] = {1222,416,1248,416,416,1248,1248,416,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,1248,416,16383,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,884,780,104,1638,416,1248,416,1248,416,1248,416,16383,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,962,702,104,1638,416,1248,416,1248,416,1248,416,16383,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,416,1248,416,1248,416,1248,416,1248,416,16383}; //AnalysIR Batch Export - RAW

void sendRawCode(byte code_type){
  // get the relevant code from PROGMEM
  int rawLen = sizeof(Signal_Open) / sizeof(unsigned int);;
  unsigned int rawCode[rawLen];
 
  switch(code_type){
    case 0:  for(int i=0; i<rawLen;i++){ rawCode[i]=(pgm_read_word(&Signal_Stop[i]));  } break; // stop
    case 1:  for(int i=0; i<rawLen;i++){ rawCode[i]=(pgm_read_word(&Signal_Open[i]));  } break; // open
    case 2:  for(int i=0; i<rawLen;i++){ rawCode[i]=(pgm_read_word(&Signal_Close[i]));  } break; // close
  }
 
  Serial.print(F("Sending raw codetype: "));
  Serial.println(code_type);
 
  irsend.sendRaw(rawCode,rawLen,38); // send the IR code
 
}
// blast code 3 times
  for(int i=0; i<3;i++){
    sendRawCode(code_type);
  }
Title: Re: Trouble sending IR command to rc curtains
Post by: AnalysIR on Mar 29, 2014, 09:51 pm
Couple of points:

First, As you probably guessed, requests for private support via PM, are ususally ignored. (Reason: other people don't get to see the solution)

Second: You are right, the 'close' signal is corrupted after the first pattern. So copy the first bit of the signal upto and including 16383 and create a new one with this first part 3 times and you should be good to go. (Alternatively, just make the signal with the first part and send it 3 times if needed. It may only need to be sent once)

Third: Yes, your current should be circa 90+ mA. This should be fine and your issue is probably the distorted signal. However, you could drive it harder becacuse the 90mA is only on for one sixth of the time (50% for spaces & 33% duty cycle => 1/2 * 1/3 =1/6).
So by adding on a second 38 ohm resistor in paralled you should still have a good safety margin and more range, if needed.

If you want an even  better circuit check this blog out:
http://www.analysir.com/blog/2013/11/22/constant-current-infrared-led-circuit/ (http://www.analysir.com/blog/2013/11/22/constant-current-infrared-led-circuit/)
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Mar 30, 2014, 01:49 am
My bad on the PM, this IR issue has been driving me crazy so there was a lapse in judgement.

The rest of this post will demonstrate how crazy.

Let's start with your suggestions I've tried. First part 3 times in one signal, and the alternative of sending the first part alone 3 times had no action at all from the curtains.

Now up until this point I've been in the dark as to what was going on and what you meant by the first part of the code being corrupt.

The post is big because I wanted to be detailed. 2l;dr is ... nothings really changed.

So I did a little reading, well more specifically this post :
http://www.hifi-remote.com/infrared/IR-PWM.shtml

I ended up writing a PHP script which takes in the PRONTO codes from the manufacturer and spits out some useful information.

Here's what I got:

Open code as input:
Code: [Select]
Carrier frequency 38028.866495633
Multiplier: 26.295814
Length of One Time Burst: 0
Length of repeat burst: 48
Lead in burst: 1157, 421
Burst pair 1: 1262, 421 | Bit 1: 1
Burst pair 2: 421, 1262 | Bit 2: 0
Burst pair 3: 1262, 421 | Bit 3: 1
Burst pair 4: 421, 1262 | Bit 4: 0
Burst pair 5: 421, 1262 | Bit 5: 0
Burst pair 6: 421, 1262 | Bit 6: 0
Burst pair 7: 1262, 421 | Bit 7: 1
Burst pair 8: 421, 1262 | Bit 8: 0
Burst pair 9: 421, 1262 | Bit 9: 0
Burst pair 10: 421, 1262 | Bit 10: 0
Burst pair 11: 421, 34895 | Bit 11: 0
Deliminator timeoff: 34895

Burst pair 12: 1262, 421 | Bit 12: 1
Burst pair 13: 1262, 421 | Bit 13: 1
Burst pair 14: 421, 1262 | Bit 14: 0
Burst pair 15: 1262, 421 | Bit 15: 1
Burst pair 16: 421, 1262 | Bit 16: 0
Burst pair 17: 421, 1262 | Bit 17: 0
Burst pair 18: 421, 1262 | Bit 18: 0
Burst pair 19: 1262, 421 | Bit 19: 1
Burst pair 20: 421, 1262 | Bit 20: 0
Burst pair 21: 421, 1262 | Bit 21: 0
Burst pair 22: 421, 1262 | Bit 22: 0
Burst pair 23: 421, 88722 | Bit 23: 0
Deliminator timeoff: 88722

Burst pair 24: 1262, 421 | Bit 24: 1
Burst pair 25: 1262, 421 | Bit 25: 1
Burst pair 26: 421, 1262 | Bit 26: 0
Burst pair 27: 1262, 421 | Bit 27: 1
Burst pair 28: 421, 1262 | Bit 28: 0
Burst pair 29: 421, 1262 | Bit 29: 0
Burst pair 30: 421, 1262 | Bit 30: 0
Burst pair 31: 1262, 421 | Bit 31: 1
Burst pair 32: 421, 1262 | Bit 32: 0
Burst pair 33: 421, 1262 | Bit 33: 0
Burst pair 34: 421, 1262 | Bit 34: 0
Burst pair 35: 421, 34895 | Bit 35: 0
Deliminator timeoff: 34895

Burst pair 36: 1262, 421 | Bit 36: 1
Burst pair 37: 1262, 421 | Bit 37: 1
Burst pair 38: 421, 1262 | Bit 38: 0
Burst pair 39: 1262, 421 | Bit 39: 1
Burst pair 40: 421, 1262 | Bit 40: 0
Burst pair 41: 421, 1262 | Bit 41: 0
Burst pair 42: 421, 1262 | Bit 42: 0
Burst pair 43: 1262, 421 | Bit 43: 1
Burst pair 44: 421, 1262 | Bit 44: 0
Burst pair 45: 421, 1262 | Bit 45: 0
Burst pair 46: 421, 1262 | Bit 46: 0
Burst pair 47: 421, 99924 | Bit 47: 0
Deliminator timeoff: 99924


Close code:

Code: [Select]
Carrier frequency 38028.866495633
Multiplier: 26.295814
Length of One Time Burst: 0
Length of repeat burst: 48
Lead in burst: 1236, 421
Burst pair 1: 1262, 421 | Bit 1: 1
Burst pair 2: 421, 1262 | Bit 2: 0
Burst pair 3: 1262, 421 | Bit 3: 1
Burst pair 4: 421, 1262 | Bit 4: 0
Burst pair 5: 421, 1262 | Bit 5: 0
Burst pair 6: 1262, 421 | Bit 6: 1
Burst pair 7: 421, 1262 | Bit 7: 0
Burst pair 8: 421, 1262 | Bit 8: 0
Burst pair 9: 421, 1262 | Bit 9: 0
Burst pair 10: 421, 1262 | Bit 10: 0
Burst pair 11: 421, 34895 | Bit 11: 0
Deliminator timeoff: 34895

Burst pair 12: 1262, 421 | Bit 12: 1
Burst pair 13: 1262, 421 | Bit 13: 1
Burst pair 14: 421, 1262 | Bit 14: 0
Burst pair 15: 1262, 421 | Bit 15: 1
Burst pair 16: 421, 1262 | Bit 16: 0
Burst pair 17: 421, 1262 | Bit 17: 0
Burst pair 18: 894, 789 | Bit 18: 1
Burst pair 19: 105, 1657 | Bit 19: 0
Burst pair 20: 421, 1262 | Bit 20: 0
Burst pair 21: 421, 1262 | Bit 21: 0
Burst pair 22: 421, 1262 | Bit 22: 0
Burst pair 23: 421, 88722 | Bit 23: 0
Deliminator timeoff: 88722

Burst pair 24: 1262, 421 | Bit 24: 1
Burst pair 25: 1262, 421 | Bit 25: 1
Burst pair 26: 421, 1262 | Bit 26: 0
Burst pair 27: 1262, 421 | Bit 27: 1
Burst pair 28: 421, 1262 | Bit 28: 0
Burst pair 29: 421, 1262 | Bit 29: 0
Burst pair 30: 973, 710 | Bit 30: 1
Burst pair 31: 105, 1657 | Bit 31: 0
Burst pair 32: 421, 1262 | Bit 32: 0
Burst pair 33: 421, 1262 | Bit 33: 0
Burst pair 34: 421, 1262 | Bit 34: 0
Burst pair 35: 421, 34895 | Bit 35: 0
Deliminator timeoff: 34895

Burst pair 36: 1262, 421 | Bit 36: 1
Burst pair 37: 1262, 421 | Bit 37: 1
Burst pair 38: 421, 1262 | Bit 38: 0
Burst pair 39: 1262, 421 | Bit 39: 1
Burst pair 40: 421, 1262 | Bit 40: 0
Burst pair 41: 421, 1262 | Bit 41: 0
Burst pair 42: 421, 1262 | Bit 42: 0
Burst pair 43: 421, 1262 | Bit 43: 0
Burst pair 44: 421, 1262 | Bit 44: 0
Burst pair 45: 421, 1262 | Bit 45: 0
Burst pair 46: 421, 1262 | Bit 46: 0
Burst pair 47: 421, 99924 | Bit 47: 0
Deliminator timeoff: 99924


Stop:

Code: [Select]
Carrier frequency 39105.155170038
Multiplier: 25.572076
Length of One Time Burst: 0
Length of repeat burst: 48
Lead in burst: 1176, 409
Burst pair 1: 1227, 409 | Bit 1: 1
Burst pair 2: 409, 1253 | Bit 2: 0
Burst pair 3: 1227, 409 | Bit 3: 1
Burst pair 4: 409, 1253 | Bit 4: 0
Burst pair 5: 409, 1253 | Bit 5: 0
Burst pair 6: 409, 1253 | Bit 6: 0
Burst pair 7: 409, 1253 | Bit 7: 0
Burst pair 8: 1227, 409 | Bit 8: 1
Burst pair 9: 409, 1253 | Bit 9: 0
Burst pair 10: 409, 1253 | Bit 10: 0
Burst pair 11: 409, 34599 | Bit 11: 0
Deliminator timeoff: 34599

Burst pair 12: 1227, 409 | Bit 12: 1
Burst pair 13: 1227, 409 | Bit 13: 1
Burst pair 14: 409, 1253 | Bit 14: 0
Burst pair 15: 1227, 409 | Bit 15: 1
Burst pair 16: 409, 1253 | Bit 16: 0
Burst pair 17: 409, 1253 | Bit 17: 0
Burst pair 18: 409, 1253 | Bit 18: 0
Burst pair 19: 409, 1253 | Bit 19: 0
Burst pair 20: 1227, 409 | Bit 20: 1
Burst pair 21: 409, 1253 | Bit 21: 0
Burst pair 22: 409, 1253 | Bit 22: 0
Burst pair 23: 409, 87942 | Bit 23: 0
Deliminator timeoff: 87942

Burst pair 24: 1227, 409 | Bit 24: 1
Burst pair 25: 1227, 409 | Bit 25: 1
Burst pair 26: 409, 1253 | Bit 26: 0
Burst pair 27: 1227, 409 | Bit 27: 1
Burst pair 28: 409, 1253 | Bit 28: 0
Burst pair 29: 409, 1253 | Bit 29: 0
Burst pair 30: 409, 1253 | Bit 30: 0
Burst pair 31: 409, 1253 | Bit 31: 0
Burst pair 32: 1227, 409 | Bit 32: 1
Burst pair 33: 409, 1253 | Bit 33: 0
Burst pair 34: 409, 1253 | Bit 34: 0
Burst pair 35: 409, 34599 | Bit 35: 0
Deliminator timeoff: 34599

Burst pair 36: 1227, 409 | Bit 36: 1
Burst pair 37: 1227, 409 | Bit 37: 1
Burst pair 38: 409, 1253 | Bit 38: 0
Burst pair 39: 409, 1253 | Bit 39: 0
Burst pair 40: 409, 1253 | Bit 40: 0
Burst pair 41: 409, 1253 | Bit 41: 0
Burst pair 42: 409, 1253 | Bit 42: 0
Burst pair 43: 409, 1253 | Bit 43: 0
Burst pair 44: 409, 1253 | Bit 44: 0
Burst pair 45: 409, 1253 | Bit 45: 0
Burst pair 46: 409, 1253 | Bit 46: 0
Burst pair 47: 409, 99066 | Bit 47: 0
Deliminator timeoff: 99066


I took all the raw codes derived from this script and tested them. They work just like the codes AnalyzeIR gave me on the first sketch. Open/stop without flaw, close sometimes works only at close range.

What's interesting is how STOP has more differences from the other 2 codes, yet it's CLOSE giving me problems. The deliminator and the frequency is different. I still fired it at 38khz without problem...

Part 2 contd...
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Mar 30, 2014, 01:50 am
In order to find patterns, I listed the important information derived like so below:

first line - binary/hex straight from manufacturer's site
second line - full binary sequence
lines 3,4,5,6 - analyzing each part of the code from line 2

Open:
Code: [Select]
Open codes from manufacturer:: 110100010000  |  D10
Binary: 10100010000 110100010000 110100010000 110100010000
Binary: 10100010000 Hex: 510 Dec: 1296 | Deliminator: 34895
Binary: 110100010000 Hex: D10 Dec: 3344 | Deliminator: 88722
Binary: 110100010000 Hex: D10 Dec: 3344 | Deliminator: 34895
Binary: 110100010000 Hex: D10 Dec: 3344 | Deliminator: 99924


Close:
Code: [Select]
Close codes from manufacturer:: 110100100000   | D20
Binary: 10100100000 110100100000 110100100000 110100000000
Binary: 10100100000 Hex: 520 Dec: 1312 | Deliminator: 34895
Binary: 110100100000 Hex: D20 Dec: 3360 | Deliminator: 88722
Binary: 110100100000 Hex: D20 Dec: 3360 | Deliminator: 34895
Binary: 110100000000 Hex: D00 Dec: 3328 | Deliminator: 99924


Stop:
Code: [Select]
Stop codes from manufacturer: 110100001000  | D08
Binary: 10100001000 110100001000 110100001000 110000000000
Binary: 10100001000 Hex: 508 Dec: 1288 | Deliminator: 34599
Binary: 110100001000 Hex: D08 Dec: 3336 | Deliminator: 87942
Binary: 110100001000 Hex: D08 Dec: 3336 | Deliminator: 34599
Binary: 110000000000 Hex: C00 Dec: 3072 | Deliminator: 99066


Some things I noticed from the above:
- OPEN/CLOSE have the same deliminators
- the first part of each binary sequence is just the manufacturer listed code minus the first digit. So for example if you remove the first digit from manufacturer's code for STOP 110100001000, it becomes 10100001000... which is the first part of the burst. This is consistent on all 3 signals so I'm assuming the binary derived from the PRONTO for the first part is okay.
- for the last part, or part4 of each codes' binary sequence... I couldn't find a consistent pattern.

Since part4 for OPEN was just the manufacturer's listed code, I decided to try that for CLOSE, while preserving the deliminator. It didn't change anything. Signal goes through sometimes at really close range but nada at slightly further distances.

Here's the raw array:
Code: [Select]
PROGMEM unsigned int Signal_Close[] = {1236,421,1262,421,421,1262,1262,421,421,1262,421,1262,1262,421,421,1262,421,1262,421,1262,421,1262,421,34895,1262,421,1262,421,421,1262,1262,421,421,1262,421,1262,894,789,105,1657,421,1262,421,1262,421,1262,421,88722,1262,421,1262,421,421,1262,1262,421,421,1262,421,1262,973,710,105,1657,421,1262,421,1262,421,1262,421,34895,1262,421,1262,421,421,1262,1262,421,421,1262,421,1262,973,710,105,1657,421,1262,421,1262,421,1262,421,99924};



I am stumped. This project is useless without CLOSE working reliably ='(

Anyways I'm going to try to amplify the signal some more per AnalysisIR's suggestion.

Edit: php code is below if anyone cares
Code: [Select]
<?php
$raw 
"0000 006D 0000 0030 002F 0010 0030 0010 0010 0030 0030 0010 0010 0030 0010 0030 0030 0010 0010 0030 0010 0030 0010 0030 0010 0030 0010 052F 0030 0010 0030 0010 0010 0030 0030 0010 0010 0030 0010 0030 0022 001E 0004 003F 0010 0030 0010 0030 0010 0030 0010 0D2E 0030 0010 0030 0010 0010 0030 0030 0010 0010 0030 0010 0030 0025 001B 0004 003F 0010 0030 0010 0030 0010 0030 0010 052F 0030 0010 0030 0010 0010 0030 0030 0010 0010 0030 0010 0030 0010 0030 0010 0030 0010 0030 0010 0030 0010 0030 0010 0ED8";

$splithex explode(" ",$raw);


// first convert all entires to decimal
foreach($splithex as $each){
$split_dec[] = hexdec($each);

}

// remove first 0000
unset($split_dec[0]);
unset(
$each);


// Get carrier frequency from 2nd item
$freq 1000000/($split_dec[1]*0.241246);

// calc multiplier microsec
$microsecs 1/$freq*1000*1000;

$out "Carrier frequency ".$freq."<br>";
$out .= "Multiplier: ".$microsecs."<br>";

// get num of burst pairs with 3rd number
$out .= "Length of One Time Burst: ".$split_dec[2]."<br>";

// 4th - length of repeat burst
$length_repeat $split_dec[3];
$out .= "Length of repeat burst: ".$length_repeat."<br>";

// 5,6 - lead in burst
$timeon round($microsecs*$split_dec[4]);
$timeoff round($microsecs*$split_dec[5]);
$out .= "Lead in burst: ".$timeon.", ".$timeoff."<br>";
$rawarray "{".$timeon.",$timeoff";

unset(
$split_dec[1]);
unset(
$split_dec[2]);
unset(
$split_dec[3]);
unset(
$split_dec[4]);
unset(
$split_dec[5]);
unset(
$timeon);
unset(
$timeoff);

// 7,8 onwards
$i=1;
$k=6;

while(
$i $length_repeat){
$timeon round($microsecs*$split_dec[$k],0);
$timeoff round($microsecs*$split_dec[$k+1],0);

// the binary bit
$bit = ($timeon>$timeoff) ? 10;

$out .= "Burst pair $i: ".$timeon.", ".$timeoff." | ";
$out .= "Bit $i$bit <br>";

// Figure out if deliminator
if($timeoff>10000){
$binary .= $bit." ";

$binarytotal .= $binary." ";
$binaries[] = trim($binary); // add to array to seperate
$deliminators[] = $timeoff;
$binary "";

$out.= "Deliminator timeoff: $timeoff<br><br>";


}else{
$binary .= $bit;
}


// add to output array
$rawarray .= ",$timeon,$timeoff";

$k $k+2;
$i++;
}

$rawarray .= "};";

$out .= "Binary: $binarytotal <br>";

// convert binaries to hex
unset($each);
$i=0;
foreach(
$binaries as $each){
$delim $deliminators[$i];
$out .= "Binary: $each " "Hex: ".bin2hex($each)." Dec: "bindec($each) . " | Deliminator: $delim<br>";
$i++;
}


$out .="<br><textarea>$rawarray</textarea>";



echo 
$out;

//var_dump($binaries);
?>

Title: Re: Trouble sending IR command to rc curtains
Post by: AnalysIR on Mar 30, 2014, 03:32 pm
Looks like you are becomming a bit of an expert !   :)
Well done on the offline work & research.

The signals you posted originally in PRONTO format, have the same signal repeated three time(=  4 x signal)

The Close signal is corrupted. However, the first part is looks OK. That is why I suggested sending the first part repeated 3 times (or even just once).


So can you post the 'CLose' signal you created (as per my suggestion, if the signal below does not work)


PS: The problem is unlikely to be related to the power of the signal.


heck....try this
Code: [Select]
unsigned int Signal_Close_2[] =
{1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,16383
,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,16383
,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,16383
,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,16383}; //AnalysIR Batch Export - RAW


it looks like your stop signal has some corruption as well, which could be cleaned up like above
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Mar 30, 2014, 08:25 pm
I forking did it !!

The signal you suggested didn't work. So I tried sending the raw D20 code 4 times.. didn't work.

I'll spare you all the things I tried that didn't work.

What worked:

Overriding the frequency in my php script to 40khz and using that raw dump for the signal. Wtf right?

Like my script extracts the frequency from the manufacturer's codes that they emailed me. Normally I get :
Code: [Select]
Carrier frequency 38028.866495633

I overrode that and changed it to 40000. With carrier frequency you get the multiplier in microseconds.

Whenever I changed frequency in IRsend... it either didn't make a difference or it stopped working entirely.

So this begs the question.... what's even the point of setting the frequency in irsend.sendRaw() ? If you were entering the PRONTO code format as raw, I could understand. Or even hex->decimal in raw, but with the values already taking in the multiplier.... ah who cares it works.

Thanks a lot for the help man!

Title: Re: Trouble sending IR command to rc curtains
Post by: AnalysIR on Mar 30, 2014, 10:51 pm
Sounds like the the manufacturer got the PRONTO codes from a customer and it looks like the customer didnt do a great job capturing the signal, as it is corrupted.

Main thing is it works.

BTW: setting the frequency is important, but most systems tolerate some deviation. So it would not be surprising to be able to receive a 40kHz signal on a 38kHz receiver and vice-versa . Of course range & reliability would be impacted.


After some more thought I decided to cross reference the signals against the binary codes provided and was able to generate the signals from the binary codes as folows:
Code: [Select]
unsigned int Signal_Open_0[] =
{1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,16383
,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,16383
,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,16383
,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,16383
}; //AnalysIR Batch Export - RAW   Open- 110100010000

unsigned int Signal_Close_2[] =
{1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,1248,416,416,416,1248,416,416,1248,416,1248,416,16383
,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,1248,416,416,416,1248,416,416,1248,416,1248,416,16383
,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,1248,416,416,416,1248,416,416,1248,416,1248,416,16383
,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,1248,416,416,416,1248,416,416,1248,416,1248,416,16383
}; //AnalysIR Batch Export - RAW    Close- 110100100000


unsigned int Signal_Stop_1[] =
{1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,1248,416,16383
,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,1248,416,16383
,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,1248,416,16383
,1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,1248,416,416,1248,416,1248,416,1248,416,1248,416,16383
}; //AnalysIR Batch Export - RAW   Stop- 110100001000


below is the approach taken based on the following codes (Close example)
Close- 110100100000, Open- 110100010000, Stop- 110100001000
Code: [Select]

Close- 110100100000

ORIGINAL SIGNAL
1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,416,1248,416,1248,1248,416,416,1248,416,1248,416,16383
       1        1        0        1        0        0        0        0        1        0        0    0
NEW SIGNAL
1248,416,1248,416,416,1248,1248,416,416,1248,416,1248,1248,416,416,416,1248,416,416,1248,416,1248,416,16383
       1        1        0        1        0        0        1        0        0        0       0   0


If you have time , try these new ones out at 38 kHz (and of course 40 etc if they dont work)
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Apr 16, 2014, 08:28 pm
So I'm back and having similar IR issues again.

Not with the curtains though, I bought a lutron IR lightswitch and I'm attempting to control that with the duino.

I think I figured out why my previous attempts to clone the curtain signal didn't work: wrong receiver frequency. Unfortunately the lightswitch is also at 40 khz whereas my receiver is 38khz... so there isn't much chance on me cloning it through that method.

So I checked the manufacturer's website and found this:

Code: [Select]

Full On:
IRCommand: FF8884B80h
Pronto: 0000 0069 0006 0000 032a 010e 005a 010e 005a 0168 005a 00b4 005a 005a 010e 0276

Full Off:
IR Command: FF88BD120h
Pronto: 0000 0069 0007 0007 032a 010e 005a 010e 005a 005a 0168 005a 005a 010e 005a 00b4 005a 01c2 032a 010e 005a 010e 005a 005a 0168 005a 005a 010e 005a 00b4 005a 01c2



So I took the pronto codes and dumped it in php script and tried using the sendRaw command in the duino. No luck =x

Raw code for off:

Code: [Select]
{20518,6839,2280,6839,2280,11399,2280,6839,2280,6839,2280,11399,20518,6839,2280,6839,2280,11399,2280,6839,2280,6839,2280,11399};



I find that the decoded PRONTO codes are a bit weird. For example for the off code:

Code: [Select]
PRONTO code: 0000 0069 0006 0006 032a 010e 005a 010e 005a 01c2 005a 010e 005a 010e 005a 01c2 032a 010e 005a 010e 005a 01c2 005a 010e 005a 010e 005a 01c2
Carrier frequency 39477.585219276
Multiplier: 25.33083
Length of One Time Burst: 6
Length of repeat burst: 6
Lead in burst: 20518, 6839
Burst pair 1: (90,270) 2280, 6839 | Bit 1: 0
Burst pair 2: (90,450) 2280, 11399 | Bit 2: 0
Burst pair 3: (90,270) 2280, 6839 | Bit 3: 0
Burst pair 4: (90,270) 2280, 6839 | Bit 4: 0
Burst pair 5: (90,450) 2280, 11399 | Bit 5: 0
Burst pair 6: (810,270) 20518, 6839 | Bit 6: 1
Deliminator timeoff: 6839

Burst pair 7: (90,270) 2280, 6839 | Bit 7: 0
Burst pair 8: (90,450) 2280, 11399 | Bit 8: 0
Burst pair 9: (90,270) 2280, 6839 | Bit 9: 0
Burst pair 10: (90,270) 2280, 6839 | Bit 10: 0
Burst pair 11: (90,450) 2280, 11399 | Bit 11: 0
Binary: 000001


Each bit isn't as obvious as the curtains, where you could easily tell if it was 1 or 0 because it was a combination of 2 different numbers. Whereas this code has more variation.

Here is a link to lutron's IR specs:
http://webcache.googleusercontent.com/search?q=cache:WkVDdMfTqUUJ:www.lutron.com/TechnicalDocumentLibrary/048158.doc+&cd=4&hl=en&ct=clnk&gl=ca (http://webcache.googleusercontent.com/search?q=cache:WkVDdMfTqUUJ:www.lutron.com/TechnicalDocumentLibrary/048158.doc+&cd=4&hl=en&ct=clnk&gl=ca)

Not sure if I goofed the decoding or not.
Title: Re: Trouble sending IR command to rc curtains
Post by: AnalysIR on Apr 16, 2014, 10:45 pm
A couple of things.....

- First, I have imported the signals and uploaded a screenshot of both signals, FYI
- You can see that your calculations for PRONTO conversion, differs from mine (I think mine is more correct)
- check your calculations for rounding errors or similar.
- The frequency is 40 kHz
- The second OFF signal is just sent twice, which is why it is longer
- The IR protocol is pretty easy to decode (if you know how  :) )
- All it is....each bit in the signal is 2250 uSecs long. So just divide the mark length by 2250 and you get the number of 1s at that position. - Ditto for spaces to get 0's. I verified the first ON signal to match the HEX codes you provided.
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Apr 17, 2014, 02:57 am
So does that come out to this array for sendRaw? I tried this one but it didn't work. =(

Code: [Select]
int on_signal= {1000,20250,6750,2250,6750,2250,9000,2250,4500,2250,2250,6750,15750};

Where does the first 1000 come from?

Btw I bought a copy of AnalysisIR =). I guess I need to get it activated before I can import the PRONTO to a channel right?
Title: Re: Trouble sending IR command to rc curtains
Post by: AnalysIR on Apr 17, 2014, 12:13 pm
We just add 1000 at the start of displayed signals, to make things pretty. It is removed automatically on export.

Below are your signals exported for IRLib.
Code: [Select]
/*
Automatically Generated by AnalysIR - Batch Export Utility
Registered to: xxxxxxxx
Session History
Type : Key : Value : Bits
0 : RAW :  : : 0
1 : RAW :  :  : 0
*/

// 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=40; //NB Change this default value as neccessary to the correct modulation frequency


unsigned int Signal_0_0[] = {20250,6750,2250,6750,2250,2250,9000,2250,2250,6750,2250,4500,2250,11250,20250,6750,2250,6750,2250,2250,9000,2250,2250,6750,2250,4500,2250,11250}; //AnalysIR Batch Export - RAW

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


unsigned int Signal_1_1[] = {20250,6750,2250,6750,2250,9000,2250,4500,2250,2250,6750,15750}; //AnalysIR Batch Export - RAW

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


Note: because of the longer bursts in these signals, IRremote cannot send them (because of the max length of delayMicroseconds in Arduino). So you will need to use the latest version of IRLib which now supports these longer type bursts (based on our suggestions)
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Apr 18, 2014, 02:31 am
I think I love you!!

I used AnalysisIR export to get the other remote functions to work as well. Like you said they only work with IRlib but not IRremote.

But...

Before changing my code to use the new library, I wanted to test all of the curtain's commands. OPEN and STOP work as expected, but CLOSE is giving me problems again. It just doesn't work. How is it possible that the same raw code that works fine on IRremote does not work with IRlib?

I tried changing the frequencies as well with no luck. Not sure what to do next.
Title: Re: Trouble sending IR command to rc curtains
Post by: juntao65 on Apr 18, 2014, 03:03 am
SOLVED!

And I'm even more confused...

I was able to get it to work because I remembered you mentioning that delayMicroseconds has a maximum allowable value of 16383. Well the close code I used had values far larger than this. So I made a sketch to figure out exactly what IRremote was doing when it called delayMicroseconds for values larger than 16383.

Code: [Select]

void loop() {
  if (Serial.read() != -1) {
    float start = micros();
   
    delayMicroseconds(95000);
   
    float ending = micros();
   
    float diff = ending - start;
   
    Serial.println(diff);
   
    delay(1000);
  }
}


So I took all of the values larger than 16383 from my original CLOSE array and replaced them with the numbers outputted through the above sketch.

Some example conversions:
95000 became 13160
33175 became 408
84350 became 2448

Original array:
Code: [Select]
PROGMEM unsigned int Signal_Close[] = {1175,400,1200,400,400,1200,1200,400,400,1200,400,1200,1200,400,400,1200,400,1200,400,1200,400,1200,400,33175,1200,400,1200,400,400,1200,1200,400,400,1200,400,1200,850,750,100,1575,400,1200,400,1200,400,1200,400,84350,1200,400,1200,400,400,1200,1200,400,400,1200,400,1200,925,675,100,1575,400,1200,400,1200,400,1200,400,33175,1200,400,1200,400,400,1200,1200,400,400,1200,400,1200,400,1200,400,1200,400,1200,400,1200,400,1200,400,95000};


New array:
Code: [Select]
PROGMEM unsigned int Signal_Close[] = {1175,400,1200,400,400,1200,1200,400,400,1200,400,1200,1200,400,400,1200,400,1200,400,1200,400,1200,400,408,1200,400,1200,400,400,1200,1200,400,400,1200,400,1200,850,750,100,1575,400,1200,400,1200,400,1200,400,2448,1200,400,1200,400,400,1200,1200,400,400,1200,400,1200,925,675,100,1575,400,1200,400,1200,400,1200,400,408,1200,400,1200,400,400,1200,1200,400,400,1200,400,1200,400,1200,400,1200,400,1200,400,1200,400,1200,400,13160};


So if IRremote didn't have that delaymicrosecond limit then I would have never got close to work.... wth right?
Title: Re: Trouble sending IR command to rc curtains
Post by: AnalysIR on Apr 18, 2014, 02:34 pm
I am not sure if you still have a problem? & if so what it is?

However, using floats for your calculations is likely to be inaccurate or incorrect.

If I remember correctly, delayMicroseconds takes an unsigned int (16 binary bits) as the delay value which has a max value of  65535 (256*256-1 = 65535)

It then multiplies it by 4 (reason below) which means anything more than 16383 overflows and which is why the max is 16383.

So when you have, say 84530, it is passed as a 16 bit unsigned int as (85530-65536) = 19994.

Then it is multiplied by 4 to get 79976, which also overflows to (79976-65536) 14440 .

So your actual delay ends up being 14440/4 = 3610 uSecs.


The reason for the x4 multiplication is that a very accurate 0.25 uSec delay is used within the function  (4 clock cycles of a 16MHz AVR 8 but MCU is exactly 0.25 uSecs).

For longer delays I often use, for example:
Code: [Select]
unsigned long uSecDelay = 84530;  //too long for delayMicroseconds!
unsigned long startTime = micros();
while ((micros()-startTime ) > uSecDelay);//wait here until uSec delay has elapsed

note the use of unsigned long vs unsigned int.


Conclusion: if you have signals with marks or spaces longer than 16383 uSecs....use the latest version of IRLib.