I am using the Tone player simulink model to generate sounds. But, in my task, the participant is required to follow a track and if the participant deviates from the task, i want a sound signal to keep beeping until the participant gets back into the track. And this should continue till the end of the task until they reach the end of the track.
But, the problem that i am facing is that the trigger subsystem in the Tone player model which contains the blocks responsible for the sending the signals gets activated once and then stops.
And if i put it in a loop in stateflow then it stays activated and generates sound even when the participant is inside the track. How do i turn on and turn off sound generation subsystem when i need to?
Please let me know.
Parallel states in Stateflow will accomplish what you want. MATLAB has lots of documentation on how parallel states work. The quick version is:
- Create a large state to contain the parallel sub states
- Right click the state and set the decomposition to “AND (parallel)”
- Add 2 large “sub states”
- The main task logic will be in one of the sub states, the other will be the tone playing system
- In the main task logic you can trigger the tone playing states to enter or exit the tone playing state
- The tone playing state would need to use the “duration” of the tone to wait in between the e_Play_Tone events
I hope that helps. Please let us know if we can provide any more information.
All the best,