[?] Subscribe To This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Add to Newsgator
Subscribe with Bloglines


Become a subscriber (Free)

Join 29,000 other subscribers to receive subscriber sale discounts and other free resources.
:
:
Don't worry -- your e-mail address is totally secure. I promise to use it only to send you MicroZine.
Custom Search

Sign up for MicroZine:
''The'' Microcontroller Newsletter


Enter your first Name and primary email address in the form below:

And receive absolutely FREE a full project for:


"Measuring Analogue Voltages
Without An ADC"

(Using only one pin).

Instant Download:
You Can
Get It Right Now

Warning: This project could be Removed
at any time.  

It will NOT be
available indefinitely SO

To avoid
disappointment get it:

Now



:
:
Don't worry -- your e-mail address is totally secure. I promise to use it only to send you MicroZine
Remember this is a project with full description and fully debugged C Source code - and it's not available from the main website.

You can only get it through this newsletter.


To get exclusive access Enter your first name Name and primary email address Now in the form above.:

But wait !

There's more...

You'll receive more
free and exclusive reports as well as site information and site product updates.

Scroll up to the form above and sign up NOW.  Don't forget it's FREE and if you don't like it you can unsubscribe at any time.

Click Here Now to use the form above to get your Valuable information absolutely free.



Social Bookmarking
Click & Add:
add to BlinkBlink
add to Del.icio.usDel.icio.us
add to DiggDigg
add to FurlFurl
add to GoogleGoogle
add to SimpySimpy
add to SpurlSpurl
Bookmark at TechnoratiTechnorati
add to YahooY! MyWeb
Readers comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's

SUPERB and FANTASTIC."


- Ranish Pottath


"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan

bursach<at>gmail.com

Learn PIC C Now
Wondering how to program your next project using C and need a great start?


"Awesome site,
very, very easy and nice
to navigate!"


- Matt
matt_tr<at>
wolf359.cjb.net


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."


- Dave

de_scott<at>bellsouth.net

Learn Microcontrollers
"Interested in
Microcontrollers?"


Sign up for The
Free 7 day guide:

FREE GUIDE : CLICK HERE

"Your site is a great
and perfect work.
congratulations."


- Suresh

integratredinfosys<at>
yahoo.com

"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.
Regards."


- Anon





Universal Serial Infrared Receiver.

You can use this Universal Infrared Receiver (UIR) project to control your PC:
  •  Starting Windows programs,
  •  setting the Windows volume control,
  •  even moving the mouse around the screen!
All at the touch of a button - with your TV remote control in fact!

Infrared receiver block diagram

It uses a PIC microcontroller to characterize the demodulated infrared signal and then transmit it as a serial data stream to the PC.  

Software running on the PC recognizes data stream for each key press (in fact the PC software has to learn the data stream for each key press) and activates the program (or event) that you specify.  Since the software can learn each key press you can use it with any remote control  e.g. TV, video, DVD, satellite etc.  

It's even good with multiple remotes so you could use any one of a set of remotes to control the PC

Specification for Serial Infrared receiver project.

Baud Rate 57600 Baud
Clock Internal 8Mhz 
Remove Control type Any (Point any control at it and let the PC software learn its codes).

Note: Some remote controls need two key presses (if you press the same key) as they output an inverted key sequence for a repeated key.  If you press a different key then it works as a normal remote.

Serial Infrared receiver : Project Details

Serial Infrared Receiver Project
Compiler Mikrolectronika C compiler V5.0.0.3 Free!
Target 16F88 (retargetable to other PICs that have a built in USART).
Software level Easy.
Software notes No special notes.
Hardware level Easy.
Hardware notes No special notes.
Project version 1.00 Initial Release
Project files Enter your details to get the Download Link
and get the microcontroller newsletter:


(Note: Your email is safe it will never be sold or rented).
You will get All the C source code and hex file.

Note: Check your email for the project code download link.
  


Learn to program in C

in easy steps.

Essential & EASY:

PIC C Programming Course:

CLICK HERE

How the Serial Infrared receiver works

This project uses a standard Infrared detector module (one of those 3 pin devices) as the main input.

It's not worth making your own circuit up as it will not match the performance of a three pin demodulator module.

I had a go using some circuits I found on the web and but these use a PIN diode and a high impedance amplifier e.g. LM3140 - but the circuits are actually light meters and saturate when a light shines on them  
(even desk lamp) - so they become insensitive to the IR light - the PIN diode reacts to any light source.  You can get some use out of them up to about six feet but a lot of engineering has gone into the three pin modules so it really is worth using them and they are very cheap.

Inside the module is a PIN diode, AGC circuit, band pass filter, control logic and output detector.  The datasheet specifies use from 15m (45ft) up to possibly 30m (90ft) max!. These are very good detectors that are also insensitive to sunlight (has a physical filter over the PIN diode and the electronic bandpass filter).

Serial Infrared receiver 

How the Serial Infrared receiver works.

This project took longer than it should have and I have ended up with a far smaller source code than my initial attempts!  First off I used the capture facility in the CCP and the Timer1 timer to accurately measure each period of high and low decoded IR.  This turned out to be too accurate!

IR signal codes decoding accuracy

You don't need accuracy in this project - IR codes are designed not to need accurate measurement and if you attempt it slight variations in the edge positions or measuring accuracy cause the output numbers to change.  Since the decoder software in the PC relies on a repeatable data stream (with slight variation) this method does not work.

IR signals are designed so that you can sample them but this requires that you know the code sequence (or encoding e.g. RC5) in advance so that you can time from the start sequence to the exact middle of a bit position.

Since this project allows you to use any remote control unit, the encoding sequence can not be known in advance, so the the solution is to sample the remote control sequence at a high frequency.  

The problem is that if you start decoding from the first rising edge then errors accumulate due to slight variations in the remote control output (or the sampling edge occurs at the same time as an input transition) causing a random data stream output which can not reliably be decoded by the PC software.

IR decode solution

The solution is to sample the input data starting from each rising and falling edge where a bit measurement period counter (period counter) is reset.  At each sample point (here it is about 50us) the period counter is incremented.  This gives a number that represents the period of each high or low part of the signal. 

The 50us sample period is about ten times the expected signal period (IR codes generally use 500us minimum period) so this gives a good period measurement.

Note that the period counter is 8 bits long so that for long input sequences (high or low) the counter wraps around - this does not matter since the period counter will always produce the same value for the same input sequence and this is what the PC decoder software is looking for.

RS232 Output

At every signal transition the period counter value is sent to the RS232 interface so the value represents the number of 50us periods in the previous frame.  The value sent is a raw binary number and you can not view it on a terminal such as hyperterminal as you won't get a readable value.

To stop the sequence from generating RS232 data forever the counter value is monitored until it goes above 200. If at the same time the value of the input is zero then output stops and control is returned to waiting for the next interrupt i.e. the next remote control key press.

Note: The internal USART takes about 30us to set up and it then goes off and transmits the byte by itself which at 57600 baud takes about 170us so there is plenty of time before the next transmission (500us IR code period).  You could use a lower baud rate e.g 38400 which would still fit.  

If you used a baud rate such as 9600 then a byte would take ~1ms to transmit which would mean lost period data - it probably works as you would still get an indication of code periods but may not always work.

PC Software

The PC software used is PC Remote Control.  As it does not require the use of the RX line on the USART.  

It is better for experimentation as it lets you generate TX data only and it does not check whether the microcontroller is active by querying the microcontroller (generating data to the Rx port of the microcontroller) i.e. you only have to generate TX data and not worry about RX data so it's  easier.  Some control programs won't proceed unless the microcontroller gives the correct response.

You can find it here.

Testing

I have tested the infrared receiver and PC Remote Control with the following remotes:

  • JVC
  • Thomson
  • Philips
  • Samsung
  • Grundig
  • Medion
These all worked fine - some you have to press the button twice as the code alternated for the same key.  It expect it to work with just about any remote control as these represent a wide range of differing encoding schemes.

Serial Infrared receiver Hardware

Serial infrared remote receiver schematics.
(click to open pdf)

Infrared receiver remote receiver schematics


The universal infrared receiver uses an IR decoder module (Note that there is no standard pinout and you have to check your version's pinout using its data sheet).

There is nothing difficult about the circuit and it just consists of a PIC micro, an ICSP interface and an RS232 level translator.

Serial Infrared receiver Software

The software is contained in two files:

Infrared Receiver Source Files

16F88-infrared-decoder.c
bit.h

bit.h contains compiler independent bit manipulation macros.

Infrared Receiver Project Files

16F88_Infrared_decoder.ppc

Infrared Receiver Output files:

16F88_Infrared_decoder.hex

For a tutorial on compiling these files click here.

You can recompile the serial Infrared receiver files to examine the operation of the code (using the built in simulator) or change the source code. The hex file is contained within the download.

You can program the PIC in circuit through the ICSP connector.

16F877A-Infrared-decoder.c

The only use for main( ) is to initialize the ports and interrupts - it then enters an infinite loop waiting for an interrupt.

Input pin RB0 is used as an interrupt source and then polled.  An interrupt for RB0 is setup to trigger when a rising edge occurs (probably should be falling edge as the decoded output is inverted - but it works as is!)

When the interrupt occurs the routine sample_bits is called  - Note this is within the interrupt so sample_bits becomes part of the interrupt routine itself.

sample_bits() takes control and polls the RB0 input as described previously.  It also returns control to the interrupt routine at an appropriate point; waiting for the next remote control key press.


Jump from PIC Infrared Receiver to
Best Microcontroller Projects Home Page.




Google

Privacy Policy | Contact | About Me

Site Map |Terms of Use | Links
  Best Microcontroller projects.










<-- --> <-- -->