IR software & hardware basics


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Since (according to your 1st post) you want to end up with some sort of IR communication, I'd suggest getting rid of that phototransistor and getting an IR receiver module as dhouston suggested earlier.

    If you do a search on 'GP1U' at www.digikey.com, you'll get a bunch of hits for various IR detectors.

    The GP1UM261RK (which just happens to be the one that I use for a lot of my projects and it works very well) is sensitive to IR modulated at 38Khz.

    At the transmitter end, I use a 555 timer tuned to 38Khz @ 50% duty cycle (actually nowadays I'm using a 10F200 for the same function and it's more accurate). I run the output of that to an input of an AND gate, the other input of that same AND gate goes to a serial output pin on the PIC. The output of the AND gate (which is the 38Khz carrier, switched on and off by the PIC), goes to the IR LED unit (which is usually either one IR LED or a few IR LEDs switched by a MOSFET).

    At the receiver end, I have the above mentioned IR detector unit hooked up. The output has a 1K pullup on it, and is connected to a PIC pin used for serial input.

    According to the datasheets, this detector takes about 8 cycles of 38Khz to lock on (.21ms), so baud rate is limited by the carrier frequency. In the very best of circumstances, the highest baud rate you'll achieve is 1200 baud. I use 300 baud when I need to 'move' data, and usually stick with something around 100 baud if I'm just switching something on or off.

    This is the code I use in my MP3 player that I built. I used an old Pioneer sound system remote control to run it:
    Code:
    'IR sensor - Digikey Part # 425-1147-ND, GP1UM281QK, 38KHz,
    'side mount, 2 22uF tantalum cap's paralleled across 
    'power/ground, 47ohm resistor in series between power source and power pin
    'PIC18F4620 @ 40Mhz, pulsin will change according to oscillator frequency
    
    remotecheck:
    irdata1 = 0 : pulsin irbit , 0 , temp1w
    if ( temp1w > 1200 ) then
    	if ( temp1w < 3300 ) then      'header pulse is about 2.2ms, check for
                                        'a pulse a bit longer than a binary 1, but
                                        'shorter than 1 1/2 header pulses
    getnextpulse1:
    		for temp1 = 0 to 11
                         pulsin irbit , 0 , temp1w : orbits = 0
                         if temp1w < 275 then orbits = 1
    		     if temp1w > 1650 then orbits = 1
    		     if orbits = 1 then
    				goto remotecheck
    		     else
    				if temp1w < 825 then irdata1.0[temp1] = 0
                           'Sony IR Remote Signals - Unit, T=550us,
                           'Header = 4T Pulse followed by 1T space,
                           'Binary 0 = 1T Pulse followed by 1T space
                           'Binary 1 = 2T Pulse followed by 1T space
    				if temp1w > 825 then irdata1.0[temp1] = 1
    		     endif
    		next temp1
    'irdata1 has any data received and decoded by ir detector, 12 bit sony code
    	endif
    endif

  2. #2
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default

    Thanks a lot skimask,

    I'm gonna try an IR module.

    I've seen on rentron's web site that he used a NAND.

    Going to check this out - didn't read this carefully enough.

    May I ask you over which distance you got good & reliable results?

    Dave, just saw your post. Yup, going for a module!!
    Roger

  3. #3
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post
    May I ask you over which distance you got good & reliable results?
    The receiver filters out ambient IR from sunlight, incandescent lights, fluorescent lights, etc. If it's narrow-band it only reacts to IR that is modulated at the carrier frequency it is designed for. It's also designed for a specific wavelength (your phototransistor is 900nM while most consumer IR uses 940nM). Your test setup is about as bad as one could imagine.

    A few years back I designed a CF card that fit an iPAQ and acted as a Consumer IR transmitter. With a single IR emitter and 3.3V it regularly got 30 meters range but that's about 5 times what I expected.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post
    Thanks a lot skimask, I'm gonna try an IR module.
    I've seen on rentron's web site that he used a NAND. Going to check this out - didn't read this carefully enough. May I ask you over which distance you got good & reliable results? Dave, just saw your post. Yup, going for a module!!
    Maybe I did use a NAND gate, don't remember at the moment...
    Some people use gates, some people actually switch the PICs internal timer that generates the 38Khz on and off really fast.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    And there's those which build their own serial IR routine... or modify the existing SEROUT/DEBUG etc etc. To me the AND gate is sure an option... but not needed when you can do everything in software... with some head-banging for sure.

    I remind that Darrel already did something like that here modifying the SERIAL macro in the PBP files, i will try to find it.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    well, it was for XOUT, but there's an interesting concept.
    http://www.picbasic.co.uk/forum/show...ignal+stronger
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Benefits of hardware usart over software?
    By sccoupe in forum Serial
    Replies: 2
    Last Post: - 19th March 2009, 01:16
  2. Hardware or Software
    By bmagistro in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th March 2009, 23:22
  3. hardware counting while software runs
    By Archangel in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 2nd October 2006, 03:26
  4. Programming software for PicAll Hardware
    By bcd in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 16th July 2006, 08:15
  5. how to get pic to pic communication
    By kinsiro in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th August 2005, 17:12

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts