Path: Home => AVR-Overview => Applications => PCM-Decoder
Remote controler AVR-Single-Chip-Processors
AT90Sxxxx

in practical examples.

Decoder for remote control signals

  1. General overview
  2. Details of remote control signal encoding
  3. Conversion of remote control signals to an analogue voltage
  4. Required hardware
  5. Program structure

General overview

The decoder converts puls-encoded remote control signals, supplied on the input pin of a AT90S2323 processor (Port-Bit 0, Pin 5), to a pulse generator on the output (Port-Bit 1, Pin 6). By filtering this pulse generator output in a simple RC network a analogue signal results, which linearly rises with the pulse length of the applied PCM signal on the input. The analogue signal can be fed into a comparator and driver for remote controlled equipment like airplane models etc. If false signals are detected or if the input signal is missing a pre-defined default value is set on the analogue output. To detect this condition, a LED can be connected to Port-Bit 2, Pin 7, for testing purposes.
The current version of the program is predefined to detect active high PCM signals of 0.8 to 2.2 ms duration and an overall signal length of 25 ms. The default value for the analogue output is set to be 50% (2.50 Volt) after a single failure. All parameters of the program can be re-adjusted for other purposes and timings. Only a few commented parameters in the source code have to be re-adjusted to fit to other timings.
HTML-Format Source-code-Format Flow chart in GIF-Format Flow chart in PDF-Format
Wiring in PDF-Format Wiring in GIF-Format


To top of this document

Details on remote control signal encoding

A remote control signal has to encode an analogue signal (e.g. a voltage sensed from a variable resistor) to a digital signal, which can be decoded by the receiver back to the analogue signal and drives a motor or other equipment.
The analogue signal is first encoded to a pulse signal. The duration of that pulse varies with the input signal. If the voltage is zero, the signal is more or less exactly 0.8 ms long. If the voltage is on the upper end of the scale, the signal is 2.2 ms long. The information of the analog voltage is encoded into the pulse length, it is modulating the pulse length. These signals are called PCM-encoded. More time is between this and the next pulse: two pulses are 25 ms from each other, 40 pulses fit into one second and so a frequency of 40 Hz results. The pulse-encoded signal is then fed into a transmitter. This encodes the pulse a second time and modulates a high-frequency signal, which is transmitted over the antenna. A HF receiver decodes the received signal again and its output is the same PCM-encoded signal that we modulated on the HF.

To top of this document

Conversion to an analogue signal

The pure PCM-encoded signal has to be converted first to be used further on. This stage is what the AT90S2323 is doing: he counts the length of the pulse, between 0.8 and 2.2 ms, and converts it to pulse width signal on the output. There are many other ways to do this, but these are more or less convenient and reliable. We leave the counting to a micro.
The small AT90S2323 is clocked by a crystal oscillator, so he knows exactly what time it is. The only things he has to do is counting: the length of the input signal and the length of the output signal. Easy, but looking at the program below, the clock signal has to fit exactly. The AT90S2323 has no pulse width generator, so we do have to do this counting by software.
Switching the pulse width generator on and off is smoothed by the external RC network, so a very smooth output signal results.

To top of this document

Required hardware

The required hardware is very lean (the PDF-file).

Wiring PCM2PWG

The Xtal is responsable for the whole timing of the processor, the two capacitors improve the oscillator reliablility. The RC combination on pin 1 provides the Reset signal for the processor.
The PCM-encoded input signal is connected to pin 5 of the processor. The PWG output loads and unloads the capacitor and is smoothed by the resistor on the output pin 6. The error LED is connected to pin 7 and only required for testing purposes.

To top of this document

Program structure

The whole software is sensitive to the timing and does not use interrupts or subroutine calls.
HTML-Format Source-Code-Format Flow chart in GIF-Format Flow chart in PDF-Format
The duration of the pulse is counted in 233 single loop steps, each 6 microseconds long. That covers the 1.4 ms of the longest pulse. Pulses that are a little bit shorter than 0.8 ms or a little bit longer than 2.2 ms are tolerated by use of extra counting loops and do not set an error condition. Pulse with a very short (0,8 ms - 10%) or a very long duration (2.2 ms + 10%), pulses followed with less than the required inactive time, or missing pulses after a certain time-out set such an error condition. Subsequent errors are counted down. Reaching zero sets the error LED on and sets the PWG to the pre-defined default value, in our case 50% pulse width or 2.5 Volts.
The pulse width generator is in the current version clocked with 1.4 ms pulses, a frequency of around 714 Hrz results. Accuracy of the signal counting and the PWG is below 0.5% and hence good enough for serious applications.

To top of this document

©2002 by http://www.avr-asm-tutorial.net