Page 1 of 2
ChibiOS + STM32F4 + Matlab/Simulink
Posted: Wed Nov 27, 2013 3:54 pm
by petro
Hello,
I'm wondering, did someone try to connect project generated from Simulink(Matlab) embedded target with ChibiOS ? Is there any simple way to do that ? Some tips/tricks ? Thank you for answers...
Re: ChibiOS + STM32F4 + Matlab/Simulink
Posted: Thu Nov 28, 2013 2:34 am
by jafrey
petro wrote:Hello,
I'm wondering, did someone try to connect project generated from Simulink(Matlab) embedded target with ChibiOS ? Is there any simple way to do that ? Some tips/tricks ? Thank you for answers...
Unless you've broken into my head/laptop then I don't think there is another project out there.
Target Language Compiler (TLC) is not the simplest thing in the world to learn. I'm hacking my way through stuff. I'm hoping to be able to create blocks for the HAL and then make the rest need to be hand coded.
Re: ChibiOS + STM32F4 + Matlab/Simulink
Posted: Sat Dec 07, 2013 5:45 am
by jafrey
jafrey wrote:Target Language Compiler (TLC) is not the simplest thing in the world to learn. I'm hacking my way through stuff. I'm hoping to be able to create blocks for the HAL and then make the rest need to be hand coded.
So I've spent quite a few hours into the wee hours figuring out TLC. For simplicity of having to learn a whole nother 'language' I've decided to not do MEX files and am using Level-2 M-file S-functions instead.
I don't have a whole lot done. But it will create a skeleton main(), generate mcuconf.h (for STM32F4 chips) and a chconf.h. It'll also generate a make file but that make file doesn't quite work yet. I need to work out some paths. Depending on how much time I get to work on this I'm hoping to have a simple PWM HAL block done so it'll compile straight to .hex and flash the board.
This is what I have so far:
https://github.com/jedediahfrey/ChibiOS ... 7f83592bbb





This is all a work in progress. So comments and help aren't there nor is the code the cleanest.
I can document, I promise.
Re: ChibiOS + STM32F4 + Matlab/Simulink
Posted: Sat Dec 07, 2013 9:09 am
by Giovanni
Interesting work. Similar to what I am doing into SPC5Studio where all OS settings are generated from a visual configuration tool.
Giovanni
Re: ChibiOS + STM32F4 + Matlab/Simulink
Posted: Sat Dec 07, 2013 11:02 am
by jafrey
Giovanni wrote:Interesting work. Similar to what I am doing into SPC5Studio where all OS settings are generated from a visual configuration tool.
It's similar however this is just the tip of the iceberg of what Simulink is for. The problem is getting everything setup initially. Once that's done it allows people to rapidly generate code directly from models. ST has released a set of Blocks however they're only for Atollic, IAR and Keil. (I did get it working in GCC). Plus it's not for ChibiOS, it just uses the systick to run periodically.
http://www.st.com/web/catalog/tools/FM1 ... 3/PF258513The generic term for it is "Model Based Design":
http://en.wikipedia.org/wiki/Model-based_designSome reading if you're interested.
http://www.mathworks.com/products/simulink-coder/http://www.mathworks.com/model-based-design/http://www.mathworks.com/company/newsle ... esign.htmlhttp://www.mathworks.com/company/user_s ... ace-1.htmlhttps://www.mathworks.com/tagteam/20303 ... 1-0894.pdf
Re: ChibiOS + STM32F4 + Matlab/Simulink
Posted: Mon Dec 09, 2013 1:05 am
by DeusExMachina
Great job
I used Simulink code generation for ARM Linux board, and results were very interesting

Re: ChibiOS + STM32F4 + Matlab/Simulink
Posted: Wed Dec 11, 2013 1:46 am
by jafrey
Re: ChibiOS + STM32F4 + Matlab/Simulink
Posted: Sat Dec 14, 2013 6:59 am
by jafrey
Success.
I can go straight from my simulink model to the STM32F4 board with just a make command. Currently only works with Timer 4 and the LED's on the STM32F4 Discovery. But I got the hard part of tying together the make commands.
Re: ChibiOS + STM32F4 + Matlab/Simulink
Posted: Sat Dec 14, 2013 11:29 am
by Tectu
Very interesting work. It would be interesting if you could write down your effort and results in form of a guide once you reached a satisfying result. The
community pages section would be just perfect for this. Take a look at the already existing ones.
~ Tectu
Re: ChibiOS + STM32F4 + Matlab/Simulink
Posted: Tue Dec 17, 2013 3:52 am
by jafrey
Tectu wrote:Very interesting work. It would be interesting if you could write down your effort and results in form of a guide once you reached a satisfying result. The
community pages section would be just perfect for this. Take a look at the already existing ones.
~ Tectu
Definitely! I got it working for single tasking and multitasking. Also added GPIO outputs, all it does now is toggle the LED's but uses the PAL HAL for the GPIO read and write. A cheap and dirty way of doing priorities is the fastest event gets the highest priority.
Once the initial stuff is done the HAL makes it much easier to add new features. Once that is done getting it optimized
I'm still trying to figure out a clean way to specify a chip's features. I'm thinking of an XML file.