How to add a reference position without manually updating it from the Matlab Editor

2 visualizzazioni (ultimi 30 giorni)

Hello everyone, we are working on a 2D Ball/Plate Balancing system for our project and we have a presentation in a couple of days where we have to show our first kind of controller for the Board (a PD for instance).
The x_ref and y_ref of the ball is manually updated from the MatLab editor in [mm] as shown in the picture below:

Following this convention:

In order to have more interaction with the system, I would like to know if there's a way to insert the x_ref and y_ref position straight from an interface like this one:

Please note the x_ref and y_ref positions are passed on Simulink and are deployed on a target hardware (due to the interface with Arduino).
Thank you everyone in advance for a reply.

Risposte (1)

Maneet Kaur Bagga
Maneet Kaur Bagga il 7 Gen 2024
Modificato: Maneet Kaur Bagga il 17 Feb 2024
Hello,
As per my understanding, to create an interface in MATLAB for interacting with the "2D Ball/Plate" Balancing System please refer to the following workaround:
  • Open your Simulink model. Go to the Library Browser, and under the "Simulink" tab, find the "Dashboard" library. Drag and drop a "Slider" or "Knob" block for "x_ref" and for "y_ref" in the model canvas. Connect the output of these blocks to "x_ref" and "y_ref" from the inputs of the model.
  • Double-click on the "Slider" or "Knob" block to open its parameters. Set the minimum and maximum values according to the range of motion of the plate. Run the model once the interface is setup.
  • If deploying to hardware, make sure that the blocks used are supported for code generation. Configure the hardware target settings in Simulink to ensure compatibility with the Arduino setup.
Please refer to the code below to configure a slider block in the Simulink model:
% Assuming 'model' is the name of your Simulink model
open_system(model);
% Add a Slider block for x_ref
x_ref_slider = add_block('simulink/Dashboard/Slider', [model '/x_ref_slider'], ...
'Position', [100 100 200 120], ...
'Min', '-50', 'Max', '50', ...
'Value', '0');
% Add a Slider block for y_ref
y_ref_slider = add_block('simulink/Dashboard/Slider', [model '/y_ref_slider'], ...
'Position', [100 200 200 220], ...
'Min', '-50', 'Max', '50', ...
'Value', '0');
% Connect the Slider blocks to the corresponding inputs in your model
% (Assuming you have input ports named 'x_ref_input' and 'y_ref_input')
add_line(model, 'x_ref_slider/1', 'x_ref_input/1');
add_line(model, 'y_ref_slider/1', 'y_ref_input/1');
Please refer to the following MATLAB Documentation for more information:
Hope this helps!

Categorie

Scopri di più su Multicore Processor Targets in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by