Ir sensor from asus eeepc remote - inconsistent ir signal using arduino - Page 1
Forum section: electronics / beginners

author: amateur_25
author_rank: Regular Contributor
timestamp: April 16, 2014, 09:02:21 am
content: I took apart a asus eee pc remote control and borrowed it's ir sensor to implement the remote using my arduino. I have a sketch I borrowed from ladyada so I can look at the raw ir signal. Since she has a professional scope and I have a cheapo one who doesn't trigger properly. But I don't get the same results each time. I tested the sensor using the asus board without it's case and it works fine.I noticed on the asus board it has some fitlering caps,100 ohm resistor and what looks like an inductor/fuse. Am assuming I shouldn't just wire the vcc = 5v gnd=gnd ouput = digital 2? How should I be wiring this up

author: ttp
author_rank: Regular Contributor
timestamp: April 16, 2014, 11:14:08 am
content: There is nothing wrong with wiring like you have described - vcc = 5v gnd=gnd ouput = digital 2. What are the inconsistencies/differences you are not happy about?

author: amateur_25
author_rank: Regular Contributor
timestamp: April 17, 2014, 10:36:19 am
content: Code:/* Raw IR decoder sketch!This sketch/program uses the Arduno and a PNA4602 todecode 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 thedurations detectedCode is public domain, check out [url=http://www.ladyada.net]www.ladyada.net and adafruit.comfor 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// for MEGA use these!//#define IRpin_PIN PINE//#define IRpin 4// 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; // pair is high and low pulseuint8_t currentpulse = 0; // index for pulses we're storingvoid setup(void) {Serial.begin(9600);Serial.println("Ready to decode IR!");}void loop(void) {uint16_t highpulse, lowpulse; // temporary storage timinghighpulse = 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 microsecondshighpulse++;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 resetif ((highpulse >= MAXPULSE) && (currentpulse != 0)) {printpulses();currentpulse=0;return;}}// we didn't time out so lets stash the readingpulses = highpulse;// same as abovewhile (! (IRpin_PIN & _BV(IRpin))) {// pin is still LOWlowpulse++;delayMicroseconds(RESOLUTION);if ((lowpulse >= MAXPULSE) && (currentpulse != 0)) {printpulses();currentpulse=0;return;}}pulses = 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 * RESOLUTION, DEC);Serial.print(" usec, ");Serial.print(pulses * RESOLUTION, DEC);Serial.println(" usec");}// print it in a 'array' formatSerial.println("int IRsignal[] = {");Serial.println("// ON, OFF (in 10's of microseconds)");for (uint8_t i = 0; i < currentpulse-1; i++) {Serial.print("\t"); // tabSerial.print(pulses * RESOLUTION / 10, DEC);Serial.print(", ");Serial.print(pulses[i+1] * RESOLUTION / 10, DEC);Serial.println(",");}Serial.print("\t"); // tabSerial.print(pulses[currentpulse-1] * RESOLUTION / 10, DEC);Serial.print(", 0};");}This is supposed to output the raw data out of a PNA4602. I borrowed it from ladyadahttps://learn.adafruit.com/ir-sensor/using-an-ir-sensor.I can only assume if I press the same button each time, the output on the terminal should be the same right? Otherwise how does the arduino know I've actually pressed the same button? Am I correct in this I think reasonable assumption for an amateur

author: electr_peter
author_rank: Unknown
timestamp: April 17, 2014, 10:47:05 pm
content: IR remotes use many different transmission protocols and IR frequencies, so I cannot say anything specific about your remote.Repeated button presses can be implemented in multiple ways (depending on IR protocol):1) send the same button press (repeat same codes)2) send short command signaling repetition (receiver should remember last valid signal)3) send alternating codefor multiple presses (for simple example, ENTER button code could be 00010, then 00011, then 00010, 00011, etc. I had LG tv which similar type remote)4) any other wayI have tested multiple remotes - each may be different in radical ways, but most follow NEC IR pattern.Code you posted may not take into account this behaviour. I would suggest for you too look at the code, modify it so it print IR pulse ON-OFF times. Then try pressing the button multiple times and see on-off time pattern - use this to adapt code to your remote.Scope is not necessary, Arduino is well suited to decode IR frequencies.

author: JoeO
author_rank: Frequent Contributor
timestamp: April 18, 2014, 01:33:08 am
content: This website is an excellent site to learn about IR.http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html

author: AnalysIR
author_rank: Contributor
timestamp: April 23, 2014, 02:11:49 pm
content: You may be best served using the IRremote or newer IRLib libraries for Arduino.You will always get different timings for the same signal via typical IR receivers, so the behaviour you described seems normal.Once you pass the raw timings into a decoder like the libraries above, you should start to see consistent 'decoded' results.(Decoders can allow +/- 100USecs or more variance on mark space timings when analysing a signal)You might be interested in some of our recent blog posts:http://www.analysir.com/blog/2014/03/27/infrared-receivers-signal-lag/orhttp://www.analysir.com/blog/2014/03/05/arduino-10-common-pitfalls-infrared-remote-control/