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

    Pressure advance tuning with conditional G-code

    Scheduled Pinned Locked Moved
    Gcode meta commands
    11
    43
    3.3k
    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.
    • PCRundefined
      PCR @Heartleander81
      last edited by

      @chrishamm

      Via privat chat @Heartleander81 and I tried to solve his problem.

      He is using a D3 with SBC. I am using a D3M+ standalone. I sent him my macro and he tried to simulatet it. He got this error:

      GetFileInfo: Cannot convert Z parameter to float (value {var.layer_height})
      

      We both are running 3.4 B5. Could this be a DSF Problem?

      @oozeBot i know you have some printer running D3 with SBC. Can you try to simulate it?

      Best

      Heartleander81undefined chrishammundefined 2 Replies Last reply Reply Quote 0
      • Heartleander81undefined
        Heartleander81 @PCR
        last edited by

        I have copy second time the Code from first comment.

        I have the error with the line 139 and 141 but the test run now.

        1 Reply Last reply Reply Quote 0
        • chrishammundefined
          chrishamm administrators @PCR
          last edited by

          @pcr Can you please send me the full G-code file?

          Duet software engineer

          PCRundefined 1 Reply Last reply Reply Quote 0
          • PCRundefined
            PCR @chrishamm
            last edited by

            @chrishamm here ya goPA.g

            1 Reply Last reply Reply Quote 0
            • oozeBotundefined
              oozeBot
              last edited by oozeBot

              Here is the console output. This was tested on a 6HC with attached SBC running 3.4b5.

              After simulation:

              M37 P"0:/gcodes/1636019653286-pa.g"
              Error: Operation failed (Reason: ArgumentException in SimpleCode: Cannot convert Z parameter to float (value {var.layer_height}))
              

              After upload:

              Failed to get file info for 1636019653286-pa.g
              Operation failed (Reason: ArgumentException in GetFileInfo: Cannot convert Z parameter to float (value {var.layer_height}))
              
              1 Reply Last reply Reply Quote 0
              • Heartleander81undefined
                Heartleander81
                last edited by

                Am I correct that the SBC scans the file and since it does not find a clear layer height, the error is there? Is only a guess, since without sbc the error is apparently not there

                The test run now at my printer with the 2 error line 139 and 141. Nice work.

                Schmartundefined 2 Replies Last reply Reply Quote 0
                • Schmartundefined
                  Schmart @Heartleander81
                  last edited by

                  @heartleander81 said in Pressure advance tuning with conditional G-code:

                  Am I correct that the SBC scans the file and since it does not find a clear layer height, the error is there? Is only a guess, since without sbc the error is apparently not there

                  Well, it does indeed seem the handling is different compared to running the G-code on a standalone board. Please run the following macro, first with M37 and then with M98. Make sure you've homed the Z-axis yourself, and/or adjust the macro to suit your printer.

                  var z = 25.0
                  G1 Z{var.z} F600
                  

                  I think that if this small snippet fails, we should follow up with one of the developers.

                  I've also run the code posted by @PCR on my printer as well, with M37, M32 and M98. The only thing that was noticeably different, were some printer-specific adjustments he made, and lines ending with \x0A\x0A (LFLF) characters, while mine uses \x0D\x0A (CRLF). So this code should run fine.

                  The test run now at my printer with the 2 error line 139 and 141. Nice work.

                  So you're still seeing the weird 'purge_139_flow_ratio' and 'purge_141_flow_ratio' errors? These kind of errors are triggered when a variable is not defined. I can't explain the cause of that. But it seems that the word 'line' in the variable name purge_line_flow_ratio gets substituted with the named constant called 'line' in the firmware part that prepares macro error messages. That also shouldn't happen.

                  I can't reproduce this with my firmware build, and I haven't yet tested with an older firmware. Can you check what the following macro yields?

                  G1 X{var.a_line_liner} F600
                  

                  On my printer this results in the following expected error message. It doesn't say unknown variable 'a_1_liner' or unknown variable 'a_1_1r' or something like that:

                  1b67efa6-9389-4a6c-b1d3-112343e05db0-image.png

                  Furthermore, can you run the macro(s) without the SBC (don't know if that's possible with your setup) and/or share what M122 returns?

                  Creality CR-20 Pro with a Duet 2 Maestro, 3Dfused X+Z-axis rail kit, HIWIN-based DIY solution for the Y-axis, E3D Hemera, working ST7565 MiniPanel and various other small hardware improvements.

                  Heartleander81undefined 1 Reply Last reply Reply Quote 0
                  • Schmartundefined
                    Schmart @Heartleander81
                    last edited by

                    @heartleander81 About variables and this script running on a SBC, the documentation does still state that "These are supported in RRF 3.3 running in standalone mode". I'm not sure if this still applies, but it might explain your problems.

                    Creality CR-20 Pro with a Duet 2 Maestro, 3Dfused X+Z-axis rail kit, HIWIN-based DIY solution for the Y-axis, E3D Hemera, working ST7565 MiniPanel and various other small hardware improvements.

                    1 Reply Last reply Reply Quote 0
                    • Schmartundefined
                      Schmart @izeman
                      last edited by Schmart

                      @izeman said in Pressure advance tuning with conditional G-code:

                      I wanted to try the code as well, and it doesn't seem to work as expected. The nozzle and bed heat up, and then the heater is turned off again as it starts printing it seems.

                      I came across this fix in the release notes for RepRapFirmware 3.4.0beta3:

                      M568 did not allow the P parameter to be omitted

                      So that explains that! 🤗

                      Creality CR-20 Pro with a Duet 2 Maestro, 3Dfused X+Z-axis rail kit, HIWIN-based DIY solution for the Y-axis, E3D Hemera, working ST7565 MiniPanel and various other small hardware improvements.

                      1 Reply Last reply Reply Quote 0
                      • izemanundefined
                        izeman @Schmart
                        last edited by izeman

                        @schmart said in Pressure advance tuning with conditional G-code:

                        @izeman I'm missing text like 'Axes to be homed' in the console, so I'm assuming you had to modify the code for the topology of your printer.

                        Yes. Thanks. I inserted my G32 & G29 S1. All axes are homed.
                        And I now just have to correct the M568 command, as I'm running 3.3 still. And then we'll see 🙂

                        1 Reply Last reply Reply Quote 0
                        • Heartleander81undefined
                          Heartleander81 @Schmart
                          last edited by

                          @schmart

                          Screenshot_20211105-113036.jpg

                          That come when I make a macro with: G1 X{var.a_line_liner} F600.

                          My M122

                          === Diagnostics === 
                          RepRapFirmware for Duet 3 MB6HC version 3.4.0beta5 (2021-10-12 13:53:56) running on Duet 3 MB6HC v1.01 or later (SBC mode) 
                          Board ID: 08DJM-9P63L-DJ3T8-6J1DA-3SD6P-KV4H9 
                          Used output buffers: 1 of 40 (14 max) 
                          === RTOS === 
                          Static ram: 151104 
                          Dynamic ram: 66408 of which 240 recycled 
                          Never used RAM 132920, free system stack 200 words 
                          Tasks: SBC(resourceWait:,0.6%,518) HEAT(notifyWait,0.0%,321) Move(notifyWait,0.0%,351) CanReceiv(notifyWait,0.0%,772) CanSender(notifyWait,0.0%,374) CanClock(delaying,0.0%,339) TMC(notifyWait,8.2%,92) MAIN(running,91.0%,921) 
                          IDLE(ready,0.2%,30), total 100.0% 
                          Owned mutexes: HTTP(MAIN) 
                          === Platform === 
                          Last reset 00:09:14 ago, cause: software 
                          Last software reset at 2021-11-05 11:27, reason: User, GCodes spinning, available RAM 127336, slot 0 
                          Software reset code 0x0003 HFSR 0x00000000 CFSR 0x00000000 ICSR 0x0043c000 BFAR 0x00000000 SP 0x00000000 Task SBC Freestk 0 n/a 
                          Error status: 0x00 
                          Aux0 errors 0,0,0 
                          Step timer max interval 134 
                          MCU temperature: min 30.8, current 32.7, max 43.3 
                          Supply voltage: min 25.1, current 25.2, max 25.2, under voltage events: 0, over voltage events: 0, power good: yes 
                          12V rail voltage: min 12.1, current 12.1, max 12.2, under voltage events: 0 
                          Heap OK, handles allocated/used 0/0, heap memory allocated/used/recyclable 0/0/0, gc cycles 0 Driver 0: pos 0, standstill, SG min/max 0/0, reads 8042, writes 14 timeouts 0 
                          Driver 1: pos 0, standstill, SG min/max 0/0, reads 8041, writes 15 timeouts 0 
                          Driver 2: pos 0, standstill, SG min/max 0/0, reads 8041, writes 15 timeouts 0 
                          Driver 3: pos 0, standstill, SG min/max 0/0, reads 8042, writes 14 timeouts 0 
                          Driver 4: pos 0, standstill, SG min/max 0/0, reads 8042, writes 14 timeouts 0 
                          Driver 5: pos 0, standstill, SG min/max 0/0, reads 8045, writes 11 timeouts 0 
                          Date/time: 2021-11-05 11:37:02 Slowest loop: 24.87ms; fastest: 0.04ms 
                          === Storage === 
                          Free file entries: 10 
                          SD card 0 not detected, interface speed: 37.5MBytes/sec 
                          SD card longest read time 0.0ms, write time 0.0ms, max retries 0 
                          === Move === 
                          DMs created 125, segments created 0, maxWait 0ms, bed compensation in use: none, comp offset 0.000 
                          === MainDDARing === 
                          Scheduled moves 0, completed 0, hiccups 0, stepErrors 0, LaErrors 0, Underruns [0, 0, 0], CDDA state -1 
                          === AuxDDARing === 
                          Scheduled moves 0, completed 0, hiccups 0, stepErrors 0, LaErrors 0, Underruns [0, 0, 0], CDDA state -1 
                          === Heat === 
                          Bed heaters = 0 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1, chamberHeaters = -1 -1 -1 -1 
                          === GCodes === 
                          Segments left: 0 
                          Movement lock held by null 
                          HTTP* is doing "M122" in state(s) 0 
                          Telnet is idle in state(s) 0 
                          File is idle in state(s) 0 
                          USB is idle in state(s) 0 
                          Aux is idle in state(s) 0 
                          Trigger* is idle in state(s) 0 
                          Queue is idle in state(s) 0 
                          LCD is idle in state(s) 0 
                          SBC is idle in state(s) 0 
                          Daemon is idle in state(s) 0 
                          Aux2 is idle in state(s) 0 
                          Autopause is idle in state(s) 0 
                          Code queue is empty 
                          === CAN === 
                          Messages queued 4978, received 11016, lost 0, longest wait 2ms for reply type 6049, peak Tx sync delay 5611, free buffers 49 (min 48), ts 2772/2771/0 Tx timeouts 0,0,0,0,0,0 
                          === SBC interface === 
                          State: 4, failed transfers: 0, checksum errors: 0 
                          Last transfer: 2ms ago 
                          RX/TX seq numbers: 21916/21916 
                          SPI underruns 0, overruns 0 
                          Disconnects: 0, timeouts: 0, IAP RAM available 0x2b7dc 
                          Buffer RX/TX: 0/0-0 
                          === Duet Control Server === 
                          Duet Control Server v3.4-b5 
                          Code buffer space: 4096 
                          Configured SPI speed: 8000000Hz 
                          Full transfers per second: 39.68, max wait times: 45.1ms/18.9ms 
                          Codes per second: 0.15 
                          Maximum length of RX/TX data transfers: 3040/832
                          
                          Schmartundefined 1 Reply Last reply Reply Quote 0
                          • medicusdkfzundefined
                            medicusdkfz
                            last edited by

                            Hi,

                            thank you for your incredible job... Could you tell me, what the latest version is?

                            TY, Pierre

                            PCRundefined Schmartundefined 2 Replies Last reply Reply Quote 1
                            • PCRundefined
                              PCR @medicusdkfz
                              last edited by

                              @medicusdkfz still the first one. Which is working perfectly here

                              1 Reply Last reply Reply Quote 0
                              • CNCModellerundefined
                                CNCModeller @Schmart
                                last edited by

                                @schmart

                                This seems to be working a treat on my machine. Thanks very much for the effort!

                                The only tweaks I did was to:

                                • Move the position of the print as I can't print in the centre of my bed, and alter the basic print settings.

                                • Add a var to control if the file was simulated or not in a single location. I then put an if before the relevant GCode statements w.r.t. setting and un setting simulation mode.

                                ; Single location to activate simulation mode
                                var sim_mode = 0
                                
                                if {var.sim_mode > 0}
                                   M37 S1 ; Enter simulation mode
                                
                                if {var.sim_mode > 0}
                                   M37 S0 ; Leave simulation mode
                                
                                

                                Disable Bed heating if the temperature is set to 0 as I don't have a working heated bed yet.

                                if {var.bed_temperature > 0}
                                   M190 S{var.bed_temperature} ; Wait for bed temperature to reach setpoint
                                
                                if {var.bed_temperature > 0}
                                   M140 S0 ; Turn off bed
                                
                                

                                Just thinking a similar approach to retraction / de-retraction distances might be a nice project too, albeit I'm going to have to learn a lot about conditional GCode to figure that out!!

                                Anyway thanks again, this is great 🙂

                                Best Regards
                                Barry M

                                Polar Duet3 Mini + 1HCL
                                https://youtube.com/playlist?list=PLWjZVEdMv1BY82izahK45qKh-hp3NFkix
                                Wanhao D4S: Duet2
                                https://forum.duet3d.com/post/296755
                                K40 Laser, Duet2
                                https://forum.duet3d.com/post/312082
                                Wanhao D5S
                                https://www.youtube.com/CNCModellerUK

                                Schmartundefined 1 Reply Last reply Reply Quote 0
                                • Schmartundefined
                                  Schmart @Heartleander81
                                  last edited by

                                  @heartleander81 that little one-liner you ran (error message pun intended) confirmed that variables in the meta command language are not yet (fully) supported on SBC setups. Unfortunately, my macro heavily relies on variables and I don't see a simple alternative to avoid using them. I think your best chance is to ask one of the RRF developers for an outlook on support for SBC-based setups.

                                  Creality CR-20 Pro with a Duet 2 Maestro, 3Dfused X+Z-axis rail kit, HIWIN-based DIY solution for the Y-axis, E3D Hemera, working ST7565 MiniPanel and various other small hardware improvements.

                                  1 Reply Last reply Reply Quote 0
                                  • Schmartundefined
                                    Schmart @medicusdkfz
                                    last edited by

                                    @medicusdkfz said in Pressure advance tuning with conditional G-code:

                                    Hi,

                                    thank you for your incredible job... Could you tell me, what the latest version is?

                                    TY, Pierre

                                    Thanks Pierre! And yes, the macro in the first post is still the latest version. I'm planning to provide an update with minor changes this week, including the ones from @CNCModeller, but probably nothing drastic. If you have any ideas for improvement, let me know.

                                    Creality CR-20 Pro with a Duet 2 Maestro, 3Dfused X+Z-axis rail kit, HIWIN-based DIY solution for the Y-axis, E3D Hemera, working ST7565 MiniPanel and various other small hardware improvements.

                                    1 Reply Last reply Reply Quote 0
                                    • Schmartundefined
                                      Schmart @CNCModeller
                                      last edited by

                                      @cncmodeller said in Pressure advance tuning with conditional G-code:

                                      This seems to be working a treat on my machine. Thanks very much for the effort!

                                      You're welcome, I'm happy that you got it working 👍

                                      • Add a var to control if the file was simulated or not in a single location. I then put an if before the relevant GCode statements w.r.t. setting and un setting simulation mode.

                                      I've since learned that M37 also supports simulating a macro based on meta commands, and that doesn't require changing the code itself, so that might even be a more robust option for a less confident user?

                                      On the other hand, your approach 1) puts the code itself in "debugging mode" which is persistent and developer-friendly and 2) doesn't add the "time taken" at the bottom of the macro file.

                                      Disable Bed heating if the temperature is set to 0 as I don't have a working heated bed yet.

                                      That's an excellent point, I hadn't considered printers without a heated bed. If you don't mind, I would like to incorporate your optimizations.

                                      Just thinking a similar approach to retraction / de-retraction distances might be a nice project too, albeit I'm going to have to learn a lot about conditional GCode to figure that out!!

                                      The reason why I found the pressure advance tuning such a good first use case, is because I couldn't convince my slicer to print a contiguous perimeter/wall with different speeds. At least in PrusaSlicer, the modifiers insisted on splitting the model in separate parts.

                                      However, I was also a bit proud and hand-crafted all G-code and calculations myself, with secondary features like the brim taking a disproportional amount of time. So I wouldn't necessarily recommend doing that.

                                      I'm currently tackling retraction tuning with PrusaSlicer entirely. I simply add two cylinder shapes some distance apart, and enter a height-based formula in the "Before layer change G-code" text box in PrusaSlicer that determines the retraction value.

                                      Theoretically, such a test model would not be difficult to convert to a macro. However, I'm dearly missing the concept of a 'function' in the meta command instruction set, which would make it easier to create and maintain such code. Therefore, I think the quickest road to success is to further resist the urge to DIY things like infill and circular perimeters and start by parameterizing the G-code of a pre-sliced model.

                                      Do you have any favorite models to tune retraction?

                                      Anyway thanks again, this is great 🙂

                                      😁

                                      Creality CR-20 Pro with a Duet 2 Maestro, 3Dfused X+Z-axis rail kit, HIWIN-based DIY solution for the Y-axis, E3D Hemera, working ST7565 MiniPanel and various other small hardware improvements.

                                      CNCModellerundefined 2 Replies Last reply Reply Quote 0
                                      • CNCModellerundefined
                                        CNCModeller @Schmart
                                        last edited by

                                        @schmart feel free to use anything I've contributed.

                                        I'm only just getting to the point of wanting to dial in my printer by science rather than guessing / witchcraft. Print quality and speed has only just got good enough to warrant the effort.

                                        I believe Teaching Tech's calibration website is a pretty good resource. But I used your code before venturing over there.

                                        link

                                        Personally I was thinking the same way as you, two decent diameter thin wall towers and judge stringing and wall gaps on un-retract when starting a layer on each tower.

                                        Definitely something I need to get to grips with!

                                        Thanks again 🙂

                                        All the best.
                                        Barry M

                                        Polar Duet3 Mini + 1HCL
                                        https://youtube.com/playlist?list=PLWjZVEdMv1BY82izahK45qKh-hp3NFkix
                                        Wanhao D4S: Duet2
                                        https://forum.duet3d.com/post/296755
                                        K40 Laser, Duet2
                                        https://forum.duet3d.com/post/312082
                                        Wanhao D5S
                                        https://www.youtube.com/CNCModellerUK

                                        Schmartundefined 1 Reply Last reply Reply Quote 0
                                        • CNCModellerundefined
                                          CNCModeller @Schmart
                                          last edited by

                                          @schmart

                                          PS: w.r.t functions, I think it's possible to call other gcode files as subroutines and I even think you can pass in variables in recent beta firmware but not sure about returning results. More reading required lol.

                                          Polar Duet3 Mini + 1HCL
                                          https://youtube.com/playlist?list=PLWjZVEdMv1BY82izahK45qKh-hp3NFkix
                                          Wanhao D4S: Duet2
                                          https://forum.duet3d.com/post/296755
                                          K40 Laser, Duet2
                                          https://forum.duet3d.com/post/312082
                                          Wanhao D5S
                                          https://www.youtube.com/CNCModellerUK

                                          T3P3Tonyundefined 1 Reply Last reply Reply Quote 0
                                          • T3P3Tonyundefined
                                            T3P3Tony administrators @CNCModeller
                                            last edited by

                                            @cncmodeller, @Schmart you would need to use a global variable, set in the sub macro, to pass information back to the main calling macro.

                                            www.duet3d.com

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