Difference between revisions of "IRMP"

From Ethersex_Wiki
Jump to: navigation, search
 
(27 intermediate revisions by 5 users not shown)
Line 2: Line 2:
 
{{Module
 
{{Module
 
|NAME=IRMP
 
|NAME=IRMP
|MENUCONFIG={{I/O}}->IR->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]].
 +
 +
 +
== 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''' 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 [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
 +
  │ │                      [ ] 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|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 [[StellaLight|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 = 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;
 +
</source>
 +
 +
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.