IRlib on STM32?

Can someone help me port this library?
Cmustard
Posts: 8
Joined: Sat Apr 09, 2016 3:17 pm

IRlib on STM32?

Post by Cmustard » Sun Apr 10, 2016 1:13 pm

Did anyone have some degree of success to get an infrared library working in send and recieve mode yet?

I found this nice initiative https://github.com/petoknm/STM32_NEC_Decode
but that's only focussing on the Decode piece and not the sending part.

As IRlib has done a great job in decoupling the HW related timer things from the decoding and sending logic I thought it might be a nice project to sink my teeth in.
maybe it's fairly easy to just focussing on the hardware specific parts in the library.

Although I'm not as seasoned as most of you guys out here on the board,
An I think it might be overly ambitious for me, but still may be worth a try.

Best regards,

Paul

User avatar
mrburnette
Posts: 1829
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: IRlib on STM32?

Post by mrburnette » Sun Apr 10, 2016 1:25 pm

@Paul,
Victor_pv was looking into it here and GarthC stated he was using NEC here.http://www.stm32duino.com/viewtopic.php ... t=20#p3896

But, I have an opinion on this (I would, would not I?) A tremendous amount of bandwidth is given up to a software IR solution, IMO. The STM32F1 has the clock cycles, but many years ago, I developed an independent uC approach based on a tiny85. I was doing some real time instrument displays for a friend that owns an Experimental plane and I simply did NOT want to interfere with my loop repetition rate by throwing in IR ... this was on an AVR 2560. I wanted IR to be used to set-up the realtime clock and to enter offsets, corrections factors, etc. In today's world, I would use Bluetooth.

Anyway,here is the dedicated t85 solution.

Ray
"Waste not your extra processor cycles today, you may need them tomorrow!"

User avatar
RogerClark
Posts: 7157
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: IRlib on STM32?

Post by RogerClark » Sun Apr 10, 2016 9:49 pm

@paul

One thing to bear in mind is that the example code uses STM's HAL API, but our core does not use the HAL. ( our core was originally written my Leaflabs long before they released the HAL API)

So you would need to replace the HAL calls with code to directly access the hardware ( but as the HAL is now open source, it would be reasonably easy to see what the HAL calls do, or possibky just copy them imto your code.)

I noticed that STM have several application notes on IR decoding and encoding, but I dont know if any apply to the F103 ( one AN is for the F0 and F3 but I dont know why they focussed on those to devices and not the F1 and F2 as well)

Anyway, if you choose to have a go at making a STM32 IR lib, I am sure it would be handy for a lot of people

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

Re: IRlib on STM32?

Post by Cmustard » Mon Apr 11, 2016 4:48 pm

Hi Gentle gentlemen,

I've found several timer docs and presentations that all the timing stuff could be handled by the hardware directly
as the STM32FXXX'es all have hardware timers.
That's when I figured it shouldn't be too hard as long as I could stick to ST's good advice,
examples etc. and possibly copy in several code sniplets as long as it was compatible with the duino Core.
and that's probably where it gets hairy..

some more background on my motivation:
I've set myself on a target to develop a laser tag game (With overly ambitious targets)
Various game types (capture the flag) (hunt the rabbit) team A vs Team B etc. and more of such things.
So a player needs to know by whom of which team he/she was hit.
Typically I need line of sight IR communication as part of the
Ideally I'd like a central server to keep track of the scores and that kind of palaver.

similar to the comercial stuff in lasergame venues.
However that's the long term goal... short term I'd like to work on the individual components.
and IR send recieve is the most important part.

I've tried stuff with the pro-mini (as the HW needs to be tiny enough to be built in a gun.)
but coupling an SPI OLED display AND ESP8266 AND buttons AND LEDs AND a Laser AND IRsensor AND an MP3 module for the sounds
Even if I'd do I2C stuff instead of SPI etc. I'd probably still end up in an assylum before it works.

All the individual stuff worked great, some together also, but all together as a final product...not so
I even looked at shift out registers etc. but that didn't help much due to fixed pin functions and overlap of some functions
and last but not least the mini had not enough oomph.

So I moved over to the nodeMCU and things quickly got worse when I realised that that thing was unstable as hell and didn't solve much of my initial problems. hahaha.. stupid me for not digging through the specs. enough before I bought a set. buy hey they were cheap :-)

So I learned from that mistake and started by sifting MCU's designs.
The hardware of the STM32 looked pretty good and fit for purpose
The pin flexibility interrupts timer functions etc. all looked promissing.
only one caveat... a missing IR library.. well at least in duino-land

Now That's the why, behind my story.

Ray's comment on not willing to spend SW time cycles is an interresting view
I came across that on the pro mini as well (realtime handling of all the functions became a horror quickly as you can imagine)

Paul

User avatar
RogerClark
Posts: 7157
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: IRlib on STM32?

Post by RogerClark » Mon Apr 11, 2016 8:25 pm

I cant remember who it was, But Im fairly sure someone else on the forum was building a laser tag system.

Re:Using STs examples

The STM32s have some cool hardware features, (most of which we have only scratched the surface of)
So if ST have some application notes on how to use the hardware more efficiently for this, its definitely worth reading.

However, be aware that different processors in the family have additional hardware that the F103 does not possess.
e.g. I think the F3 series seems to be targeted at analog input and processing.

stevech
Posts: 441
Joined: Thu Aug 27, 2015 6:32 am

Re: IRlib on STM32?

Post by stevech » Mon Apr 11, 2016 11:13 pm

The ST "Standard Peripheral Library" (SPL) is an alternative to the HAL. Indeed the HAL was derived from the SPL.

Both are terrific open source (vast) drivers and MCU management that I use, and watch somewhat sadly, while ArduinoARM people reinvent these wheels. Freescale/NXP has something similar to HAL and SPL but I find them to be way inferior and limited.

User avatar
mrburnette
Posts: 1829
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: IRlib on STM32?

Post by mrburnette » Mon Apr 11, 2016 11:35 pm

stevech wrote:The ST "Standard Peripheral Library" (SPL) is an alternative to the HAL. Indeed the HAL was derived from the SPL.

Both are terrific open source (vast) drivers and MCU management that I use, and watch somewhat sadly, while ArduinoARM people reinvent these wheels. Freescale/NXP has something similar to HAL and SPL but I find them to be way inferior and limited.
While it is true the SPL was available over 2 years before Leaflabs released the Maple and their ArduinoIDE, ST to my knowledge was not marketing to the hobby market strongly represented by Arduino - then and now. So, while the timing is such that Leaflabs were aware of the SPL, direct use of SPL under the Arduino umbrella would have been awkward. Even ST says this in the intro to the library documentation:
For many applications, the library may
be used as is. However, for applications having tough constraints in terms of code size and/or execution
speed, the library drivers should be used as a reference on how to configure the peripheral and tailor
them to specific application requirements.
Ray

User avatar
RogerClark
Posts: 7157
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: IRlib on STM32?

Post by RogerClark » Tue Apr 12, 2016 12:06 am

The problem with the SPL (and the HAL) is that they were only made truly Open Source, fairly recently.

Prior to that, although you could download the SPL and use it for your own commercial or non-commercial products, it was not possible to write an Open Source product which referenced the SPL, without requiring the end user to download the SPL separately (as the code contains a non-redistribution clause)

Hence why, we believe, that Leaflabs had to code their own API to the hardware from scratch.

Its really only since the beginning of the year that the output from the STM Cube could be used for Open Source projects, and even then some files initially had licensing issues (though not deliberately)

Note. I know that some other projects, like MakerLabMe etc have published SPL code from STM in their repo's, but AFIK know it most likely breaches the terms of use in those SPL files to redistribute them (e.g on GitHub)

stevech
Posts: 441
Joined: Thu Aug 27, 2015 6:32 am

Re: IRlib on STM32?

Post by stevech » Wed Apr 13, 2016 2:33 am

By "open source".. what do you mean?
SPL and HAL - I've been working with them for only 1 1/2 years. I'm not an IP guru, but they are provided by ST to anyone who wants to register with name/email and download. No fees I'm aware of to incorporate these into products. Indeed, the ST's purpose of these is to speed time to market and cost of development. NXP/Freescale does the same thing.

I'm doing commercial work with with HAL and there's no issue with leaving their credits in the source, nor if we have to, crediting them in the release of the product that uses the binaries. Like many product cycles, no ST-original source code is provided, nor usually wanted by the customers.

I do NOT modify ST's code for obvious reasons - mainly that I don't need to and also I don't want to cause a configuration mess as they release updates several times a year. I can take my sources minus ST's sources from HAL and CubeMX, and create a baseline and tell someone how to do their own download of ST's code and code-generate with CubeMX and get the same result. If need be.

non-commercial applications - I've not read the fine print. But I don't think there are restrictions other than leaving the ST credit in place. Seems fair to me, as if I had to develop all those drivers from bare metal, it would have made the cost and schedule, and complexity, impractical. Not like a bit of code for a PIC or AVR.

Hobby market... well, you know that story. The best is to get it into University labs for imprinting - as Apple is want to do.

Lastly, the low cost of MCUs, and M3/M4 with generous sized flash/RAM - makes it illogical to do as we all used to do way back.. work for hours with an undersized MCU is false economics. Big non-recurring labor costs make sense only if you are building a million and have a big amortization base. For avocational.. we're talking insignificant parts cost deltas.

So, I certainly missed the point of the posting.

User avatar
RogerClark
Posts: 7157
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: IRlib on STM32?

Post by RogerClark » Wed Apr 13, 2016 4:28 am

There was a non-distribution clause in the STM

It means that its fine for you and anyone else to download and use the code

However, it was not possible to base an Arduino "core" on the STM, as the Arduino Core's are shipped as source code, and it was not possible to include any SPL code.

If you do work for anyone and use the SPL, Technically you couldn't (prior to this year) bundle the SPL with your code when you hand it over

Your client, technically had to download their own copy of the SPL to compile your code


Of course this is all history now, as STM changed their IP license this year to allow redistribution.

I was just trying to explain why the LibMaple Arduino core written by Leaflabs in 2012 did not use the SPL.

Post Reply