Simulink output triggered by Serial
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi guys,
I'm trying to solve a problem that using simulink to communicate with arduino and sending data.
Let's say I have a matrix of size 500X3, each column contain a 3D coordinates. I also have a tag-number to indicate how many rows in the matrix is none-zero (although the matrix have 500 row, only the first 200rows contain corrdinates, while others are zero). Next, I want to let arduino sending message to simulink in order to get one row form the matrix, and it won't send another line if the ardunio not asking.
So how this could be done? I make my own simulink model as this:
The manual trigger will be replaced into a serial receive, I just put that to control my system as I wanted.
And this is how it looks inside while loop:
But I got some problem with it. First, the output only gives me the last iteartion result. But what I want is result from each iteration. Second, the value of res won't be reset to initial condition when the program enter the while loop again. For example, the time step is 1s and I let it run for 3s, at the point of 1s, the system should finish the loop once and gives me an output. After that it should run the model for the second time and give me another output. But when the second time come, although I put initial condition in the Delay One Step block, it still mantain the value from last time step.
Did anyone got some idea about how to solve this two questions?
Thanks.
0 Commenti
Risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!