Path: Home =>
AVR-overview =>
IR Remote Control => Receiver for remote control signals
IR receiver for switching and volume control with AVR processor ATtiny13
Do you have an old amplifier, that came without an IR remote control? You don't want to put it to the
waste bin, because it worked now for 25 years, and modern amplifiers just do the same thing
(amplifying analogue signals and moving speaker membranes in and out). To not being urged by this
device to leave your sofa, because some commercial TV stations increase their volume each time they
bring urgent PR messages to you, this is your next do-it-yourself project. It brings your oldtimer
to the hypermodern world. And, the best is: you don't need an additional box extra for this, but it
works with all your remote controllers, if you program it that way. And all that without even opening
your oldtimer's top.
- Properties,
- Hardware, how it works,
- Construction,
- Software.
This page describes an IR remote control receiver with an ATtiny13 that switches the power of a
connected device on and off and controls the volume of an audio source. The device has the following
functions:
- The signals of an IR remote controller are received, decoded, and
- swith the power supply of a connected device via a relais on and off,
- control the volume of an audio signal.
- By programming the ATtiny13 processor each IR remote control and desired key of that control
can be connected with these functions. The example shown here uses a remote signal for a beamer.
The amplifier is switched on and off together with the beamer, the volume control of the beamer
is not used by the beamer, so it is used here.
- By exchanging the processor that is used here with a type with more I/O pins additional remote
functions con be implemented.
- In that software version an attached device is automatically switched off after five hours.
By changing the software you can fit this feature to your own needs.
To the top of page, To the IR title page
The hardware is shown in the schematic. The single modules power supply, relais switch, microcontroller
and analog volume control are marked separately.
Power supply
The power supply provides 12 V for the relais and regulated 5 V for the processor and
the analogue unit. The low current requires a 1 VA transformer only. The standby consumption
is dominated by the transformer and the LED, and is very low.
Relais switch unit
The 12 V-relais is driven with a transaistor and switches 240 V/8 A load.
MC unit
The microcontroller ATtiny13 runs with its internal RC generator of 1.2 MHz, without any problems
with timing. For receiving the IR signals, a commercially available IR receiver type TSOP1738 from
Vishay/Telefunken is attached to port PB0. A Siemens SFH507 oder Infineon SFH5110/5111 can probably
used instead.
To drive the relais PB2 is configured as output.
PB1 is output for driving the green LED (when debugging this displays the received signals) and inputs
the key signal. The key switches the box on without the remote control.
With PB3, PB4 and PB1 the processor controls the digital potentiometers in the analog part.
For programming the AVR a standard 10-pole ISP interface is attached. When connected, the IR receive
signal isn't detected. So remove the ISP10 line after programming.
Analogue control
For controlling the analogue signal a commercially available MCP42010MIC with two digital channels
is used. The audio signals are decoupled with condensers from DC. Volume control is managed by the
processor for both channels. The volume curve has 54 stages, with an exponential curve, to ease
control.
The exponential curve in the table for volume control.
To the top of page, To the IR title page
The whole electronic is on a breadboard and built in a plastic box.
The 240 V output and the connectors for the analogue I/O are mounted on top of the box.
On the front the IR receiver, the two LEDs and the key are visible.
To the top of page, To the IR title page
The commented assembler source code is available in HTML-Format here and in
Assembler source code format here.
The machine code
- initiates the stack, the I/O of the ATtiny13, reads the last stored value of the volume
regulator from the EEPROM, converts this to an exponential value and outputs the result to
the digital potentiometer, starts Timer 0 with a prescaler of 64 (18.75 kHz,
53.3 µs per tick), enables the PCINT on the IR receiver input, sets sleep mode
idle and enables interrupts,
- detects PCINT interrupts and measures the complete cycle duration (from low to low on the IR
receiver input), stores this timer data and sets the T flag (the further decoding of the signal
is outside the interrupt service routine),
- reacts on overflows of the counter (13.65 ms) by downcounting two additional counter
bytes (3.49 s resp. 14.9 min) and a quarter-hour counter is increased. If the
quarter-hour counter reaches 5 hours the relais output and the green LED is switched off,
- decodes the duration of the remote control signals in the main program loop.
- On the first signal (start signal) the correct duration is checked. The correct duration
of the start signal is encoded in the table "IrAdrTab" for the remote control,
and is defined with broad lower and upper bounds to not missing it.
- After that the remote control sends the bit sequence 0b00001111, where a zero is between
17 and 30, a one is 31 to 45 time cycles long. The sequence is followed by a separation
signal of 80 to 95 time cycles long.
- The further signal recognition receives eight bits and stores them in register rIrC: a
short signal shifts a zero, a long signal a one into that register.
- If the final very long signal is received the content of rIrCL is compared with the
different command bytes for switching and volume control and a short LED signal acknowledges
reception of the command.
In case the debug mode is enabled before assembling, the LED displays the received command code in
decimal form.
Required modifications for the source code are e. g.
- to fit the table "IrAdrTab" to the signal duration of your IR remote control, e.g.
shorter or lomnger durations, different address byte, no separation signal between address and
command byte, 16-bit command word instead of 8 bits, etc.,
- switching and volume control without the second verification, if your remote control sends
address and command byte only once and does not repeat those,
- fitting the hard- and software to a different modulation frequency for increased sensitivity
(the TSOP1738 is well between 36 and 40 kHz, so it works quite well with other frequencies).
Finally: the box works here very well over some monthes.
To the top of page, To the IR title page
©2011 by http://www.avr-asm-tutorial.net