RC5 Demo
|
This is the demo project for the German article about RC5 codes and IR remote controls from http://www.zotteljedi.de/rc5/. It demonstrates how to receive and decode RC5 telegrams using an external receiver IC like TSOP1736 that turns the IR signal into logic levels. It was initially developed for the ATmega32A, but should be fairly simple to be ported to other devices.
The program is split into three major parts:
The TSOP1736 needs to be connected to an external interrupt line. The BitDetector makes use of the interrupt to synchronize with the signal edges. Although it is possible to achieve a similar effect by sampling, it requires a higher timer resolution and thus puts more load onto the CPU.
The decoded telegrams are sent to the PC as text, e.g. like this:
[info] Field: 1, Toggle: 1, Address: 0, Code: 1 [info] Field: 1, Toggle: 0, Address: 0, Code: 2 [info] Field: 1, Toggle: 1, Address: 0, Code: 3
The following diagram shows the classes and data types and how everything fits together. For each class a more detailed documentation is available via the class index from the navigation bar above.
avr-classes
library are not shown (e.g. InputPin or BufferedUsart)The most important pattern that becomes visible is that each aggregated component doesn't know specific details about the component that aggregates it. For example the RC5Receiver class doesn't know the Application class. It merely knows that there is a component implementing the RC5Receiver::TelegramHandler interface. This makes the RC5Receiver reusable in other contexts without having to change the source code.
avr-gcc
)To build the software a built avr-classes
project is required. The include and libary paths for rc5demo
are already configured properly when using this directory layout:
+---avr-classes | +---include | \---lib +---rc5demo \---src
You might need to switch the microcontroller type from ATmega32A to your specific controller. Also the CPU frequency might differ, see main.cpp.
Copyright (c) 2019, 2020, Felix Opatz All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.