How can I generate multiple references in simulink?

2 vues (au cours des 30 derniers jours)
Emmanuel Bastar Torres
Emmanuel Bastar Torres le 22 Avr 2022
I am creating a simulink model for a mobile robot. The idea is to this robot goes to diferent coordinates (X, Y). I already have my controller (PI controller) and the full system simulated (motor model, dynamic model and kinematic model) and everything is working good; However, the reference I am given is based on time, this means that e.i every 100 seconds the reference is going to be change no matter if the robot reach or not the goal (the current reference in X and Y).
What I want to do is, insted of giving a centain amount of time, when the robot reach the goal (reference in X and Y), the next reference is given automatically (the referece can have a tolerance of .05 for example, so the simuluted robot does not have to reach 100% the goal).
I was thinking for doing it with a stateflow block with a feedback of the error to say something like: if the error is less than 0.05 you can send the next reference, but I am not sure how to translate it to the simulation (what to put inside the stateflow).
Of course if someone has a better idea I would like to read it.
if someone has experience with this I really appreciate your help. I attache some photos with the blocks that maybe they can better clarify it.
Current simulation block
My idea

Réponses (1)

Pratyush Swain
Pratyush Swain le 20 Nov 2023
Hi Emmanuel Bastar Torres,
I understand you want to integrate a stateflow block into your simulink model which triggers a reference point when the error constraint is satisfied. You may refer to the workflow below that can help your use case:
1-In the Stateflow Editor, go to the 'Model's explorer' or 'Symbol's pane" and define two variables:
  • 'index' (scope: Local Variable, initial value: 1)
  • 'matrixArray' (scope: Input/Constant Variable, size: [2, N] where N is the number of reference points)
'matrixArray' can be the reference points matrix containing time stamps and coordinate values that can be taken as input values in the stateflow chart or defined with a constant/local scope.
The above illustration is an example view of 'model explorer' where the variables are enlisted. Please note instead of 2D matrixmatrixArray, the variable 'points' is a 1-D array described as an local scope variable which is used for example purpose.
2- You can create three states in the stateflow chart for handling the error values which will be received as an input.
  • InitialState : To perform input handling and handle edges cases(for ex- out of index) if any
  • Intial0State  : A state to handle where error is less than specified threshold(for ex:0.5)
  • Intial1State :  A state to handle where error is more than specified threshold.
The above illustration is an example stateflow where 3 states are constructed to show expected functionality. Please note, error condition statements are specified as 0 and 1 for example purpose and 'InitialState' state is currently empty for simplicity and can be modified. The operations happening in each of the state blocks can be explained in the next step.
3- Define appropriate state actions:
  • The aim is to increase the index whenever error is within a specified threshold and define reference output as the updated value fetched from that index from the array.(Initial0State).
  • Similarly, whenever error is more than the specified threshold, the index value will not increase, and reference output will not be updated, returning the old value.(Initial1State).
  • The example above implements this on an array, but this methodology can also be applied when working with matrix type data.
This stateflow achieves the task of generating new set of reference only when error threshold is satisfied.
For more information on stateflow data and actions, please refer to following documentation:
Hope this helps.

Catégories

En savoir plus sur Complex Logic dans Help Center 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