Column-by-Column (SIMULINK)

1 Ansicht (letzte 30 Tage)
Domi
Domi am 6 Apr. 2020
Kommentiert: Domi am 10 Apr. 2020
Hey guys,
I would like to do a "slow" iteration..
As far as I know Simulink first executes a block and passes its value over. Which means, If I have a loop it finishes the loop and gives out the last value. But I need to give specific elements from my array as a command and send it. Which means I need to execute element 1 followed by element 2 in a ordered manner.
I would like to have sth like this pseudocode
A = 2x6 (like a constant block [1 2 3 4 5 6; 0 0 0 0 0 0])
for i = 1:6 do / or while loop
output col 1 of A
wait like 5 seconds or if-condition (like if trigger == 1 -> only(!) next col and wait for next trigger to output next col)
output col 2 of A
wait like 5 seconds or if-condition
output col 3 of A
..etc..
end loop
I already tried an assignment block.. but it outputs the full matrix
..and I tried direct look-up table... but I do not know how to get a right counter/incrementer for it.. sth like a triggered or slow incrementation..
In MATLAB you can write a pause and some commands in each loop step but a pause in simulink pauses the whole simulation and that is not what I want at all..
any tips?
  1 Kommentar
Domi
Domi am 6 Apr. 2020
I need this because I have a 2xN array of pathpoints which I want to send via UDP Send/Receive from my raspberry to my robot, both running simulink. I know I can send a hugh Nx1 array and make it back to 2xN on the robot side.. but the next problem is, that I need to go through every column on robot.. which leads to the same problem as above :/

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jonas
Jonas am 7 Apr. 2020
Bearbeitet: Jonas am 7 Apr. 2020
You need the Selector block to capture the column you need, and then a Trigger Subsystem which executes on your command. You can also use a subsystem triggered by a function call. You can control the time delay between executions by using a Stateflow with the state transition 'after(5,sec)' for example, or implement an integrator block with gain 1, which will build up in real-time and you then trigger based on when it reaches a threshold.
You can also in Stateflow maintain a counter and increment with each sample time. Since you know your sample time, you can let the UDP Send trigger after the counter has reached a value.
  1 Kommentar
Domi
Domi am 10 Apr. 2020
Thank you sir! I managed to get it done with the direct lookup table and a resetable counter system based on switches and delays. Stateflow was a good input for me, because I looked up how it works. Thanks

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by