필터 지우기
필터 지우기

problem with change a port in arduino connection in apps design

조회 수: 1 (최근 30일)
Imam Pratama Setiady
Imam Pratama Setiady 2021년 7월 20일
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
this a refresh code
function RefreshButtonPushed(app, event)
delete(instrfind);
p = instrhwinfo('serial');
app.PortList.Items = p.AvailableSerialPorts;
end
this the pict of connection

답변 (0개)

카테고리

Help CenterFile Exchange에서 Instrument Control Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by