please help me I want to command the valve on-off with G-code at the mark point I want, where I have 324 mark positions. and make it loop until 324 positions are complete
2 ビュー (過去 30 日間)
古いコメントを表示
for i=1:11
tar_point=['X',num2str(pos(i,1)),' Y',num2str(pos(i,2)),' Z',num2str(pos(i,3))];
comd1=['G01 F200 ',tar_point];
writeline(s,'M03 on') ;
writeline(s,comd1);
pause(1.0);
writeline(s,'M05 off') ;
end
%Each mark point is in the pos variable.
0 件のコメント
回答 (1 件)
Vaibhav
2023 年 10 月 19 日
Hi Matthew,
I understand that you would like to loop over for 324-mark positions.
You can update the code by replacing "for i = 1:11" with "for i = 1:324"; this change ensures the loop encompasses all 324 mark positions and the rest of the code remains the same.
You can refer to the updated code below:
for i = 1:324
% Create a G-code command for the target point
tar_point = ['X', num2str(pos(i, 1)), ' Y', num2str(pos(i, 2)), ' Z', num2str(pos(i, 3))];
comd1 = ['G01 F200 ', tar_point];
% Send commands to turn on the valve (M03), move to the target point, and turn off the valve (M05)
writeline(s, 'M03 on');
writeline(s, comd1);
pause(1.0); % Pause for 1 second (adjust as needed)
writeline(s, 'M05 off');
end
You can refer to below MathWorks documentation to know more about "for" loop to repeat specific number of times:
Hope this helps!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Robotics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!