AC signal troubleshooting

Everything related to protocols and IR codes
User avatar
AnalysIR
Site Admin
Posts: 633
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

AC signal troubleshooting

Post by AnalysIR »

One backer asked....
I’m trying to decode the IR remote that my AC unit uses, I’ve hat little luck using IRremote or IRlib to record raw IR and play it back, its just not working, but I’ve verified I’m replicating the signal exactly, I suspect maybe its a different frequency than 38kHz… I’m not too sure where else to look, I’ve successfully mirrored back raw codes to my samsung TV for on and of, but this AC unit is stumping me.

Any pointers?
and then followed up with some data...
1 (Heat On, 86, Fan Auto)
For IR Scope:
+8900 -4400 +700 -500 +650 -550 +650 -1600 +700 -1550 +700 -500 +700 -1550 +700 -500 +700 -500 +650 -550 +650 -1600 +700 -1550 +700 -1600 +650 -500 +700 -500 +700 -500 +650 -550 +650 -500 +700 -500 +700 -500 +650 -500 +700 -500 +700 -1600 +650 -1600 +700 -500 +650 -500 +700 -500 +700 -500 +650 -1600 +700 -1600 +650 -500 +700 -1600 +650 -500 +700 -500 +700 -1550 +700 -500 +700
For Arduino sketch:
unsigned int raw[74] = {8900,4400,700,500,650,550,650,1600,700,1550,700,500,700,1550,700,500,700,500,650,550,650,1600,700,1550,700,1600,650,500,700,500,700,500,650,550,650,500,700,500,700,500,650,500,700,500,700,1600,650,1600,700,500,650,500,700,500,700,500,650,1600,700,1600,650,500,700,1600,650,500,700,500,700,1550,700,500,700,};
irsend.sendRaw(raw,74,38);

2 Off
For IR Scope:
+8900 -4400 +650 -500 +700 -500 +700 -1550 +700 -500 +700 -500 +700 -1550 +700 -500 +700 -500 +650 -550 +650 -1600 +650 -1600 +700 -1600 +650 -500 +700 -500 +700 -500 +650 -550 +650 -500 +700 -500 +700 -500 +650 -500 +700 -500 +700 -1550 +700 -1600 +650 -550 +650 -500 +700 -500 +700 -500 +650 -1600 +700 -1550 +700 -500 +700 -1600 +650 -500 +700 -500 +700 -1550 +700 -500 +700
For Arduino sketch:
unsigned int raw[74] = {8900,4400,650,500,700,500,700,1550,700,500,700,500,700,1550,700,500,700,500,650,550,650,1600,650,1600,700,1600,650,500,700,500,700,500,650,550,650,500,700,500,700,500,650,500,700,500,700,1550,700,1600,650,550,650,500,700,500,700,500,650,1600,700,1550,700,500,700,1600,650,500,700,500,700,1550,700,500,700,};
irsend.sendRaw(raw,74,38);
and for completeness the Arduino code to generate the above is

Code: Select all

#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

int c = 1;

void dump(decode_results *results) {
  int count = results->rawlen;
  Serial.println(c);
  c++;
  Serial.println("For IR Scope: ");
  for (int i = 1; i < count; i++) {
   
	if ((i % 2) == 1) {
  	Serial.print("+");
  	Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
	}
	else {
  	Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
	}
	Serial.print(" ");
  }
  Serial.println("");
  Serial.println("For Arduino sketch: ");
  Serial.print("unsigned int raw[");
  Serial.print(count, DEC);
  Serial.print("] = {");
  for (int i = 1; i < count; i++) {
   
	if ((i % 2) == 1) {
  	Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
	}
	else {
  	Serial.print((int)results->rawbuf[i]*USECPERTICK, DEC);
	}
	Serial.print(",");
  }
  Serial.print("};");
  Serial.println("");
  Serial.print("irsend.sendRaw(raw,");
  Serial.print(count, DEC);
  Serial.print(",38);");
  Serial.println("");
  Serial.println("");
}

void loop() {
  if (irrecv.decode(&results)) {
	dump(&results);
	irrecv.resume(); // Receive the next value
  }
}

User avatar
AnalysIR
Site Admin
Posts: 633
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: AC signal troubleshooting

Post by AnalysIR »

OK

We managed to import the Infrared signals into AnalysIR and the screenshot is attached.

Some things to note:
  • The signal is like a typical NEC type signal, but with different timings and a different number of bits (looks like 35 bits on first glance)
  • Next there is an issue with your IRremote code - your count is 74 and it should be 73.
  • The signal partly decodes as a Daewoo signal, but there are additional bits in your AC IR signal
  • IRremote records timings in 50 microsecond steps. This can put some 'border-line' signals out and seems to be more of an issue for AC units than TVs.
  • So, if the change to 73 does not work, then the next step is to record the timings using AnalysIR's included code, which records the signal times to +/- 4 microseconds vs 50 for IRremote. In case the modulation frequency is incorrect, you could also check from 36 to 50 in steps of 1
  • Once we get the timings from AnalysIR we should be able to confirm the exact timings used by your AC remote!
Finally, please let us know which model of AC this query relates to and also what model of IR receiver you are using to record the signal...tnx
You do not have the required permissions to view the files attached to this post.

briankwest
Posts: 11
Joined: Wed Nov 27, 2013 4:20 pm

Re: AC signal troubleshooting

Post by briankwest »

I've installed the capacitor as you recommended and the signal still seems to be noisy. I'm going to wait till my better IR receiver gets here to see if I can capture a cleaner signal out of this thing. I've done the same signal twice on channel 1 and channel 2 and they are different, I would expect the same command to look the same from try to try as it is on my Samsung TV when I cloned the ON / OFF and had it working fine.

/b

User avatar
AnalysIR
Site Admin
Posts: 633
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: AC signal troubleshooting

Post by AnalysIR »

OK - lets wait for the new IR Receivers.

One other thing to try, is to double check that you have the IR Receiver signal pin actually connected to Pin 2 (I have seen situations where an input is connected to an adjacent pin & there was crosstalk onto the correct pin. This is unlikely given the proportion of clean signal being achieved, but worth a double check).

AS the receiver works fine for your samsung TV remote, it could be that the AGC in the receiver is blocking the signal after 'x' pulses.

User avatar
AnalysIR
Site Admin
Posts: 633
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: AC signal troubleshooting

Post by AnalysIR »

Just for completeness/reference, I have attached a trace of the problem signals here, captured using AnalysIR.
You do not have the required permissions to view the files attached to this post.

briankwest
Posts: 11
Joined: Wed Nov 27, 2013 4:20 pm

Re: AC signal troubleshooting

Post by briankwest »

Here is the latest capture of Power on using the better sensor.

/b
You do not have the required permissions to view the files attached to this post.

User avatar
AnalysIR
Site Admin
Posts: 633
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: AC signal troubleshooting

Post by AnalysIR »

Great

This is a much cleaner image & and you will notice the large gap in the middle of 19820 uSecs. Unfortunately, IRremote cant handle this. However, we should be able to send you some code to work around this.

I will test this out for you tomorrow and post the example code. (its late here now)

If you can could you upload a photo of the previous sensor you used together with the model number, just for future reference.
You do not have the required permissions to view the files attached to this post.

briankwest
Posts: 11
Joined: Wed Nov 27, 2013 4:20 pm

Re: AC signal troubleshooting

Post by briankwest »

It was RadioShack Part number 276-640, It has no markings on it at all so its hard to tell what exactly it is.

It looks more like this http://media3.rsdelivers.cataloguesolut ... 142-01.jpg

/b

User avatar
AnalysIR
Site Admin
Posts: 633
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: AC signal troubleshooting

Post by AnalysIR »

Ok

with the help of the Batch export feature of AnalysIR (Menu->File->Batch Export->IRremote) I ammended some existing code I had to generate your AC power signal from above.
I have included an image of the original signal and a newly generated on from an Arduino, below. I will explaing some of the issues in a follow up post.
You do not have the required permissions to view the files attached to this post.

User avatar
AnalysIR
Site Admin
Posts: 633
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: AC signal troubleshooting

Post by AnalysIR »

This post contains the Arduino code used to generate the above signal.

The code below (other than IRremote etc, which is open source) is free to use by all. (Just credit AnalysIR where possible and link to http://www.AnalysIR.com)

Code: Select all

#include <IRremote.h>

/*
Automatically Generated by AnalysIR - Batch Export Utility
 Registered to: xxxxxx
 Session History: POWER ON
 Type : Key : Value : Bits
 0 : RAW : ACpower :  : 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 xxxxxxxxxx, visit http://www.AnalysIR.com or email info@....... for further details


unsigned int Signal_ACpower_partA[] = {
  9040,4388,720,1572,720,1568,720,480,720,1572,724,476,724,472,724,476,724,476,724,1568,716,480,720,480,720,1572,724,472,728,472,724,476,724,476,724,476,720,476,724,476,724,476,724,472,724,1568,720,1572,724,472,728,472,756,444,756,444,752,1536,720,1572,728,472,724,1568,720,476,752,448,752,1540,744,456,744}; //AnalysIR Batch Export - RAW
unsigned int Signal_ACpower_partB[] = {
  720,480,716,484,748,448,748,452,748,452,748,448,748,452,748,452,748,452,744,452,748,452,748,452,748,448,748,1544,752,448,752,448,752,444,752,448,752,448,752,444,752,448,752,448,752,448,752,444,752,448,752,448,752,444,752,448,752,448,752,448,748,448,752,1540,748}; //AnalysIR Batch Export - RAW

IRsend irsend;

unsigned char khz = 38; //NB always change this modulation frequency to suit your system (for 38,000 Hz use 38 as a value)

unsigned int i=0;

void setup()
{
  Serial.begin(9600);
  reportFreeRAM(0xFFFF);//you can remove this once you are happy with the code

  //clean the signals to remove effect of IR receivers
  for (i=0;i<sizeof(Signal_ACpower_partA)/sizeof(int);i++) {//clean first part of signal
    Signal_ACpower_partA[i]=cleanTimingAC(Signal_ACpower_partA[i]);
  }

  for (i=0;i<sizeof(Signal_ACpower_partB)/sizeof(int);i++) {//clean second part of signal
    Signal_ACpower_partB[i]=cleanTimingAC(Signal_ACpower_partB[i]);
  }
}

void loop() {
  if (Serial.available()) { //send the test signal when we get a character over serial
    Serial.println(Serial.read());//dump it back out
    irsend.sendRaw(Signal_ACpower_partA, sizeof(Signal_ACpower_partA)/sizeof(int), khz); 
    accurateDelayuSecs(20000-16383);//corrects for issue(s) with Arduino timer & IRremote (split the signal and insert the delay in ms vs uSecs
    irsend.sendRaw(Signal_ACpower_partB, sizeof(Signal_ACpower_partB)/sizeof(int), khz); 
    delay(10000); //just for testing  - make sure there is a 10 sec gap between signals
    reportFreeRAM(0xFFFF);//you can remove this once you are happy with the code
  }
}

unsigned int cleanTimingAC(unsigned int val){
#define timeUnit 430
  if (val<1000) return 600; //Bit Marks & Space 0...all Marks
  if (val<2000) return 1690; //Space 1
  if (val<5000) return 4500; //Header Space
  if (val<10000) return 9000; //Header Mark
  return val;//if none of the above
}

void accurateDelayuSecs(unsigned long del){//gets over problems with Arduino bug
  unsigned long endTime = micros()+del;
  while ((endTime-micros())>3);//only 4 usecs granularity
}

//you can remove this once you are happy with the code
void reportFreeRAM(unsigned int f){ //report freeRam to host if less than f or f is false
  extern int __heap_start, *__brkval; 
  int v; 
  int freeRAM = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
  if (freeRAM<=f){
    Serial.print(F("!Free RAM: "));//send line as comment
    Serial.print(freeRAM);
    Serial.println(F("!"));//send line as comment
  }
}

You will notice that there are some minor timing differences, which we will have to fix if this initial signal does not work as expected.

To send the signal, you will have to send a charater via the Arduino Serial Monitor. There is also a 10 econd delay betweeen signals to avoid confusing the AC unit. This delay can be removed once we have the signal working.

So try it out and post back with the results.....

Post Reply