I've been learning about IR protocols for quite some time now. How to send and receive IR signals. At this point, the only thing remaining is the IR protocol of AC remotes.
Unlike traditional remotes of nearly all electronics devices (say a TV) where only one button's information is sent at the time, In AC remotes all of the parameters are encoded and sent at once. Hence, It can be a little bit tricky to decode the signal from a microcontroller.
In this instructable, I'll Explain how we can easily decode IR protocols of any AC remote. I'll be using my HID IR KEYBOARD to read and decode the IR signals by writing a new program. but you can use nearly any microcontroller you're familiar with as long as it supports External interrupts coupled with a TSOP IR demodulator.
Step 1: Tools Required
- Soldering Station.(eg. THIS)
Although you can use cheaper irons but a good quality soldering station is recommended if you're into electronics.
- Pickit 2.(eg. THIS)
You can also use a PICKIT 3 but then you'll have to use a separate USB-to-UART converter to read the output from the microcontroller.
- An oscilloscope.
Well, I don't have it. but if you have one, it'll make your life a whole lot easier. Definately buy one, if you can afford one.
- A computer.
Step 2: Components Required.
- PIC18F25J50(eg. HERE)
- TSOP IR receiver.(eg. HERE)
- LM1117 3.3v regulator.(eg. HERE)
- 2x220nf capacitors.
- 470 ohm resistor.
- 10k ohm resistor.
These are the components required to make my HID IR keyboard project.. if you have any other pic development board or an arduino, You'll just need the TSOP IR decoder module.
- An AC remote.
The remote that needs to be decoded. I'll be using my Videocon AC's remote. This one doesn't has a display but works similar to other remotes with displays.
Step 3: How It Works (IR Protocol)
Before proceeding, Let's understand some basics.
IR remotes uses an IR led to transmit signal from remote to the receiver by rapidly switching the LED on and off. But many other light sources produce IR light as well. So, to make our signal special, a PWM signal is used at a certain frequency.
Frequencies used in almost all IR remotes are 30khz, 33khz, 36khz, 38khz, 40khz and 56khz.
Most common ones though, are 38khz and 40khz.
The TSOP module demodulates the carrier signal(eg. 38khz) to a more suitable TTL logic of GND and VCC.
The duration of HIGH of LOW logic denotes bit '1' or '0' . The duration varies by every remote protocol.(eg. NEC)
To understand IR protocol in detail, you can refer to THIS document.
Step 4: The Remote.
The remote I'm using belongs to a rather old air conditioner fitted in my room. So it doesn't have any fancy display but it pretty much functions same as any AC remote with a display.
We can change following settings using the remote.
- Power on/off
- Sleep mode on/off
- Turbo mode on/off
- Swing on/off
- Fan speed (Low, Med, High)
- Mode select (Cool, Dry, Fan)
- Temperature (from 16 to 30 degrees celsius)
Step 5: Capturing RAW Samples.
In the image, you can see the RAW samples spitted out by the TSOP ir receiver. the numbers denotes the duration of the burst and the +/- sign denotes the MARK and SPACE of the signal.
here 1 unit denotes 12us (microseconds.)
So, a burst of 80 denotes 960us and so on.
following piece of code captures the data and outputs to the serial monitor of the pickit2. (The IDE is MikroC PRO for PIC)
For some reason, the Instructable editor messes up with the code tag. So, I've just attached the screenshot of the the code please refer to the second image of this step.
I would've attached the whole project folder, but it's a mess right now and is not quite ready yet for what i'm trying to achieve.
Step 6: Observing the RAW Samples and Converting It to a Human Readable Format.
If we closely look at the RAW samples we can easily observe that there are four ranges of burst durations.
The last three values are always +250 -250 +250. Hence, we can safely assume that it's the STOP bit of the burst data. Now, using the following code snippet, we can divide these four burst durations into '-' , '.' and '1'.
Refer to the 3rd image of this step for the code snippet.
You can may have noticed that I ignored the number ~80 burst in the code. that's because every odd placement of the code is insignificant. By printing the _rawprocess[ ] array to the serial monitor, (as you can see in the second image of this step.) We have a much clear picture of the data received. Now by pressing different buttons on the remote we can observe the pattern changes in the data as explained in the next step.
Step 7: Observing Patterns by Comparing Multiple Raw Samples.
By printing just the decoded data we can get a much clear picture of what bits are used to send which data.
The POWER SLEEP and TURBO setting uses just one bit. i.e either '.' or a '1'.
The SWING uses three bits adjacent to each other. which goes as either '...' or '111'.
The Fan and Mode select also uses 3 bits each '1..' '.1.' and '..1'
The Temperature uses four bits which sends value using binary coded bits with an offset of 16 which mean '....' sends the value of 16 degrees celsius while '111.' sends 30 degrees celsius.
Step 8: OUTPUT the Decoded Data to the Serial Monitor.
As you can see in the image i successfully decoded all of the bits sent by the AC remote.
From here on, Those who have experience dealing with ir protocols already knows How to re-encode the signal and start sending them to the AC. If you want to see how that can be done, wait for my next instructable that i'll post in a week or so.
Step 9: Finish.
Thanks for your time.
please leave a comment if you liked the project. or if you may have noticed any mistake.
Have a nice day.