Get data in real time, draw graphics changing in real time.
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, I'm getting real-time data from the manipulator, its current position.
channel = ddeinit('ipc_data', 'ipc_1');
data(1,1)=ddereq(channel,'mw1311'); % X coordinate
data(1,2)=ddereq(channel,'mw1312');% Y coordinate
data(1,3)=ddereq(channel,'mw1313');% Z coordinate
I need to represent the manipulator's position on the chart. and when the manipulator moves, it should be evident in the chart.
댓글 수: 0
채택된 답변
Paulo Silva
2011년 4월 12일
clf
p=plot3(nan,nan,nan);
while 1
data(1,1)=ddereq(channel,'mw1311'); % X coordinate
data(1,2)=ddereq(channel,'mw1312');% Y coordinate
data(1,3)=ddereq(channel,'mw1313');% Z coordinate
set(p,'XData',[0 data(1,1)],'YData',[0 data(1,2)],'ZData',[0 data(1,3)])
pause(0.5) %read and draw data every 0.5 seconds
end
To stop the loop do CTRL+C
Alternative way, using a timer:
function test
fig=figure;
set(fig,'CloseRequestFcn','delete(gcf);')
h = plot3(NaN, NaN, NaN,'LineWidth',5);
t = timer('TimerFcn',@readdata,...
'Period', 0.5,'executionmode','fixedSpacing');start(t)
function readdata(g1,gg1)
if (~ishandle(fig)),stop(t),return,end
data(1,1)=ddereq(channel,'mw1311'); % X coordinate
data(1,2)=ddereq(channel,'mw1312');% Y coordinate
data(1,3)=ddereq(channel,'mw1313');% Z coordinate
set(p,'XData',[0 data(1,1)],'YData',[0 data(1,2)],'ZData',[0 data(1,3)])
end
end
댓글 수: 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!