MBD: Blocks or C-code ?

3 views (last 30 days)
Erik Voigt
Erik Voigt on 9 Oct 2012
Hi We are in the process of introducing model based design (mbd) here, with all the diciplines/aspects sketched by Mathworks. We have a history of writing our control-algorithms (electrical motor control) in C-code and wrap them in S-functions. So the big question now is: Should we shift to blocks, so we can use all tools from Mathworks to do mbd - or should we stick to C-code, where we also need tools from the SW-community to do all the mbd-deciplines ?
My/our analysis tells me so far, that the advantages with blocks are not so obvious, and we can get to mbd also with C-code. Please note that our models are complex and contains many nonlinearities (if..else...statemachines).
If there are any comments and even maybe experience on this I would be happy to hear about it.
Kind Regards Erik

Answers (1)

Ryan G
Ryan G on 9 Oct 2012
Edited: Ryan G on 16 Oct 2012
It would be tough to say exactly what is best given the unknowns in this case. However, in general, using blocks should be the way forward for control design in Simulink using a Model Based Design approach. This will allow you to:
  • set oprating points
  • linearize a model for control design
  • find and tune gains for controllers
  • use stateflow machines to visually model state machines
  • use fuzzy logic toolbox for control methods (if needed)
When you use the Simulink blocks you will find it easier to work between these tools compared to using s-functions, which I would consider a big advantage. S-functions can often be used as well, but there will typically be a bit more work to make sure everything is set to work properly. You will also find more examples/demos that you can utilize for your design process with blocks versus s-functions.

Categories

Find more on Multicore Processor Targets in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!