======================INFRARED====================== infrared remote controls communicate using an identical carrier scheme. At transmitter, a 38Khz or 40Khz square wave is gated by a logic signal of no more than about 1Kbps. signal is fed to one or more infrared emitters. most efficient pulse duty cycle is 50%. The reciever circuit consists of a photodiode, a preamplifier, and a demodulator circuit. preamplifier contains a bandpass filter limits sensitivity to about +/- 2Khz, near centre . An AGC circuit adjusts incoming level to demodulator, which explains presence of long leading pulse in many of protocols. This allows reciever to stabilize its AGC circuit, prior to reception of bitstream. output of reciever is a binary bitstream, like to original modulation signal at transmitter It is often an open collector pull-down. signal is active low, so that "ones" in terms of carrier signal appear as "zeros" at demodulator. ---------------------------------------------------------------------------- Protocol 1 code consists of two main types of packet. first is a normal packet which indicates that a certain key has been pressed. second is sent repeatedly while a key is held down. This repeat packet is devoid of information, consisting only of an AGC pulse and one stop bit. normal packet consists of an AGC pulse, a pause, and 50 consecutive information bits. Each one of these 50 bits is made up of two parts. first part conveys binary information. second part is a stop bit, always a zero. It is important when you are dealing with this protocol, that some equipment sends say 48 or 49. best policy is to treat these as incoming zeroes. It is possible that these bits somehow represent fewer bits through some unknown encoding scheme, for example, bit position modulation. Timing Summary: Single Keypress packet: Signal Duration Polarity ------ -------- -------- AGC Pulse 9.15ms 1 Pause 4.33ms 0 data bit 750us transmitted data stop bit 375us 0 "held down" packet: Signal Duration Polarity ------ -------- -------- AGC Pulse 9.15ms 1 Pause 2.10ms 0 stop databit 750us 1 time till next packet 38.6ms 0 ****************************************** ---------------------------------------------------------------------------- Protocol 2 Sony specific protocol, transmitting 12 information bits comprising a 5-bit device ID followed by a 7-bit command code. These bits are transmitted least significant bits first. an AGC pulse of 2.4 ms. is first transmitted, followed immediately by 12 databits. Each databit consists of 600 us. of logic zero, followed by either 600 us. and 1200 us. of logic one,representing "0" and "1" databit respectively total packet length is fixed at 45 ms. Further information is available in Scott Coleman's file "zapper.txt". Signal Duration Polarity ------ -------- -------- AGC Pulse 9.15ms 1 databit = 0 0.6ms 0 0.6ms 1 databit = 1 0.6ms 0 1.2ms 1 total length 45.0ms ****************************************** ---------------------------------------------------------------------------- Protocol 3 "Japanese-Format."(JF) (Toshiba) and (Pioneer) both use same format, while my TV (RCA) uses a completely different format. JF allows for 256 different devices to be controlled, so it is possible that each manufacture could have been allocated a range of numbers. Then again it might just be coincidence. A JF consists of 3 parts. first part is preamble. 8 ms wide pulse of carrier followed by 4ms of no carrier ( carrier is an IR light beam modulated at 40 KHz. RCA TV uses about a 36 KHz carrier. second part of code is 16 bits of data. first 8 bits are what I call Device Code(DC), followed 8 bits are logical not of preceeding 8 bits(DC). (This apparently is used as a checksum to insure data validity. and protect against random noise.) third part is 16 more bits of data, first 8 being what I call Function Code (FC). then followed by its logical NOT as was DC. provides ability to control up to 256 different devices, each having up to 256 functions. most functions are controlled with a single JF frame. The timing of data is as follows: Each bit cell is proceeded by IR pulse about (600us). then followed by a no-carrier period .4ms or 1.2ms long. A zero is sent if off period is .4ms, one is sent if off period is 1.2 ms. a 0 is bit cell who's total time is about 1 ms, a 1 is a bit cell who's total time is about 2 ms, i.e. pulse period modulation. The DC and FC are sent LSB first. So in time it looks like: DC LSB->MSB, NOT-DC LSB-MSB , FC LSB-MSB , NOT-FC LSB-MSB The DCs I know are: (all numbers in hex) A5 Pioneer amp A4 Pioneer tuner A2 Pioneer CD A1 Pioneer cassette deck. (I've wondered what A3 might be, open reel tape deck perhaps) 44 Toshiba SV-771 VCR The FCs share great commonalty across 8] ---------------------------------------------------------------------------- Minimizing SUN's noise in IR reception A 'baffle' is a perforated disk or disks spaced inside your 'shade tube'. The idea is to trap all reflections, leaving only light coming in on exact axis of tube to strike IR Detector. __________________________________ | | | | DET <- IR LIGHT | | | | ---------------------------------- ^Baff ^Baff ^Baff Off-axis light, 'noise', will be caught by baffles and dissipated through reflection between baffles. Paint inside of your tube black ... in fact, check into what paints/coatings are 'black' to IR wavelenghts. Just because a paint LOOKS black does not mean it won't reflect IR. Check into an astronomy or optics group to get formula for ideal spacing of baffles and how big a hole should be in them. Getting this right will improve your system performance. ---------------------------------------------------------------------------- Decoding IR Remote Controls The origin of this posting was question what to do with an old TV. I suggested to use infrared remote control as an input keyboard for a microcontroller board and mentioned a piece of code I had written for 8052 microcontroller. I was asked by some people to share my information about remote controls, so here it is: There are at least two international standards which are used by remote controls to encode commands, RC5 and RECS 80 code. The RECS 80 code uses pulse length modulation. Each bit to be transmitted is encoded by a high level of duration T followed by a low level of duration 2T representing a logical '0' or 3T representing a logical '1'. T 2T T 3T T 2T _ _ _ | | | | | | _| |__| |___| |__ 0 1 0 Notice that a '1' takes more time to be transmitted than a '0'. The RC 5 code instead has a uniform duration of all bits. A transition in middle of time interval assigned to each bit encodes logical value. A '0' is encoded by a high to low transition and a '1' by a low to high transition. Therefore we need additional transitions at beginning of each bit to set proper start level if a series of equal bits is sent. We don't need this additional transition if next bit has a different value. This is also called a 'biphase' code. |1.Bit|2.Bit|3.Bit|4.Bit| __ __ __ __ | | | | | | |__| |_____| |__| 0 0 1 1 Instead of being fed direct into IR emitter, most remote controls modulate a 20-30 kHz carrier with this signal. A logic one is represented by a burst of oscillations. ______/\/\/\/\_______/\/\/\/\________ 0 1 0 1 0 The reason is, that you can use a filter tuned to carrier frequency to distinguish signal from noise in ambient light. Fluorescent lamps are main source of such noise. Photodiodes behind an optical filter which transmits infrared light but blocks visible light are used as detectors. The signal from photodiode is fed through a filter tuned to carrier fequency and then amplified. The amplified signal is demodulated just like carrier is demodulated in any AM radio receiver. + | _|_ photodiode /_\ demodulator | |\ _|_ ____| \_____| |__ __|\|___ __L and C form a | | | / | | | |/| | circuit resonant | / |/ _|_ | out to the carrier === \ amplifier /_\ === |C / L | | |___|_________________|________|____ It can be a lot of pain to design a sensitive receiver that does'nt start to oscillate. It is also necessary to have some automatic gain control to avoid overload of amplifier at close distance to emitter. It is easier to use some integrated circuit that does all of job. The best i have ever seen (and used) is SFH505A manufactured by SIEMENS (no, I don't work for this company). It looks like one of this three legged voltage regulators and uses a single 5V supply. It incorporates an optical filter, photodiode, a filter tuned to about 30 kHz , amplifier with automatic gain control and demodulator. If you don't know which code your remote control is transmitting you can identify it by viewing output of your receiver with an oscilloscope. The RECS 80 code uses high pulses of uniform length while low pulses differ in length. If there are high and low pulses of two different lengths it might be RC5 code. Note that your receiver may invert levels. How are commands like volume control or channel selction encoded? In case of RC5 code there is an international standard. Every command is encoded by 14 bits. The first two bits S are startbits to allow receiver to adjust automatic gain control and to synchronize. Next a bit T follows, that toggles with every new keystroke. Next is address A of device which shall respond to command. At last command itself follows. | S | S | T | A4 | A3 | A2 | A1 | A0 | C5 | C4 | C3 | C2 | C1 | C0 | Some important addresses and commands: Address: Device: Command: 0 TV1 0...9 Numbers 0...9 (channel select) 1 TV2 12 Standby 5 VCR1 16 Master Volume + 6 VCR2 17 Master Volume - 17 Tuner 18 Brightness + 18 Audio Tape 19 Brightness - 20 CD Player 50 Fast rewind 52 Fast run forward 53 Play 54 Stop 55 Recording There are integrated decoder circuits which have inputs to select device address and parallel outputs activated by commands. Since this is comp. robotics devices you wish to control will have a microcontroller on board which can do all decoding. Here is an input routine I have written for 8052 microcontroller family to receive RC5 codes. My cousin has written a similar routine for RECS80 code which i will try to make available also. Perhaps we can start a collection of such routines and archive them somewhere. ---------==========----------==========---------=========--------- ; Interrupt Driven Receiving Routine for RC5 code ; written by Juergen Putzger (juergen.putzger@physik.uni-regensburg.de) ; Address: Device: Command: 0 TV1 0...9 Numbers 0...9 (channel select) 1 TV2 12 Standby 5 VCR1 16 Master Volume + 6 VCR2 17 Master Volume - 17 Tuner 18 Brightness + 18 Audio Tape 19 Brightness - 20 CD Player 50 Fast rewind 52 Fast run forward 53 Play 54 Stop 55 Recording ---------==========----------==========---------=========--------- $MOD52 INPUT EQU P3.2 ; Port3,Bit2 is used as input. The demodulated signal ; with active low level is connected to this pin LF EQU 0AH ; Linefeed CR EQU 0DH ; Carriage return SPC EQU 20H ; Space RB0 EQU 000H ; Select Register Bank 0 RB1 EQU 008H ; Select Register Bank 1 ...poke to PSW to use DSEG ; This is internal data memory ORG 20H ; Bit adressable memory FLAGS: DS 1 CONTROL BIT FLAGS.0 ; toggles with every new keystroke NEW BIT FLAGS.1 ; Bit set when a new command has been received COMMAND: DS 1 ; Received command byte SUBAD: DS 1 ; Device subaddress BUFFER: DS 30 ; Buffer to store length of transmitted pulses STACK: DS 1 ; Stack begins here CSEG ; Code begins here ---------------------------------------------------------------------------- Universal Remote Control set remote to two or three digit code typical for a sony below for hex 04 low level means light form IR light with key held down repeat 45ms .5ms high by .7ms low 1.3ms low .5ms .7m 1.3ms _______ _ _ _ | _ _ | _ _ _ _ _ _ _ ____ | 2.5ms | | | | | |V| | | |V | | | | | | | | | | | | | | | |_________| |_| |_| |_| |_| |__| |_| |_| |__| |_| |_| |_| |_| | 0 | 0 | 0 | 0 | 1 | 0 | 0 | | 0 | 0 | 0 | 0 | |<-Leader>|<------- Data_Bits--------->|<------Trailer----->| ___ ______________________ ___ | ||||||||||||| | ||||||||||||| |_||||||||||||| |_||||||||||||| |<--18ms------>|<-------27ms-------->| ---------------------------------------------------------------------------- infrared remote controls communicate using an identical carrier scheme. At the transmitter, a 38Khz or 40Khz square wave is gated by a logic signal of no more than about 1Kbps. The resulting signal is fed to one or more infrared emitters. The most efficient pulse duty cycle is 50%. The reciever circuit consists of a photodiode, a preamplifier, and a demodulator circuit. This combination is commercially available as the Sharp GP51UX, and IS1u60x. The preamplifier contains a bandpass filter which limits the reciever's sensitivity to about +/- 2Khz, near the centre frequency. An AGC circuit adjusts the incoming level to the demodulator, which explains the presence of a long leading pulse in many of the protocols. This allows the reciever to stabilize its AGC circuit, prior to the reception of the bitstream. The output of the reciever is a binary bitstream, corresponding to the original modulation signal at the transmitter. It is often an open collector pull-down. Note that this signal is active low, so that "ones" in terms of the carrier signal appear as "zeros" at the demodulator. ****************************************** Conventions: 1) The presence of IR modulation is referred to throughout this document as a binary "one", and its absence, a "zero". This is to avoid confusion, should future receivers adopt a non-inverting output. ****************************************** Index: 1. A common protocol 2. Sony SIRCS 3. "JF" - Japanese format 4. Denon format ****************************************** Protocol 1 ---------- Attributed to: Ken Willmott (yku01468@human.yorku.ca) Description: This code consists of two main types of packet. The first is a normal packet which indicates that a certain key has been pressed. The second is sent repeatedly while a key is held down. This repeat packet is devoid of information, consisting only of an AGC pulse and one stop bit. The normal packet consists of an AGC pulse, a pause, and 50 consecutive information bits. Each one of these 50 bits is made up of two parts. The first part conveys the binary information. The second part is a stop bit, always a zero. It is important to realize when you are dealing with this protocol, that some equipment sends a few less than 50 bits, say 48 or 49. The best policy is to treat these as incoming zeroes. It is possible that these bits somehow represent fewer bits through some unknown encoding scheme, for example, bit position modulation. Timing Summary: --------------- Single Keypress packet: Signal Duration Polarity ------ -------- -------- AGC Pulse 9.15ms 1 Pause 4.33ms 0 data bit 750us transmitted data stop bit 375us 0 "held down" packet: Signal Duration Polarity ------ -------- -------- AGC Pulse 9.15ms 1 Pause 2.10ms 0 stop databit 750us 1 time till next packet 38.6ms 0 ****************************************** Protocol 2 ---------- Attributed to: Scott Coleman (coleman@f69.n233.z1.fidonet.org) Description: This is a Sony specific protocol, transmitting 12 information bits comprising a 5-bit device ID followed by a 7-bit command code. These bits are transmitted least significant bits first. In this scheme, an AGC pulse of 2.4 ms. is first transmitted, followed immediately by the 12 databits. Each databit consists of 600 us. of logic zero, followed by either 600 us. and 1200 us. of logic one, representing a "0" and a "1" databit respectively. The total packet length is fixed at 45 ms. Further information is available in Scott Coleman's file "zapper.txt". Signal Duration Polarity ------ -------- -------- AGC Pulse 9.15ms 1 databit = 0 0.6ms 0 0.6ms 1 databit = 1 0.6ms 0 1.2ms 1 total length 45.0ms ****************************************** Protocol 3 ---------- Attributed to: bbb@kuhub.cc.ukans.edu (Brett Bennett) Description: I can tell you about what I call the "Japanese-Format."(JF) I call it this because my VCR (Toshiba) and my Stereo (Pioneer) both use the same format, while my TV (RCA) uses a completely different format. It would be interesting to see if other Japanese manufactures are using same format as well. As I'll explain in a moment, the JF allows for 256 different devices to be controlled, so it is possible that each manufacture could have been allocated a range of numbers. Then again it might just be coincidence. A picture would really help here, but I'm not up to trying to draw an ASCII graphic. The JF consists of 3 parts. The first part is what I'll call the preamble. It is a 8 ms wide pulse of the carrier followed by 4 ms of no carrier. ( In case you don't already know the carrier is an IR light beam modulated at 40 KHz. My JF equipment uses 40 KHz , while my RCA TV uses about a 36 KHz carrier. This made my IR controller that I built more complicated because the difference was enough that I couldn't use as single time base. More on the controller later.) The second part of the code is 16 bits of data. The first 8 bits are what I call the Device Code(DC),followed 8 bits that are the logical not of the preceeding 8 bits(DC). (This apparently is used as a checksum to insure data validity. and protect against random noise.) The third part is 16 more bits of data, the first 8 being what I call the Function Code (FC). This FC is then followed by its logical NOT as was the DC. This provides the ability to control up to 256 different devices, each having up to 256 functions. There appear to even be some special sequences, like for my CD deck, which consists of two JF frames back to back that cause special functions to occur. In general however, most functions are controlled with a single JF frame. The timing of the data is as follows: Each bit cell is proceeded by an IR pulse that is about .6 ms long (600us). It is then followed by a no-carrier period that is ether .4ms long or 1.2ms long. A zero is sent if the off period is .4ms, and one is sent if the off period is 1.2 ms. Another way of thinking about it is, a 0 is bit cell who's total time is about 1 ms, and a 1 is a bit cell who's total time is about 2 ms, i.e. pulse period modulation. The DC and FC are sent LSB first. So in time it looks like: DC LSB->MSB, NOT-DC LSB-MSB , FC LSB-MSB , NOT-FC LSB-MSB The DCs I know are: (all numbers in hex) A5 Pioneer amp A4 Pioneer tuner A2 Pioneer CD A1 Pioneer cassette deck. (I've wondered what A3 might be, open reel tape deck perhaps) 44 Toshiba SV-771 VCR The FCs share great commonalty across 8] ===================================================================== Date : 951003 Author: David Novick E-mail: dkn@cimar.me.ufl.edu --------------------------------------------------------------------- Stamp model : BS1-IC Code available: YES Filename : N/A URL : http://www.me.ufl.edu/~dkn --------------------------------------------------------------------- Description : Using two stamps, a robot with six legs (2 degrees of freedom each) was able to walk and turn (at this stage, not very gracefully). ===================================================================== Title : EXPBOT Robot controlled by Stamp [# 009] ===================================================================== Date : 951009 Author: Marvin Green E-mail: ma END ---------------------------------------------------------------------------- 500_mW/cm^2 = 500_mW/sr@ 1cm sr =sterradians Radian_Sensitive_Area_mm^2 7_mm^2 \ | / |\ Max_power_mW _____ \ | / | \ ___\ | | | ___ LED ___ \ | ___ > 8.75_mW _|_ / | Max_Idiode / | \ \| / ^ \ | 4.4_mA / | \ /_\ / V <---20mm---> |_____| Max_power_mW/sr Spect_Sensitive_uA/uW 500_mW/sr 0.5_uA/uW Max_power_mW = 500_mW/sr*(7mm^2/(20m)^2) Radian_Sensitive_Area_mm^2 \ | / |\ Min_power_mW _____ \ | / | \ ___\ | | | ___ LED ___ \ | ___ > 0.04_uW _|_ / | Min_Idiode / | \ \| / ^ \ | 0.14_uA / | \ 7_mm^2 /_\ / V |_____| Min_power_mW/cm^2 Spect_Sensitive_uA/uW 0.4_uW/cm^2 0.5_uA/uW Radian_Sensitive_Area_mm^2 \ | / |\ Sun_power_mW _____ \ | / | \ ___\ | | | ___ SUN ___ \ | ___ > 7mW _|_ / | Sun_Idiode / | \ \| / ^ \ | 3.5mA / | \ 7_mm^2 /_\ / V |_____| Sun_power_mW/cm^2 Spect_Sensitive_uA/uW 1mW/cm^2 0.5_uA/uW ^ 5V /|\ | re_ohms= .026/Idc = 2600_ohms _| ____|' NPN I_shot_A/rt(Hz) = sqrt(q*2*Idc) | |`-> I_shot = 1.7pA/rt(Hz) _|_ | 10uA V_shot = 4.65_nV/rt(Hz) /// / | \ V V_therm_nV /rt(Hz)=4*sqrt(R/1K_ohm) 1Mohm / V_therm = 126.5_nV/rt(Hz) \|/ V -10.7V ^ 5V /|\ | _| ____|' NPN | |`-> re_ohms= 2600_ohms _|_ _|_ /// / \ V_shot = 4.65_nV/rt(Hz) \___/ __ |____| | 10uA | |__| V_shot(2.6K) = 4.65_nV/rt(Hz) | / NOTE ! V \ V_therm(2.6K)= 6.44_nV/rt(Hz) / 1Mohm _|_ / \ V_therm = 126.5_nV/rt(Hz) \___/ | | \|/ V -10.7V re_ohms= 2600_ohms ____________ _|_ | _|_ /// | / _ \ _|_ \/ \/ | I_shot = 1.7pA/rt(Hz) \ / /\_/\ V _V_ \___/ ___ |_______|____| | V_shot = 4.65_nV/rt(Hz) _|_ |___| / _ \ 10uA \/ \/ | /\_/\ V \___/ | \|/ V -10.7V _____ ___\ | | | ___ >.043pW/rt(Hz) _|_ / | Noise_Idiode / ^ \ | .021pA/rt(Hz) /_\ / V |_____| Noise_power_W/rt(Hz) Spect_Sensitive_uA/uW .043pW/rt(Hz) 0.5_uA/uW Dark_Current 2nA ________________ | _|_ _|_ _|_ / _ \ / _ \ ^ | \/ \/ \/ \/ Dark_shot_I=.025pA/rt(Hz) /_\ | /\_/\ /\_/\ | V \___/ \___/ |_______|________| Noise_Floor_Dark = Dark_shot_I*SQRT(BandWidth_Hz) = .025pA/rt(Hz)*SQRT(10_MHz) = .075nA_@10MHz Noise_Floor_Sun = Sun_shot_I*SQRT(BandWidth_Hz) = 34pA/rt(Hz)*SQRT(10_MHz) = 106nA_@10MHz Noise_Floor_LTC = 1.79pA/rt(Hz)*SQRT(10_MHz) = 5.6nA_@10MHz If I_signal >> I_noise .. jitter is low (spec +/1%) Want Bit_Error_Rate (BER) less than 10^-8 _______ | | C_diode=C_zero/(1-V_diode/phi)^M _|_ __|__ ^ _____ C_zero_pf = 72 /_\ | phi_mV = 700 | | M = .45 |_______| C_diode_@2V = 40pF Start Stop bit <----------Data_Perfect_Signal------------> bit _ _ lsb_ _ _ _ _ _ _ msb | | | | | | | | | | | | | | | | | | | | _| |__| |__| |__| |__| |__| |__| |__| |__| |__V__V || <---Jitter-> || Defined at rising edge _ _ _ _ _ _ | | | | | | | | | | | | | | _| |_| |___| |________| |___________| |__| |__V__V ^ Measured Signal /|\ |____ Used as reference TEST PATTERNS for Jitter 01111111 7F 01010101 5A 00001111 0F 00110011 33 01110111 77 01000000 40 00000000 00 distance 0 to 1meter Signal Modulation Pulse Jitter BW_MHz Rate 115.2kb/s RZI 1.63us +/-445n 5 1.152Mb/s RZI 217ns +/-56n +/-25ns 4Mb/s 4PPM 125ns +/-10n +/-10ns 100 ____ _________ ____ | 1 | 0 0 | 1 1 | 0 | 1 | 0 NRZ _| |_________| |____| |____ ^ ^ ^ ^ ^ ^ ^ ^ ^ Transmit a infared when ever a zero. _ _ _ _ | | | | | | | | ________| |__| |____________| |_______| |____ 1.152Mb/s ^ ^ ^ ^ ^ ^ ^ ^ ^ expect +/-12.5ns jitter from 40MHz clock and +/-5ns jitter LED and driver _________ _________ | 1 | 0 0 | 1 | ___| |___________________| |_______ 4Mb/s ^ chip1 ^ chip2 ^ chip3 ^ chip4 ^ <--------------Dt=500ns----------------> Data Bit Pair 4PPM Data (DBP) Symbol(DD) 00 1000 01 0100 10 0010 11 0001 noise peaking interference filtering tail simulations ---------------------------------------------------------------------------- Infra Red Remote Transponder cheif problem is just stray environmental noise with any slowly changing amplitude modulated IR signal (lots of 60 Hz noise, and sunlight noise). Most IR remotes work around a 40KHz carrier, so that they can just pulse this digitally, and just bandpass filter it at receiving end. This boosts range of unfocused IR remotes to tens of feet (around 20-30 feet). Adding two IR Leds helps alot, by sending out more IR signals. IR DETECTOR CIRCUIT 30Hz BANDPASS FILTER gain = 1 Q = 4 30Hz BANDPASS FILTER gain = 1 Q = 4 +5V .1uF | || 330K \ +---||--+-----/\/\/------+ / | || | | \ 100K | | | / | | | \ | | | | | .1uF | ___ | | 39K | || | | \___ | +--\/\/--+---||--+--|- \___ | IR | | || | \ | Detector | | | LM3900 -+ | | | ___/ | ||---+ \ +--|+ ___/ | || / | |___/ | ||---+ \ 5.6K \ | | / / | | \ \ 1M | | | / | | | \ | GND GND | | +5V | | | +---------------------------------- | | ___ | 120K | \___ +-------\/\/\---|- \___ SCHMITT TRIGGER | \ | LM3900 -+-- Vout | ___/ | +--|+ ___/ | | |___/ | | | | | 1.1M | 1.1M | +5V --\/\/\-----+-------\/\/\----+ | ----- 1uF ----- | | GND IR EMITTER CIRCUIT IR EMITTER CIRCUIT +5V 555 +5V | TIMER | / +-----------+ | \ 1| |8 | / 10ohms GND -----|GND Vcc|-----+ \ | | \ / | | / | 3| | \ 2.2K +-------------------|OUT | / | | |7 \ | | DISCH|-----+ | 4|- | \ D ||--+ +5V -----|R | / <||IR LED | | \ 200K ||--+ | | / | 2| |6 \ | +---|TRIG THRES|-----+----+ | | | | | | | | +-----------+ | | GND | | ----- | .1uF | ----- +---------------------+ | | GND Notes: Adding more IR LED's will increase range of IR detector. The signal on pin 3 of 555 is 30Hz and has a duty cycle of 50% Due to very small pull-up resistor 555 sinks about 109mA. The specs say 555 can sink up to 225mA so it's well below danger level. ---------------------------------------------------------------------------- Cheap 40KHz clock Use a 40KHz Xtal and a 74C14 schmitt trigger: ________ <---- 2.2 M resistor ___| 2M2 |___ | |________| | | | | | | |\ |Output 40KHz | | \ | +-----| O------+--------> | | / | |/ gate 1 of 74C14 | | --+-- XXX 40KHz Xtal --+-- | | ----- --- - This circuit has worked for me in many applications. (it might be an idea to buffer signal befor using it. (There are still 5 unused gates in 'C14.. ---------------------------------------------------------------------------- very STABLE 40khz generator A circuit that I have used before is based on CD4060 (14stage binary counter) and a 640Khz ceramic resonator. The CD4060 is basically an oscillator and a ripple counter to divide 640khz down to something more usable. Here is pinout of CD4060 (frequencies are assuming a 640khz input signal into pins 10/11/12 - circuit shown below): +-\/-+ 160hz 1 | | 16 Vcc 80hz 2 | | 15 625hz 40hz 3 | | 14 2.5khz 10khz 4 | | 13 125hz 20khz 5 | | 12 \ 5khz 6 | | 11 >---- 40khz 7 | | 10 / GND 8 | | 9 NC +----+ see sub-circuit below Sub-circuit for a 640khz ceramic resonator: 12 >----------------------+ 740pf | 11 >-------+----+---|(----+ | | | 640khz --- \ | res. O / 1Mohm | --- \ | | | | 10 >-------+----+---|(----+ 740pf | GND >----------------------+ (you may be able to obtain a resonator with builtin capacitors and three leads) A nice part about this circuit is that it delivers a STABLE 40khz signal, as well as delivering several other frequencies that can be used to modulate 40khz carrier. For example, person that designed this circuit (Ken Boone, member of Triangle Amateur Robotics) used it to build several beacons in his yard to serve as navigation points for a robotic lawnmower. By diode-OR'ing results of 40khz carrier and one of lower frequencies (such as 125Hz) line to drive a ring of IR-LEDs, he could locate beacon and tell which, of several, beacons he had found. This circuit has proven to be VERY stable, and is fairly inexpensive (about $1.50 for CD4060 and 640Khz ceramic resonator). ---------------------------------------------------------------------------- IR 'slotted switch' sensor There is a type of detector known as a "slotted switch" that consists of a phototransistor/LED pair mounted on a solid frame with a small air gap between two elements. A typical circuit might be: o +5v o +5v | | | | \ \ 220 ohms / / 4.7K \ \ / / | | | +-------> Vout _|_ / \ / |/ ----- |\ NPN | \ | | | | | | GND GND | air gap | When air gap is unobstructed, transistor saturates, pulling Vout to ground; when gap is blocked, transistor cuts off and Vout is +5 volts. ---------------------------------------------------------------------------- IR REMOTE CONTROLS DECODING IR REMOTE CONTROLS by Juergen Putzger The origin of this posting was the question what to do with an old TV. I suggested to use the infrared remote control as an input keyboard for a microcontroller board and mentioned a piece of code I had written for the 8052 microcontroller. I was asked by some people to share my information about remote controls, so here it is: There are at least two international standards which are used by remote controls to encode the commands, the RC5 and RECS 80 code. The RECS 80 code uses pulse length modulation. Each bit to be transmitted is encoded by a high level of the duration T followed by a low level of duration 2T representing a logical '0' or 3T representing a logical '1'. T 2T T 3T T 2T _ _ _ | | | | | | _| |__| |___| |__ 0 1 0 Notice that a '1' takes more time to be transmitted than a '0'. The RC 5 code instead has a uniform duration of all bits. A transition in the middle of the time interval assigned to each bit encodes the logical value. A '0' is encoded by a high to low transition and a '1' by a low to high transition. Therefore we need additional transitions at the beginning of each bit to set the proper start level if a series of equal bits is sent. We don't need this additional transition if the next bit has a different value. This is also called a 'biphase' code. |1.Bit|2.Bit|3.Bit|4.Bit| __ __ __ __ | | | | | | |__| |_____| |__| 0 0 1 1 Instead of being fed direct into the IR emitter, most remote controls modulate a 20-30 kHz carrier with this signal. A logic one is represented by a burst of oscillations. ______/\/\/\/\_______/\/\/\/\________ 0 1 0 1 0 The reason is, that you can use a filter tuned to the carrier frequency to distinguish the signal from noise in the ambient light. Fluorescent lamps are the main source of such noise. Photodiodes behind an optical filter which transmits infrared light but blocks visible light are used as detectors. The signal from the photodiode is fed through a filter tuned to the carrier fequency and then amplified. The amplified signal is demodulated just like the carrier is demodulated in any AM radio receiver. + | _|_ photodiode /_\ demodulator | |\ _|_ ____| \_____| |__ __|\|___ ____ L and C form a | | | / | | | |/| |signal circuit resonant | / |/ _|_ | out to carrier === \ amplifier /_\ === |C / L | | |___|_________________|________|____ It can be a lot of pain to design a sensitive receiver that does'nt start to oscillate. It is also necessary to have some automatic gain control to avoid overload of the amplifier at close distance to the emitter. It is easier to use some integrated circuit that does all of the job. The best i have ever seen (and used) is the SFH505A manufactured by SIEMENS (no, I don't work for this company). It looks like one of this three legged voltage regulators and uses a single 5V supply. It incorporates an optical filter, the photodiode, a filter tuned to about 30 kHz , the amplifier with automatic gain control and the demodulator. If you don't know which code your remote control is transmitting you can identify it by viewing the output of your receiver with an oscilloscope. The RECS 80 code uses high pulses of uniform length while the low pulses differ in length. If there are high and low pulses of two different lengths it might be RC5 code. Note that your receiver may invert the levels. How are commands like volume control or channel selction encoded? In the case of the RC5 code there is an international standard. Every command is encoded by 14 bits. The first two bits S are startbits to allow the receiver to adjust the automatic gain control and to synchronize. Next a bit T follows, that toggles with every new keystroke. Next is the address A of the device which shall respond to the command. At last the command itself follows. | S | S | T | A4 | A3 | A2 | A1 | A0 | C5 | C4 | C3 | C2 | C1 | C0 | Some important addresses and commands: Address: Device: Command: 0 TV1 0...9 Numbers 0..9 (channel select) 1 TV2 12 Standby 5 VCR1 16 Master Volume + 6 VCR2 17 Master Volume - 17 Tuner 18 Brightness + 18 Audio Tape 19 Brightness - 20 CD Player 50 Fast rewind 52 Fast run forward 53 Play 54 Stop 55 Recording There are integrated decoder circuits which have inputs to select the device address and parallel outputs activated by the commands. Since this is comp. robotics the devices you wish to control will have a microcontroller on board which can do all the decoding. Here is an input routine I have written for the 8052 microcontroller family to receive RC5 codes. My cousin has written a similar routine for the RECS80 code which i will try to make available also. Perhaps we can start a collection of such routines and archive them somewhere. Juergen Putzger (still looking for that public domain 8052 C-compiler....) ------------------------ source text begins here ------------------------- ; ---------==========----------==========---------=========--------- ; Interrupt Driven Receiving Routine for RC5 code ; written by Juergen Putzger (juergen.putzger@physik.uni-regensburg.de) ; ---------==========----------==========---------=========--------- $MOD52 INPUT EQU P3.2 ;Port3,Bit2 is input. demodulatedsignal ; active low level connected to this pin LF EQU 0AH ; Linefeed CR EQU 0DH ; Carriage return SPC EQU 20H ; Space RB0 EQU 000H ; Select Register Bank 0 RB1 EQU 008H ; Select Register Bank 1 ..poke to PSW DSEG ; This is internal data memory ORG 20H ; Bit adressable memory FLAGS: DS 1 CONTROL BIT FLAGS.0 ; toggles with every new keystroke NEW BIT FLAGS.1 ; Bit set when new command received COMMAND: DS 1 ; Received command byte SUBAD: DS 1 ; Device subaddress BUFFER: DS 30 ; Buffer to store length of trans pulses STACK: DS 1 ; Stack begins here CSEG ; Code begins here ;---------==========----------==========---------=========--------- ;PROCESSOR INTERRUPT AND RESET VECTORS ;---------==========----------==========---------=========--------- ORG 00H ; Reset JMP MAIN ORG 0003H ; External Interrupt0 JMP RECEIVE ; ---------==========----------==========---------=========--------- ; Output routines ;Don't forget to set up serial port and Baud rate ! ; ---------==========----------==========---------=========--------- N_OUT: ADD A,#30H ;Convert BCD number to ASCII C_OUT: JNB TI,$ ;Wait until transmission completed. CLR TI ;Clear interrupt flag. MOV SBUF,A ;Write out character to serial port. RET BIN2BCD: ;Convert 8 bit value in Acc to 3 digit BCD MOV B,#100 DIV AB CALL N_OUT XCH A,B MOV B,#10 DIV AB CALL N_OUT XCH A,B CALL N_OUT RET ; ---------==========----------==========---------=========--------- ;Interrupt routine entered by first high to low transition ;at Port3-Bit2. Stores length of all pulses occuring ;in buffer Analyzes thetiming of startbits to calculate ;threshold between short and long pulses. routine is ;independent of CPU speed. device address and command are ;extracted from bit stream. Two flags are set upon exit, ;control bit which toggles with every new keystroke and ;NEW bit indicating that a new command has been received. ; ---------==========----------==========---------=========--------- RECEIVE: PUSH PSW ; save current registerset MOV PSW,#RB1 PUSH ACC MOV R0,#BUFFER REC: MOV A,#0 REC0: INC A ; Measure duration of low-level NOP NOP ; Delay NOP NOP JZ TIMEOUT ;End transmission if exeeds256 counts JNB INPUT,REC0 MOV @R0,A INC R0 MOV A,#0 REC1: INC A ; Measure duration of high-level NOP NOP ; Delay NOP NOP JZ TIMEOUT ; End of transmission JB INPUT,REC1 MOV @R0,A INC R0 JMP REC TIMEOUT: MOV A,BUFFER ; calc between short/long pulses INC R0 ; length of first low-pulse ADD A,BUFFER+1 ; plus length of first high-pulse CLR C RRC A ; divided by two MOV R1,A CLR C RRC A ; plus half of the time ADD A,R1 MOV R5,A ; yields threshold MOV R0,#BUFFER MOV R1,#1 ; initial value MOV R2,#13 ; Number of bits to decode DECODE: MOV A,@R0 INC R0 CLR C SUBB A,R5 ; compare length with threshold MOV A,#0 CPL C ; short=1 RLC A JNZ NOSKIP INC R0 ; if short skip over next pulse NOSKIP: XRL A,R1 ; new bit XOR with previous bit MOV R1,A ;Store new bit RRC A MOV A,R3 ; Store new Bit in R3/R4 by rotating RLC A MOV R3,A MOV A,R4 RLC A MOV R4,A DJNZ R2,DECODE MOV A,R3 ANL A,#00111111B ; extract command from R3 MOV COMMAND,A MOV A,R3 RLC A ; do some rotating to extract XCH A,R4 RLC A ;device address XCH A,R4 RLC A XCH A,R4 RLC A CLR CONTROL JNB ACC.5,TZ ; Check control bit SETB CONTROL TZ: ANL A,#00011111B ; mask device address MOV SUBAD,A POP ACC ; Restore old registerset POP PSW SETB NEW ;Set flag to indicate new command RETI ; ---------==========----------==========---------=========--------- ;Main routine.Program execution here.Don't forget to add ;code to initialize serial port and Baud rate if monitor ;program doesn't do that.Main loop waits until a command ;been received.control bit, subaddress and command byte ;are printed separated by spaces. zeroes not suppressed. ;When standby command (12) received, main loop is ;terminated and program returns to monitor. ; ---------==========----------==========---------=========--------- MAIN: MOV TCON,#00H ; MAKE SURE TIMERS ARE SHUT DOWN. MOV PSW,#RB0 ; Select register bank 0 MOV SP,STACK SETB EX0 ; Enable external Interrupt0 CLR IT0 ; triggered by high to low transition SETB EA CLR NEW LOOP: JNB NEW,LOOP ; Wait until command been received MOV A,#CR CALL C_OUT ; Ouput carriage return and linefeed MOV A,#LF CALL C_OUT MOV A,FLAGS ANL A,#00000001B CALL BIN2BCD ; Output control Bit MOV A,#SPC CALL C_OUT MOV A,SUBAD CALL BIN2BCD ; Output subaddress MOV A,#SPC CALL C_OUT MOV A,COMMAND CALL BIN2BCD ; Output command MOV A,COMMAND CLR C SUBB A,#0CH ; compare for standby command CLR NEW JNZ LOOP ; go on receiving CLR EX0 ; stop receiving CLR EA ; and JMP 8000H ; return to monitor which has entry ; point at 8000H END