How to sent a hex ir remote code

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

How to sent a hex ir remote code

Postby Danny1799 » Wed May 02, 2012 2:14 pm

Hi, I have a Sanyo camcorder and it come with a infrared remote. I would like to use arduino to replace the remote control so that I can take somea time=lapse photos. I am able to decode the Sanyo remote control code in hex format . I am not sure which method I can use in IRremote.h. I tried, something like sendSony(0xE654E234, 32), to take a photo, but no response I guess sendSony is only for Sony device, right? So what method I can use in order to set out the Sanyo remote control signal?

Thanks
danny
Danny1799
 
Posts: 5
Joined: Fri Apr 20, 2012 1:37 pm

Re: How to sent a hex ir remote code

Postby pylon » Wed May 02, 2012 3:29 pm

You wrote you can decode your Sanyo remote. When decoding with the IRremote library it tells you which type it thinks the remote is. You just have to use the same type when sending signals.
pylon
 
Posts: 14
Joined: Tue Apr 24, 2012 10:27 am

Re: How to sent a hex ir remote code

Postby Danny1799 » Wed May 02, 2012 3:54 pm

My meaning of decode is I use an arduino + ir reciever to get the HEX code when I press a button in the Sanyo remote. I have all the hex code for each buttons which I display in the serial monitor. Now, I assume the Hex code I get are the signals to control my Sanyo camorder. In order to see if it works or not, I need to do a irsend via my arduino + ir led to send those Hex code to my camorder to see if has response or not. My problem is I don't know how to sent hex code out. As I said, I tried using sendSony(), but is not working. I am not sure where can I get the remote type from. Could you mind give me some sample codes to shoe me how this can be done. Can someone tell me if sentSony() is only good for Sony device. I check the Arduino Cookbook and it is not quite clear about this. All example I found in the internet is using sendSony()??
Danny1799
 
Posts: 5
Joined: Fri Apr 20, 2012 1:37 pm

Re: How to sent a hex ir remote code

Postby pylon » Wed May 02, 2012 4:20 pm

I'd say begin with using the IRrelay example from IRremote. If IRremote knows your code it will tell you the type of the remote and the hex code. If that does not work it may be IRremote does not know the code of your remote yet. Then you may find descriptions of the remote for the LIRC project on the internet and use that information to code the new type. If this don't work too, you may have to reverse engineer it the hard way...
pylon
 
Posts: 14
Joined: Tue Apr 24, 2012 10:27 am

Re: How to sent a hex ir remote code

Postby wnc » Tue May 08, 2012 8:35 am

Hi
I have different problem with regard to IR Remote control.
I have tried that IRremote library did not support my Pioneer banned Player and Sharp TV RC and I don't know how to modify IRremote library either.
Therefore I looked for other alternative method to capture the IR code. Finally it was found at http://www.ladyada.net/learn/sensors/ir ... r_commands

Tutorial is written such that even layman like me can understand and follow exactly.
However , when come into application, I still can not make it work.
I thought I captured the code quite accurately because result is all ok. When I used it, then it doesn't work.
Of course, I write the sketch ( just combine capture sketch and send sketch) and applied the captured code.

Anybody have any idea about those sketch and ever successfully used it before?

Thanks in advance.
wnc
 
Posts: 38
Joined: Tue May 08, 2012 8:16 am

Re: How to sent a hex ir remote code

Postby pylon » Tue May 08, 2012 1:13 pm

Please post your code, maybe the community finds the problem.
pylon
 
Posts: 14
Joined: Tue Apr 24, 2012 10:27 am

Re: How to sent a hex ir remote code

Postby wnc » Tue May 08, 2012 9:04 pm

Hi
Here is the code. As I said earlier, I just modify the codes to serve the purpose. I have tested the sketch that it transmit the code(IR signals). Because I monitor the signals by installing IRreceiver&LED. However my Pioneer banned player did not play. The attached code is for Pioneer "Play" signal.
Help me to check whether my sketch is correct.

============================================xxx===================================
#include "ircodes.h"

int IRledPin = 13; // LED connected to digital pin 13

// The setup() method runs once, when the sketch starts

void setup() {
// initialize the IR digital pin as an output:
pinMode(IRledPin, OUTPUT);

Serial.begin(9600);
}

void loop()
{
Serial.println("Sending IR signal");

SendNikonCode();

delay(60*1000); // wait one minute (60 seconds * 1000 milliseconds)
}

// 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 SendNikonCode() {
// This is the code for my particular Nikon, for others use the tutorial
// to 'grab' the proper code from the remote
for(int i=0; i<80;i++) {
pulseIR(ApplePlaySignal[i*2+0]);
delay(ApplePlaySignal[i*2+1]);}
}

=========================+++==================Below is the H file

long ApplePlaySignal[]={
// ON, OFF (in 10's of microseconds) play button
834, 414,
54, 152,
54, 154,
54, 52,
52, 52,
50, 54,
50, 154,
54, 52,
52, 152,
54, 52,
52, 52,
52, 154,
54, 152,
54, 152,
56, 52,
52, 152,
54, 52,
50, 54,
50, 154,
54, 154,
52, 154,
54, 152,
54, 54,
50, 54,
50, 154,
54, 152,
54, 52,
52, 52,
52, 52,
52, 52,
52, 152,
54, 154,
54, 52,
52, 2640,
832, 414,
54, 154,
54, 152,
54, 52,
52, 52,
52, 52,
52, 152,
54, 54,
50, 154,
54, 52,
52, 52,
50, 154,
54, 152,
56, 152,
54, 52,
52, 152,
54, 52,
52, 52,
52, 154,
52, 154,
54, 152,
54, 154,
52, 54,
52, 52,
52, 152,
54, 154,
52, 54,
50, 52,
52, 52,
52, 52,
52, 154,
54, 152,
54, 52,
52, 2638,
834, 414,
54, 152,
54, 154,
52, 54,
52, 52,
50, 54,
50, 154,
54, 52,
54, 54,
50, 0};
wnc
 
Posts: 38
Joined: Tue May 08, 2012 8:16 am

Re: How to sent a hex ir remote code

Postby Danny1799 » Tue May 08, 2012 10:07 pm

Hi, I have problems setting up the hardware to test the IRrelay example from IRremote.
I am look for the schematic or reference links, any help?

Thanks
danny
Danny1799
 
Posts: 5
Joined: Fri Apr 20, 2012 1:37 pm

Re: How to sent a hex ir remote code

Postby wnc » Wed May 09, 2012 12:29 am

Danny
IRreceiver outlet connect to pin 11 and relay (it can be LED) connect to pin 4.
you can connect a LED to pin 13 to monitor the relay status. As per sketch, relay and LED do the same.
Do take note that even if your set up is correct, it doesn't mean it will work.
I have tested and it did not work.Because my RC is none of them supported RC.
Good luck.
wnc
 
Posts: 38
Joined: Tue May 08, 2012 8:16 am

Re: How to sent a hex ir remote code

Postby pylon » Wed May 09, 2012 8:27 am

wnc

In your header file at least the comment seems to be wrong (there it's defined the values to be in thens of microseconds, in the code the values are treated as microseconds).

Many of your values are about twice the wavelength, probably signal noise. What looks like a signal from the remote are the values above 400 microseconds. Pioneer probably did not choose signal lengths which are below 6-8 ticks of the underlying modulation frequency.

Have you looked if someone from LIRC community already decoded your remote's signals? Because transferring these values is easier than getting them yourself.

To your code: try adding the values below 400 to get a shorter sequence of values above 400 microseconds. Take care that the values above 400 are still on the same side (ON/OFF).

The code you're basing on is written for a Nikon remote. Maybe you should change to a code based on IRremote because that is using timers and PWM to get the necessary exactness. Nikon cameras may be more tolerant to timing errors than your banned player is.
pylon
 
Posts: 14
Joined: Tue Apr 24, 2012 10:27 am

Re: How to sent a hex ir remote code

Postby philba » Wed May 09, 2012 10:34 am

I'm never had good luck driving an IR emitter directly from an Arduino pin. It's always been too weak to give any kind of distance. Instead, I use an NPN and drive the IR emitter at about 100mA. That seems to work really well. Off the Arduino pin directly, I got about 12" of distance. With the NPN driver I am getting at least 15 ft. This is with a Nikon D90. The circuit below gives you a bit less than 100 mA.
Image
philba
 
Posts: 387
Joined: Mon Dec 19, 2011 5:59 pm

Re: How to sent a hex ir remote code

Postby wnc » Thu May 10, 2012 3:34 am

Thanks Pylon for your comments.
pylon wrote:In your header file at least the comment seems to be wrong (there it's defined the values to be in thens of microseconds, in the code the values are treated as microseconds).

You are right. I overlook the comment which is true. It means the number in the code has to be corrected.
pylon wrote:Have you looked if someone from LIRC community already decoded your remote's signals? Because transferring these values is easier than getting them yourself.

I have checked LIRC as well as http://www.remotecentral.com/cgi-bin/codes/
There are codes for my RC. But I don't know how to apply them in my sketch. Do you have any idea?
pylon wrote:To your code: try adding the values below 400 to get a shorter sequence of values above 400 microseconds. Take care that the values above 400 are still on the same side (ON/OFF).

Sorry I cannot figure out what it means by that. I am not tech savvy. Appreciate it if you can rephrase it.

As you suggested, I try to improve the sketch to suit my application.

I will post the finding.

Thanks
wnc
 
Posts: 38
Joined: Tue May 08, 2012 8:16 am

Re: How to sent a hex ir remote code

Postby adafruit_support_rick » Thu May 10, 2012 10:45 am

You have more than one code sequence in your array. Is that your intention? The first sequence ends with the long off at 52, 2640. The second sequence ends at 52, 2638. That is followed by an incomplete sequence.

You should have a look at the following pages, to make sure you understand exactly what the numbers in your array mean:
http://wiki.altium.com/display/ADOH/NEC+Infrared+Transmission+Protocol
http://www.sbprojects.com/knowledge/ir/nec.php

It might be easier to keep all this straight if you change your array numbers to microseconds instead of 10's of microseconds.

As you can see from the URLs above, the first on/off pair in a sequence is the leading pulse-burst and space, which are ideally 9000us and 4500us, respectively. Your sequence starts with a pulse-burse and space of 8340us and 4140us.

Then, you can see that you've got a couple of '1' pulses:
540us, 1520us
540us, 1540us

then a couple of '0' pulses:
540us, 520us
540us, 520us

and so on. (You might want to think about ways to organize your code so that you can work with sequences that make a little more sense than random-looking 520's and 1540's). You should now be able to look at your array sequence and verify that the bit stream is in the correct format.

The next thing you need to know is just how accurate pulseIR and delay loops are. If you have access to an oscilloscope, you should be able to probe your output pin to see if you're actually putting out a 38KHz carrier, and if your pulse widths are correct. Exact pulse widths aren't critical, but they should at least be close. adjust your loop constants and/or array values to make it all look right.

Next, you are turning interrupts on in between calls to pulseIR. You don't want to do that, as it can cause abnormally long spaces in your pulse sequence. You want interrupts off for the length of an entire sequence.

Also, your array and the argument to pulseIR don't need to be type long, as none of your values are > 32767. The long arithmetic will take longer than short arithmetic, which will further skew your pulse-width timing.
User avatar
adafruit_support_rick
 
Posts: 2907
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: How to sent a hex ir remote code

Postby wnc » Sat May 12, 2012 3:13 am

Hi
Thank you gentlemen for your invaluable inputs, comments and suggestion.
Without you, I may stuck where I was.

Now, I am pleased to inform you all that I got it done successfully. I tested in Sharp TV on/off mode only and it works. I will continue to work for other keys like channel up/down, volume up/don.
Below are the correction that I made.

Errors: The seconds stated in array are of 10's microseconds and I used it as it is. But in the sketch, I used it as microseconds.
Correction: I changed 10's microseconds to microseconds and fine tune the each microseconds wherever necessary.
Improvement: I used philba circuit, thinking that I might be weak signal.

I would like to thank http://www.ladyada.net/learn/sensors/ir.html for good tutorial.
And I personally thank to pylon and driveblock for their inputs. You guys are genius.

Thanks
wnc
 
Posts: 38
Joined: Tue May 08, 2012 8:16 am

Re: How to sent a hex ir remote code

Postby adafruit_support_rick » Sat May 12, 2012 10:46 am

wnc-
You are very welcome.
I recently wrote an IR decoder for a commercial audio amplifier, so I had to spend some time learning all this. Glad I had an opportunity to share what I learned! :D
User avatar
adafruit_support_rick
 
Posts: 2907
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY


Return to Arduino

Who is online

Users browsing this forum: No registered users and 14 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [108]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[31]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[34]
LCDs & Displays[48]
Components & Parts[70]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[111]
 
Wireless[14]
Cables[62]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]