How should I order the commands so that the valve can be opened and closed at the desired position?
1 view (last 30 days)
Show older comments
for i=1:5
comd2=['M03 on',tar_point];
writeline(s,comd2)
tar_point=[' X',num2str(pos(i,1)),' Y',num2str(pos(i,2)),' Z',num2str(pos(i,3))]; ้
comd1=['G01 F200 ',tar_point];
writeline(s,comd1)
pause(1.0) ์
comd3=['M05 off',tar_point];
writeline(s,comd3)
end
%Positions are placed in the 'pos' variable.
0 Comments
Answers (1)
Pratik
on 5 Jan 2024
Hi Matthew,
As per my understanding, you would like to write a code to automate the opening and closing of a valve and want to know what the correct order of commands will be to achieve the objective.
After analysing the code provided, the order of commands looks correct. However, in “comd2” it can be noticed that the “tar_point” variable is used before it is initialized for that position.
Please refer to the following code snippet for reference:
for i=1:5
tar_point=[' X',num2str(pos(i,1)),' Y',num2str(pos(i,2)),' Z',num2str(pos(i,3))];
comd2=['M03 on',tar_point];
writeline(s,comd2)
comd1=['G01 F200 ',tar_point];
writeline(s,comd1)
pause(1.0)
comd3=['M05 off',tar_point];
writeline(s,comd3)
end
%Positions are placed in the 'pos' variable.
I Hope this helps.
0 Comments
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!