Display Aerotech Position in App Designer

5 vues (au cours des 30 derniers jours)
Richard Wright
Richard Wright le 15 Juin 2021
Modifié(e) : Richard Wright le 21 Juin 2021
I'm attempting to display the position feedack of axes from Aerotech Motion Composer. The position parameter is in a matlab function I call AxisPositions where the relevant line of code is:
posXFeedback = A3200StatusGetItem(handle, 0, A3200StatusItem.PositionFeedback, 0);
I want to grab this value continuously in real time and display in an Edit Field (or any appropriate component) in an App Designer GUI.
In App Designer I have an Edit Field where I have attempted to call the posXFeedback variable to be displayed as the value:
function PresentXposEditFieldValueChanged(app, event)
app.PresentXposEditField.Value = AxisPositions;
end
Can anyone suggest how to approach this?
Thanks in advance.

Réponses (1)

Aghamarsh Varanasi
Aghamarsh Varanasi le 18 Juin 2021
Hi,
You can use a timer-class to execute a function after a particular time interval. This will help you to query and display the position feedback from Aerotech Motion Composer at specific intervals of time. For reference, you can check this app designer example that uses a timer-based data update.
Note that in your case, you can choose an appropriate period (as low as 0.01 sec) to make the updates seem real time.
Hope this helps
  2 commentaires
Richard Wright
Richard Wright le 20 Juin 2021
Thank you. This does give me much more direction.
Attempted code does not work yet but appears to be in the right direction.
methods (Access = public)
function t = UPDATER(app)
t = timer;
t.UserData = secondsBreak;
t.StartFcn = @Axispositions;
t.Period = .01;
t.TasksToExecute = Inf;
t.ExecutionMode = 'fixedRate';
t.TimerFcn = @PresentXposEditFieldValueChanged;
start(t)
end
Richard Wright
Richard Wright le 21 Juin 2021
Modifié(e) : Richard Wright le 21 Juin 2021
Perhaps displaying values in realtime cannot be done with the NumericEditField. Maybe a different component is needed. According to documentation about callbacks:
Value changed callback, specified as one of these values:
  • A function handle.
  • A cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.
  • A character vector containing a valid MATLAB expression (not recommended). MATLAB evaluates this expression in the base workspace.
The callback executes when the user changes text in the edit field and either presses Enter or clicks outside the edit field. It does not execute if the edit field value changes programmatically.
This callback function can access specific information about the user’s interaction with the edit field. MATLAB passes this information in a ValueChangedData object as the second argument to your callback function. In App Designer, the argument is called event. You can query the object properties using dot notation. For example, event.PreviousValue returns the previous value of the edit field. The ValueChangedData object is not available to callback functions specified as character vectors.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by