1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

AVR InfraRed Remote code capture project

Discussion in 'AVR' started by eblc1388, Apr 4, 2008.

  1. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    I wanted to use IR for controlling purposes so I need to write some decoding routines.

    I searched for projects on the web that allow me to actually look at the IR waveforms timings. I built several but the results are disappointing. Some how the designer expects everyone to know exactly what to do next and how to capture a real IR signature when one has the hardware built.

    I nearly gave up but then I found the following project by Steve Childress to be very helpful. It was hidden in the project section of the AVRFreaks.net and dated back to year 2006.

    The project name is "Two-way Infra-red Processor (TWIRP)" and you'll need to be a member to download it but anyone can register.

    This implementation sits between the IR detector and PC host serial port. Not only does it logs and shows the timing between each logic level changes it also draw up a nice graph on the PC showing the waveform shapes. This helps to identify the remote codes variety easily.

    I have made minor cosmetic changes to the result display and the following animated GIF shows the operation of the setup, recording a capture from a NEC remote control that I have.

    Besides showing you the timing data, it also decode it into several bytes. It has other added features like assigning user defined key records to received IR signals so one can later play them back as if they are coming from the original IR remote control. I have not tried them out yet.

    Unfortunately, the author did not include a schematic in the project file so it might create difficulties for someone else who wants to build it. I therefore provide my own schematic I "deduced" from the C source code definition of AVR pins. The original design uses a AT90S2313 but I drew it as a Tiny2313 instead because the AT90S2313 is now hard to find.

    The original design uses 10.000MHz crystal which I don't have so I changed it into using 10.240MHz instead. I have also changed the communication baudrate from 19200bps into 56700bps. This would require changing both the AVR firmware and the associate Visual Basic Code so one would be better off starting the project with the original code provided by the author before making any changes.

    You would need the CodeVision AVR compiler too but an evaluation version can be downloaded from the manufacturer's site which does have a 2K code size limit. Perfect for use on Tiny2313 which has only 2K program memory.

    Sorry the project source code and additional information remains the intellectual property of the AvrFreaks.net and Mr. Steve Childress so I would not be distribute them here.

    If you have any questions, you can direct them to Stevech in the Avrfreaks.net forum.
     

    Attached Files:

  2. Papabravo

    Papabravo Well-Known Member

    Joined:
    Mar 9, 2006
    Messages:
    2,889
    Likes:
    25
    Location:
    Michigan, USA (GMT-5)
    I'm curious, did you use the input capture pin on the processor. I've experimented with using input capture on an ATmega128. We use a TFMS-5380 which produces negative edges when carrier is detected. These parts supposedly have a filter in them which will reject other frequencies besides 38 kHz. Works like a champ.
     
  3. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    No. Its just polls the IR input pin in a loop.

    The author use the 16-bit timer1 to generate 38KHz IR carrier instead for sending out signal to target equipment after receiving a command from the HOST.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,331
    Likes:
    653
    Location:
    Derbyshire, UK

    They do have a filter, but it's not particularly narrow, a 38KHz IC will work well outside it's specified frequency with little loss of performance.
     
  6. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    Subsequent to my posting, I have located another huge AVR user site in China in which an user has built the same with a Mega8 and communicate using USB instead.The USB hardware interface is done in the Mega8 using the popular USB firmware from obdev so no other chips are needed. The IR timing capture is done via the capture pin of the Mega8 timer.

    All one need is a Mega8 AVR, a 12MHz crystal, a IR module and a few resistors.

    The PC HOST interface collects the data from USB, graphs it with timing data and allows zoom in and out on the captured waveform. Just learning how one can do that using software is rewarding.

    The kind author "lzf713" has provided all the information like source code and HEX for AVR firmware, EXE and C++ builder source code for HOST software for free downloading. Just look for the file "ourdev_196057.rar" near the top of the webpage shown in the link below.

    Projects like this are a tremendous gift to every hobbyist because it provide insights into how different parts of an useful application are being linked together. It is the process that one learned during the making of the project.

    Thanks lzf713 again for sharing.

    Link for original article & software
     

    Attached Files:

    Last edited: Apr 5, 2008
  7. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    I have built the AVRUSB_IR project above using a Mega8 with a 12MHz crystal.

    The image is the result of a capture using my RC5 remote.
     

    Attached Files:

  8. crust

    crust New Member

    Joined:
    Sep 30, 2003
    Messages:
    728
    Likes:
    3
    My PS3 IR to bluetooth box does kind of what you want. I am using the input capture circuit though I did consider polling early on. The input capture fits well with the event driven software model.
     
  9. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,331
    Likes:
    653
    Location:
    Derbyshire, UK
    That's looking pretty good!.

    I did something similar years ago (to decode Sharp remotes) using a 16MHz 386SX DOS laptop with an IR receiver connected to the parallel port, and a program written using Turbo Pascal 6.0 :D

    It wasn't as pretty as that though.
     
  10. crust

    crust New Member

    Joined:
    Sep 30, 2003
    Messages:
    728
    Likes:
    3
    Actually if you are still going to pursue this, I might have a PCB and some parts for exactly this. It would have the IR decoder, ATTiny2313 AVR Micro, 10 pin ISP header, LED, etc. It also has room for a CPLD but I don't think you would need that part. The PCB was a prototype for another project, but I have a couple that are not populated. The PCB fits into a hammond enclosure (can't recall exactly which).
     
  11. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    Hi Crust,

    Thanks for the PCB offer but these projects are just fun exercises for me. I have the Mega8 mounted on the breadboard and I will very soon move on to another project.

    The great fun is in the trying, and modifying the way things work to my heart desire and see how the resultant display behave.

    I have always wondering how one can display something on the PC screen that resemble an oscilloscope trace, with zoom and pan adjustment, and these examples do tell me a lot on how it is done in VisualBasic and C++.
     
  12. crust

    crust New Member

    Joined:
    Sep 30, 2003
    Messages:
    728
    Likes:
    3
    If you look around there are several people that have generated the appropriate sync signals for a monitor from a micro. I can't recall if it was a vga monitor or a TV. I know I have seen it done for LCDs as well, but the refresh will not be as fast.
     
  13. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    Sorry about my ambiguous wording.

    I meant when one have gotten the set of timing data, between logic transitions, one would need to display them nicely on a chart or graph using software.

    Some design even allows one to place cursors and measure the timing or frequency between cursors.
     
  14. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,331
    Likes:
    653
    Location:
    Derbyshire, UK
    Look on the PICList, there's an audio spectrum analyser using FFT and directly driving a VGA monitor - using a 17C series PIC if I recall correctly?.

    I've always meant to see about converting it for an 18F series PIC - but, like most things, I've never got round to it yet.
     
  15. mramos1

    mramos1 Active Member

    Joined:
    Sep 15, 2005
    Messages:
    2,403
    Likes:
    9
    Location:
    Boynton Beach, Florida USA
    eblc1388, can you post the source code for the Mega8 version. I went to get it and saw it was not in English. I pulled the schematic and I have the parts and a dragon programmer.

    Like to get the Mega8 code and the PC code if possible, mainly the mega8 code to play with a USB interface.

    Thanks
     
  16. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    Sorry for the later reply. The files total size comes to ~1.5MB and this forum failed to accept such large file size, although the file size limit is some 9.8MB shown in the upload window. So I break them up into two.

    As requested, the zip file(s) attached. Inside content are:

    1. M8 C source file as an AVR Studio project
    2. M8 HEX file for direct download to M8 via ISP.
    3. Host EXE file for Windows
    4. Host C++ Source files for BCB
    5. Schematic(with minor changes & two additional LEDs)
    6. Usbasp Windows Driver( for first connection to USB port)
    7. Readme.txt file

    Please report back if outcome is successful. Thanks
     

    Attached Files:

  17. yanctl

    yanctl New Member

    Joined:
    Oct 5, 2009
    Messages:
    1
    Likes:
    0
    zip files

    Hi eblc1388,

    I've downloaded the 2 zipped files, attached to your last post, however, for some unknown reaasons, I'm not able to unzip them.

    Appreciate if you could kindly email them to me.

    my email address is yanctl@yahoo.com.sg

    Thank you
     
  18. RRRE

    RRRE New Member

    Joined:
    Nov 17, 2012
    Messages:
    1
    Likes:
    0
    Hi Guys,

    My Name is RRRE. I have already built this project but it did not work may be by wrong fuse bytes. Pls help
     

Share This Page