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
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Vaibhav
el 19 de Oct. de 2023
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 comentarios
Ver también
Categorías
Más información sobre Robotics en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!