How to repeat a block of code hundreds of times.

Post Reply
Chris Dawson
Posts: 2
Joined: Fri Sep 27, 2019 1:44 am

How to repeat a block of code hundreds of times.

Post by Chris Dawson » Fri Sep 27, 2019 2:19 am

Hello All,

This is my first post so bear with me. I am building my own CNC machine from the ground up basically. It is for the patterning of glass tubes (mounted to a rotary table), with dots of melted color glass off of the end of a glass rod. The Z axis is cloned and controls two stepper motors which will push the glass color rod (through an oxy-propane torch flame) into the glass tube, then retract the rod at a certain rate, allowing the glass to melt off in the flame, and finally positioning the rod tip in the flame to keep the end melted.

My question is this: If I am going to be putting possibly hundreds of dots on a piece of tubing, do I literally have to copy-paste a block of code controlling the z axis hundreds of times, considering GRBL 1.1 doesn't allow subroutines? Or can I build a script or a macro in bCNC to do that?

Any ideas would be greatly appreciated, thanks.

Bertus Kruger
Site Admin
Posts: 1490
Joined: Wed Feb 03, 2016 10:26 pm
Location: Wellington , New Zealand
Contact:

Re: How to repeat a block of code hundreds of times.

Post by Bertus Kruger » Mon Sep 30, 2019 6:41 pm

There are a few ways to do it...

Generating a G-Code file with an file editor is the simplest way and then using a G-Code sender to send each line to GRBL.

If the g-code commands are not the exactly the same you will have to consider writing a script to generate the above file.

Or you can just write a G-code sender that generates the g-code on the fly and sends it to GRBL via serial. (Custom G-code sender.)

The issue with the non-file way is that if something happens half way in the job, it will be harder to recover.

Chris Dawson
Posts: 2
Joined: Fri Sep 27, 2019 1:44 am

Re: How to repeat a block of code hundreds of times.

Post by Chris Dawson » Thu Oct 17, 2019 9:51 pm

Ok, thanks.
Next question is: when writing gcode in a text editor, how can I make blocks out of lines of code so that when I load the file in bcnc, the proper lines of code are inside the blocks?

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests