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...
ChibiOS + STM32F4 + Matlab/Simulink
Moderator: RoccoMarco
Re: ChibiOS + STM32F4 + Matlab/Simulink
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
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.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: ChibiOS + STM32F4 + Matlab/Simulink
Interesting work. Similar to what I am doing into SPC5Studio where all OS settings are generated from a visual configuration tool.
Giovanni
Giovanni
Re: ChibiOS + STM32F4 + Matlab/Simulink
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/PF258513
The generic term for it is "Model Based Design": http://en.wikipedia.org/wiki/Model-based_design
Some 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.html
http://www.mathworks.com/company/user_s ... ace-1.html
https://www.mathworks.com/tagteam/20303 ... 1-0894.pdf
- DeusExMachina
- Posts: 223
- Joined: Tue Apr 03, 2012 5:08 am
- Has thanked: 3 times
- Been thanked: 3 times
Re: ChibiOS + STM32F4 + Matlab/Simulink
Great job
I used Simulink code generation for ARM Linux board, and results were very interesting
I used Simulink code generation for ARM Linux board, and results were very interesting
Re: ChibiOS + STM32F4 + Matlab/Simulink
DeusExMachina wrote:Great job![]()
I used Simulink code generation for ARM Linux board, and results were very interesting
This weekend I spent quite a bit of time cleaning up things. Also just finished getting 'main' setup such that it will generate a thread for each sample rate. Still just a tip of the iceberg of what needs to be done. It doesn't actually output anything yet.
Here's the main.c that gets generated: https://github.com/jedediahfrey/ChibiOS ... iOS/main.c
Where each of the threads are different sample rates. Next step is to get PWM to drive something and after that get it to compile straight to the board then start implementing more functions.






Re: ChibiOS + STM32F4 + Matlab/Simulink
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.
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
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
~ Tectu
Re: ChibiOS + STM32F4 + Matlab/Simulink
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.