Difference between revisions of "IRMP"

From Ethersex_Wiki
Jump to: navigation, search
(quelltextpassagen korrigiert)
 
(23 intermediate revisions by 3 users not shown)
Line 2: Line 2:
 
{{Module
 
{{Module
 
|NAME=IRMP
 
|NAME=IRMP
|MENUCONFIG={{I/O}}->IR Receivers->IRMP
+
|MENUCONFIG={{I/O}}->IR Receivers->IRMP IR
 
|STATUS={{stable}}
 
|STATUS={{stable}}
 
|PINNING=yes
 
|PINNING=yes
Line 9: Line 9:
 
|DEPENDS=[[ECMD]]
 
|DEPENDS=[[ECMD]]
 
|REQUIRES= -
 
|REQUIRES= -
 +
|TIMER={{occupies_timer|0}}&{{occupies_timer|2}} (RX & TX)
 
|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]
 
}}
 
}}
 +
 +
[[File:Irm.jpg|200px|thumb|right|IR sender/receiver module with display and USB connector]]
  
 
IRMP is a port of the [http://www.mikrocontroller.net/articles/IRMP infrared multi-protocol decoder] for [[Ethersex]].
 
IRMP is a port of the [http://www.mikrocontroller.net/articles/IRMP infrared multi-protocol decoder] for [[Ethersex]].
Line 38: Line 41:
 
* IRMP_RX_LOW_ACTIVE - the IR receiver is low-active (undef = high-active)
 
* 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_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 - 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''' Without an external modulator, pins other than OC0 or 0C2 can not be used. Trying to do so will fail without an error message.
 
* IRMP_TX_LED_LOW_ACTIVE - the control LED of the sender is switched to USS (undef = switched to GND)
 
* IRMP_TX_LED_LOW_ACTIVE - the control LED of the sender is switched to USS (undef = switched to GND)
  
 
== Configuration ==
 
== 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].
+
Each supported IR protocol occupies memory of code. Therefore, one should select only the required protocols. A detailed overview of the protocols are in [http://www.mikrocontroller.net/articles/IRMP#Die_IR-Protokolle_im_Detail article in the mikrocontroller forum].
  
 
   │ │          Load a Default Configuration  --->
 
   │ │          Load a Default Configuration  --->
Line 66: Line 69:
 
   │ │                      [*] IRMP ecmd
 
   │ │                      [*] IRMP ecmd
 
   │ │                      --- Protocols
 
   │ │                      --- Protocols
   │ │                      [ ] SIRCS
+
   │ │                      [ ] A1TVBOX
   │ │                      [*] NEC
+
   │ │                      [ ] ACP24
   │ │                      [ ] 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
 
   │ │                      [ ] THOMSON
 +
  │ │                      [ ] VINCENT
 +
  │ │                      --- Network
 +
  │ │                      [*] Remote IRMP
 +
  │ │                      (10001) UDP port (default 10001)
 
   │ │                      --- Debugging Flags
 
   │ │                      --- Debugging Flags
   │ │                      [ ] IRMP Debug
+
   │ │                      [ ] IRMP
 
+
  │ │                      [ ] Remote IRMP
  
 
IRMP also decodes the RC5 protocol, so that the separately [[Ethersex]] contained [[RC5]] decoder is not needed any longer.
 
IRMP also decodes the RC5 protocol, so that the separately [[Ethersex]] contained [[RC5]] decoder is not needed any longer.
Line 101: Line 85:
 
== [[ECMD]] ==
 
== [[ECMD]] ==
  
IRMP implements a [[ECMD]] interface for reading received and decoded IR commands and send IR commands. See [[ECMD_Reference|ECMD reference]].
+
IRMP implements an [[ECMD]] interface for reading received and decoded IR commands and send IR commands. See [[ECMD_Reference|ECMD reference]].
  
 
== [[Control6|Control6]] ==
 
== [[Control6|Control6]] ==
Line 107: Line 91:
 
=== Output received characters via [[SYSLOG|Syslog]] ===
 
=== Output received characters via [[SYSLOG|Syslog]] ===
  
CONTROL_START
+
<source lang="text">
+
 
THREAD(read_irmp)
+
CONTROL_START
ON IRMP_READ > 0 DO
+
 
  SYSLOG("IRMP %02hhd:%04hX:%04hX:%02hhX\n",
+
THREAD(read_irmp)
 +
ON IRMP_READ > 0 DO
 +
  SYSLOG("IRMP %02hhd:%04hX:%04hX:%02hhX\n",
 
         IRMP_PROTOCOL, IRMP_ADDRESS, IRMP_COMMAND, IRMP_FLAGS);
 
         IRMP_PROTOCOL, IRMP_ADDRESS, IRMP_COMMAND, IRMP_FLAGS);
END
+
END
THREAD_END(read_irmp)
+
THREAD_END(read_irmp)
+
 
ON STARTUP DO
+
ON STARTUP DO
  THREAD_START(read_irmp);
+
  THREAD_START(read_irmp);
END
+
END
+
 
CONTROL_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.
 
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 ===
+
=== Control of [[StellaLight|Stella]]/Pins by IR commands ===
  
C6_HEADER(`/* This will be in control6.h */')
+
<source lang="text">
#include "services/stella/stella.h"
+
 
CONTROL_START
+
C6_HEADER(`/* This will be in control6.h */')
 +
#include "services/stella/stella.h"
 +
CONTROL_START
 
   
 
   
THREAD(control_stella)
+
THREAD(control_stella)
ON IRMP_READ > 0 DO
+
ON IRMP_READ > 0 DO
  if(IRMP_PROTOCOL==8 && IRMP_ADDRESS==0x0002)
+
  if(IRMP_PROTOCOL==8 && IRMP_ADDRESS==0x0002)
  {
+
  {
    switch(IRMP_COMMAND)
+
    switch(IRMP_COMMAND)
    {
+
    {
        case 0x0268:
+
      case 0x0268:
          stella_setValue(STELLA_SET_IMMEDIATELY, 0, 255);
+
          stella_setValue(STELLA_SET_IMMEDIATELY, 0, 255);
          break;
+
          break;
 +
 
 +
      case 0x0068:
 +
          stella_setValue(STELLA_SET_IMMEDIATELY, 0, 0);
 +
          break;
 +
    }
 +
  }
 +
END
 +
THREAD_END(control_stella)
 
   
 
   
        case 0x0068:
+
ON STARTUP DO
          stella_setValue(STELLA_SET_IMMEDIATELY, 0, 0);
+
  THREAD_START(control_stella);
          break;
+
END
    }
 
  }
 
END
 
THREAD_END(control_stella)
 
 
   
 
   
ON STARTUP DO
+
CONTROL_END
  THREAD_START(control_stella);
+
 
END
+
</source>
 
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.<br>
 
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>
Line 160: Line 152:
 
=== Send IR commands ===
 
=== Send IR commands ===
  
dnl 01 = SIRCS
+
<source lang="text">
dnl 02 = NEC
+
dnl 01 = SIRCS
dnl 03 = SAMSUNG
+
dnl 02 = NEC
dnl 04 = MATSUSHITA
+
dnl 03 = SAMSUNG
dnl 05 = KASEIKYO
+
dnl 04 = MATSUSH
dnl 06 = RECS80
+
dnl 05 = KASEIKYO
dnl 07 = RC5(x)
+
dnl 06 = RECS80
dnl 08 = DENON
+
dnl 07 = RC5
dnl 09 = RC6
+
dnl 08 = DENON
dnl 10 = SAMSUNG32
+
dnl 09 = RC6
dnl 11 = APPLE
+
dnl 10 = SAMSG32
dnl 12 = RECS80EXT
+
dnl 11 = APPLE
dnl 13 = NUBERT
+
dnl 12 = RECS80EX
dnl 14 = BANG&OLUFSEN
+
dnl 13 = NUBERT
dnl 15 = GRUNDIG
+
dnl 14 = BANG
dnl 16 = NOKIA
+
dnl 15 = GRUNDIG
dnl 17 = SIEMENS
+
dnl 16 = NOKIA
dnl 18 = FDC
+
dnl 17 = SIEMENS
dnl 19 = RCCAR
+
dnl 18 = FDC
dnl 20 = JVC
+
dnl 19 = RCCAR
dnl 21 = RC6A
+
dnl 20 = JVC
dnl 22 = NIKON
+
dnl 21 = RC6A
dnl 23 = RUWIDO   * no tx support yet
+
dnl 22 = NIKON
dnl 24 = IR60     * no tx support yet
+
dnl 23 = RUWIDO
dnl 25 = KATHREIN * no tx support yet
+
dnl 24 = IR60
dnl 26 = NETBOX   * no tx support yet
+
dnl 25 = KATHREIN
dnl 27 = NEC16
+
dnl 26 = NETBOX
dnl 28 = NEC42
+
dnl 27 = NEC16
dnl 29 = LEGO
+
dnl 28 = NEC42
dnl 30 = THOMSON   * no tx support yet
+
dnl 29 = LEGO
+
dnl 30 = THOMSON
IRMP_PROTOCOL = 2;
+
dnl 31 = BOSE
IRMP_ADDRESS = 1234;
+
dnl 32 = A1TVBOX
IRMP_COMMAND = 5678;
+
dnl 33 = ORTEK
IRMP_FLAGS = 1;
+
dnl 34 = TELEFUNKEN
+
dnl 35 = ROOMBA
IRMP_WRITE;
+
dnl 36 = RCMM32
 +
dnl 37 = RCMM24
 +
dnl 38 = RCMM12
 +
dnl 39 = SPEAKER
 +
dnl 40 = LGAIR
 +
dnl 41 = SAMSG48
 +
dnl 42 = MERLIN
 +
dnl 43 = PENTAX
 +
dnl 44 = FAN
 +
dnl 45 = S100
 +
dnl 46 = ACP24
 +
dnl 47 = TECHNICS
 +
dnl 48 = PANASONIC
 +
dnl 49 = MITSU_HEAVY
 +
dnl 50 = VINCENT
 +
dnl 51 = SAMSUNGAH
 +
dnl 52 = IRMP16
 +
dnl 53 = RADIO1
 +
 
 +
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.
 
Command 5678 to device 1234 will be send with one repetition using the NEC protocol.
 +
 +
== Remote IRMP ==
 +
[[File:Remote_buttler.png|200px|thumb|right|Android App]]
 +
This is an implementation of the [https://www.mikrocontroller.net/articles/Remote_IRMP Remote IRMP protocol ] in [[Ethersex]]. Control your HiFi equipment with your smartphone.

Latest revision as of 18:27, 10 May 2018

IRMP
Status
Stable
menuconfig I/O->IR Receivers->IRMP IR
Pinning yes
Ecmd yes
Control6 yes
Uses Timer Timer 0& Timer 2 (RX & TX)
Depends on ECMD
Requires -
Code https://github.com/ethersex/ethersex/tree/master/hardware/ir/irmp
IR sender/receiver module with display and USB connector

IRMP is a port of the 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)
    Caution: 0A to 2A if MCU with A / B channel Without an external modulator, pins other than OC0 or 0C2 can not be used. Trying to do so will fail without an error message.
  • 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 in 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
 │ │                      [ ] A1TVBOX
 │ │                      [ ] ACP24
 ...
 │ │                      [ ] THOMSON
 │ │                      [ ] VINCENT
 │ │                      --- Network
 │ │                      [*] Remote IRMP
 │ │                      (10001) UDP port (default 10001)
 │ │                      --- Debugging Flags
 │ │                      [ ] IRMP
 │ │                      [ ] Remote IRMP

IRMP also decodes the RC5 protocol, so that the separately Ethersex contained RC5 decoder is not needed any longer.

ECMD

IRMP implements an 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 = MATSUSH
dnl 05 = KASEIKYO
dnl 06 = RECS80
dnl 07 = RC5
dnl 08 = DENON
dnl 09 = RC6
dnl 10 = SAMSG32
dnl 11 = APPLE
dnl 12 = RECS80EX
dnl 13 = NUBERT
dnl 14 = BANG
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
dnl 24 = IR60
dnl 25 = KATHREIN
dnl 26 = NETBOX
dnl 27 = NEC16
dnl 28 = NEC42
dnl 29 = LEGO
dnl 30 = THOMSON
dnl 31 = BOSE
dnl 32 = A1TVBOX
dnl 33 = ORTEK
dnl 34 = TELEFUNKEN
dnl 35 = ROOMBA
dnl 36 = RCMM32
dnl 37 = RCMM24
dnl 38 = RCMM12
dnl 39 = SPEAKER
dnl 40 = LGAIR
dnl 41 = SAMSG48
dnl 42 = MERLIN
dnl 43 = PENTAX
dnl 44 = FAN
dnl 45 = S100
dnl 46 = ACP24
dnl 47 = TECHNICS
dnl 48 = PANASONIC
dnl 49 = MITSU_HEAVY
dnl 50 = VINCENT
dnl 51 = SAMSUNGAH
dnl 52 = IRMP16
dnl 53 = RADIO1

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.

Remote IRMP

Android App

This is an implementation of the Remote IRMP protocol in Ethersex. Control your HiFi equipment with your smartphone.