IRMP auf STM32 - ein USB IR Empfänger/Sender/Einschalter mit Wakeup-Timer

Aus der Mikrocontroller.net Artikelsammlung, mit Beiträgen verschiedener Autoren (siehe Versionsgeschichte)
Wechseln zu: Navigation, Suche

Ein IR Fernbedienungsempfänger mit vielen Funktionen auf Basis preiswerter Hardware.

Einleitung

Für ca. 4 - 8 € kann man auf ebay einen ST-Link Emulator oder ein STM32F103 Board kaufen, meistens in China hergestellt. Auf den darauf befindlichen STM32F103 Mikrocontroller wird eine Open Source Firmware mit vielen Funktionen geflasht.

Funktionen

  • Anschluss über USB
  • meldet sich als HID Device an, kein Treiber nötig, erscheint als „HID konformes Gerät“ oder /dev/hidraw
  • überträgt die Daten per USB2 in Hardware mit Fullspeed
  • IR Empfänger (ca. 40 Protokolle werden in HW dekodiert)
  • PC mit Fernbedienung Einschalten aus S3 (STR) und S4 (STD) über USB oder aus S3, S4 und S5 (SoftOff) über Motherboard-Schalter (+5V nötig, auf USB oder vom Netzteil/Motherboard zugeführt)
  • PC mit eingebautem Timer Einschalten aus S3 (STR) und S4 (STD) über USB oder aus S3, S4 und S5 (SoftOff) über Motherboard-Schalter (+5V nötig, auf USB oder vom Netzteil/Motherboard zugeführt)
  • IR Sender (ca. 40 Protokolle)
  • die Konfiguration wird im emulierten Eeprom gespeichert
  • im Rahmen der Größe des Eeproms beliebig viele Makros mit beliebiger Tiefe und beliebig viele Wakeups: MACRO_SLOTS x (MACRO_DEPTH + 1) + WAKE_SLOTS < 85 bei F103, < 170 bei F105

Open Source Software Linux

  • stm32IRconfig für die Konfiguration: Wakeup Code, Makros, Alarmzeit setzen und auslesen, IR senden und Anzeigen der empfangenen IR Codes
  • stm32IRalarm zum Alarmzeit setzen und auslesen per Skript
  • irmplircd ist ein Daemon, der im Hintergrund als eigenständiger lirc Server läuft und die IR Codes/events an die Anwendung weitergibt https://github.com/realglotzi/irmplircd
  • irctl für die Konfiguration: https://github.com/olebowle/irctl

Software Windows

  • SimpleHIDWrite empfängt Code vom und sendet Code zum Mikrocontroller

Download

https://github.com/j1rie/IRMP_STM32

Pinbelegung

IR Sendediode - PB6
Logging - PB10 = Tx, verbinden mit Rx vom USB-seriell-TTL
F103:
IR TSOP - PB11
Einschalter Motherboard - PB14 und über USB
Toggle LED - PB13
F105:
IR TSOP - PC6
Einschalter Motherboard - PB7 und über USB
Toggle LED - PB12

Firmware kompilieren

Linux: mit arm-none-eabi-gcc
Windows: mit Coocox CoIDE (benutzt auch arm-none-eabi-gcc)
http://www.olliw.eu/2013/stm32-this-and-that/#coocoxinstall

Firmware flashen

Firmware Flashen USB-seriell-TTL (STM32F103):
Ground und 5V bzw. 3,3V verbinden, Rx an Tx , Tx an Rx
BOOT0 Jumper auf 3,3V (Vorsicht, auf manchen Boards ist BOOT0 fälschlich mit BOOT1 beschriftet, Position siehe Bilder), Reset
./stm32flash -v -w /Pfad/IR.bin /dev/ttyUSB0
BOOT0 wieder auf Ground, Reset, USB neu anschliessen (oder USB Jumper ab, an)

Firmware Flashen über USB (STM32F105):
BOOT0 Jumper auf 3,3V, Reset, USB neu anschliessen (oder USB kurz auf low)
./dfu-util -a 0 -s 0x8000000 -D /Pfad/IR.bin
BOOT0 wieder auf Ground, Reset, USB neu anschliessen (oder USB kurz auf low)

Firmware Flashen mit ST-Link:
Programmer SWDIO -> Ziel PA13/TMS , Programmer SWCLK -> Ziel PA14/TCK , Gnd - Gnd, 3,3V – 3,3V

andere STM32 Mikrocontroller

  • die STM32F103 Firmware ist einfach anpassbar an STM32L1xx und STM32F3xx, da dieselbe USB Library genutzt wird
  • die STM32F105 Firmware ist einfach anpassbar an STM32F107, STM32F2xx und STM32F4xx, da dieselbe USB Library genutzt wird

Fotos

3pcs.jpg

Auf dem STM32F103C8T6 Entwickler Board sind BOOT0 und BOOT1 vertauscht beschriftet. Auf dem roten ST-Link Emulator ist das Plastik etwas aufgeschnitten. Auf dem blauen ST-Link Emulator sind CLK und TCK sowie DIO und TMS vertauscht.

Recv.jpg

Am Roten eine TSOP „Attrappe“ und 1 € zum Größenvergleich.
An den St-Links muss eventuell der PullUp Widerstand (Roter) bzw. PullDown Widerstand (Blauer) an SWIM entfernt werden. Oder man wählt eine Funktion, die dadurch nicht gestört wird.

STM32 based 3rd axis extension board for Alexmos gimbal controller.jpg

Mit diesem STM32F105 Board, das ursprünglich für die Kamera-Aufhängungs-Ansteuerung gedacht war, fing die Entwicklung an.

Jmpr flsh.jpg

Jumper Position für Flashen über Tx/Rx (auch wenn die Beschriftung vertauscht ist)

TODO

Download, Entpack und Patch Skript für Windows
Konfigurationsprogramme für Windows und Einbinden in Windows HTPC Anwendungen

Danke an

Frank Meyer für IRMP und IRSND. [1]
Uwe Becker für das Anpassen von IRMP und IRSND an den STM32F4xx
und seinen USB-HID für den STM32F4xx. [2]
Seine Arbeit war hilfreich, um mit dem STM32F105 anfangen zu können.
Andrew Kambaroff für seinen USB-HID für den STM32F103. [3]
Seine Arbeit war hilfreich, um mit dem STM32F103 anfangen zu können.
Ole Ernst für Code Review, Linux Makefile und Download-Auspack-Patch-Skript, viel bessere Makro Implementierung und neues Protokoll. [4]

[1] https://www.mikrocontroller.net/articles/IRMP
[2] http://mikrocontroller.bplaced.net/wordpress/?page_id=744
[3] http://sysmagazine.com/posts/208026/
[4] https://github.com/olebowle

Diskussion

Meinungen, Verbesserungsvorschläge, Kritik und Ähnliches kann im https://www.mikrocontroller.net/topic/347290 geäussert werden.

Bauanleitung

https://www.mikrocontroller.net/articles/IRMP_auf_STM32_-_Bauanleitung

Viel Spaß mit IRMP auf STM32!


IRMP on STM32 - a USB IR receiver/sender/powerswitch with wakeup-timer

A remote control receiver with many functions based on cheap hardware.

Introduction

For 4 - 8 € you can buy on ebay a ST-Link emulator or a STM32F103 development board, manufactured in China usually. Onto the STM32F103 mikrocontroller on it an open source firmware with many functions will be flashed.

Functions

  • connection via USB
  • registers as HID device, no driver needed, appears as /dev/hidraw or "Custom HID device"
  • transfers the data via USB2 in hardware with fullspeed
  • IR receiver (ca. 40 protocols decoded in hardware)
  • switch PC on via remote control from S3 (STR) and S4 (STD) via USB or from S3, S4 and S5 (SoftOff) via motherboard-switch (+5V needed, on USB or from PSU or motherboard)
  • switch PC on via build in timer from S3 (STR) and S4 (STD) via USB or from S3, S4 and S5 (SoftOff) via motherboard-switch (+5V needed, on USB or from PSU or motherboard)
  • IR sender (ca. 40 protocols)
  • the configuration is stored in the emulated eeprom
  • within eeprom size any number of macros with any depth and any number of wakeups: MACRO_SLOTS x (MACRO_DEPTH + 1) + WAKE_SLOTS < 85 for F103, < 170 for F105

Open Source Software Linux

  • stm32IRconfig for configuration: set and get wakeup code, macros, alarm time, send IR and show the received IR code
  • stm32IRalarm for setting and reading alarm time via script
  • irmplircd is a daemon, running in background as an independent lirc server and passing the IR codes/events on to the application https://github.com/realglotzi/irmplircd
  • irctl for configuration: https://github.com/olebowle/irctl

Software Windows

  • SimpleHIDWrite receives code from and sends code to the microcontroller

Download

https://github.com/j1rie/IRMP_STM32

Pin-Out

IR send diode - PB6
logging - PB10 = Tx, connect to Rx of USB-serial-TTL
F103:
IR TSOP – PB11
power on switch motherboard - PB14 and via USB
toggle LED - PB13
F105:
IR TSOP - PC6
power on switch motherboard - PB7 and via USB
toggle LED - PB12

Firmware Compilation

Linux: arm-none-eabi-gcc
Windows: Coocox CoIDE (uses arm-none-eabi-gcc too)
http://www.olliw.eu/2013/stm32-this-and-that/#coocoxinstall

Firmware Flashing

flash firmware with USB-serial-TTL (STM32F103):
connect ground and 5V resp. 3,3V, Rx - Tx , Tx - Rx
BOOT0 jumper on 3,3V, (caution, on some boards BOOT0 is labeled wrongly as BOOT1, see images for position), reset
./stm32flash -v -w /path/IR.bin /dev/ttyUSB0
BOOT0 back to ground, reset, reconnect USB (or USB jumper off, on)

flash firmware via USB (STM32F105):
BOOT0 jumper on 3,3V, reset, reconnect USB (or USB low shortly)
./dfu-util -a 0 -s 0x8000000 -D /path/IR.bin
BOOT0 back to ground, reset, reconnect USB (or USB low shortly)

flash firmware via ST-Link:
SWDIO -> PA13, SWCLK -> PA14, Gnd - Gnd, 3,3V - 3,3V

Other STM32 Microcontrollers

  • the STM32F105 firmware is easily customizable to STM32F107, STM32F2xx and STM32F4xx, as the same USB library is used
  • the STM32F103 firmware is easily customizable to STM32L1xx and STM32F3xx, as the same USB library is used

Images

3pcs.jpg

On the STM32F103C8T6 developer board BOOT0 and BOOT1 labels are exchanged. On the red ST-Link emulator the plastic is cut open some. On the blue ST-Link emulator CLK and TCK are exchanged and DIO und TMS as well.

Recv.jpg

Attached to the red a TSOP „dummy“ and 1 € for size comparison.
On the St-Links it might be necessary to remove the pullup resistor (red) or the pulldown resistor (blue) on SWIM. Or use a function, which is not disturbed by them.

STM32 based 3rd axis extension board for Alexmos gimbal controller.jpg

With this STM32F105 board, intended as camera gimbal controller, the development started.

Jmpr flsh.jpg

Jumper position for flashing via Tx/Rx (also if labeled incorrectly)

TODO

download, unpack and patch script for Windows
configuration programs for Windows and integration into Windows HTPC applications

Thanks to

Frank Meyer for IRMP und IRSND. [1]
Uwe Becker for adapting IRMP and IRSND to the STM32F4xx
and his USB-HID for the STM32F4xx. [2]
His work helped me in getting started with the STM32F105.
Andrew Kambaroff for his USB-HID for the STM32F103. [3]
His work helped me in getting started with the STM32F103.
Ole Ernst for code review, linux Makefile and download-extract-patch-script, much better macro implementation and new protocol. [4]


[1] https://www.mikrocontroller.net/articles/IRMP
[2] http://mikrocontroller.bplaced.net/wordpress/?page_id=744
[3] http://sysmagazine.com/posts/208026/
[4] https://github.com/olebowle

Discussion

Express opinions, suggestions for improvement, criticism and similar at https://www.mikrocontroller.net/topic/347290.
Much fun with IRMP on STM32!

Construction manual

https://www.mikrocontroller.net/articles/IRMP_auf_STM32_-_Bauanleitung