Difference between revisions of "IRMP"
(translation of german article) |
|||
Line 11: | Line 11: | ||
|CODE=[https://github.com/ethersex/ethersex/tree/master/hardware/ir/irmp https://github.com/ethersex/ethersex/tree/master/hardware/ir/irmp] | |CODE=[https://github.com/ethersex/ethersex/tree/master/hardware/ir/irmp https://github.com/ethersex/ethersex/tree/master/hardware/ir/irmp] | ||
}} | }} | ||
+ | |||
+ | IRMP is a port of the [http://www.mikrocontroller.net/articles/IRMP infrared multi-protocol decoder] for [[Ethersex]]. | ||
+ | |||
+ | |||
+ | == Connection == | ||
+ | |||
+ | The reception of IR signals is performed by a receiver TSOP1736 type (or similar). This may be connected to any pin. The interrogation of the pins and the decoding of the IR protocol is done in an ISR, which occupies one 8-bit timer of the ATmegas. | ||
+ | |||
+ | When sending the signal with the carrier frequency of the respective IR Protocol is [[PWM]] modulated. This is another 8-bit timer of the ATmegas (OC0/OC2) is demonstrated. On the [[Etherrape]] board takes a [[NE555]] this function, ie the option ''Use external modulator for the transmitter'' is activated. It saves a timer on the [[AVR]] is set at a carrier frequency. | ||
+ | |||
+ | Example of a ATMega32 from: ''pinning/hardware/pollin_evalboard_addon.m4'' | ||
+ | |||
+ | ifdef(`conf_IRMP', `dnl | ||
+ | pin(IRMP_RX, PD2) | ||
+ | #define IRMP_USE_TIMER2 | ||
+ | #define IRMP_RX_LOW_ACTIVE | ||
+ | #undef IRMP_RX_LED_LOW_ACTIVE | ||
+ | pin(IRMP_TX, PD7) dnl OC2/OC2A | ||
+ | #undef IRMP_TX_LED_LOW_ACTIVE | ||
+ | ') | ||
+ | |||
+ | Meaning: | ||
+ | |||
+ | * IRMP_RX - pin the IR receiver is connected to | ||
+ | * IRMP_USE_TIMER2 - use Timer2 for receiver, Timer0 for sender (undef = reversed) | ||
+ | * IRMP_RX_LOW_ACTIVE - the IR receiver is low-active (undef = high-active) | ||
+ | * IRMP_RX_LED_LOW_ACTIVE - the control LED of the receiver is switched to USS (undef = switched to GND) | ||
+ | * IRMP_TX - pin the IR sender is connected to (=output of Timer0 or Timer2, see IRMP_USE_TIMER2)<br>'''Caution: 0A to 2A if MCU with A / B channel''' | ||
+ | * IRMP_TX_LED_LOW_ACTIVE - the control LED of the sender is switched to USS (undef = switched to GND) | ||
+ | |||
+ | == Configuration == | ||
+ | |||
+ | Each supported IR protocol occupies memory of code. Therefore, one should select only the required protocols. A detailed overview of the protocols are the [http://www.mikrocontroller.net/articles/IRMP#Die_IR-Protokolle_im_Detail article in the mikrocontroller forum]. | ||
+ | |||
+ | │ │ Load a Default Configuration ---> | ||
+ | │ │ General Setup ---> | ||
+ | │ │ [*] Status LEDs ---> | ||
+ | │ │ [*] Status LED (Received) | ||
+ | │ │ [-] RFM12 RX | ||
+ | │ │ [ ] ZBUS RX | ||
+ | │ │ [*] IRMP RX | ||
+ | ... | ||
+ | │ │ Network ---> | ||
+ | │ │ I/O ---> | ||
+ | ... | ||
+ | │ │ [*] IR Receivers ---> | ||
+ | ... | ||
+ | │ │ [ ] RC5 IR ---> | ||
+ | │ │ [*] IRMP IR ---> | ||
+ | ... | ||
+ | │ │ [*] Receive IR-codes | ||
+ | │ │ [*] Send IR-codes | ||
+ | │ │ [ ] Use external modulator for sender | ||
+ | │ │ [*] IRMP ecmd | ||
+ | │ │ --- Protocols | ||
+ | │ │ [ ] SIRCS | ||
+ | │ │ [*] NEC | ||
+ | │ │ [ ] NEC16 | ||
+ | │ │ [ ] NEC42 | ||
+ | │ │ [ ] JVC | ||
+ | │ │ [ ] SAMSUNG | ||
+ | │ │ [ ] MATSUSHITA | ||
+ | │ │ [ ] KASEIKYO | ||
+ | │ │ [*] DENON | ||
+ | │ │ [ ] RECS80 | ||
+ | │ │ [ ] RECS80EXT | ||
+ | │ │ [*] RC5(X) | ||
+ | │ │ [ ] RC6 | ||
+ | │ │ [ ] NUBERT | ||
+ | │ │ [*] BANG&OLUFSEN | ||
+ | │ │ [*] GRUNDIG | ||
+ | │ │ [ ] NOKIA | ||
+ | │ │ [*] SIEMENS | ||
+ | │ │ [ ] FDC | ||
+ | │ │ [ ] RCCAR | ||
+ | │ │ [ ] NIKON | ||
+ | │ │ [ ] RUWIDO | ||
+ | │ │ [ ] IR60 | ||
+ | │ │ [ ] KATHREIN | ||
+ | │ │ [ ] NETBOX | ||
+ | │ │ [ ] LEGO | ||
+ | │ │ [ ] THOMSON | ||
+ | │ │ --- Debugging Flags | ||
+ | │ │ [ ] IRMP Debug | ||
+ | |||
+ | |||
+ | IRMP also decodes the RC5 protocol, so that the separately [[Ethersex]] contained [[RC5]] decoder is not needed any longer. | ||
+ | |||
+ | == [[ECMD]] == | ||
+ | |||
+ | IRMP implements a [[ECMD]] interface for reading received and decoded IR commands and send IR commands. See [[Ecmd_Reference|ECMD reference]]. | ||
+ | |||
+ | == [[Control6|Control6]] == | ||
+ | |||
+ | === Output received characters via [[SYSLOG|Syslog]] === | ||
+ | |||
+ | <source lang="text"> | ||
+ | |||
+ | CONTROL_START | ||
+ | |||
+ | THREAD(read_irmp) | ||
+ | ON IRMP_READ > 0 DO | ||
+ | SYSLOG("IRMP %02hhd:%04hX:%04hX:%02hhX\n", | ||
+ | IRMP_PROTOCOL, IRMP_ADDRESS, IRMP_COMMAND, IRMP_FLAGS); | ||
+ | END | ||
+ | THREAD_END(read_irmp) | ||
+ | |||
+ | ON STARTUP DO | ||
+ | THREAD_START(read_irmp); | ||
+ | END | ||
+ | |||
+ | CONTROL_END | ||
+ | |||
+ | </source> | ||
+ | |||
+ | IRMP_READ checks for received IR code and stores it in the variables IRMP_PROTOCOL, IRMP_ADDRESS, and IRMP_COMMAND IRMP_FLAGS. Return values greater than zero indicate the validity of the variables. If IRMP_FLAGS = 1 it is a repetition. | ||
+ | |||
+ | === Control of [[Stella_Light)|Stella]]/Pins by IR commands === | ||
+ | |||
+ | <source lang="text"> | ||
+ | |||
+ | C6_HEADER(`/* This will be in control6.h */') | ||
+ | #include "services/stella/stella.h" | ||
+ | CONTROL_START | ||
+ | |||
+ | THREAD(control_stella) | ||
+ | ON IRMP_READ > 0 DO | ||
+ | if(IRMP_PROTOCOL==8 && IRMP_ADDRESS==0x0002) | ||
+ | { | ||
+ | switch(IRMP_COMMAND) | ||
+ | { | ||
+ | case 0x0268: | ||
+ | stella_setValue(STELLA_SET_IMMEDIATELY, 0, 255); | ||
+ | break; | ||
+ | |||
+ | case 0x0068: | ||
+ | stella_setValue(STELLA_SET_IMMEDIATELY, 0, 0); | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | END | ||
+ | THREAD_END(control_stella) | ||
+ | |||
+ | ON STARTUP DO | ||
+ | THREAD_START(control_stella); | ||
+ | END | ||
+ | |||
+ | CONTROL_END | ||
+ | |||
+ | </source> | ||
+ | |||
+ | The script switches the Stella channel 0 to 255 or 0, the remote control is a Denon (Protocol 8). With ''include'' access to the Stella sources granted.<br> | ||
+ | Instead of ''"stella_setValue (STELLA_SET_IMMEDIATELY, 0, 255);"'' ''"PIN_SET (LED)"'' and ''"PIN_CLEAR (LED)"'' can be used ([[Named_PIN|named pin]]). | ||
+ | |Named PIN]]). | ||
+ | |||
+ | === Send IR commands === | ||
+ | |||
+ | <source lang="text"> | ||
+ | dnl 01 = SIRCS | ||
+ | dnl 02 = NEC | ||
+ | dnl 03 = SAMSUNG | ||
+ | dnl 04 = MATSUSHITA | ||
+ | dnl 05 = KASEIKYO | ||
+ | dnl 06 = RECS80 | ||
+ | dnl 07 = RC5(x) | ||
+ | dnl 08 = DENON | ||
+ | dnl 09 = RC6 | ||
+ | dnl 10 = SAMSUNG32 | ||
+ | dnl 11 = APPLE | ||
+ | dnl 12 = RECS80EXT | ||
+ | dnl 13 = NUBERT | ||
+ | dnl 14 = BANG&OLUFSEN | ||
+ | dnl 15 = GRUNDIG | ||
+ | dnl 16 = NOKIA | ||
+ | dnl 17 = SIEMENS | ||
+ | dnl 18 = FDC | ||
+ | dnl 19 = RCCAR | ||
+ | dnl 20 = JVC | ||
+ | dnl 21 = RC6A | ||
+ | dnl 22 = NIKON | ||
+ | dnl 23 = RUWIDO * no tx support yet | ||
+ | dnl 24 = IR60 * no tx support yet | ||
+ | dnl 25 = KATHREIN * no tx support yet | ||
+ | dnl 26 = NETBOX * no tx support yet | ||
+ | dnl 27 = NEC16 | ||
+ | dnl 28 = NEC42 | ||
+ | dnl 29 = LEGO | ||
+ | dnl 30 = THOMSON * no tx support yet | ||
+ | |||
+ | IRMP_PROTOCOL = 2; | ||
+ | IRMP_ADDRESS = 1234; | ||
+ | IRMP_COMMAND = 5678; | ||
+ | IRMP_FLAGS = 1; | ||
+ | |||
+ | IRMP_WRITE; | ||
+ | </source> | ||
+ | |||
+ | Command 5678 to device 1234 will be send with one repetition using the NEC protocol. |
Revision as of 11:40, 6 October 2011
IRMP | |
---|---|
Status | Stable
|
menuconfig | I/O->IR Receivers->IRMP |
Pinning | yes |
Ecmd | yes |
Control6 | yes |
Depends on | ECMD |
Requires | - |
Code | https://github.com/ethersex/ethersex/tree/master/hardware/ir/irmp |
IRMP is a port of the infrared multi-protocol decoder for Ethersex.
Contents
Connection
The reception of IR signals is performed by a receiver TSOP1736 type (or similar). This may be connected to any pin. The interrogation of the pins and the decoding of the IR protocol is done in an ISR, which occupies one 8-bit timer of the ATmegas.
When sending the signal with the carrier frequency of the respective IR Protocol is PWM modulated. This is another 8-bit timer of the ATmegas (OC0/OC2) is demonstrated. On the Etherrape board takes a NE555 this function, ie the option Use external modulator for the transmitter is activated. It saves a timer on the AVR is set at a carrier frequency.
Example of a ATMega32 from: pinning/hardware/pollin_evalboard_addon.m4
ifdef(`conf_IRMP', `dnl pin(IRMP_RX, PD2) #define IRMP_USE_TIMER2 #define IRMP_RX_LOW_ACTIVE #undef IRMP_RX_LED_LOW_ACTIVE pin(IRMP_TX, PD7) dnl OC2/OC2A #undef IRMP_TX_LED_LOW_ACTIVE ')
Meaning:
- IRMP_RX - pin the IR receiver is connected to
- IRMP_USE_TIMER2 - use Timer2 for receiver, Timer0 for sender (undef = reversed)
- IRMP_RX_LOW_ACTIVE - the IR receiver is low-active (undef = high-active)
- IRMP_RX_LED_LOW_ACTIVE - the control LED of the receiver is switched to USS (undef = switched to GND)
- IRMP_TX - pin the IR sender is connected to (=output of Timer0 or Timer2, see IRMP_USE_TIMER2)
Caution: 0A to 2A if MCU with A / B channel - IRMP_TX_LED_LOW_ACTIVE - the control LED of the sender is switched to USS (undef = switched to GND)
Configuration
Each supported IR protocol occupies memory of code. Therefore, one should select only the required protocols. A detailed overview of the protocols are the article in the mikrocontroller forum.
│ │ Load a Default Configuration ---> │ │ General Setup ---> │ │ [*] Status LEDs ---> │ │ [*] Status LED (Received) │ │ [-] RFM12 RX │ │ [ ] ZBUS RX │ │ [*] IRMP RX ... │ │ Network ---> │ │ I/O ---> ... │ │ [*] IR Receivers ---> ... │ │ [ ] RC5 IR ---> │ │ [*] IRMP IR ---> ... │ │ [*] Receive IR-codes │ │ [*] Send IR-codes │ │ [ ] Use external modulator for sender │ │ [*] IRMP ecmd │ │ --- Protocols │ │ [ ] SIRCS │ │ [*] NEC │ │ [ ] NEC16 │ │ [ ] NEC42 │ │ [ ] JVC │ │ [ ] SAMSUNG │ │ [ ] MATSUSHITA │ │ [ ] KASEIKYO │ │ [*] DENON │ │ [ ] RECS80 │ │ [ ] RECS80EXT │ │ [*] RC5(X) │ │ [ ] RC6 │ │ [ ] NUBERT │ │ [*] BANG&OLUFSEN │ │ [*] GRUNDIG │ │ [ ] NOKIA │ │ [*] SIEMENS │ │ [ ] FDC │ │ [ ] RCCAR │ │ [ ] NIKON │ │ [ ] RUWIDO │ │ [ ] IR60 │ │ [ ] KATHREIN │ │ [ ] NETBOX │ │ [ ] LEGO │ │ [ ] THOMSON │ │ --- Debugging Flags │ │ [ ] IRMP Debug
IRMP also decodes the RC5 protocol, so that the separately Ethersex contained RC5 decoder is not needed any longer.
ECMD
IRMP implements a ECMD interface for reading received and decoded IR commands and send IR commands. See ECMD reference.
Control6
Output received characters via Syslog
CONTROL_START
THREAD(read_irmp)
ON IRMP_READ > 0 DO
SYSLOG("IRMP %02hhd:%04hX:%04hX:%02hhX\n",
IRMP_PROTOCOL, IRMP_ADDRESS, IRMP_COMMAND, IRMP_FLAGS);
END
THREAD_END(read_irmp)
ON STARTUP DO
THREAD_START(read_irmp);
END
CONTROL_END
IRMP_READ checks for received IR code and stores it in the variables IRMP_PROTOCOL, IRMP_ADDRESS, and IRMP_COMMAND IRMP_FLAGS. Return values greater than zero indicate the validity of the variables. If IRMP_FLAGS = 1 it is a repetition.
Control of Stella/Pins by IR commands
C6_HEADER(`/* This will be in control6.h */')
#include "services/stella/stella.h"
CONTROL_START
THREAD(control_stella)
ON IRMP_READ > 0 DO
if(IRMP_PROTOCOL==8 && IRMP_ADDRESS==0x0002)
{
switch(IRMP_COMMAND)
{
case 0x0268:
stella_setValue(STELLA_SET_IMMEDIATELY, 0, 255);
break;
case 0x0068:
stella_setValue(STELLA_SET_IMMEDIATELY, 0, 0);
break;
}
}
END
THREAD_END(control_stella)
ON STARTUP DO
THREAD_START(control_stella);
END
CONTROL_END
The script switches the Stella channel 0 to 255 or 0, the remote control is a Denon (Protocol 8). With include access to the Stella sources granted.
Instead of "stella_setValue (STELLA_SET_IMMEDIATELY, 0, 255);" "PIN_SET (LED)" and "PIN_CLEAR (LED)" can be used (named pin).
|Named PIN]]).
Send IR commands
dnl 01 = SIRCS
dnl 02 = NEC
dnl 03 = SAMSUNG
dnl 04 = MATSUSHITA
dnl 05 = KASEIKYO
dnl 06 = RECS80
dnl 07 = RC5(x)
dnl 08 = DENON
dnl 09 = RC6
dnl 10 = SAMSUNG32
dnl 11 = APPLE
dnl 12 = RECS80EXT
dnl 13 = NUBERT
dnl 14 = BANG&OLUFSEN
dnl 15 = GRUNDIG
dnl 16 = NOKIA
dnl 17 = SIEMENS
dnl 18 = FDC
dnl 19 = RCCAR
dnl 20 = JVC
dnl 21 = RC6A
dnl 22 = NIKON
dnl 23 = RUWIDO * no tx support yet
dnl 24 = IR60 * no tx support yet
dnl 25 = KATHREIN * no tx support yet
dnl 26 = NETBOX * no tx support yet
dnl 27 = NEC16
dnl 28 = NEC42
dnl 29 = LEGO
dnl 30 = THOMSON * no tx support yet
IRMP_PROTOCOL = 2;
IRMP_ADDRESS = 1234;
IRMP_COMMAND = 5678;
IRMP_FLAGS = 1;
IRMP_WRITE;
Command 5678 to device 1234 will be send with one repetition using the NEC protocol.