Maybe a noob question



  • Im trying to avoid putting any scripting inside my gcode files and let the Duet take care of it all.

    where do i put the codes?



  • Most of it can be handled by the system macros.
    There's info here
    https://reprap.org/wiki/RepRap_Firmware_macros

    Otherwise put your code into custom macros and call them using M98 P"path_to_macro"



  • @joehsmash Not exactly sure what you are trying to achieve but when you first apply power to the printer, the contents of config.g get read in, then config override if you use that. So your scripting commands can be run at power up, you can put them at the end of either of those two files. Other than that, the only other files that get read are macros. So if your scripting commands involve homing moves or settings, you can put them in the homing macros. Or you can create your own macros.



  • There are system macros and user macros. You call Macros using M98.

    System macros (besides config.g and the homing macros) that are more or less equivalent to slicer start/end gcodes are start.g, stop.g setting up pause.g, cancel.g resume.g is a good idea as well I guess).

    RRF also supports machine side filament management including temperature setting, pressure advance, flow rate correction etc. I've not used that but it probably is worth looking into.

    Do note that many slicers put some start and end gcode into their gcode files if you didn't set up any yourself (or, even more annoying, set bed and heater heat up gcode if you have custom start gcode that doesn't cover that).

    Lastly, make sure to read the following indispensable wiki pages



  • Awesome thanks guys,

    basically what im looking at now is that in my simplify 3d slicer im currently running these in my start script

    G28 ; home all axes
    G29 S1
    G1 X-114.0 Y-122.00 F6000 ; Move for prime
    G1 E40.0 ; Prime Hotend
    G1 X0 Y0 F6000

    so for instance would i just put these in the config under the custom settings?

    im trying to get out of the habbit of having to reclice something and reupload it every time i want to make an adjustment.



  • @joehsmash
    As stated above, anything in config.g will get run at power up.
    You could put that in start.g

    You need to take the time to read the links provided so that you understand which macro gets called at which point and/or in response to which G or M command..


  • Moderator

    Doing a prime line in start.g is a bit problematic because normally the filament temperatures are set by the slicer and unless you use the same type of filament all the time, you can't reliably preheat in start.g. So here's how I do it.

    Start.g preheats and homes the printer, resets some variables, and passes off to the sliced gcode file.

    Slicer sets final bed and nozzle temps and waits before it inserts the start gcode section.. which only has a single line that calls nozzle prime macro with M98 P"NozzlePrime.g"

    The nozzle prime macro extrudes a prime line at the corner and then the actual print starts.



  • @Phaedrux So looking though my g files, and i dont have a start.g any where. which was why i asked here.

    if there were start.g and end.g it would make perfect sense,

    im kind of with you, i didnt see the point of adding some of my start routine into the config.g as thats loaded when the machine starts. not nessicarily when the print starts.

    @OwenD so lets say i create a start.g and i add all of my scripts/macros in there how do i get the duet firmware to want to call the start.g inorder to start a print?

    currently i just right click on an stl that i have uploaded and start it from there.

    same with the end.g, ive found that now when ever a print finishes, the printer leaves the nozzle just above the last point, i have it now that when it finishes it moves the print head to the back left hand corner of the printer.



  • @joehsmash
    start.g and stop.g are not automatically created.
    If they exist, they will run automatically at the start and end of a print.
    Note the caveats that @Phaedrux stated with regards to slicer settings.

    I still do quite a bit in my slicer start section.
    In my slicer end section I just have a single command M0
    Running M0 will call stop.g (if it exists)
    All my code for shutting everything off is in there.


  • Moderator

    start.g

    M106 P2 F30000 S0.5 H-1 C"Duet Fans"
    M140 S65		; set heated bed to 65 and release
    T0			; Select Tool 0
    M291 P"Print Started. Preheating and Homing." T10
    G4 S1
    M98 P"0:/macros/Musical Tunes/LuckyTune.g" ; Lucky tune to start print off on the right foot
    G4 S1
    M220 S100		; Set speed factor back to 100% in case it was changed
    M221 S100		; Set extrusion factor back to 100% in case it was changed
    M290 R0 S0		; clear babystepping
    M106 S0			; Turn part cooling blower off if it is on
    G10 P0 R0 S80		; Set extruder to 80 and release
    M190 S65		; set heated bed to 65 and wait
    G28			; home XYZ
    G29 S1			; load heightmap
    M400
    G10 P0 R80 S180	; Set extruder to 180 and release
    M98 P"0:/sys/ZSpeedsPrint.g"	; Load Z speeds for printing
    M98 P"0:/sys/CurrentsPrint.g"	; Load print motor currents
    
    ; Slicer Start Gcode begins.
    

    Slicer sets temps and calls prime...

    ;M98 P"0:/sys/PrimeNozzle.g"
    
    G90 			; Absolute positioning
    G1 X1 Y270 F6000 	; Move to rear left corner
    M400 			; clear movement buffer
    M116 			; Wait for temps
    G1 Z0.3 F100		; Move Z to prime height
    G91 			; Relative positioning
    M83 			; Relative extrusion
    G1 X40 E10 F300 	; Prime nozzle
    G10			; Retract
    G1 Y-1 X1 F10000 	; Wipe nozzle
    M400
    

    File prints.

    Slicer end gcode has M0 which calls stop.g

    ; stop.g
    ; called when M0 (Stop) is run (e.g. when a print from SD card is cancelled)
    ; Also called by slicer end gcode by M0
    ;
    M400			; Finish move queue
    M104 S0 		; Extruder heater off
    M140 S0 		; Bed heater off
    M106 S255 		; Fan at 100 to cool nozzle and bed
    G91			; Relative positioning
    M220 S100		; Set speed factor back to 100% in case it was changed
    M221 S100		; Set extrusion factor back to 100% in case it was changed
    G1 E-2 F9000			; Retract filament 2mm
    G1 X5 Y5 F9000		; Wipe nozzle 
    G1 Z20 F500			; raise nozzle 5mm from printed part
    G90				; absolute positioning
    G1 X150 Y130 F6000		; Move x and Y axis over to bed center so probe is on top of bed
    ;M104 S35		; Set hot end low and wait
    G4 S60			; Wait 5 minutes
    ;M116			; wait for temp to drop
    G28 X Y			; Home X and Y
    G28 X Y			; Home it again, Sam.
    M290 R0 S0		; clear babystepping
    M84			; Steppers off
    M98 P"ZSpeedsNormal.g"	; Load normal z speed settings again.
    M106 S0			; Fan off
    M106 P2 F30000 L0.1 X0.8 B0.5 T35:70 H100:101:102 C"Duet Fans"
    
    ;Play a little beep beep beep to show print ended.
    M400			; Clear queue again before jingle
    G4 S1
    M300 P250 S750
    G4 P251
    M300 P200 S1250
    G4 P201
    M300 P250 S750
    G4 P251
    M300 P200 S1250
    G4 P201
    M300 P250 S2500
    G4 P251
    M300 P150 S2000
    G4 P151
    M300 P150 S2500
    G4 P151
    M300 P350 S3700
    G4 P351
    


  • @OwenD great, that totally clears it up.

    just wasnt sure on how to call them!

    @Phaedrux thank you for your examples theres a lot of good stuff in here that i may or may not borrow when and if i can get this new layer shifting issue fixed.

    thanks again!
    Joeh


Log in to reply