GOTO and/or G41

Would there be any way to add the "GOTO" command to the list of commands you can program into Gcode? 

Example code:

N1 G1 E1 F500
N2 G0 X1 Y2 Z1
N3 G0 X2 Y1 Z2
N3 GOTO N1

If that could be written into the firmware or the main program, this feature would make Repetier a very powerful tool for hackers to use on machines that aren't primarily 3d printers. 

I posted a question about it in the tips and tricks section of this forum, but I figured I would post another question in this section, because this feature makes it really easy to build your own code without having to model it and slice it, then edit it.  Not everyone can use this, but in some instances, one could program many small parts to print and with an offset, they can make, write and use small batches of code for repetitious processes.  I'm personally using Repetier host to run a custom machine that does the same 5 to 10 lines of code, over and over.

If there is something I'm missing, let me know. 

Thanks,

Scot

Comments

  • No that is not possible. Gcode ha sno line numbers - they are added on transfer for error correction only and you can not know which line in code gets which line send.
  • Repetier said:
    No that is not possible. Gcode ha sno line numbers - they are added on transfer for error correction only and you can not know which line in code gets which line send.
    So there is no way to do that at all?  Maybe I'm just old fashioned, but I can see this feature, if added could sincerely enhance the product. 

    Perhaps there is another Gcode interpreter that can.  I guess I'm on a journey for arduino, cnc, rather than arduino 3d printing.  I guess GRBL is the closest thing, but still not sure if it can do that code juggle. 


  • I don't think grbl can do this either.
  • G41 is not supported by GRBL, if you just want to repeat some sequences you can do this via scripts in repetier host
  • RAyWB said:
    G41 is not supported by GRBL, if you just want to repeat some sequences you can do this via scripts in repetier host
    I found that out.  It's true.  G41 isn't supported by much of anything out there in the Arduino cnc world.  But I know it's possible.  It just didn't have a need for most people.  I understand that things like this can be done using some Mcodes now in GRBL.   I'm pretty new to repetier host and scripts, though.  Any tips on how to do this in a clean manner?  I've got 5 lines of code that need to be repeated 864 times or less, but not more.  This program actuates a mechanism that performs a specific, semi-hard automated task. 

    Any pointers would really help.  I'm not new to CNC, just to the 3d printer controllers.  They're awesome.  But a bit limited in some ways.  Then again, it's a printer, not a mill. 

    From what I see, this platform has very real potential in basic robotics for small scale things.  I used to make tiny screws on CNC lathes.  This would be perfect for things like sorting, counting, packaging, etc. 

    Anyway, I'll be looking into scripts, but if there is any shortcuts to doing it right, let me know! 
  • edited January 2018
    OK , so 864 times is a lot,  not comfortable to manual click that number of repetitions via script.
    might be better  to generate a file  f.e.  in excel .
  • Arduinos do not store teh gcode (only 8kb ram) so they forget a line after parsing it. You could write a own gcode for the repeated task if that is so important. Then only send the gcode for task instead. G-code generators should be able to add the gcode where needed or you must write your own postprocessor to do so.
  • Hi,
    I am happily using Repetier Host with my STARTT3D (clone of TRONXY XY-100) with repetier 0.92 firmware. I am currently doing a small upgrade to the printer with a custom small drill, mounted on the cursor. This is used to help me in doing PCB prototypes of course. I was able to program the printer to drill all holes (exported from an Excellon file by FlatCAM), and the result was very nice.



    Now I would like to try to "Cut" the board with a mill but I need to perform multiple passes for the profile of the PCB, with very small increments of the Z axis. I mean 20 or more passes. So I was interested in a way to implement a "loop" in the code. 

    Since the g-code is sent line by line from the editor of the host to the controller, it would be possible to implement host-specific codes, like for example @execute command param1 param2 to define a label in the source code, a counter and a conditional statement to perform a loop, something like this:

    @setVar 1 0 ; set var "1" equal to "0", ; maybe a small array of variables can be defined. @label 1 ; set label "1" to this line number of the gcode source ; Profile pass
    G1 Z-0.02 F10
    G4 P250
    G1 X+38.8000 Y0.0000 F1
    G1 X0.0000 Y+33.5000 F1
    G1 X-38.8000 Y0.0000 F1
    G1 X0.0000 Y-33.5000 F1
    @incrementVar 1 ; increment var "1" by one.
    @checkVarGreaterVal 1 20 ; check if var "1" is greater than value "20" and ; store a flag (0:false 1:true)
    @gotoLabelIfTrue 1 ; go to label "1" if the flag is true ; (after that reset the flag) ; otherwise ignore the goto and move on. ...

    This is inspired by a typical assembly approach when implementing a controlled loop, but I think it could be possible and not that much difficult to implement. Maybe this could be a start point for more complex workflows. I really hope that this could be done :)

    Francesco.

  • Nice approach but if we start adding a language then we should do it right meaning real equations etc. Not really sure if and when I would implement this. Even in your case you could simply make z increment relative and just copy the code 20 times. Might be nice for test scripts if we also add feedback from printer as variables. 
  • Repetier said:Nice approach but if we start adding a language then we should do it right meaning real equations etc. Not really sure if and when I would implement this. 
    Yes, I know what you mean. 
    Repetier said:
     Might be nice for test scripts if we also add feedback from printer as variables. 
    Exactly, so the script can check for example the position and modify the flow accordingly. For the loop thing, maybe a starting point could be to be able to execute one of the custmizable scripts n times. Maybe a specific text box can contain the numeric value that the used can edit, then by clicking on the icon of a script the host sends the program n times...
  • The script solution does not sound good to me. I feel it is too hacky. But I guess the minimal scripts will come some time.
  • Yes, but the scripting feature could be "the thing that makes the difference" since there is a way to use the firmware in CNC mode for laser and mill. Sometimes it's useful to create a "program" and move the tool to perform specific tasks. Anyway, I like Repetier so much and for now, this is good. 
  • Yes, small programs or wizards that can be written and shared would be something I really like to have in the end. I mean with some gui in addition. Maybe I get a good idea how to allow writing this maybe as a simplified javascript code that I can load. Then we get the interactivity form javascript and server gui just needs some help functions to make up the gui. But currently we have more urgend stuff to write. But that is where I want to go in the end.
  • This is good to know. Meanwhile, I was wondering if there is a doc where I can understand how the repetier firmware receives gcode lines and sends back an acknowledge to move to the next command. This could be useful for writing a simple sequencer of commands. maybe using Python...
  • We send the ack "ok" when the command has been moved from input buffer. Executing happens shortly after this. This makes communication a bit faster then waiting with "ok" until command is executed.
Sign In or Register to comment.