IRlib on STM32?

Can someone help me port this library?
stevech
Posts: 441
Joined: Thu Aug 27, 2015 6:32 am

Re: IRlib on STM32?

Post by stevech » Wed Apr 27, 2016 3:57 am

Very interesting article part 1 on IR with microprocessors.

Circuit Cellar magazine. May 2016.

User avatar
Just4Fun
Posts: 61
Joined: Tue Jan 05, 2016 9:48 pm
Contact:

Re: IRlib on STM32?

Post by Just4Fun » Fri Apr 29, 2016 6:34 pm

Last version 2.1.0 of IRremote library (https://github.com/z3t0/Arduino-IRremote) can be used with Teensy 3.0/3.1, that uses a 32bit ARM Cortex M4 MCU @72MHz, and Teensy-LC with a Cortex M0+ ARM. So the distance "may" be not so much... (anyway on Teensy 3.x CMT timer is used, that is a specialized timer in the Freescale MPU. Just a 2 minutes search...)

User avatar
rexnanet
Posts: 203
Joined: Wed Mar 16, 2016 10:34 am

Re: IRlib on STM32?

Post by rexnanet » Tue May 10, 2016 10:07 am

Just4Fun wrote:Last version 2.1.0 of IRremote library (https://github.com/z3t0/Arduino-IRremote) can be used with Teensy 3.0/3.1, that uses a 32bit ARM Cortex M4 MCU @72MHz, and Teensy-LC with a Cortex M0+ ARM. So the distance "may" be not so much... (anyway on Teensy 3.x CMT timer is used, that is a specialized timer in the Freescale MPU. Just a 2 minutes search...)
Thanks. I'll take a look and see if it's possible (easy) to port it to STM32.

Cmustard
Posts: 8
Joined: Sat Apr 09, 2016 3:17 pm

Re: IRlib on STM32?

Post by Cmustard » Fri May 13, 2016 10:02 am

The timer specific thingies on the STMs are not so easy.

If you have the STM32 variety that can do AND gate operations on 2 output clocks then it's much easier..
set the 38Khz signal as a base freq. and then turn the signal on and off on the 2nd timer to get the right output.
I could do it that way by combining two timers on separate pins but that would consume two pins and needs two extra transistors on the outside for F103.type boards which is probably what the majority of hobby bobs are using.
but that's a HW hack to get things right.

another way would be to build a mini timer circuit for the base freq. (e.g. 38Khz) using a 555 timer IC and a few resistors but again that's a HW hack I'd like to avoid if possible as it is a bit besides the point of a SW library.
but then again it would simplify the problem considerably :D

The reason I looked at IR lib is because the signal generation (protocol specific) and hardware part are split in the library itself.
and all is housed in separate functions which is great.
This makes IRlib pretty portable but the HW part proved more difficult to me than initally expected (due to the points mentioned above).
In the current library there is a lot of low level AVR stuff going on to get the timings right
(stop interrupts, register pusing and shoving enabling interrupts again etc.)
In the STM's this could be done similar but that might have a huge impact on the interrups and thus possibly on other libraries/functions in a project.
so I'm not too fond of that method and am looking for alternatives.
It looks like I'll not be having something working soon BTW.
Also becaue I'm struggling in how to combine HAL stuff with the duino IDE I'm not sure how much I end up in conflict with the core libs by doing so.

And especially as I'm not a seasoned programmer things take extra time :-(
but still it's good time spent !

Paul

User avatar
zoomx
Posts: 496
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: IRlib on STM32?

Post by zoomx » Fri May 13, 2016 10:46 am

I found this german post
IRMP on STM32 - a USB IR receiver / transmitter / off switch with wakeup timer
https://www.mikrocontroller.net/article ... keup-Timer

Here with Google translate
https://translate.google.it/translate?s ... edit-text=

User avatar
Just4Fun
Posts: 61
Joined: Tue Jan 05, 2016 9:48 pm
Contact:

Re: IRlib on STM32?

Post by Just4Fun » Fri May 13, 2016 11:03 am

zoomx wrote:I found this german post
IRMP on STM32 - a USB IR receiver / transmitter / off switch with wakeup timer
https://www.mikrocontroller.net/article ... keup-Timer
Very interesting.... they have implemented a multiprotocol suite.. like IRremote...

PS: Buon pranzo zoomx... :lol: (have a nice lunch...)

User avatar
zoomx
Posts: 496
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: IRlib on STM32?

Post by zoomx » Fri May 13, 2016 12:31 pm

Grazie! Thanks! ;)

Found an original english page here
https://www.mikrocontroller.net/articles/IRMP_-_english

User avatar
rexnanet
Posts: 203
Joined: Wed Mar 16, 2016 10:34 am

Re: IRlib on STM32?

Post by rexnanet » Fri May 27, 2016 3:39 pm

zoomx wrote:I found this german post
IRMP on STM32 - a USB IR receiver / transmitter / off switch with wakeup timer
https://www.mikrocontroller.net/article ... keup-Timer
Can't this be used to get a STM32duino version working?
I haven't looked deep into the code but maybe some of it could be ported here... even in a ".c" library for example...
Cmustard wrote:The timer specific thingies on the STMs are not so easy.

If you have the STM32 variety that can do AND gate operations on 2 output clocks then it's much easier..
set the 38Khz signal as a base freq. and then turn the signal on and off on the 2nd timer to get the right output.
I could do it that way by combining two timers on separate pins but that would consume two pins and needs two extra transistors on the outside for F103.type boards which is probably what the majority of hobby bobs are using.
but that's a HW hack to get things right.
Does the AVR have a special feature on the timers that make this library easier than on STM32?

gasparobr
Posts: 7
Joined: Tue Jan 17, 2017 4:15 pm

Re: IRlib on STM32?

Post by gasparobr » Tue Jan 17, 2017 4:21 pm

Hi I tried to compile this with STM32duino, but it not work. I keep having a lot of erros. Does any one had sucess with any IR library for STM32?

zoomx wrote:I found this german post
IRMP on STM32 - a USB IR receiver / transmitter / off switch with wakeup timer
https://www.mikrocontroller.net/article ... keup-Timer

Here with Google translate
https://translate.google.it/translate?s ... edit-text=
Arduino: 1.6.12 (Mac OS X), Placa:"Generic STM32F103Z series, STM32F103ZE, STM32duino bootloader"


# warning The STM32 port of IRMP uses the ST standard peripheral drivers which are not enabled in your build configuration.

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.c: In function 'irmp_init':
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:40:56: error: 'GPIOB' undeclared (first use in this function)
# define IRMP_PORT CONCAT(GPIO, IRMP_PORT_LETTER)

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:38:49: note: in definition of macro '_CONCAT'
# define _CONCAT(a,b) a##b

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:40:49: note: in expansion of macro 'CONCAT'
# define IRMP_PORT CONCAT(GPIO, IRMP_PORT_LETTER)

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.c:2193:5: note: in expansion of macro 'IRMP_PORT'
IRMP_PORT &= ~(1<<IRMP_BIT); // deactivate pullup

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:40:56: note: each undeclared identifier is reported only once for each function it appears in
# define IRMP_PORT CONCAT(GPIO, IRMP_PORT_LETTER)

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:38:49: note: in definition of macro '_CONCAT'
# define _CONCAT(a,b) a##b

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:40:49: note: in expansion of macro 'CONCAT'
# define IRMP_PORT CONCAT(GPIO, IRMP_PORT_LETTER)

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.c:2193:5: note: in expansion of macro 'IRMP_PORT'
IRMP_PORT &= ~(1<<IRMP_BIT); // deactivate pullup

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:48:56: error: 'GPIO_Pin_6' undeclared (first use in this function)
# define IRMP_BIT CONCAT(GPIO_Pin_, IRMP_BIT_NUMBER)

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:38:49: note: in definition of macro '_CONCAT'
# define _CONCAT(a,b) a##b

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:48:49: note: in expansion of macro 'CONCAT'
# define IRMP_BIT CONCAT(GPIO_Pin_, IRMP_BIT_NUMBER)

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.c:2193:23: note: in expansion of macro 'IRMP_BIT'
IRMP_PORT &= ~(1<<IRMP_BIT); // deactivate pullup

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.c:2194:5: error: 'IRMP_DDR' undeclared (first use in this function)
IRMP_DDR &= ~(1<<IRMP_BIT); // set pin to input

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.c: In function 'irmp_ISR':
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.c:2764:5: warning: implicit declaration of function 'GPIO_ReadInputDataBit' [-Wimplicit-function-declaration]
irmp_input = input(IRMP_PIN);

^
In file included from /Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.c:25:0:
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:40:56: error: 'GPIOB' undeclared (first use in this function)
# define IRMP_PORT CONCAT(GPIO, IRMP_PORT_LETTER)

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:50:72: note: in definition of macro 'input'
# define input(x) (GPIO_ReadInputDataBit(x, IRMP_BIT))

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:39:49: note: in expansion of macro '_CONCAT'
# define CONCAT(a,b) _CONCAT(a,b)

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:40:49: note: in expansion of macro 'CONCAT'
# define IRMP_PORT CONCAT(GPIO, IRMP_PORT_LETTER)

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:49:49: note: in expansion of macro 'IRMP_PORT'
# define IRMP_PIN IRMP_PORT // for use with input(x) below

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.c:2764:24: note: in expansion of macro 'IRMP_PIN'
irmp_input = input(IRMP_PIN);

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:48:56: error: 'GPIO_Pin_6' undeclared (first use in this function)
# define IRMP_BIT CONCAT(GPIO_Pin_, IRMP_BIT_NUMBER)

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:38:49: note: in definition of macro '_CONCAT'
# define _CONCAT(a,b) a##b

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:48:49: note: in expansion of macro 'CONCAT'
# define IRMP_BIT CONCAT(GPIO_Pin_, IRMP_BIT_NUMBER)

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.h:50:75: note: in expansion of macro 'IRMP_BIT'
# define input(x) (GPIO_ReadInputDataBit(x, IRMP_BIT))

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.c:2764:18: note: in expansion of macro 'input'
irmp_input = input(IRMP_PIN);

^
/Users/nancysbinda/Documents/Arduino/libraries/irmp/irmp.c:3594:25: warning: implicit declaration of function 'memcpy_P' [-Wimplicit-function-declaration]
memcpy_P (&irmp_param, irmp_param_p, sizeof (IRMP_PARAMETER));

^
Usando biblioteca irmp na pasta: /Users/nancysbinda/Documents/Arduino/libraries/irmp (legacy)
exit status 1
Erro compilando para a placa Generic STM32F103Z series
Biblioteca inválida encontrada em /Users/nancysbinda/Documents/Arduino/libraries/hardware: /Users/nancysbinda/Documents/Arduino/libraries/hardware
Biblioteca inválida encontrada em /Users/nancysbinda/Documents/Arduino/libraries/libraries: /Users/nancysbinda/Documents/Arduino/libraries/libraries
Biblioteca inválida encontrada em /Users/nancysbinda/Documents/Arduino/libraries/hardware: /Users/nancysbinda/Documents/Arduino/libraries/hardware
Biblioteca inválida encontrada em /Users/nancysbinda/Documents/Arduino/libraries/libraries: /Users/nancysbinda/Documents/Arduino/libraries/libraries

User avatar
ahull
Posts: 1597
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: IRlib on STM32?

Post by ahull » Tue Jan 17, 2017 10:52 pm

You can cheat a bit if you want to send and receive serial data over IR. -> http://www.ebay.com/itm/5V-IR-Infrared- ... SwGYVXBLQW

For what its worth, here is ST's take on the problem -> http://www.st.com/content/ccc/resource/ ... 053084.pdf

It would be good to get a software only solution of course, either based on ST''s approach or perhaps using DMA to shift out a 1010101 bit stream at 36 38 or 40kHz in to which we inject our data. Getting the timing right is of course the big trick with IR, but from personal experience (my day job involves software development for set TV top boxes for Hotels), once you have your that nailed, the rest is relatively trivial.
- Andy Hull -

Post Reply