SAMSUNG remote control decoder

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

SAMSUNG remote control decoder

Post by Spanish_dude »

Hi everyone,

I made a SAMSUNG remote control decoder.

First of all I want to say that I only have one SAMSUNG remote control, so I don't know if the program I made is compatible with other SAMSUNG remote controls.
Secondly, I didn't find much info (almost nothing) about the SAMSUNG protocol, so I measured the IR signal of the remote control with a 36kHz IR receiver and a scope and the program is based on the IR signal.

The remote control send a data of. The first half (16 bit) is the address and the second half (16 bit) is the command.

Before it sends the 32 bits, there is a startbit of ~9ms => ~4.5ms low and ~4.5ms high.

Image

The SAMSUNG remote controls uses pulse distance encoding of the bits. Each pulse is ~660Βµs long. A logical "1" takes 2.25ms to transmit, while a logical "0" is only 1.15ms.

The first thing that the microcontroller will do is 'detect' the startbit. To do this, a first loop is executed to detect the first half of the startbit (~4,5ms low) and then a second one will detect the second half of the startbit (~4,5ms).

After the startbit is detected, a third loop is executed to detect the ~660Βµs pulse (logical '0').
If it didn't detect it, nothing happens. If it did detect it, then it will wait until the signal is high.
When it is high, a variable named timer will increase by one every 50Βµs, until the signal is low (= the 660Βµs) again.
If the variable timer is greater than 18, then an array called Address[bit] = '1' else it'll be '0'.
The first time this part of the program is executed the variable bit is = 0.
After that the variable bit will increase by one and the variable timer is reset to 0. This will be done 16 times, so that the microcontroller will save 16 bits in the array Address.

A fourth loop will be executed and will do the same as the third one, but it will 'save' each bit in an array called Command.

Then the saved bits are converted into decimal numbers and then in hexadecimal.
Once that is done, you can read on the LCD the Address and the Command.


It's still on a breadboard, but I made a little circuit that controls to relays and with that remote control decoder and some code added to the program, I can turn two 40W lights on and off using four buttons of the remote control. Two to turn the light on and two to turn them off.
I also added a double electric switch (don't know the right english term ^^), so I can turn the lights on and off with that double switch AND the remote control.

That's it for now, I hope you understood something : D

Nicolas
Attachments
decoder.fcf
SAMSUNG remote control decoder flowcode file
(18.43 KiB) Downloaded 1604 times

goblin
Posts: 10
Joined: Tue Aug 11, 2009 7:47 pm
Contact:

Re: SAMSUNG remote control decoder

Post by goblin »

Thanks Spanish Dude,
Did you by any change also made a Samsung IR transmitter. Since my Samsung stereo does not have a alarm clock function it would be nice to control it via IR, a RTC and a micro.
But your code is a start.

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: SAMSUNG remote control decoder

Post by Spanish_dude »

Hi,

First of all, sorry for the late reply.

I think, not really sure about it, that I made a SAMSUNG IR transmitter.
I'll try to find it or re-program it.

Harry Tuttle
Posts: 27
Joined: Sat Aug 01, 2009 3:15 pm
Has thanked: 2 times
Been thanked: 10 times
Contact:

Re: SAMSUNG remote control decoder

Post by Harry Tuttle »

Hello,

That looks like NEC Extended Protocol developed by NEC Electronics. I have just made a transmitter to operate the shutter on my camera which is controled by this IR protocol, it took age's to figure it out!!

Have a look at:
http://www.sbprojects.com/knowledge/ir/nec.htm

regards,
ben

goblin
Posts: 10
Joined: Tue Aug 11, 2009 7:47 pm
Contact:

Re: SAMSUNG remote control decoder

Post by goblin »

Hello Spanish Dude,
it has been a while, but did you find your Samsung IR transmitter.
regards

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: SAMSUNG remote control decoder

Post by Spanish_dude »

Hi,

I'm sorry, I totally forgot about that ...

I did find a program for a SAMSUNG IR transmitter somewhere in my files, but I don't remember if I did try it "in real" and if it worked...
I'm using RA0 as output for the IR.

The attached file is what you need !
If you have any problems/questions just ask me.
Attachments
telecommande_32 bit.fcf
IR Transmitter
(18.32 KiB) Downloaded 1215 times

goblin
Posts: 10
Joined: Tue Aug 11, 2009 7:47 pm
Contact:

Re: SAMSUNG remote control decoder

Post by goblin »

thanks dude
i will dive into it this week. let you know if i have any questions

Harry Tuttle
Posts: 27
Joined: Sat Aug 01, 2009 3:15 pm
Has thanked: 2 times
Been thanked: 10 times
Contact:

Re: SAMSUNG remote control decoder

Post by Harry Tuttle »


goblin
Posts: 10
Joined: Tue Aug 11, 2009 7:47 pm
Contact:

Re: SAMSUNG remote control decoder

Post by goblin »

goblin wrote:thanks dude
i will dive into it this week. let you know if i have any questions
hello again dude
something went wrong during importing to an AVR chip.
would you be so kind to send the c code. and i will try to solve the missing variable
regards

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: SAMSUNG remote control decoder

Post by Spanish_dude »

goblin wrote: hello again dude
something went wrong during importing to an AVR chip.
would you be so kind to send the c code. and i will try to solve the missing variable
regards
Sure ;)
Attachments
telecommande_32 bit.c
(12.98 KiB) Downloaded 1011 times

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: SAMSUNG remote control decoder

Post by greentech »

Hello Spanish,

I have tried to learn your example, but i am unable to understand how i will do this via an analogue input method, rather than serial data.

the remote i am working on is Sony RMT-CY3A i have captured its modulation for reference. Hope you can explain. :)

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: SAMSUNG remote control decoder

Post by greentech »

Hello Spanish,

I have tried to learn your example, but i am unable to understand how i will do this via an analogue input method, rather than serial data.

the remote i am working on is Sony RMT-CY3A i have captured its modulation for reference. Hope you can explain. :)
Attachments
IMG_0018.JPG
(77.22 KiB) Downloaded 28206 times

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: SAMSUNG remote control decoder

Post by Spanish_dude »

The only experience I have with IR protocols is this samsung IR remote control.
Try to search on google some info about your remote controls protocol.

Seems like your remote uses this protocol : http://www.sbprojects.com/knowledge/ir/sirc.htm

cheers,

Nicolas

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Sony remote control decoder

Post by greentech »

Please some one help me with Sony Cy3a Remote. I am trying to decode but all goes invain.... :? .

please gimme some :idea:

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: SAMSUNG remote control decoder

Post by greentech »

what i am not getting is:

How to detect the start pulse which is for about 4.2 ms..

and secondly how to store address and command & then how will a detect the whole code all over again.. if i keep pressing the remote button the pulse repeats after about 21ms

i am driving the pic micro at 4Mhz

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: SAMSUNG remote control decoder

Post by Spanish_dude »

Hi,

Look how I have made my decoder, that should be enough to help you ;)

Check your input, if it's low, check if it's low for 4.2 ms, then do the same for the data that's being received. That's it.

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Sony remote control decoder

Post by greentech »

i tried but all invain, i keep on getting different hex values each time if i keep pressing the button.

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: SAMSUNG remote control decoder

Post by Spanish_dude »

From your oscilloscope picture your signal is high, when nothing is received.

Let's assume you're using RB0 as input.

From what you said, the start pulse is a 4.2ms low pulse.
To check if you are receiving some data, you'll need to check the 4.2ms pulse.
So first thing to do is wait until you receive that 4.2ms start pulse.

Code: Select all

char counter = 0; // this is a counter used for the 4.2ms pulse

while(1)
{
    RB_0 = PORTB & 0x01; // read RB0

    if (RB_0 == 0) // if RB0 is low
    {
        delay_us(100); // delay for 100 µs
        counter = counter + 1; // increment counter with 1

        // 100µs * counter is the time the input RB0 is low
        if (counter >= 40) // if the counter is 40 or higher (40 * 100µs = 4ms)
            break; // exit loop
    }
    else
        counter = 0; // else reset counter
}
Once the program exit this loop, you'll be receiving data. Don't forget that after each low pulse you're receiving a high pulse of 600µs (?).
This data needs to be "decoded" the same way I did with the start pulse.

I'll let you try to decode the data.
If you still have problems I'll show you how to do it, but you'll see that it's pretty easy to do !

(Of course we are not using any interrupts here, but you could use one)

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

remote control decoder

Post by greentech »

Billion Thanks for replying brother....Ill give it a try and let you know the latest.

Best Regards.....& may Fate always shine on u.

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Sony IR decoder

Post by greentech »

Finding the start pulse took alot of time, finally i have done it according to your advice. You are good in it.

I am now trying to decode the data but not really getting how to go by 600us pulses..... there is also a 1200us low pulse in the data.

Plz shed some light on this :idea:

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: SAMSUNG remote control decoder

Post by Spanish_dude »

Hi,

I made this little program, I haven't tested it, but I think it should work.
Simulation won't work as I'm using C code.
Attachments
SONY-CY3A.fcf
(10.68 KiB) Downloaded 986 times

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Sony IR decoder

Post by greentech »

Thanks alot brother...

ill try understand it and then get back to u.
:) Million thanks again.....

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Sony Cmy3a emote control decoder

Post by greentech »

Brother, i tried to understand the code which u sent. It is functioning also.. but some times the variables change. Specially there are three buttons when i press then they bring different variable onto the lcd.

1- power button brings up Address =4 command = 21 but this differs.
2- forward button also brings on command and adress.
3- the stop button is also doing the same thing. all other buttons are functioning well..

could it be the problem with my hardware?

i am using sharp infrared receiver with no resistors and capacitors. +ve is hooked up to +5V, -ve is to ground. and tx straight to rb6 input to pic.

please guide.

Best regards.

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: SAMSUNG remote control decoder

Post by Spanish_dude »

Hi,

In this post : http://www.matrixmultimedia.com/mmforum ... red#p13641
The member used a pull-up resistor, so you could try that ?

Also, try to check the signal of the power, forward and stop button. Check if those are changing (I doubt they are).

I can't help more than that, try to play with the program and see if you can get it to work 100%.

User avatar
greentech
Flowcode V4 User
Posts: 158
Joined: Mon Jan 31, 2011 2:11 pm
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: SAMSUNG remote control decoder

Post by greentech »

it works. Thankyou very much for your assistance. I really appreciate it bro. please send me your address i would love to send u some gifts......:)

Post Reply