Simulink model running on STM32F4: Best way of logging current signal data to workspace at trigger event only

조회 수: 6 (최근 30일)
Dear Matlab Community,
I need some tipps to find the right way. I´m sure it works, but I just don´t get the right search terms yet..
First my setting:
I have a Simulink model running on an STM32F446RE NUCLEO board. It my case it is hooked on top of an analog PLL and can read some analog voltages as well as overlay an analog output signal to control the PLL. It´s purpose is to filter and classify an analog reading and based on a casually detected peak (I call this a trigger event), it should "write down" the current output signal and some values of other readings of interest etc.
Since it´s a prototype only, I need a simple solution to store those selected variable values and analog readings. It must not be nice nor fast. I am ok if I need to do some postprocessing in Matlab later. It must not be written on the internal memory unless this makes sense(?) for my case, I am fine if this only works in "Monitor and Tune" mode or with debugging tools like "logging signal data" active.
Yet I help myself using the Data Inspection tool and export the timeseries of the signals to workspace. But here I get all readings from every execution. If I put some energy into post processing I could just find the index of the peaks in the timeseries and continue from there on. No big deal I guess.
I am aware of sending variables from simulink models using "To Workspace", but my understanding is that again I as well get a time series of all readings, so similar post processing would be required.
In order to have a simple post processing only, and no need to "pick" the right value from the timeseries I would prefer to save the data only when needed.
I am sure there must be a way of casually filling a log file or array or adding data to a workspace-variable based on a trigger event. I just can´t find anything helpful on my own. Could you help me out with some ideas how to proceed? What is the best way in your opinion?
Thanks in advance for your time and any good hint!
Regards
Janis
  댓글 수: 1
Ilario Cirillo
Ilario Cirillo 2024년 6월 11일
If it's ok to use "Monitor & tune", you might be able to achieve what you want using the external mode trigger.
We have some information about this in this page
and more details on the controls available here
In your case, if you mark for logging a signal you want to use as trigger, then you can configure the model to only log when it reaches a specific value. To do that, in the "Signal & Triggering Dialog Box":
  • Select that signal as trigger signal.
  • Select as trigger source "signal".
  • Choose the "duration" you want. This is the number of samples that will be logged when the trigger is activated.
  • Configure the direction and level of the signal that should activate the trigger.
Once you do that, everything that is logged when pressing "Monitor & tune" (with blocks or by marking signal for logging) will only be logged when the trigger is activated, for the duration you configured.
Hope this helps,
Ilario

댓글을 달려면 로그인하십시오.

답변 (0개)

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by