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

    save tooloffsets on SD

    Scheduled Pinned Locked Moved
    Gcode meta commands
    3
    5
    278
    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.
    • johonlineundefined
      johonline
      last edited by

      I wrote a macro that takes the offset position from the current position (over a permanently installed camera) using G10.

      ;_Cam_XYset.g
      ;setze Offset X, Y für das aktive Tool
      
      var curX = 310 - move.axes[0].machinePosition
      var curY = -3 - move.axes[1].machinePosition
      
      if !(state.currentTool == -1)
      	G10 P{state.currentTool} X{var.curX} Y{var.curY} 
      

      it works fine.

      now I would like to automatically write the values to a file (e.g.:XYZ_offsete.g). But my attempt does not resolve the variables.

      ;save_offsets.g
      
      M28 "0:/sys/xyz_offset.g"
      
      G10 P0 X{tools[0].offsets[0]} Y{tools[0].offsets[1]} Z{tools[0].offsets[2]}        ; T0
      G10 P1 X{tools[1].offsets[0]} Y{tools[1].offsets[1]} Z{tools[1].offsets[2]}        ; T1
      G10 P2 X{tools[2].offsets[0]} Y{tools[2].offsets[1]} Z{tools[2].offsets[2]}        ; T2
      G10 P3 X{tools[3].offsets[0]} Y{tools[3].offsets[1]} Z{tools[3].offsets[2]}        ; T3
      
      
      M29 "0:/sys/xyz_offset.g"
      

      returns

      ;xyz_offset.g"
      
      G10 P0 X{tools[0].offsets[0]} Y{tools[0].offsets[1]} Z{tools[0].offsets[2]}
      G10 P1 X{tools[1].offsets[0]} Y{tools[1].offsets[1]} Z{tools[1].offsets[2]} 
      G10 P2 X{tools[2].offsets[0]} Y{tools[2].offsets[1]} Z{tools[2].offsets[2]}  
      G10 P3 X{tools[3].offsets[0]} Y{tools[3].offsets[1]} Z{tools[3].offsets[2]} 
      

      but it should return like that

      G10 P0 X19.85 Y43.7 Z-7.68	     
      G10 P1 X20.45 Y44 Z-6.71	
      G10 P2 X20.15 Y44 Z-7.46	
      G10 P3 X21.25 Y43.7 Z-6.99		
      
      
      infiniteloopundefined 1 Reply Last reply Reply Quote 0
      • infiniteloopundefined
        infiniteloop @johonline
        last edited by

        @johonline Starting with RRF 3.4.0, you can use the echo command to achieve your goal. Try this (untested):

        var fName = "xyz_offset.g"
        
        echo >{var.fName} "; Stored Offsets"
        echo >>{var.fName} "G10 P0 X"^X{tools[0].offsets[0]}^" Y"^Y{tools[0].offsets[1]}^" Z"^Z{tools[0].offsets[2]}
        ...
        

        With a single ">", echo creates a new file or overwrites an existing one. With ">>", echo appends a line to the file.

        1 Reply Last reply Reply Quote 1
        • Phaedruxundefined Phaedrux moved this topic from Tuning and tweaking
        • OwenDundefined
          OwenD
          last edited by

          Doesn't M500 P10 achieve what you need?
          Then put M501 at the end of your config.g

          1 Reply Last reply Reply Quote 0
          • johonlineundefined
            johonline
            last edited by

            Thanks
            I can use both solutions in my project.

            johonlineundefined 1 Reply Last reply Reply Quote 0
            • johonlineundefined
              johonline @johonline
              last edited by

              @johonline
              My solution to measure the nozzle tip on the tool changer with a 2nd micro switch on the edge of the print bed (in series in the micro switch on the tool carrier). --> I no longer need to adjust the microsteps! (the nozzle and the bed should be hot!)

              T-1
              M98 P"homez.g"			; Home Z
              G90
              G1 Z10
              G1 X309.5 Y205 Z10 F50000
              G30 S-1
              var null_Z = move.axes[2].machinePosition 0.03;   0.1 eng   -0.6 weit
              
              G1 Y190 Z10
              
              T0
              G90
              G1 Z10
              G1 X309.5 Y200 Z10 F50000
              G1 X309.5 Y205 Z10 F50000
              G30 S-1
              var tool_Z0 = var.null_Z - move.axes[2].machinePosition
              G10 P0 Z{var.tool_Z0}
              G1 Y190 Z10
              
              
              T1
              G90
              G1 Z10
              G1 X309.5 Y200 Z10 F50000
              G1 X309.5 Y205 Z10 F50000
              G30 S-1
              var tool_Z1 = var.null_Z - move.axes[2].machinePosition
              G10 P1 Z{var.tool_Z1}
              G1 Y190 Z10
              
              
              T2
              G90
              G1 Z10
              G1 X309.5 Y200 Z10 F50000
              G1 X309.5 Y205 Z10 F50000
              G30 S-1
              var tool_Z2 = var.null_Z - move.axes[2].machinePosition
              G10 P2 Z{var.tool_Z2}
              G1 Y190 Z10
              
              
              T3
              G90
              G1 Z10
              G1 X309.5 Y200 Z10 F50000
              G1 X309.5 Y205 Z10 F50000
              G30 S-1
              var tool_Z3 = var.null_Z - move.axes[2].machinePosition
              G10 P3 Z{var.tool_Z3}
              
              G1 Y190 Z10
              
              T-1
              
              M500 P10
              
              
              
              

              DSC_2135.JPG

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