Display Aerotech Position in App Designer

조회 수: 5 (최근 30일)
Richard Wright
Richard Wright 2021년 6월 15일
편집: Richard Wright 2021년 6월 21일
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