Display Aerotech Position in App Designer

5 次查看(过去 30 天)
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.

回答(1 个)

Aghamarsh Varanasi
Aghamarsh Varanasi 2021-6-18
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 个评论
Richard Wright
Richard Wright 2021-6-20
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 2021-6-21
编辑:Richard Wright 2021-6-21
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by