Jump to content


Photo

External IR receiver to which will alow you to use others remote controls


  • Please log in to reply
20 replies to this topic

#1 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 31 May 2018 - 18:58

Hello,
 
I am preparing very cheap external IR receiver connected via USB or RS232TTL which will alow you to use others remote controls (for example from others set-top-box).
I already prepared prototype hardware connected via USB and using it on H2H set-top-box. 
 
I can use any remote using NEC protocols. Support for remotes using others protocol can be easy added if I have such one.
The core of this hardware extension is ATtiny2313 mikroprocesor.  To be able to connect it to STB via USB I used cheap PL2303HX and IR decoder TSOP4838.
 
Cost of all used hardware component is less than 4$. If your set-top-box have RS232 port or you can open your STB and locate RS232 TTL on the motherboard then then you can connect it directly.
So, PL2303HX will be not needed (made hardware cheaper) and it will not take USB port.
 
When I have some time I will provide schemes with pictures and instruction how/to. I think that this project can be useful for many users :)
 
Many, even good set-top-boxes, have not, so good remotes.  This can cause frustration, sometimes.
With this very cheap hardware extension this will be no more problem.

 

Are you interested with such hardware?


Edited by samsamsam, 31 May 2018 - 18:59.


Re: External IR receiver to which will alow you to use others remote controls #2 Persian Prince

  • Senior Member
  • 1,982 posts

+247
Excellent

Posted 31 May 2018 - 19:49

+100 ;)

Open Vision sources: https://github.com/OpenVisionE2


Re: External IR receiver to which will alow you to use others remote controls #3 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 1 June 2018 - 23:11

This is hardware of External IR receiver which I am using currently with Zgemma H2H STB:
 
extended_usb_ir_receiver.png
 
1. ATtiny2313 datasheets
 
2. TSOP4838


Re: External IR receiver to which will alow you to use others remote controls #4 Abu Baniaz

  • PLi® Contributor
  • 2,499 posts

+64
Good

Posted 2 June 2018 - 00:45

Pity we cant use LIRC like the Fulan receivers.

Re: External IR receiver to which will alow you to use others remote controls #5 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 2 June 2018 - 08:40

@Abu Baniaz

 

With such external receiver you will be able to use LIRC. But LIRC is not, so good as you think. 

When you know protocol and know your ir receiver spec then you can better handle key press, keys repeat, timeouts and so on.

But as I said with such external receiver there is no problem to use LIRC.


Edited by samsamsam, 2 June 2018 - 08:42.


Re: External IR receiver to which will alow you to use others remote controls #6 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 2 June 2018 - 14:50

Something about software.

 

For ATtiny2313  I used 

https://github.com/MalteP/nec-decoder

with some patches to better handle my remote. I will publick these patches later.

 

Additionally I flashed ATtiny2313 with bootloader to be able to update firmware via RS232.

 

Bootloader which I used:

https://www.avrfreak...em_type=project

fboot21.zip

 

To be able to flash compiled nec-decoder firmware via RS232 I used bootloader-1.1.tar.gz

https://www.avrfreak...em_type=project

 

So, at now I am able to update firmware of the ATtiny2313 without need to disconnect it from my set-top-box.

 

 

Enigma2:

To be able to use such external IR your kernel must have uinput driver (this is standard kernel driver).

Not all kernel have enabled this driver by default bud this is not problem at all. For example OpenPli image for "Miraclebox Premium Micro" does not have enabled uinput driver, so there is need to compile it separately and then insert it to kernel like that:

modprobe -f uniput.ko

 

Later I will provide description how to compile uinput driver for your set-top-box if you do not have it.

If you have /dev/uinput then you do not need to compile it.

 

 

To receive decoded key press from ATtiny2313 and expose it to enigma2 I write simple program:

https://github.com/s...er/serial_input

 

it must run on set-top-box as daemon.

 

It have simple config file in INI format (default location /etc/srcd ):

[config]
name = ATtiny2313-uinput
serial = /dev/ttyUSB0
uinput = /dev/uinput
delay = 300
period = 80
 
[keymap]
# https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h
# map key code to linux event code
0 = 3      ; KEY_1;
1 = 3      ; KEY_2;
2 = 4      ; KEY_3;
3 = 5      ; KEY_4;
4 = 6      ; KEY_5;
5 = 7      ; KEY_6;
6 = 8      ; KEY_7;
7 = 9      ; KEY_8;
8 = 10     ; KEY_9;
9 = 11     ; KEY_0;
10 = 115   ; KEY_VOLUMEUP;
11 = 114   ; KEY_VOLUMEDOWN;
12 = 402   ; KEY_CHANNELUP;
13 = 403   ; KEY_CHANNELDOWN;
16 = 103   ; KEY_UP;
17 = 105   ; KEY_LEFT;
18 = 108   ; KEY_DOWN;
19 = 106   ; KEY_RIGHT;
20 = 352   ; KEY_OK;
21 = 174   ; KEY_EXIT;
27 = 364   ; KEY_FAVORITES;
30 = 116   ; KEY_POWER;
32 = 113   ; KEY_MUTE;
33 = 358   ; KEY_INFO;
34 = 399   ; KEY_GREEN;
35 = 400   ; KEY_YELLOW;
36 = 401   ; KEY_BLUE;
37 = 398   ; KEY_RED;
38 = 139   ; KEY_MENU;
43 = 385   ; KEY_RADIO;
44 = 174   ; KEY_EXIT; //KEY_BACK;
48 = 412   ; KEY_PREVIOUS;
49 = 388   ; KEY_TEXT;
52 = 370   ; KEY_SUBTITLE;
54 = 395   ; KEY_LIST;
55 = 365   ; KEY_EPG;
56 = 392   ; KEY_AUDIO;
69 = 168   ; KEY_REWIND;
70 = 128   ; KEY_STOP;
71 = 164   ; KEY_PLAYPAUSE;
72 = 208   ; KEY_FASTFORWARD;
74 = 167   ; KEY_RECORD;
75 = 357   ; KEY_OPTION;

 

As I wrote this program receive key code from ATtiny2313 via RS232 then map it to  linux event code used by Enigma2 and insert it to kernel via uinput driver.

Kernel will create additional /dev/input/eventX device which will be used by enigma2, so there is NO need to made any change in the Enigma2.

 

Maybe description is not so simple but this is really simple. 

https://github.com/s...er/serial_input

 



Re: External IR receiver to which will alow you to use others remote controls #7 Martin_B

  • Senior Member
  • 115 posts

0
Neutral

Posted 7 June 2018 - 10:48

This is absolutely great!

Thanks a lot!

 

I tried the same by bulding an IR receiver (Arduino Nano) to receive IR codes an send (translated) IR-Codes.

But your solution is much better.

 

Unfortunately I have no idea what to do exactely to get it to work.

 

- Build up hardware (no problem)

But I do not understand the next steps ...

 

Do you think it would be possible to have it as a Plugin?

Connect Hardware an ready to go?


Edited by Martin_B, 7 June 2018 - 10:49.


Re: External IR receiver to which will alow you to use others remote controls #8 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 8 June 2018 - 16:33

Hello,

 

The "biggest problem" is to program ATtiny2313A bootloader.

When got ATtiny2313A there is no any program at flash and you will not be able to flash it using UART (RX/TX pins).

 

So, you must program it using external programmer (RESET, SCL, MISO, MOSI pins).

With programmer you must flash ATtiny2313A  with bootloader and enable self-programming. 

 

Then you will not need external programmer any more, because you will be able to flash your ATtiny via  UART (RX/TX pins).

So, yes it will be possible to have this as plugin. 

And not, connect hardware will be not enough because you must flash ATtiny2313A with bootloader and enable self programming.

You not need to buy external programmer. There is manny project how made simple programmer. 

For example I using Raspberry Pi to flash bootloader and set valid fuse bits.

 

Let, me know if you interested with such method. I can wrote simple FAQ how to program your ATtiny2313A  using Raspberry Pi.



Re: External IR receiver to which will alow you to use others remote controls #9 Martin_B

  • Senior Member
  • 115 posts

0
Neutral

Posted 9 June 2018 - 07:06

I would use an arduino-nano clone.

I have program code ready to receive IR codes from remote.

I would then "translate" the codes to event codes listed above (3, 4, ... 358, ...) correct?

And send these codes via RS232 (/*baudrate B9600, 8 bits, no parity, 1 stop bit */) correct?

 

0 = 3      ; KEY_1;
1 = 3      ; KEY_2;
2 = 4      ; KEY_3

 

Should it be 0=2, 1=3, 2=4 ?

 

Then I have to run your program on box:
 

To receive decoded key press from ATtiny2313 and expose it to enigma2 I write simple program:

https://github.com/s...er/serial_input

it must run on set-top-box as daemon.

 

 

Sorry for the dump questions, but I have no idea how to run it on my box

and how to run it as deamon ...

 

One more question;

Will it be possible to start the box with alternative remote?

Or will I have to use original remote to start the box (VU SOLO)?


Edited by Martin_B, 9 June 2018 - 07:09.


Re: External IR receiver to which will alow you to use others remote controls #10 Persian Prince

  • Senior Member
  • 1,982 posts

+247
Excellent

Posted 9 June 2018 - 07:18

I have RPi3, would you please help me to program the ATtiny2313A?


Open Vision sources: https://github.com/OpenVisionE2


Re: External IR receiver to which will alow you to use others remote controls #11 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 9 June 2018 - 13:39

@Martin_B

 

​When you receive key code from your REMOTE on the MCU  microcontroller) site, you should send it as is via UART (/*baudrate B9600, 8 bits, no parity, 1 stop bit */).

You should not made any key code translation on the MCU site.

 

For example you will press key "1" on your remote and your MCU will receive code for example "0", because when you press key 1 on our remote it send code 0 (this is only example).

So, you send message:

P 000

if you will not receive any repeat  key during some timeout (typically 120ms) then you need to send release message via UART.

R 000

 

Because, your remote send 0 when key 1 is pressed (this is only example).

So, you should add following row to [keymap in the /etc/srcd.ini.:

0 = 3      ; KEY_1;  

This mean: when you receive code 0 send KEY_1 event to kernel via /dev/uinput device. In the kernel KEY_1 is defined as 3.

 

You should not send repeat  key codes received by your remote. You need to send press and release messages only.

Key release can be detected using timeout and this should be done on MCU site.

 

 


Sorry for the dump questions, but I have no idea how to run it on my box

 

It need to be compiled first. You can use this http://iptvplayer.vl...xternal_ir/srcd precompiled version form MIPSEL hard FPU.

 

 


and how to run it as deamon ...

Before you run it as demon first you can check if everything is working when you run is manually.

 

From your set-top-box console:

cd /tmp
wget http://iptvplayer.vline.pl/external_ir/srcd
chmod 777 srcd
./srcd

One more question;

Will it be possible to start the box with alternative remote?

Or will I have to use original remote to start the box (VU SOLO)?

 

What you mean by "start the box"? Are you asking about to wake up set-top-box from deep standby? 


Edited by samsamsam, 9 June 2018 - 13:41.


Re: External IR receiver to which will alow you to use others remote controls #12 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 9 June 2018 - 17:03

As I wrote, in the first post, if set-top-box has UART than there is possible to connect external IR receiver directly to UART.

With this solution all hardware can be hidden inside set-top-box.

 

An additional advantage is to connect ATtiny2313A to power button on front panel to be possible to our external IR receiver be able to wake up set-top-box from deep standby.

 

I made such hardware for Zgemma H2H.

 

Below I present real photos:

http://iptvplayer.vl...ternal_ir/1.jpg

http://iptvplayer.vl...ternal_ir/2.jpg

http://iptvplayer.vl...ternal_ir/3.jpg

http://iptvplayer.vl...ternal_ir/4.jpg

http://iptvplayer.vl...ernal_ir/5a.jpg

http://iptvplayer.vl...ernal_ir/5b.jpg



Re: External IR receiver to which will alow you to use others remote controls #13 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 9 June 2018 - 17:42

@Persian Prince

Here is very nice article how to use Raspberry Pi gpio pins to programm ATtiny2313A.

https://learn.adafru...o-pins/overview

 

Generally you can do this as follow (all commands should be executed from RPi console):

sudo apt-get install avrdude
cp /etc/avrdude.conf /home/pi/avrdude_gpio.conf

 

Edit configuration file and add section:

# Linux GPIO configuration for avrdude.
# Change the lines below to the GPIO pins connected to the AVR.
programmer
  id    = "pi_3";
  desc  = "Use the Linux sysfs interface to bitbang GPIO lines";
  type  = "linuxgpio";
  reset = 12;
  sck   = 24;
  mosi  = 23;
  miso  = 18;
;

 

You should use GPIO pins which you have free on your pi.

 

The connect ATtiny2313A  according to this section. Additionally you need to connect:

ATtiny2313A VCC to Raspberry Pi 3,3 volt pin.
ATtiny2313A GND to Raspberry Pi ground pin.
 
First you need to change ATtiny2313A  fuse bits to allow self programming and disable CLOCK DIV by 8:
avrdude -p t2313 -C /home/pi/avrdude_gpio.conf -c pi_3 -v -U lfuse:w:0xe4:m -U hfuse:w:0xdf:m -U efuse:w:0xfe:m
 
Then you can program your ATtiny2313A  with bootloader:
wget http://iptvplayer.vline.pl/external_ir/BootloaderAttiny2313.hex
avrdude -p t2313 -C /home/pi/avrdude_gpio.conf -c pi_1 -v -U flash:w:/home/pi/BootloaderAttiny2313.hex:i


Re: External IR receiver to which will alow you to use others remote controls #14 Martin_B

  • Senior Member
  • 115 posts

0
Neutral

Posted 9 June 2018 - 19:02

Thanks for the pictures!

 

5a questions:

 

1: UART: GND, RX, TX, GND correct?

2: IR Receiver + - SIG

3: +5V, GND correct?

4: ?



Re: External IR receiver to which will alow you to use others remote controls #15 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 9 June 2018 - 20:05

1. UART

From left to right:  

    U_P1  (white):  GND

    U_P2  (blue):    RX (need to be connected to TX pin of the ATtiny2313A)

    U_P3  (black):  TX (need to be connected to RX pin of the ATtiny2313A)

    U_P4:  3.3V (power - not available in deep standby, It is connected to PD5 pin (configured as input) of  the ATtiny2313A to detect if set-top-box is in the low power mode or not)

 

2. IR receiver (TSOP4838)

    YELLOW:  OUT (need to be connected to INT0 pin of the ATtiny2313A)

    ORANGE: GND

    RED: Vs (3,3V) 

 

3. This is ON/OFF button from front panel:

    BLUE: GND

    GREEN: input (high ~3,3)

   I use this connection to be able to "emulate" power button press from ATtiny2313A.

   So, I connect to this pins bipolar transistor NPN (BC546B). Blue to emmiter, GREEN collector. Base is connected via 10K resistor to pin PD4 (configured as output)  of the ATtiny2313A 

   In case when Set-top-box is in the deep standby then there is no sens to send RCU commands via UART because linux is not working. To be able to wake UP set-top-box from deep standby/low power mode (when linux is not working)  I emulate press of Power button on front panel, when user press POWER key on the remote. 

 

4. 

This is power 3.3 V (available even if the set-top-box is in the deep standby/low power mode) connected to pin  20 VCC of the ATtiny2313A. 

 

I will provide scheme later.

 

I do not have VU SOLO, so I do not know if this set-top-box have UART available on mainboard and if it have POWER button on front pannel. 

Anyway if someone not use deep standby/lowe power mode (most users does not use) then there is no need to "emulate" press of the POWER button from front panel.


Edited by samsamsam, 9 June 2018 - 20:09.


Re: External IR receiver to which will alow you to use others remote controls #16 Martin_B

  • Senior Member
  • 115 posts

0
Neutral

Posted 9 June 2018 - 20:25

Ok Thanks again.

I will try and report.

 

Great project !!

 

Regards Martin



Re: External IR receiver to which will alow you to use others remote controls #17 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 10 June 2018 - 11:52

zgemma_h2h_schem.png



Re: External IR receiver to which will alow you to use others remote controls #18 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 7 April 2019 - 18:39

Similar modification for the Zgemma H9 Combo:

Attached Files



Re: External IR receiver to which will alow you to use others remote controls #19 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 7 April 2019 - 19:00

There are two difference between in the modyfication for Zgemma H9 models.

 

1. 3.3V power from RS232 connector is available also in deep standby, so this line can be used to power ATtiny2313A.

The diffrence point is used to detect if set-top-box is in the low power mode or not.

 

2. H9 models does not have power button, so to be able to wake up STB from deep standby the different approach is used.

We will not use transistor to simulate power button press, but we will send original POWER remote button code using IR line to achieve this.

 

Two switching diodes 1N4148, one to connect out line from orginal IR receiver and one to connect pin PD4 from ATtiny2313A (to be able to re-send orginal POWER code in case when ATtiny2313A receives power button from our remote but STB is in the deep standby).

 

One more important thing! My Zgemma H9 Combo has Rs232 connector soldered the other way around. So, there is need to check were is GND and were is 3.3V, same with RX and TX.

 

If you compare Zgemma H9S and Zgemma H9 Combo the RS232 pins from left to right are same but connector is soldered vice versa.



Re: External IR receiver to which will alow you to use others remote controls #20 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 7 April 2019 - 19:16

All software used by me for this modification:

 

1. Bootloader for ATtiny2313A

https://github.com/e...vr_fastboot.git

 

2. Firmware for ATtiny2313A:

 
3, Demon working on STB which receive key codes from ATtiny2313A map them to linux event codes:
 
4. Utility which allow update ATtiny2313A firmware (which already has avr_fastboot) directly from the STB via RS232

Edited by samsamsam, 7 April 2019 - 19:17.



8 user(s) are reading this topic

0 members, 8 guests, 0 anonymous users