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

    Feature Request - workpiece angle compensation CNC

    Scheduled Pinned Locked Moved
    Firmware wishlist
    11
    54
    2.7k
    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.
    • CanDo415undefined
      CanDo415 @Phaedrux
      last edited by

      @Phaedrux 3.4.1

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

        @CanDo415 Please update to 3.5.1 and double check your macro that it matches the one shared. Particularly the line number the error reports.

        Z-Bot CoreXY Build | Thingiverse Profile

        CanDo415undefined 1 Reply Last reply Reply Quote 0
        • CanDo415undefined
          CanDo415 @Phaedrux
          last edited by

          @Phaedrux
          copied the macro.
          I have to fix all problems from the update first. Messed up my whole config😧

          1 Reply Last reply Reply Quote 0
          • CanDo415undefined
            CanDo415
            last edited by CanDo415

            "Error: in file macro line 37 column 12: meta command: unknown variable 'var'"
            is the new result after updating to 3.5.1

            var y_first_measurement = 0
            var y_second_measurement = 0
            var y_length = 0
            var x_first_measurement = 0
            var x_second_measurement = 0
            var x_length = 0
            var y_over_x = 0
            var y_x_tan_rads = 0
            var y_x_tan_deg = 0
             
            M291 P"Probe links vor das Werstück positionieren" S2 X1 Y1 Z1					; Pop up box asking for operator input
            M558 F1500																		; Set the initial probing speed
            G38.2 Y600 P0 K0																	; Probe the material as a first pass
            G1 Y{move.axes[1].machinePosition-5}											; Move 5mm away from the material
            M558 F150																		; Set the final probing speed
            G38.2 Y600 P0 K0																	; Probe the material again
            M400																			; Make sure all movement is complete
            set var.y_first_measurement=move.axes[1].machinePosition						; Record the stop position y_first_measurement
            set var.x_first_measurement=move.axes[0].machinePosition						; Record the stop position x_first_measurement
            M400																			; Make sure all data recording is complete
            G1 Y{move.axes[1].machinePosition-10}											; Move 5mm away from the material
            G1 X{move.axes[0].machinePosition+50}											; Move along the workpiece in X
            M558 F1500																		; Set the initial probing speed
            G38.2 Y600 P0 K0																	; Probe the material as a first pass
            G1 Y{move.axes[1].machinePosition-5}											; Move 5mm away from the material
            M558 F150																		; Set the final probing speed
            G38.2 Y600 P0 K0																	; Probe the material again
            M400																			; Make sure all movement is complete
            set var.y_second_measurement=move.axes[1].machinePosition						; Record the stop position y_second_measurement
            set var.x_second_measurement=move.axes[0].machinePosition						; Record the stop position x_second_measurement
            M400																			; Make sure all data recording is complete
            set var.y_length={var.y_second_measurement-var.y_first_measurement}
            set var.x_length={var.x_second_measurement-var.x_first_measurement}
            set var.y_over_x={var.y_length/var.x_length}
            set var.y_x_tan_rads=atan(var.y_over_x)
            set var.var y_x_tan_rads=degrees{var.y_x_tan_rads}
            G68 A0 B0 R{var.y_x_tan_rads}
            
            jay_s_ukundefined droftartsundefined 2 Replies Last reply Reply Quote 0
            • jay_s_ukundefined
              jay_s_uk @CanDo415
              last edited by

              @CanDo415 i have a mistake in my macro. i have corrected my original

              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

              CanDo415undefined 1 Reply Last reply Reply Quote 0
              • CanDo415undefined
                CanDo415 @jay_s_uk
                last edited by

                @jay_s_uk
                @Phaedrux
                Error: line 37 column 22: meta command: unknown value 'degrees'
                there seems to be a bit more

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

                  @CanDo415 i've made another change but I don't think its going to fix the issue.
                  I don't know why "degrees" throws an error though as its a built in command

                  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

                  CanDo415undefined OwenDundefined 2 Replies Last reply Reply Quote 0
                  • CanDo415undefined
                    CanDo415 @jay_s_uk
                    last edited by

                    that's why i added Phaedrux.

                    I want to change it a bit to get the corner as well. so the degrees issue has to be solved anyway.
                    Thanks for the great start jay

                    CanDo415undefined 1 Reply Last reply Reply Quote 0
                    • CanDo415undefined
                      CanDo415 @CanDo415
                      last edited by

                      @dc42
                      maybe he can help?

                      1 Reply Last reply Reply Quote 0
                      • droftartsundefined
                        droftarts administrators @CanDo415
                        last edited by

                        @CanDo415 @jay_s_uk

                        set var.var y_x_tan_rads=degrees{var.y_x_tan_rads}

                        There's a space in the variable name, ie var.var y_x_tan_rads isn't a valid variable name.

                        Ian

                        Bed-slinger - Mini5+ WiFi/1LC | RRP Fisher v1 - D2 WiFi | Polargraph - D2 WiFi | TronXY X5S - 6HC/Roto | CNC router - 6HC | Tractus3D T1250 - D2 Eth

                        CanDo415undefined 1 Reply Last reply Reply Quote 0
                        • CanDo415undefined
                          CanDo415 @droftarts
                          last edited by CanDo415

                          @droftarts
                          jay corrected it already.
                          the problem shifted to the degrees command

                          1 Reply Last reply Reply Quote 0
                          • OwenDundefined
                            OwenD @jay_s_uk
                            last edited by

                            @jay_s_uk said in Feature Request - workpiece angle compensation CNC:

                            @CanDo415 i've made another change but I don't think its going to fix the issue.
                            I don't know why "degrees" throws an error though as its a built in command

                            degrees() is a function

                            You've used curly braces instead of parentheses

                            set var.y_x_tan_deg=degrees{var.y_x_tan_rads}
                            

                            try

                            set var.y_x_tan_deg=degrees(var.y_x_tan_rads)
                            
                            jay_s_ukundefined CanDo415undefined 2 Replies Last reply Reply Quote 2
                            • jay_s_ukundefined
                              jay_s_uk @OwenD
                              last edited by jay_s_uk

                              @OwenD i knew it would be something about the way its been formatted
                              updated the original again

                              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
                              • CanDo415undefined
                                CanDo415 @OwenD
                                last edited by

                                @OwenD
                                thank you for showing up the problem

                                CanDo415undefined 1 Reply Last reply Reply Quote 0
                                • CanDo415undefined
                                  CanDo415 @CanDo415
                                  last edited by

                                  G68 A0 B0 R{-var.y_x_tan_rads}
                                  the "-" seems important. otherwise the system gets turned the wrong way round

                                  CanDo415undefined 1 Reply Last reply Reply Quote 0
                                  • CanDo415undefined
                                    CanDo415 @CanDo415
                                    last edited by CanDo415

                                    @jay_s_uk
                                    i modified it quite a bit. some points are still not ready.
                                    I'm not shure how to ent the if passage.
                                    end if seems not to work

                                    var y_1 = 0
                                    var x_1 = 0
                                    var x_2 = 0
                                    var x_3 = 0
                                    var x_4 = 0
                                    var x_5 = 0
                                    var delta_x = 0
                                    var y_2 = 0
                                    var y_3 = 0
                                    var y_4 = 0
                                    var y_5 = 0
                                    var delta_y = 0
                                    var z0 = 0
                                    var d_probe = 0
                                    var m_1 = 0
                                    var m_2 = 0
                                    var m_1_tan_rads = 0
                                    var m_1_tan_deg = 0
                                     
                                    M291 P"position probe over front left corner of workpiece" S2 X1 Y1 Z1	; Pop up box asking for operator input
                                    M558 F300																		; Set the initial probing speed
                                    G38.2 Z-60 P0 K0																; Probe the material as a first pass
                                    M558 F50																		; Set the final probing speed
                                    G38.4 Z50 P0 K0	                                                                                                                                ; Move away from workpiece in Z
                                    M400																			        ; Make sure all movement is complete
                                    set var.z0=move.axes[2].machinePosition	                			    		                ; Record the stop position y_first_measurement
                                    M400																			        ; Make sure all data recording is complete
                                    
                                    G1 Z{move.axes[2].machinePosition+5}										; Move along the workpiece in X
                                    G1 X{move.axes[0].machinePosition-20}										; Move 5mm away from the material
                                    G1 Y{move.axes[1].machinePosition+5}										; Move 5mm away from the material
                                    G1 Z{move.axes[2].machinePosition-3}											; Move along the workpiece in X
                                    
                                    M558 F1000																		; Set the initial probing speed
                                    G38.2 X100 P0 K0																; Probe the material as a first pass
                                    M558 F50																		; Set the final probing speed
                                    G38.4 X-10 P0 K0	                                                                                                                        ; Move away from workpiece in X
                                    M400																			        ; Make sure all movement is complete
                                    set var.y_1=move.axes[1].machinePosition							    		        ; Record the stop position y_first_measurement
                                    set var.x_1=move.axes[0].machinePosition							    		        ; Record the stop position x_first_measurement
                                    M400																			        ; Make sure all data recording is complete
                                    
                                    G1 X{move.axes[0].machinePosition-5}											; Move 5mm away from the material
                                    G1 Z{move.axes[2].machinePosition+10}										; Move along the workpiece in X
                                    G1 X{move.axes[0].machinePosition+15}										; Move 5mm away from the material
                                    G1 Y{move.axes[1].machinePosition-20}										; Move 5mm away from the material
                                    G1 Z{move.axes[2].machinePosition}	    										; Move along the workpiece in X
                                    
                                    M558 F1000																		; Set the initial probing speed
                                    G38.2 Y100 P0 K0																; Probe the material as a first pass
                                    M558 F50																		; Set the final probing speed
                                    G38.4 Y-10 P0 K0															        ; Probe the material again
                                    M400																			        ; Make sure all movement is complete
                                    set var.y_2=move.axes[1].machinePosition								    	        ; Record the stop position y_first_measurement
                                    set var.x_2=move.axes[0].machinePosition					    				        ; Record the stop position x_first_measurement
                                    M400																			        ; Make sure all data recording is complete
                                    G1 Y{move.axes[1].machinePosition-50}										; Move 5mm away from the material
                                    G1 X{move.axes[0].machinePosition+50}										; Move along the workpiece in X
                                    M558 F1000																		; Set the initial probing speed
                                    G38.2 Y100 P0 K0																; Probe the material as a first pass
                                    M558 F50																		; Set the final probing speed
                                    G38.4 Y-10 P0 K0																; Probe the material again
                                    M400																			        ; Make sure all movement is complete
                                    set var.y_3=move.axes[1].machinePosition								    	        ; Record the stop position y_second_measurement
                                    set var.x_3=move.axes[0].machinePosition								    	        ; Record the stop position x_second_measurement
                                    M400																			        ; Make sure all data recording is complete
                                    M291 P"Probe Diameter" R"enter diameter of probe" S5 L0 H10			; Pop up box asking for operator input diameter of 
                                    set var.d_probe=input															; set the diameter of the probe
                                    ;calculation
                                    set var.delta_y={var.y_3-var.y_2}
                                    set var.delta_x={var.x_3-var.x_2}
                                    set var.m_1={var.delta_y/var.delta_x}											; m of the staight P2-P3
                                    set var.m_2={(-var.delta_x)/var.delta_y}										        ; m of perpendicilar to straight P2-P3
                                    set var.m_1_tan_rads=atan(var.m_1)
                                    set var.m_1_tan_deg=degrees(var.m_1_tan_rads)
                                    
                                    ;calc the corner of workpeace
                                    set var.x_4=((var.y_1-(-(var.x_3-var.x_2)/(var.y_3-var.y_2))*var.x_1)-(var.y_2-((var.y_3-var.y_2)/(var.x_3-var.x_2)*var.x_2)))/(((var.y_3-var.y_2)/(var.x_3-var.x_2))-(-(var.x_3-var.x_2)/(var.y_3-var.y_2)))
                                    set var.y_4=(-(var.x_3-var.x_2)/(var.y_3-var.y_2))*((var.y_1-(-(var.x_3-var.x_2)/(var.y_3-var.y_2))*var.x_1)-(var.y_2-((var.y_3-var.y_2)/(var.x_3-var.x_2)*var.x_2)))/(((var.y_3-var.y_2)/(var.x_3-var.x_2))-(-(var.x_3-var.x_2)/(var.y_3-var.y_2)))+(var.y_1-(-(var.x_3-var.x_2)/(var.y_3-var.y_2))*var.x_1)
                                    If var.y_2>var.y_3																; workpiece Zero coordinates
                                    set var.x_5=var.x_4+(COS(ARCTAN(var.m_1))+COS(ARCTAN(var.m_2)))*var.d_probe/2
                                    set var.y_5=var.y_4+(SIN(ARCTAN(var.m_1))+SIN(ARCTAN(var.m_2)))*var.d_probe/2
                                    If var.y_2<var.y_3
                                    set var.x_5=var.x_4+(COS(ARCTAN(var.m_1))-COS(ARCTAN(var.m_2)))*var.d_probe/2
                                    set var.y_5=var.y_4+(SIN(ARCTAN(var.m_1))-SIN(ARCTAN(var.m_2)))*var.d_probe/2
                                    
                                    ;move over workpiece zero and set tool x&y to 0
                                    G1 Y{move.axes[1].machinePosition-1}											        ; Move 1mm away from the material
                                    G1 Z{move.axes[2].machinePosition+10}											; Move above workpiece
                                    
                                    ;G68 A0 B0 R{-var.m_1_tan_deg}                                                                                                        ; set Rotation
                                    
                                    Exerqtorundefined 1 Reply Last reply Reply Quote 0
                                    • Exerqtorundefined
                                      Exerqtor @CanDo415
                                      last edited by Exerqtor

                                      @CanDo415
                                      You have to indent the lines you want to be part of the conditional statement, thats a place to start at least.

                                      CanDo415undefined 1 Reply Last reply Reply Quote 0
                                      • CanDo415undefined
                                        CanDo415 @Exerqtor
                                        last edited by

                                        @Exerqtor
                                        like:

                                        If var.y_2>var.y_3																; workpiece Zero coordinates
                                        set var.x_5=var.x_4+(COS(ARCTAN(var.m_1))+COS(ARCTAN(var.m_2)))*var.d_probe/2
                                        set var.y_5=var.y_4+(SIN(ARCTAN(var.m_1))+SIN(ARCTAN(var.m_2)))*var.d_probe/2
                                        end if
                                        
                                        If var.y_2<var.y_3
                                        set var.x_5=var.x_4+(COS(ARCTAN(var.m_1))-COS(ARCTAN(var.m_2)))*var.d_probe/2
                                        set var.y_5=var.y_4+(SIN(ARCTAN(var.m_1))-SIN(ARCTAN(var.m_2)))*var.d_probe/2
                                        end if
                                        

                                        ?

                                        Exerqtorundefined dc42undefined 2 Replies Last reply Reply Quote 0
                                        • Exerqtorundefined
                                          Exerqtor @CanDo415
                                          last edited by Exerqtor

                                          @CanDo415
                                          No like:

                                          if var.y_2 > var.y_3																; workpiece Zero coordinates
                                            set var.x_5 = var.x_4 + (COS(ARCTAN(var.m_1)) + COS(ARCTAN(var.m_2))) * var.d_probe / 2
                                            set var.y_5 = var.y_4 + (SIN(ARCTAN(var.m_1)) + SIN(ARCTAN(var.m_2))) * var.d_probe / 2
                                          
                                          if var.y_2 < var.y_3
                                            set var.x_5 = var.x_4 + (COS(ARCTAN(var.m_1)) - COS(ARCTAN(var.m_2))) * var.d_probe / 2
                                            set var.y_5 = var.y_4 + (SIN(ARCTAN(var.m_1)) - SIN(ARCTAN(var.m_2))) * var.d_probe / 2
                                          
                                          CanDo415undefined 1 Reply Last reply Reply Quote 0
                                          • CanDo415undefined
                                            CanDo415 @Exerqtor
                                            last edited by

                                            @Exerqtor
                                            i tried this before in another case... everything unter the 2nd if wasnt done if the if doesn't match.
                                            the problem of the missing end if

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