Programmable RC-5 Remote Control
Posted: Fri Oct 29, 2010 10:09 am
Programmable RC-5 System
Introduction
This article describes how the new Infra-Red RC-5 E-block (EB-060) can be used with Flowcode to develop a remote control device with the ability to learn codes from other handsets.
The RC-5 E-block contains the hardware required to transmit and receive RC-5 encoded infrared signals.
In this application the transmit channel is used to transmit individual codes allocated to each of the numeric keys on a keypad. The receive channel can be used to allow individual keys to 'learn' new messages (codes) from existing, compatible, equipment handsets.
Component
The example program attached to this article uses a Flowcode Custom Component C file (also supplied) to control the EB-060 hardware.
The code contains definitions to allow this application to run on a PIC16F877A with a 19.6608MHz crystal.
A fully integrated Flowcode RC-5 component will be available in the near future.
Custom code
To allow Flowcode to access the macros in the custom component, the attached PIC_custom.c file must be saved into the Components folder of the Flowcode installation. There will already be a file named PIC_custom.c in the folder, which should be renamed or moved before copying the new file into the folder.
Hardware
The EB-060 should be connected to Port B and configured as follows:
A wire link in the J9 sockets between pins 0 and 6.
The input selector jumper on J6.
The J8 jumper in the OFF position.
The J2 jumper in the 5V position.
The LCD E-Block (if used) should be connected to Port C
The Keypad E-Block should be connected to Port D
Program
The example program accompanying this article uses a keypad and (optional) LCD E-block to represent a traditional remote handset arrangement.
A previous article "RC5 remote control" explained the basics of the RC-5 protocol, which will not be covered in this article.
Default settings
On power-up the keys default to the typical values used for a main television (address = 0; command = key value). Pressing any of the numeric keys will cause the corresponding message to be transmitted.
Transmit mode
The example program handles each key press individually so the toggle bit changes state as each message is transmitted. The program can be modified to allow key presses to auto-repeat (volume control), transmitting repeated messages, with a constant toggle bit value, while a key is being pressed.
Learning mode
The program allows codes from existing, RC-5 compatible handsets to be detected and allocated to individual keys on an EB-014 keypad E-block. Codes for multiple types of equipment (different address values) can be acquired as long as they are all RC-5 compatible. The keys can then be used to control the transmission of each message (the program can be easily modified to use alternative input devices, or internal microcontroller events, to transmit each message).
The program uses the # key to toggle between 'Transmit' and 'Learn' mode. To prevent accidental re-programming, when the # key is used to enter programming mode, it must be followed by the * key. The # key can be used at any time to return to transmit mode.
When in 'Learn' mode, press the key to be re-programmed. Confirmation of the selected key will appear on the LCD (if it is being use).
Point a handset at the receiver on the RC-5 E-block and press the handset button that you want the system to learn. If the message is detected correctly, the values are assigned to the selected key and the system returns to transmit mode.
Further development
The system does not support auto-repeated transmission of messages while a key is held down. This feature may be required for functions like volume control. The program can be modified to continually transmit a message, at the RC-5 repeat rate (8 messages per second), with the toggle bit set at the same value for each transmission, while a button is being pressed.
Codes taught to the system are stored in RAM and are only retained while power is applied. The program can be modified to store alternative codes in EEPROM, and to search for them on power-up, so they can be retained indefinitely.
The program can be modified to accept signals from additional or alternative input devices to control system setup and message transmission.
Introduction
This article describes how the new Infra-Red RC-5 E-block (EB-060) can be used with Flowcode to develop a remote control device with the ability to learn codes from other handsets.
The RC-5 E-block contains the hardware required to transmit and receive RC-5 encoded infrared signals.
In this application the transmit channel is used to transmit individual codes allocated to each of the numeric keys on a keypad. The receive channel can be used to allow individual keys to 'learn' new messages (codes) from existing, compatible, equipment handsets.
Component
The example program attached to this article uses a Flowcode Custom Component C file (also supplied) to control the EB-060 hardware.
The code contains definitions to allow this application to run on a PIC16F877A with a 19.6608MHz crystal.
A fully integrated Flowcode RC-5 component will be available in the near future.
Custom code
To allow Flowcode to access the macros in the custom component, the attached PIC_custom.c file must be saved into the Components folder of the Flowcode installation. There will already be a file named PIC_custom.c in the folder, which should be renamed or moved before copying the new file into the folder.
Hardware
The EB-060 should be connected to Port B and configured as follows:
A wire link in the J9 sockets between pins 0 and 6.
The input selector jumper on J6.
The J8 jumper in the OFF position.
The J2 jumper in the 5V position.
The LCD E-Block (if used) should be connected to Port C
The Keypad E-Block should be connected to Port D
Program
The example program accompanying this article uses a keypad and (optional) LCD E-block to represent a traditional remote handset arrangement.
A previous article "RC5 remote control" explained the basics of the RC-5 protocol, which will not be covered in this article.
Default settings
On power-up the keys default to the typical values used for a main television (address = 0; command = key value). Pressing any of the numeric keys will cause the corresponding message to be transmitted.
Transmit mode
The example program handles each key press individually so the toggle bit changes state as each message is transmitted. The program can be modified to allow key presses to auto-repeat (volume control), transmitting repeated messages, with a constant toggle bit value, while a key is being pressed.
Learning mode
The program allows codes from existing, RC-5 compatible handsets to be detected and allocated to individual keys on an EB-014 keypad E-block. Codes for multiple types of equipment (different address values) can be acquired as long as they are all RC-5 compatible. The keys can then be used to control the transmission of each message (the program can be easily modified to use alternative input devices, or internal microcontroller events, to transmit each message).
The program uses the # key to toggle between 'Transmit' and 'Learn' mode. To prevent accidental re-programming, when the # key is used to enter programming mode, it must be followed by the * key. The # key can be used at any time to return to transmit mode.
When in 'Learn' mode, press the key to be re-programmed. Confirmation of the selected key will appear on the LCD (if it is being use).
Point a handset at the receiver on the RC-5 E-block and press the handset button that you want the system to learn. If the message is detected correctly, the values are assigned to the selected key and the system returns to transmit mode.
Further development
The system does not support auto-repeated transmission of messages while a key is held down. This feature may be required for functions like volume control. The program can be modified to continually transmit a message, at the RC-5 repeat rate (8 messages per second), with the toggle bit set at the same value for each transmission, while a button is being pressed.
Codes taught to the system are stored in RAM and are only retained while power is applied. The program can be modified to store alternative codes in EEPROM, and to search for them on power-up, so they can be retained indefinitely.
The program can be modified to accept signals from additional or alternative input devices to control system setup and message transmission.