Go Down

Topic: IR sensor detects diffrent signals each time (Read 1 time) previous topic - next topic

so i was trying to make a lcd IR remote to do different things but each time it detects the power signal it displays a huge line of different signals each time. one would b like 56000 for the first number and other times its 32000. its a Samsung bn59-01055a remote. also tested it with my uverse remote and still it changes. any idea?

johnwasser

The first number is just the delay between looking for a signal and the start of the first pulse.  It can be safely ignored.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

i mean there diffrent even after the first row. here are the example of me hitting the power button

14128 usec, 4480 usec
4420 usec, 560 usec
1660 usec, 540 usec
1660 usec, 540 usec
1660 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
1640 usec, 560 usec
1660 usec, 540 usec
1660 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
1640 usec, 560 usec
540 usec, 560 usec
560 usec, 540 usec
580 usec, 520 usec
540 usec, 560 usec
580 usec, 520 usec
560 usec, 540 usec
1680 usec, 520 usec
560 usec, 560 usec
1640 usec, 560 usec
1660 usec, 540 usec
1660 usec, 540 usec
1660 usec, 560 usec
1640 usec, 560 usec
1640 usec, 560 usec

then
37992 usec, 4480 usec
4420 usec, 560 usec
1640 usec, 560 usec
1660 usec, 540 usec
1660 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 540 usec
560 usec, 560 usec
540 usec, 560 usec
1640 usec, 560 usec
1640 usec, 560 usec
1660 usec, 560 usec
540 usec, 560 usec
540 usec, 540 usec
560 usec, 540 usec
560 usec, 540 usec
560 usec, 560 usec
560 usec, 540 usec
1640 usec, 560 usec
540 usec, 560 usec
560 usec, 540 usec
540 usec, 560 usec
540 usec, 560 usec
580 usec, 520 usec
540 usec, 560 usec
1660 usec, 540 usec
560 usec, 540 usec
1660 usec, 560 usec
1640 usec, 560 usec
1660 usec, 540 usec
1660 usec, 540 usec
1660 usec, 540 usec
1660 usec, 560 usec

44952 usec, 4500 usec
4420 usec, 560 usec
1640 usec, 560 usec
1640 usec, 560 usec
1660 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
1640 usec, 560 usec
1660 usec, 540 usec
1660 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
1640 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 560 usec
540 usec, 580 usec
520 usec, 580 usec
520 usec, 580 usec
1640 usec, 560 usec
540 usec, 560 usec
1640 usec, 560 usec
1640 usec, 560 usec
1660 usec, 560 usec
1640 usec, 560 usec
1640 usec, 560 usec
1660 usec, 560 usec

johnwasser

You have to expect SOME jitter in the pulse width measurements.  Looks like the measurements are in 20 microsecond intervals.  Ignore the jitter and you'll see patterns look nearly identical. 44xx/44xx/5xx for a start signal and then a pattern of long (16xx/5xx) and short (5xx/5xx) pulses.  I'm guessing that in real life they are all supposed to be intervals of 550 microseconds:

4400/4400/550 (8x550, 8x550, 1x550)
1650/550        (3x550, 1x550)
550/550          (1x550, 1x550)

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

i tried that and even did the whole code and still didnt work. maybe the led wont work for the tv

johnwasser

Are you trying to pulse the IR LED directly or are you calling a library that will properly modulate the LED at 38 to 40 kHz?

Perhaps if you showed your code someone could figure out why it is not doing what you expect.  It would be best if the code contained comments saying what you expect to happen.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

im using a modified code from ladyada. heres my code


Code: [Select]
/* Raw IR decoder sketch!

This sketch/program uses the Arduno and a PNA4602 to
decode IR received. This can be used to make a IR receiver
(by looking for a particular code)
or transmitter (by pulsing an IR LED at ~38KHz for the
durations detected

Code is public domain, check out www.ladyada.net and adafruit.com
for more tutorials!
*/

// We need to use the 'raw' pin reading methods
// because timing is very important here and the digitalRead()
// procedure is slower!
//uint8_t IRpin = 2;
// Digital pin #2 is the same as Pin D2 see
// http://arduino.cc/en/Hacking/PinMapping168 for the 'raw' pin mapping
#define IRpin_PIN      PIND
#define IRpin          2

// the maximum pulse we'll listen for - 65 milliseconds is a long time
#define MAXPULSE 65000

// what our timing resolution should be, larger is better
// as its more 'precise' - but too large and you wont get
// accurate timing
#define RESOLUTION 20

// we will store up to 100 pulse pairs (this is -a lot-)
uint16_t pulses[100][2];  // pair is high and low pulse
uint8_t currentpulse = 0; // index for pulses we're storing

void setup(void) {
  Serial.begin(9600);
  Serial.println("Ready to decode IR!");
}

void loop(void) {
  uint16_t highpulse, lowpulse;  // temporary storage timing
  highpulse = lowpulse = 0; // start out with no pulse length


//  while (digitalRead(IRpin)) { // this is too slow!
    while (IRpin_PIN & (1 << IRpin)) {
     // pin is still HIGH

     // count off another few microseconds
     highpulse++;
     delayMicroseconds(RESOLUTION);

     // If the pulse is too long, we 'timed out' - either nothing
     // was received or the code is finished, so print what
     // we've grabbed so far, and then reset
     if ((highpulse >= MAXPULSE) && (currentpulse != 0)) {
       printpulses();
       currentpulse=0;
       return;
     }
  }
  // we didn't time out so lets stash the reading
  pulses[currentpulse][0] = highpulse;

  // same as above
  while (! (IRpin_PIN & _BV(IRpin))) {
     // pin is still LOW
     lowpulse++;
     delayMicroseconds(RESOLUTION);
     if ((lowpulse >= MAXPULSE)  && (currentpulse != 0)) {
       printpulses();
       currentpulse=0;
       return;
     }
  }
  pulses[currentpulse][1] = lowpulse;

  // we read one high-low pulse successfully, continue!
  currentpulse++;
}

void printpulses(void) {
  Serial.println("\n\r\n\rReceived: \n\rOFF \tON");
  for (uint8_t i = 0; i < currentpulse; i++) {
    Serial.print(pulses[i][0] * RESOLUTION, DEC);
    Serial.print(" usec, ");
    Serial.print(pulses[i][1] * RESOLUTION, DEC);
    Serial.println(" usec");
  }
}

johnwasser

That sketch is for reading the code from an IR remote.  You said:
Quote

i tried that and even did the whole code and still didnt work. maybe the led wont work for the tv


That implies you tried to play the code back with an LED and were unable to control a TV.  What sketch did you use to play the code back?
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

opss wrong one lol, i had the reader and other one up at the same time. heres the real one

Code: [Select]
// This sketch will send out a Nikon D50 trigger signal (probably works with most Nikons)
// See the full tutorial at http://www.ladyada.net/learn/sensors/ir.html
// this code is public domain, please enjoy!

int IRledPin =  13;    // LED connected to digital pin 13
int button = 2;
// The setup() method runs once, when the sketch starts

void setup()   {               
  // initialize the IR digital pin as an output:
  pinMode(IRledPin, OUTPUT);     
pinMode(button, INPUT);
  Serial.begin(9600);
}

void loop()                     
{
if (digitalRead(button) == HIGH)
{
   Serial.println( "hi");
  Power();

}
}

// This procedure sends a 38KHz pulse to the IRledPin
// for a certain # of microseconds. We'll use this whenever we need to send codes
void pulseIR(long microsecs) {
  // we'll count down from the number of microseconds we are told to wait

  cli();  // this turns off any background interrupts

  while (microsecs > 0) {
    // 38 kHz is about 13 microseconds high and 13 microseconds low
   digitalWrite(IRledPin, HIGH);  // this takes about 3 microseconds to happen
   delayMicroseconds(10);         // hang out for 10 microseconds
   digitalWrite(IRledPin, LOW);   // this also takes about 3 microseconds
   delayMicroseconds(10);         // hang out for 10 microseconds

   // so 26 microseconds altogether
   microsecs -= 26;
  }

  sei();  // this turns them back on
}

void Power() {
  // This is the code for my particular Nikon, for others use the tutorial
  // to 'grab' the proper code from the remote

  pulseIR(4500);
  delayMicroseconds(4400);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(550);
  pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
    delayMicroseconds(550);
  pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
    delayMicroseconds(550);
   pulseIR(550);
    delayMicroseconds(1640);
  pulseIR(550);
      delayMicroseconds(550);
  pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
    delayMicroseconds(550);
   pulseIR(550);
       delayMicroseconds(1640);
  pulseIR(550);
      delayMicroseconds(550);
   pulseIR(550);
   delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550); 
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delay(65); // wait 65 milliseconds before sending it again

  pulseIR(4500);
  delayMicroseconds(4400);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(550);
  pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
    delayMicroseconds(550);
  pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
    delayMicroseconds(550);
   pulseIR(550);
    delayMicroseconds(1640);
  pulseIR(550);
      delayMicroseconds(550);
  pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
delayMicroseconds(550);
   pulseIR(550);
    delayMicroseconds(550);
   pulseIR(550);
       delayMicroseconds(1640);
  pulseIR(550);
      delayMicroseconds(550);
   pulseIR(550);
   delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550); 
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
  delayMicroseconds(1640);
  pulseIR(550);
}

johnwasser

When the reading sketch prints out the times the left column id the 'high' time and the right column is the 'low' time.  Is the input high with no signal and low when a 38 KHz signal is present?  If it's the other way around you'll have to reverse the logic in the sending sketch.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

RandallR

I have been playing working with IR decoding.  I am having great success with everything except my RCA remotes and my AT&T U-verse remote.
From what I can find, the RCA uses a 56kHz carrier and my detector is tuned for 38kHz so that would explain that problem.
I don't know why I am having problems with my Uverse remote.  I'm sure it would help if I had a storage scope but I don't.

The problem that I am having is that for the same button (Play, Pause, Menu, ...) I seem to get different codes each time.   I wrote some interrupt driven code to receive the signals and I have uses the code described above with similar results.

To better compare the results, I modifed the function "printpulses" to display everything on the same line.  I also removed the first reading since it was the random quite time prior to the first pulse.

I also changed the "RESOLUTION" to "10" micro seconds.  I printed the raw count so "120 uS" prints as "12"
Code: [Select]

void printpulses(void) {
  pulses[0][0] = 0;
  Serial.print("Received (uS):\t");
  for (uint8_t i = 0; i < currentpulse; i++) {
    Serial.print(pulses[i][0], DEC);
    Serial.print("\t");
    Serial.print("^");
    Serial.print(pulses[i][1], DEC);
    Serial.print("\t");
  }
  Serial.println();
}


This yielded the follow sample for the "Menu" button.
Code: [Select]

Received (uS): 0 ^42 25 ^19 101 ^13 180 ^14 73 ^13 148 ^13 45 ^14 121 ^11 47 ^12 47 ^13 29 ^14 8511 ^41 27 ^16 26 ^15 60 ^12 181 ^15 28 ^15 28 ^14 28 ^15 103 ^14 46 ^11 61 ^17 43 ^14 45 ^11 48 ^12 31 ^12
Received (uS): 0 ^41 26 ^15 28 ^14 61 ^13 29 ^14 77 ^13 46 ^13 29 ^14 28 ^14 105 ^13 121 ^13 61 ^13 46 ^13 46 ^13 89 ^13 8512 ^40 27 ^15 28 ^14 60 ^14 310 ^15 60 ^12 62 ^13 46 ^12 121 ^13 47 ^13 45 ^13 30 ^13
Received (uS): 0 ^41 27 ^13 105 ^11 31 ^14 77 ^11 49 ^11 30 ^14 28 ^16 28 ^14 28 ^14 61 ^11 48 ^13 60 ^14 46 ^13 45 ^14 8614 ^40 27 ^15 26 ^18 59 ^12 31 ^13 136 ^13 30 ^14 28 ^15 28 ^15 28 ^14 61 ^12 46 ^15 119 ^13 45 ^13 90 ^12
Received (uS): 0 ^40 145 ^13 181 ^14 72 ^14 29 ^13 61 ^12 63 ^13 46 ^12 122 ^13 45 ^14 45 ^12 30 ^13 8513 ^40 145 ^14 30 ^13 77 ^12 47 ^13 74 ^11 106 ^11 122 ^14 120 ^14 45 ^14 45 ^12 30 ^13
Received (uS): 0 ^41 27 ^15 27 ^15 60 ^12 32 ^11 138 ^12 31 ^13 29 ^15 146 ^13 47 ^12 121 ^14 45 ^13 45 ^12 31 ^13 8510 ^42 27 ^16 27 ^15 58 ^17 27 ^15 135 ^15 29 ^11 117 ^15 60 ^12 46 ^15 119 ^15 44 ^13 45 ^15 29 ^12


All codes appear to begin with a 400 uSec mark followed by 260 uSec space (usually).   But the consistency quickly disappears.   The packet are of varying lengths.  There is an 8.5 ms gap somewhere near the middle of the message but it is not always in the same place.

Does anyone recognize this protocol?  Any clue how to decode?

Go Up