how to enter function into app designer ?
2 次查看(过去 30 天)
显示 更早的评论
So I want to use UART prtocol into my project . I build the UART protocol ,but I want to use this protocol via appdesigner . So for exmaple I want to write the number In a Numeric Field box and to send this number to the UART protocol . how do I do it ?
this is my UART protocol :
%% Instrument Connection
% Find a serial port object.
obj1 = instrfind('Type', 'serial', 'Port', 'COM3', 'Tag', '');
% Create the serial port object if it does not exist
% otherwise use the object that was found.
if isempty(obj1)
obj1 = serial('COM3');
else
fclose(obj1);
obj1 = obj1(1);
end
% Connect to instrument object, obj1.
fopen(obj1);
%%% Instrument Configuration and Control\
% Communicating with instrument object, obj1.
fwrite(obj1,23 , 'uint8');
in this last line of code :
fwrite(obj1,23 , 'uint8');
I send the number that I want to send in the UART protocol . But I want to enter this number (for example 23 in this case ) via NumericEditField in the app designer . How to do it ?
0 个评论
回答(1 个)
Adam Danz
2019-8-21
编辑:Adam Danz
2020-1-18
"I want to write the number in a Numeric Field box and to send this number to the UART protocol"
From within your app code, these two lines will get the numeric text value and send it to fwrite(). The two lines can be placed in any callback function that responds to interaction with a GUI component. Assuming the numeric text field is named "EditField1",
value = app.EditField1.Value; % or whatever your handle is
fwrite(obj1, value, 'uint8');
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Instrument Connection and Communication 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!