problem with change a port in arduino connection in apps design
조회 수: 1 (최근 30일)
이전 댓글 표시
i have some problem, i succeed to connection arduino with matlab menu portlist in connection. i try to change hardware connection to other port and refresh an error message appears "StringClient transport object must be connected using transport CONNECT". why its happen ? thanks
this my code
function startupFcn(app)
spl = serialportlist('available');
if isempty(spl)
error('no serial ports available')
end
app.Property = serialport(spl(1),9600,"Timeout",5)
end
this the error message
function startButtonPushed(app, event)
app.ConnLamp.Color = app.GREEN_COLOR;
global val_stop val_data
val_stop = 0;
val_sample = 300;
val_voltage = 0;
val_count = 1;
while val_count <= val_sample
if val_stop == 1
break;
else
ADC_value = str2double (readline(app.Property));
val_const(val_count) = 5;
val_voltage(val_count) = ADC_value(1)*5/308;
plot(app.UIAxes,val_voltage);
app.UIAxes.XLim = [0 val_count+50];
app.UIAxes.YLim = [0 5.1];
val_time(val_count) = val_count;
val_data = [val_voltage; val_time];
app.UITable.Data =val_data;
val_count = val_count + 1;
end
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/689588/image.png)
this a refresh code
function RefreshButtonPushed(app, event)
delete(instrfind);
p = instrhwinfo('serial');
app.PortList.Items = p.AvailableSerialPorts;
end
this the pict of connection
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/689593/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/689598/image.png)
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Instrument Control Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!