Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Error: Bad command: macros

    Scheduled Pinned Locked Moved Solved
    General Discussion
    5
    22
    1.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Topherundefined
      Topher @code7
      last edited by

      @code7 said in Error: Bad command: macros:

      when running a print that calls macros such as "M98 P/macros/Power_OFF".

      also make sure you have the proper structure example:M98 P"mymacro.g" the macro must be fully enclosed in quotes, not the way you had shown.

      1 Reply Last reply Reply Quote 1
      • Phaedruxundefined
        Phaedrux Moderator
        last edited by Phaedrux

        https://duet3d.dozuki.com/Wiki/Gcode?revisionid=HEAD#Section_M98_Call_Macro_Subprogram

        Notes

        1 In RRF2.x and earlier, string can be enclosed in quotes if required, see Quoted Strings for details. In RRF3, quotation marks around the filename are mandatory.

        Z-Bot CoreXY Build | Thingiverse Profile

        code7undefined 1 Reply Last reply Reply Quote 0
        • code7undefined
          code7 @Phaedrux
          last edited by

          @phaedrux @LeckieTech

          The folder hasn't changed.

          Thanks for letting me know about the mandatory quote change. I've been using Simplify3D post processing to to replace M102 in the gcode file with the macro I'd like to to run but it will only replace what is between the first two occurring quotes. Do you have any ideas for a S3D post processing work around?

          {REPLACE "M102" "M98 "P/macros/Power_OFF""}
          Writes only "M98" to gcode file.

          {REPLACE "M102" "M98 P/macros/Power_OFF"}
          No longer works as mentioned above in RR 3.3

          Delta Printer Using a Duet 2 Wifi v1.04c, FW3.4.0beta2, Duet WiFi sever 1.26, Duet Web Control 3.3.0

          Topherundefined 2 Replies Last reply Reply Quote 0
          • Topherundefined
            Topher @code7
            last edited by Topher

            @code7 Unfortunately, S3D doesn't support additional quotes inside post-processing REPLACE function. The workaround I use: in your system folder, make a new file using an unused G or M command ie: M990.g then put the contents of your macro within that folder.

            In simplify, use{REPLACE "M102" "M990 ; Switch off PSU"}

            fcwiltundefined 1 Reply Last reply Reply Quote 0
            • fcwiltundefined
              fcwilt @Topher
              last edited by

              @leckietech

              Perhaps you can do what I do.

              In the section for user code I have M98 P"print_begin.g" and M98 P"print_end.g".

              This is what S3D is generating for me:

              ; S3D inserts the following before the call to this file
              ;G90				; absolute XYZ moves
              ;M83				; relative E   moves
              ;M106 S0			; fan on to 0 (correct way to do fan off)
              ;M140 S60			; set bed      temp but don't wait
              ;M104 S190 T0			; set extruder temp but don't wait
              ;M98 P"print_begin.g"           ; invokes this file
              

              I handle everything in my code.

              Frederick

              Printers: a E3D MS/TC setup and a RatRig Hybrid. Using Duet 3 hardware running 3.4.6

              Topherundefined 1 Reply Last reply Reply Quote 0
              • Topherundefined
                Topher @fcwilt
                last edited by

                @fcwilt suppose it depends on the use. If it was used to turn the power supply on it would have to be called at G90. S3D will place it too far ahead.

                In my code, I use the REPLACE function to replace G90 for my start Gcode. ```{REPLACE "G90" "G90 \nM990 ; print begin script} My actual output looks something like this:

                G90 ; This is a trigger in post for M990 print begin
                M990 ; Jump to M990.g print begin custom script in duet sys files
                M83
                M106 S0
                M104 S220 T0
                G10 Z0 ; set work place orgin 
                ; process 1 First Layer
                ; layer 1, Z = 0.150
                T0
                G110 ; Retract filament
                ; feature outer perimeter
                M204 S500
                M205 X5 Y5
                ; tool H0.150 W0.400
                G1 Z0.150 F1002
                G1 X91.152 Y75.557 F10002
                G111 ; Unretract filament
                G1 X91.735 Y74.896 E0.0242 F900
                G1 X92.392 Y74.303 E0.0243
                

                My M990.g file in /sys looks like this:

                ;----------------------------------------------------------------------------
                ;---------------------Print Begin Script-------------------------------------
                ;----------------------------------------------------------------------------
                
                ; when M990 is called do:
                
                if heat.heaters[0].current < 65
                	M104 S140
                M106 P1 S255 ; set hot end fan high
                M400 ; allow buffer to finish for lighting
                M150 U255 R55	; Set caution light
                M300 S500 P200	; tone for operator
                G4 P200
                M300 S1000 P200
                G4 P200
                M300 S500 P600
                M291 S2 R"Ready to run file?" P{job.file.fileName}
                if heat.heaters[0].current > 65
                	M140 S75
                if heat.heaters[0].current < 65
                	M140 S65
                if heat.heaters[1].current < 139.5
                	M400
                	M150 U255 B65	; set light purple for heating up
                	M109 S140	; Wait till hot end is hot to home
                
                M400
                M150 R255 ; green light to move to next phase
                G90
                M83
                if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed || !move.axes[3].homed		; Check if the printer is homed
                	G28	; Home printer if not already homed
                M572 D0 S0.3	; set linear advance
                M207 S4 ; set retraction length 
                G1 Z5 F10000
                
                ;-------------------- Prime position----------------------------
                G1 Y0 X248
                ;--------------------------------------------------------------
                G1 Z0
                if heat.heaters[0].current < 65
                	M400
                	M150 U255 B65	; set light purple for heating up
                	M140 S65
                	M190 S65	; set bed to print and wait
                M400
                if heat.heaters[0].current < 75 && heat.heaters[0].current > 65
                	M400
                	M150 U255 B65	; set light purple for heating up
                	M104 S220 T0	; set nozzle to print temp 
                	M140 S75
                	M109 S220 T0 ; wait for nozzle to get to print temp
                	M190 S75	; set bed to print and wait
                if heat.heaters[1].current < 220
                	M400
                	M150 U255 B65	; set light purple for heating up
                	M140 S75
                	M109 S220 T0 ; wait for nozzle to get to print temp
                	M190 S75	; set bed to print and wait
                M400
                M150 R255 B65	; set light to printing color 
                M106 P1 S0 ; set hotend fan low for first layer printing 
                G1 Z0.1500 ; Move noz to build plate
                G111 ; Unretract filament
                ;---------------lay down 3 lines to prime noz------------------
                G1 E2 F90 ; prime filament 
                G1 X3 Y0 E7 F900
                G1 Y0.55
                G1 X248 E7 F900
                G1 Y1.1
                G1 X3 E7 F900
                ;-------------End, go to print file----------------
                
                fcwiltundefined 1 Reply Last reply Reply Quote 0
                • fcwiltundefined
                  fcwilt @Topher
                  last edited by

                  @leckietech

                  So you want to turn on some power supply right at the beginning of a print?

                  Frederick

                  Printers: a E3D MS/TC setup and a RatRig Hybrid. Using Duet 3 hardware running 3.4.6

                  Topherundefined 1 Reply Last reply Reply Quote 0
                  • Topherundefined
                    Topher @fcwilt
                    last edited by

                    @fcwilt OP wanted to turn off his supply with M102, but you could also turn on a supply with G90 as a trigger for a script to run. you could also add a G4 S5 to allow the supply to have time to stabilize the inrush current. My setup doest use a switchable supply, we have a huge 9kw supply on a buss bar running each of our racks here 🙂

                    1 Reply Last reply Reply Quote 0
                    • Topherundefined
                      Topher @code7
                      last edited by

                      @code7 said in Error: Bad command: macros:

                      @phaedrux @LeckieTech

                      The folder hasn't changed.

                      Thanks for letting me know about the mandatory quote change. I've been using Simplify3D post processing to to replace M102 in the gcode file with the macro I'd like to to run but it will only replace what is between the first two occurring quotes. Do you have any ideas for a S3D post processing work around?

                      {REPLACE "M102" "M98 "P/macros/Power_OFF""}
                      Writes only "M98" to gcode file.

                      {REPLACE "M102" "M98 P/macros/Power_OFF"}
                      No longer works as mentioned above in RR 3.3

                      I thought of an easier way for you to do this. Just make a file in your system directory called M102.g and put your PSU macro text in the file. M102 isn't used by RRF so you can use it natively right out of S3D, not need to run any post in S3D for it.

                      dc42undefined code7undefined 2 Replies Last reply Reply Quote 0
                      • fcwiltundefined
                        fcwilt @code7
                        last edited by

                        @code7 said in Error: Bad command: macros:

                        Re: "Bad command" errors on PanelDue

                        I just updated to 3.3 and am now receiving errors when running a print that calls macros such as "M98 P/macros/Power_OFF".

                        Error: Bad command: macros/Power_OFF

                        However, If I run the macro from the terminal it runs just fine.

                        Does anyone have any ideas on how I can work around this?

                        When do you this macro to run?

                        Frederick

                        Printers: a E3D MS/TC setup and a RatRig Hybrid. Using Duet 3 hardware running 3.4.6

                        1 Reply Last reply Reply Quote 0
                        • dc42undefined
                          dc42 administrators @Topher
                          last edited by dc42

                          @leckietech although officially M98 requires quotes around the filename in RRF3, unofficially it still works without them in standalone mode. So I wonder whether S3D does something special with the forward-slash character. Have you checked what the generated GCode file contains?

                          Duet WiFi hardware designer and firmware engineer
                          Please do not ask me for Duet support via PM or email, use the forum
                          http://www.escher3d.com, https://miscsolutions.wordpress.com

                          Topherundefined 1 Reply Last reply Reply Quote 0
                          • Topherundefined
                            Topher @dc42
                            last edited by

                            @dc42 said in Error: Bad command: macros:

                            @leckietech although officially M98 requires quotes around the filename in RRF3, unofficially it still works without them in standalone mode. So I wonder whether S3D does something special with the forward-slash character. Have you checked what the generated GCode file contains?

                            when you and I were talking about this the other day, I never did get a proper output using additional quotes from S3D. I also saw on simplify's forums that many others were having the same trouble since 2018 with no solution. After you suggested making my own M codes, since then I have been using this and my own custom G110 and G111 firmware retraction codes with much success, it simply works flawlessly. I've made a dozen of my own custom codes and am in the works of adding these to all the printers in our farm! Opens the door to so much flexibility!

                            code7undefined 1 Reply Last reply Reply Quote 1
                            • code7undefined
                              code7 @Topher
                              last edited by

                              @leckietech @fcwilt

                              Thanks for the good work arounds. The script is run on retractions.

                              @dc42
                              This line produced by S3D runs fine when pasted into the DWC console, but it doesn't run from inside of a gcode file.
                              "M98 P/macros/Power_OFF"

                              Delta Printer Using a Duet 2 Wifi v1.04c, FW3.4.0beta2, Duet WiFi sever 1.26, Duet Web Control 3.3.0

                              dc42undefined fcwiltundefined 2 Replies Last reply Reply Quote 0
                              • dc42undefined
                                dc42 administrators @code7
                                last edited by

                                @code7 said in Error: Bad command: macros:

                                This line produced by S3D runs fine when pasted into the DWC console, but it doesn't run from inside of a gcode file.
                                "M98 P/macros/Power_OFF"

                                Please make the GCode file available on a file sharing site - dont copy and paste the contents because I think there may be a non-printing character embedded in that line.

                                Duet WiFi hardware designer and firmware engineer
                                Please do not ask me for Duet support via PM or email, use the forum
                                http://www.escher3d.com, https://miscsolutions.wordpress.com

                                1 Reply Last reply Reply Quote 0
                                • fcwiltundefined
                                  fcwilt @code7
                                  last edited by

                                  @code7 said in Error: Bad command: macros:

                                  The script is run on retractions.

                                  Your turning some power supply off on every retraction????

                                  Frederick

                                  Printers: a E3D MS/TC setup and a RatRig Hybrid. Using Duet 3 hardware running 3.4.6

                                  1 Reply Last reply Reply Quote 0
                                  • code7undefined
                                    code7 @Topher
                                    last edited by code7

                                    @leckietech said in Error: Bad command: macros:

                                    I thought of an easier way for you to do this. Just make a file in your system directory called M102.g and put your PSU macro text in the file. M102 isn't used by RRF so you can use it natively right out of S3D, not need to run any post in S3D for it.

                                    I've tried this with the M102.g macro within the system directory. When I send M102 from the console the green popup displays indicating the command is good but nothing runs. Do you know why this might be?

                                    @dc42
                                    Here is the S3D gcode file

                                    @fcwilt I'm turning off a device at each retraction.

                                    Delta Printer Using a Duet 2 Wifi v1.04c, FW3.4.0beta2, Duet WiFi sever 1.26, Duet Web Control 3.3.0

                                    Topherundefined fcwiltundefined 2 Replies Last reply Reply Quote 0
                                    • Topherundefined
                                      Topher @code7
                                      last edited by

                                      @code7 can you post what is in the M102.g file?

                                      1 Reply Last reply Reply Quote 0
                                      • fcwiltundefined
                                        fcwilt @code7
                                        last edited by

                                        @code7 said in Error: Bad command: macros:

                                        @fcwilt I'm turning off a device at each retraction.

                                        And you cannot use the user code hook in S3D for retraction?

                                        Frederick

                                        Printers: a E3D MS/TC setup and a RatRig Hybrid. Using Duet 3 hardware running 3.4.6

                                        1 Reply Last reply Reply Quote 0
                                        • dc42undefined
                                          dc42 administrators @code7
                                          last edited by

                                          @code7 M101, M102 and M103 are already implemented. Use a different code. I don't know why they are not listed on the GCodes wiki page.

                                          Duet WiFi hardware designer and firmware engineer
                                          Please do not ask me for Duet support via PM or email, use the forum
                                          http://www.escher3d.com, https://miscsolutions.wordpress.com

                                          code7undefined 1 Reply Last reply Reply Quote 1
                                          • code7undefined
                                            code7 @dc42
                                            last edited by

                                            @dc42
                                            I changed M102.g to another number and it's working great now. Thanks

                                            Delta Printer Using a Duet 2 Wifi v1.04c, FW3.4.0beta2, Duet WiFi sever 1.26, Duet Web Control 3.3.0

                                            1 Reply Last reply Reply Quote 1
                                            • First post
                                              Last post
                                            Unless otherwise noted, all forum content is licensed under CC-BY-SA