Script Matlab to modify a sequence of G1 commands (G code)

2 ビュー (過去 30 日間)
Federico Paolucci
Federico Paolucci 2022 年 8 月 16 日
編集済み: Walter Roberson 2022 年 8 月 17 日
Hi, I'm searching for an automatic script to insert commands G4 and M42 in a sequence of G1: I'm developing a matlab script image acquisition and I have a sequence of G1 commands that represent various positions (x,y,z) of the extruder of a 3d printer. M42 guarantees photo capture and G4 the pauses. I have to have one image for each position. in the code below there is an example of two image acquistions. So, i want to
obtain a matlab script to modify a sequence of G1 by inserting G4 P1500; M42; G4 P250; M42 between each one
  4 件のコメント
Walter Roberson
Walter Roberson 2022 年 8 月 16 日
That looks like the desired result? Can you show us what the unmodified input would look like?
Federico Paolucci
Federico Paolucci 2022 年 8 月 16 日
編集済み: Federico Paolucci 2022 年 8 月 16 日
Yes, that is the desired result. The unmodified input contains only the G1 commands
G1 F1200 X43.708 Y42.174 Z6.7
G1 F1200 X43.708 Y42.374 Z6.7
I think I need a script like that in the link to reach the result, isn't it?

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2022 年 8 月 16 日
編集済み: Walter Roberson 2022 年 8 月 17 日
in_filename = 'InputGcodeFileNameGoesHere.txt';
out_filename = 'OutputGcodeFileNameGoesHere.txt';
L = readlines(filename);
L = regexprep(L, '^G1.*$', '$1\nG4 P1500 ;ms, stabilization pause\nM42 P47 S255 ;photo capture, set 1 on pin 47\nG4 P250 ;ms, photo caption pause\nM42 P47 S0 ;set 0 on pin 47');
writelines(L, out_filename);
Though if you happen to be using MacOS or Linux, I would suggest just coding the as a shell script that invokes sed https://linux.die.net/man/1/sed

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by