How does Stateflow/Simulink define the sec intrinsic when running on actual hardware?
4 ビュー (過去 30 日間)
古いコメントを表示
Hi there,
My team and I are trying to write some firmware for a new version of a product that we're making and we've made the decision to use Stateflow and Simulink to generate the code for us from a state machine. The project will run on Energy Micro's EFM32LG980F256 MCU which runs using a Cortex-M3 core. I am the embedded systems engineer who has to somehow integrate the code and state charts that have been created by another engineer with the necessary code to make this work on hardware. As the embedded systems guy, I am very unfamiliar with Simulink/Stateflow and I am learning as I go with this project.
The engineer who has created the Stateflow charts that I'm working off of has chosen to use the after(some timeout, sec) function to help control the timing of transitions between states in the chart. It makes sense to use this intrinsic since he can create specific timing easily, and it works wonderfully in the simulations, however I'm confused as to how I can actually translate this to real-world timing when it's implemented on the hardware. I assume that there has to be some kind of trigger that's timer driven in order to get the precise timing wanted, however I am unsure as to how to set up the timer trigger to actually have the timeout represent a real time. Additionally, how does Simulink/Stateflow translate the desired fundamental sample time into real time when it's deployed on an embedded system and not being controlled by the simulation?
Working under the assumption that I have to manually trigger the Stateflow model to run at the desired fundamental sample time, I have placed the state chart that the other engineer has written into a triggered subsystem which then runs the model when an input that is tied to a timer interrupt goes high. The timer interrupt is set to go off at the machine's fundamental sample time so that the entire thing is run at that rate. It looks like this:
Where the input In1 is triggered by the timer interrupt and immediately reset following the execution of the rt_OneStep() function. Am I on the right path with this? Honestly, I'm used to writing everything in C, so this is completely foreign to me.
This couples into another question that I have regarding the actual functionality of the system. When running state charts in Simulink, does a trigger simply run through the state machine once to establish the current state of the machine and then go back to sleep until the next trigger, or does it run the entire state machine through to completion? (This is assuming that the state machine in question has a finite start and finish state).
Any and all help and suggestions are much appreciated. Thank you in advance for your help.
-Chris Hack
0 件のコメント
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!