【正文】
. This could be gap counts, pulse counts, or a bination of both. 5. Fifth, determination is made of the full length of mands. This enables the determination as to whether a button is being held down or if a new mand of the same type as previous is being issued.6. The sixth step requires the writing of code. The code will resolve the gap and pulse lengths and mand lengths into bits and button on the remote will decode to a unique seriesof bits. 7. The seventh and final step takes these codes that are received and converts them to button numbers or mands, using a lookup table.Step 1:Choosing a remote controlDepending on your application, you may choose to have an off the shelf remote control or design one yourself. Typically they have small 4bit microcontrollers in them, preprogrammed for a serial panies such as General Instrument sell them as plete units, others such as NEC sell the main ponent which can be customized by external diodes to not interfere with other applications. It is also possible to program a PIC16C57 to generate a signal that can be sent to an infrared LED for transmission. Yet another approach is to use a programmable remote control to generate any number of infrared formats and use them right off the shelf to control the target device.Step 2:Determining a modulation frequencyFor this and the next step the program will be used. To start out, use the nonmodulated receiver and a PIC16C57 running the application. Select 1 on the option selector. Press a button until the decimal point es on. Using the jumpers switch through the memorized pulse durations that the PIC16C57 will have stored in its memory. If all of the reading except the first are below 40h, the infrared format is a modulating one. If half or more of the values show up as 0FFh, then the remote is nonmodulating.If the remote control is modulated, switch to a demodulating IR receiver. With the option selector still at 1, press a button on the remote control again until the decimal point es on. The series of memorized pulse durations will now probably include a lot of FFh values. If so, move the Option selector up until the values are in the 7h to 1Fh range. The Option selector has the optimum value for the option divisor to be used in the TMR0 register. To optimize range and reliability, several demodulating receivers may be tried. These are available from Sharp or Lite On. The modulating frequencies that are presently used are kHz, kHz, kHz, , 38 kHz, 39 kHz, 40 kHz, kHz, 48 kHz, and kHz[2]. The most mon are round 40 kHz. The best match for your remote control will give the longest range and most consistent results.Step 4:Decoding ones and zerosThe next step is to map out the characteristic pulse and gap lengths that represent ones and zeros. By pressing the same button on the remote, write down the series of numbers read by the PIC16C57 running the MEASURE .ASM program. Each odd numbered entry is the duration of a burst of IR from the remote control. Each even numbered entry is the duration of a gap between bursts of infrared. The lengths of these gaps and bursts define ones and zeros. Their order will depend on which button is pressed. Once the characteristic lengths have been discovered for a one and a zero, an algorithm can then be created with a counter to translate the lengths into ones and zeros.Step 5:Finding the Command LengthPress the same button again. The mand duration can also be found. This is necessary to determine if a button is being held down or a new mand of the same type is being issued. Most remote controls repeat the mand as long as the button is held down, the repetitions separated by a long dark time, usually 0FFh on an even numbered no long even numbered counts can be found, consider that some mands can be longer than 64 transitions. The option to delay counting is available for this reason. Insert jumper 1 and MEASURE. ASM will only start storing transition times after the 32nd transition.Step 6: Translating lengths to bitsOnce the characteristic lengths of ones and zeros have been found and the length of the typical mand has been found, a program can then be writt