Purpose dedicated gcode

Hi all, i have quite an odd question.

My child has this stupid tally counter toy.
He and his friends are competing who gets to the highest count.

My son already pressed the button 40,000 times.

I wonder if I can produce a gcode for my bambulab A1 mini
that will send the extruder to the middle axis and lower and raise to a specific height at a desired speed
And obviously perform this for thousands of times, the hotend should stay cold.

This will cause it to press the button on the toy.

Once i get this done my son and friends will give up in this stupid challenge :smiley:

I assume the easiest way would be to add it to the machine startup gcode.

I am just worried I may put there code that can send the extruder to a wrong position and cause damage.

Thanks

Hi @Yarash,

Welcome to the forum

I didn’t get the purpose, but a custom g-code is possible and relatively simple.

You can get further info in some threads about it, e.g., Custom g-code
or directly at the source:
Linear Move | Marlin Firmware

To be safe, test it near the printer to manually stop (power down) if necessary. If you prefer, paste it here so one can check it.

1 Like

You could always rig up a jig saw :sweat_smile:

2 Likes

Lol

Anyone?

All I need is to move to center
And then lower and raise 3mm many times.

Should this code go into the machine start code?

Thanks

It is a rough draft that loops 5 times (up and down).

G90
G1 X{plate_size_x/2} Y{plate_size_y/2} F3000
G1 Z10 F600
M400
G91 
M400
G1 Z-3 F600  
G1 Z3 F600   
G1 Z-3 F600
G1 Z3 F600
G1 Z-3 F600
G1 Z3 F600
G1 Z-3 F600
G1 Z3 F600
G1 Z-3 F600
G1 Z3 F600

Now, so many issues can arise from this that I don’t know where to start.
Just be aware that this is a draft, so I’m unsure if it works. Also, I am unsure where you will place it in the printer g-code. Note that if something goes wrong, it is on you.

1 Like

Thanks.

I already got it :slight_smile:

I put the code in the machine startup
Right before the bed heating it worked great.

The code was similar.
I think your code with Z-3
May cause the extruder to bump into the bed, no?

You can see the result in this link

I have seen around that gcode can support while loops, that could be very useful
but couldn’t get it to work

If it goes well, no.
Before looping, the toolhead moves to a height of 10 mm (you can set more if you want to be on the safe side).
Then, G91 set relative coordinates.
Thus, Z+3 and Z-3 are relative to the last position (10 mm).

As far as I know, standard g-code doesn’t entail while loops and is interpreted line by line— also, there isn’t a GoTo function.
You may refer to custom functionalities implemented by manufacturers (as BL) or at the host.
To the best of my knowledge, BL doesn’t entail such functionality.

1 Like