MATLAB Answers

Display Aerotech Position in App Designer

1 view (last 30 days)
Richard Wright
Richard Wright on 15 Jun 2021
Edited: Richard Wright on 21 Jun 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.

Answers (1)

Aghamarsh Varanasi
Aghamarsh Varanasi on 18 Jun 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 Comments
Richard Wright
Richard Wright on 21 Jun 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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!