How can I create a self update loop in simulink for this (Ball Balancing Table)?

I'm currently trying to create a simulink model of ball balancing table. Inside of "accx, accy" boxes, there is acceleration equations of ball in terms of x and y. Inside of "posx, posy" boxes, there is trajectory equations of ball, you can see below;
function posy = posy(accy, time) %acc info comes from previous equation box you can see in block diagram
pos0y = -30; %initial position of ball
vely = accy.*time;
posy = pos0y + vely.*time + ((accy.*(time.*time))/2);
I wanted to make this function like this;
function posy = posy(accy, time) %acc info comes from previous equation box you can see in block diagram
pos0y = -30; %initial position of ball
vely = accy.*time;
despos = 15; %desired final destination, final position of ball
posy = pos0y + vely.*time + ((accy.*(time.*time))/2);
%HERE I NEED A LOOP IN ORDER TO UPDATE SOME VARIABLES UNTIL BALL REACH DESIRED POSITION
%AND WHEN THE BALL REACH THE DESIRED POSITION, ACC SHOULD BE 0 AND SIMULATION STOP
%Also if it's possible, table dimenisons are 30x30, it would be good if the
%ball reach the boundaries, motors adjust angles to change acceleration in
%order to prevent falling ball from table etc
As you can see in above, I need a loop but I'm kinda beginner in these types of things so I am not able to figure it out, I'm stucked. If you can help me, I would be really happy. If there is another and easier option for what I want, I'm ok with that too.
Thanks in advance whoever helps or not.

Réponses (0)

Catégories

En savoir plus sur Simulation dans Centre d'aide et File Exchange

Produits

Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by