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

    Syringes printer, adjust different offset

    Scheduled Pinned Locked Moved
    Firmware installation
    4
    26
    1.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.
    • FJ3Dundefined
      FJ3D @jay_s_uk
      last edited by FJ3D

      @jay_s_uk
      It is true!! changing that now these appear:

      Error: Bad command: var.current_z_pos = move.axes[2].machinePosition
      Error: in file macro line 15 column 37: meta command: unknown variable 'current_z_pos'
      

      CODE

      T0 ; pick up a tool
      G1 Z30 ; Move the bed down (probably taken care of by your tpostx.g macros already, just need to more the bed to a safe position to prevent crashes)
      G10 P0 Z0 ; clear the previous Z-offset for the active tool
      G1 X-12.5 ; move X over the switch
      G1 Y-2 ; move X over the switch
      G91 ; set to relative positioning
      G1 Z-10 H4 ; Syringe tip probes the switch and stops when the switch actuates (that's what the H4 does)
      G90 ; set to absolute positioning
      
      if exists (var.current_z_pos)
          set var.current_z_pos = move.axes[2].machinePosition 
      else
          var.current_z_pos = move.axes[2].machinePosition
      	
      var T0_z_altura = var.current_z_pos - global.z_switch_actuation_height
      
      

      MACRO.PNG

      jay_s_ukundefined 1 Reply Last reply Reply Quote 0
      • jay_s_ukundefined
        jay_s_uk @FJ3D
        last edited by

        @fj3d actually, it was right the first time without the dot as thats setting the variable up, so i was wrong on that one.
        Just thinking about it, you don't need to run an exists on a variable in a macro as you're only using it in that macro.
        The one that may be causing you the issue is the global. does that one exist?

        best to change your macro to

        var current_z_pos = 0
        T0 ; pick up a tool
        G1 Z30 ; Move the bed down (probably taken care of by your tpostx.g macros already, just need to more the bed to a safe position to prevent crashes)
        G10 P0 Z0 ; clear the previous Z-offset for the active tool
        G1 X-12.5 ; move X over the switch
        G1 Y-2 ; move X over the switch
        G91 ; set to relative positioning
        G1 Z-10 H4 ; Syringe tip probes the switch and stops when the switch actuates (that's what the H4 does)
        G90 ; set to absolute positioning
        set var.current_z_pos = move.axes[2].machinePosition
        var T0_z_altura = var.current_z_pos - global.z_switch_actuation_height
        

        I suppose the next question is what are you going to do with the variable T0_z_altura as after the macro finishes its gone

        Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

        FJ3Dundefined 1 Reply Last reply Reply Quote 0
        • FJ3Dundefined
          FJ3D @jay_s_uk
          last edited by

          @jay_s_uk

          With this code I no longer get an error.

          • Picks up the tool, positions itself at the endstop
          • Activates it and here the maro is over, it does nothing else

          Inside config I have the following:

          ;OFFSET TOOLS
          
          G10 P0 X-9 Y39 Z-18.5				; T0
          ;PARA OFFSET HERRAMIENTA
          G10 P0 Z{var.T0_z_altura} ; set new z-offset
          M500 ; save the offset (will appear in config-override.g)
          T-1 ; return the tool to the dock
          
          
          global z_switch_actuation_height = 38 - 19 ; minus the thickness of the sheet of paper, too , if needed
          
          1 Reply Last reply Reply Quote 0
          • jay_s_ukundefined
            jay_s_uk
            last edited by

            @fj3d you can't reference a variable like that as its only present during the macro its ran so you'd have to make it a global instead.

            and what do you mean you have that inside config.g? and changes to a G10 tool offset won't get saved in config.g unless M500 P10 is used

            Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

            FJ3Dundefined 1 Reply Last reply Reply Quote 0
            • FJ3Dundefined
              FJ3D @jay_s_uk
              last edited by FJ3D

              @jay_s_uk

              Ok, I misunderstood the explanation @HebigT

              What I have inside config.g goes inside the macro, of course, it's logical now thought. Sorry but I don't understand programming of this type...

              I have executed the macro and it seems that now it does everything.

              • Picks up the tool, positions itself at the endstop
              • Activate endstop and return execute T-1

              Now my question is, am I supposed to save myself with M500 the value in config-override.g right?

              But I go in and this is what I see and I have:

              ; config-override.g file generated in response to M500 at 2022-09-28 10:15
              ; This is a system-generated file - do not edit
              ; Heater model parameters
              M307 H4 R2.430 K0.560:0.000 D5.50 E1.35 S1.00 B0 V0.0
              ; Workplace coordinates
              G10 L2 P1 X0.00 Y0.00 Z0.00 C0.00
              G10 L2 P2 X0.00 Y0.00 Z0.00 C0.00
              G10 L2 P3 X0.00 Y0.00 Z0.00 C0.00
              G10 L2 P4 X0.00 Y0.00 Z0.00 C0.00
              G10 L2 P5 X0.00 Y0.00 Z0.00 C0.00
              G10 L2 P6 X0.00 Y0.00 Z0.00 C0.00
              G10 L2 P7 X0.00 Y0.00 Z0.00 C0.00
              G10 L2 P8 X0.00 Y0.00 Z0.00 C0.00
              G10 L2 P9 X0.00 Y0.00 Z0.00 C0.00
              

              My macro looks like this:

              var current_z_pos = 0
              T0 ; pick up a tool
              G1 Z30 ; Move the bed down (probably taken care of by your tpostx.g macros already, just need to more the bed to a safe position to prevent crashes)
              G10 P0 Z0 ; clear the previous Z-offset for the active tool
              G1 X-12.5 ; move X over the switch
              G1 Y-2 ; move X over the switch
              G91 ; set to relative positioning
              G1 Z-10 H4 ; Syringe tip probes the switch and stops when the switch actuates (that's what the H4 does)
              G90 ; set to absolute positioning
              
              set var.current_z_pos = move.axes[2].machinePosition
              var T0_z_altura = var.current_z_pos - global.z_switch_actuation_height
              
              ;PARA OFFSET HERRAMIENTA
              G10 P0 Z{var.T0_z_altura} ; set new z-offset
              M500 ; save the offset (will appear in config-override.g)
              T-1 ; return the tool to the dock
              

              ** Ingnore {1}, is added in the forum...**

              jay_s_ukundefined 1 Reply Last reply Reply Quote 0
              • jay_s_ukundefined
                jay_s_uk @FJ3D
                last edited by

                @fj3d you need to use M500 P10 not M500

                Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

                FJ3Dundefined 1 Reply Last reply Reply Quote 0
                • FJ3Dundefined
                  FJ3D @jay_s_uk
                  last edited by

                  @jay_s_uk

                  Yes!!!! I already see added in config-override.g!!!
                  With this it would be enough if I configure it for each tool, right? In other words, if I change the needle right now by executing this macro, my tool would already be calibrated, right?

                  ; config-override.g file generated in response to M500 at 2022-09-28 10:28
                  ; This is a system-generated file - do not edit
                  ; Heater model parameters
                  M307 H4 R2.430 K0.560:0.000 D5.50 E1.35 S1.00 B0 V0.0
                  ; Probed tool offsets
                  G10 P0 X-9.00 Y39.00 Z21.10 C0.00 0.00 0.00 0.00 0.00 0.00 0.00
                  G10 P1 X-9.00 Y39.00 Z-18.50 C0.00 0.00 0.00 0.00 0.00 0.00 0.00
                  G10 P2 X-9.00 Y39.00 Z-18.50 C0.00 0.00 0.00 0.00 0.00 0.00 0.00
                  G10 P3 X-9.00 Y39.00 Z-10.00 C0.00 0.00 0.00 0.00 0.00 0.00 0.00
                  ; Workplace coordinates
                  G10 L2 P1 X0.00 Y0.00 Z0.00 C0.00
                  G10 L2 P2 X0.00 Y0.00 Z0.00 C0.00
                  G10 L2 P3 X0.00 Y0.00 Z0.00 C0.00
                  G10 L2 P4 X0.00 Y0.00 Z0.00 C0.00
                  G10 L2 P5 X0.00 Y0.00 Z0.00 C0.00
                  G10 L2 P6 X0.00 Y0.00 Z0.00 C0.00
                  G10 L2 P7 X0.00 Y0.00 Z0.00 C0.00
                  G10 L2 P8 X0.00 Y0.00 Z0.00 C0.00
                  G10 L2 P9 X0.00 Y0.00 Z0.00 C0.00
                  
                  jay_s_ukundefined 1 Reply Last reply Reply Quote 0
                  • jay_s_ukundefined
                    jay_s_uk @FJ3D
                    last edited by

                    @fj3d assuming your endstop position is calibrated, yes, it should be.
                    but best jog down to the bed and check etc

                    Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

                    FJ3Dundefined 1 Reply Last reply Reply Quote 0
                    • FJ3Dundefined
                      FJ3D @jay_s_uk
                      last edited by

                      @jay_s_uk

                      Another question, should I remove this line from config.g ?

                      ;OFFSET TOOLS
                      
                      G10 P0 X-9 Y39 Z-18.5				; T0
                      
                      jay_s_ukundefined HebigTundefined 2 Replies Last reply Reply Quote 0
                      • jay_s_ukundefined
                        jay_s_uk @FJ3D
                        last edited by

                        @fj3d shouldn't hurt having them as they get overwritten by config-override.g

                        Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

                        1 Reply Last reply Reply Quote 0
                        • HebigTundefined
                          HebigT @FJ3D
                          last edited by HebigT

                          @fj3d Ah, sorry you ran into issues! Thanks, @jay_s_uk for your insight.

                          I think that's exactly right - you won't need to check whether that variable exists because I believe that variable (var.curr_z_pos) is lost when the macro ends. But I might be wrong.

                          You would need an 'if' statement if you set up a macro to probe multiple tools in the same macro, or maybe better, just define variables specific to each tool (curr_z_pos_T0). There may be better ways to do this, though!

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