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

    M671 like function for Delta printer

    Scheduled Pinned Locked Moved
    Gcode meta commands
    7
    45
    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.
    • OwenDundefined
      OwenD @tecno
      last edited by

      @tecno
      I'm going to have to eat my words on this one.
      There does indeed seem to be some sort of issue with saving echo commands that are not sent from the DWC channel.
      I tried putting M118 in the macro as well with no joy.

      Your only option at this point is to use echo to write to the file directly from the macro.

      echo >"0:/sys/savedData.txt"
      G30 S-1 ; do probe at current point
      echo >>"Stopped at height " ^ move.axes[2].machinePosition ^ "mm"
      
      tecnoundefined 1 Reply Last reply Reply Quote 0
      • tecnoundefined
        tecno @OwenD
        last edited by tecno

        @OwenD
        Trying this

        echo >"0:/sys/savedData.txt"
        M562                    ; clear any bed transform from mesh leveling
        G90                     ; absolute positioning
        G1 Z50 F4000            
        G1 X0 Y0				; 1 point
        G30 S-1
        echo >>"Stopped at height" ^ move.axes[2].machinePosition ^ "mm"
        

        And get this error:

        M98 P"0:/macros/test"
        Stopped at height 0.758 mm
        Error: in file macro line 7 column 28: meta command: expected an expression
        

        Above creates 2 empty files

        OwenDundefined dc42undefined 2 Replies Last reply Reply Quote 0
        • OwenDundefined
          OwenD @tecno
          last edited by

          @tecno
          Apologies.
          Should have had the filename in both echo commands.

          echo >"0:/sys/savedData.txt"
          
          G30 S-1 ; do probe at current point
          
          echo >>"0:/sys/savedData.txt" "Stopped at height " ^ move.axes[2].machinePosition ^ "mm"
          
          tecnoundefined 1 Reply Last reply Reply Quote 0
          • tecnoundefined
            tecno @OwenD
            last edited by

            @OwenD

            No reason to apoligise, I am thankful for all help I can get.

            Now I get these values in txtfile, they also show up in console but nothing can be done there.
            How to save the file so it can be exported as CSV directly from console.

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

              @tecno
              I'm not sure I understand what you are looking for.
              The use of the echo command is detailed here
              https://docs.duet3d.com/User_manual/Reference/Gcode_meta_commands#echo-command

              If you want each probe point on a single line then use three > symbols

              echo >"0:\sys\testFile.csv" "Test1,Test2,Test3,Test4,Test5,"
              while iterations < 5
                 G30 S-1
                 echo >>>"0:\sys\testFile.csv" move.axes[2].machinePosition  ^ ","
              

              The resulting file will be something like

              Test1,Test2,Test3,Test4,Test5,
              1.388,1.595,1.595,2.015,2.213,
              
              tecnoundefined 1 Reply Last reply Reply Quote 0
              • tecnoundefined
                tecno @OwenD
                last edited by

                @OwenD

                Error: in file macro line 8 column 8: meta command: expected string expression

                achrnundefined 1 Reply Last reply Reply Quote 0
                • achrnundefined
                  achrn @tecno
                  last edited by

                  @tecno said in M671 like function for Delta printer:

                  @OwenD

                  Error: in file macro line 8 column 8: meta command: expected string expression

                  None of the macro extracts you've posted in teh thread recently even have an eighth line. What does line 8 of the macro file say?

                  tecnoundefined 1 Reply Last reply Reply Quote 0
                  • tecnoundefined
                    tecno @achrn
                    last edited by

                    @achrn

                    echo >>>"0:\sys\testFile.csv" ^ move.axes[2].machinePosition ^ ","
                    
                    achrnundefined 1 Reply Last reply Reply Quote 0
                    • achrnundefined
                      achrn @tecno
                      last edited by

                      @tecno https://docs.duet3d.com/en/User_manual/Reference/Gcode_meta_commands#echo-command says >>> is only supported in firmware 3.5beta2 and later, what are you running?

                      tecnoundefined 1 Reply Last reply Reply Quote 0
                      • tecnoundefined
                        tecno @achrn
                        last edited by

                        @achrn
                        3.4.5 and nobody has said this before.

                        It runs now but still I need to get correct syntax for the csv file for all results on same line.

                        echo >>"0:\sys\testFile.csv" {move.axes[2].machinePosition} ,","
                        
                        point1,point2,point3,point4
                        0.858 ,
                        0.824 ,
                        1.322 ,
                        0.821 ,
                        
                        
                        achrnundefined 1 Reply Last reply Reply Quote 0
                        • achrnundefined
                          achrn @tecno
                          last edited by achrn

                          @tecno said in M671 like function for Delta printer:

                          @achrn
                          3.4.5 and nobody has said this before.

                          Well, it's been in the docs a while, I think.

                          It runs now but still I need to get correct syntax for the csv file for all results on same line.

                          I don't think you can, working it in a loop like that. you could dump the loop and do five separate probes storing in single variables then write to file with a single line, I think. e.g.

                              G30 S-1  ; probe
                              set var.z1 = move.axes[2].machinePosition ; memorise probe position
                              G30 S-1
                              set var.z2 = move.axes[2].machinePosition
                              G30 S-1
                              set var.z3 = move.axes[2].machinePosition
                              G30 S-1
                              set var.z4 = move.axes[2].machinePosition
                              G30 S-1
                              set var.z5 = move.axes[2].machinePosition
                             echo >>"0:\sys\testFile.csv" "whatever", var.z1,  var.z2, var.z3, var.z4, var.z5
                          
                          tecnoundefined 1 Reply Last reply Reply Quote 0
                          • tecnoundefined
                            tecno @achrn
                            last edited by tecno

                            @achrn

                            OK, will play with your suggestion and see the results.

                            tecnoundefined 1 Reply Last reply Reply Quote 0
                            • tecnoundefined
                              tecno @tecno
                              last edited by

                              M98 P"0:/macros/test var.g"
                              Stopped at height 0.708 mm
                              Error: in file macro line 7 column 13: meta command: unknown variable 'z1'
                              
                              G28
                              M562                    ; clear any bed transform from mesh leveling
                              G90                     ; absolute positioning
                              G1 Z50 F4000            
                              G1 X0 Y0				; 1 point
                              G30 S-1
                              set var.z1 = move.axes[2].machinePosition
                              G1 Z50 F4000 
                              G1 X-154 Y-164 F4000    ; 2 point   
                              G30 S-1
                              set var.z2 = move.axes[2].machinePosition
                              G1 Z50 F4000
                              G1 X-63 Y214 F4000      ; 3 point   
                              G30 S-1
                              set var.z3 = move.axes[2].machinePosition
                              G1 Z50 F4000
                              G1 X217 Y-52 F4000      ; 4 point   
                              G30 S-1
                              set var.z4 = move.axes[2].machinePosition
                              G1 Z50 F4000
                              echo >>"0:\sys\testFile.csv" "whatever", var.z1, var.z2, var.z3, var.z4
                              G28
                              
                              
                              achrnundefined 1 Reply Last reply Reply Quote 0
                              • achrnundefined
                                achrn @tecno
                                last edited by

                                @tecno said in M671 like function for Delta printer:

                                Error: in file macro line 7 column 13: meta command: unknown variable 'z1'
                                

                                Well yes, you need to initialise the variables.

                                var z1 = 0
                                var z2 = 0
                                var z3 = 0
                                var z4 = 0
                                var z5 = 0
                                

                                before you first refer to any of them.

                                tecnoundefined 1 Reply Last reply Reply Quote 0
                                • tecnoundefined
                                  tecno @achrn
                                  last edited by

                                  @achrn said in M671 like function for Delta printer:

                                  @tecno said in M671 like function for Delta printer:

                                  Error: in file macro line 7 column 13: meta command: unknown variable 'z1'
                                  

                                  Well yes, you need to initialise the variables.

                                  var z1 = 0
                                  var z2 = 0
                                  var z3 = 0
                                  var z4 = 0
                                  var z5 = 0
                                  

                                  before you first refer to any of them.

                                  Works like a charm now!

                                  Is there a way to replace "whatever" with date + time?

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

                                    @tecno said in M671 like function for Delta printer:

                                    echo >>"Stopped at height" ^ move.axes[2].machinePosition ^ "mm"

                                    Should be:

                                    echo >>"0:/sys/savedData.txt" "Stopped at height" ^ move.axes[2].machinePosition ^ "mm"
                                    

                                    i.e. you need to specify the filename again.

                                    Instead of using move.axes[2].machinePosition I suggest you use sensors.probes[0].lastStopHeight as I suggested earlier.

                                    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

                                    tecnoundefined 1 Reply Last reply Reply Quote 1
                                    • tecnoundefined
                                      tecno @dc42
                                      last edited by

                                      This is what works now, only missing part is date/time stamp.

                                      ; test var.g macro
                                      datetime 0.758 1.074 1.122 0.821
                                      datetime 0.708 1.074 1.022 0.771
                                      
                                      G28
                                      var z1 = 0
                                      var z2 = 0
                                      var z3 = 0
                                      var z4 = 0
                                      M562                    ; clear any bed transform from mesh leveling
                                      G90                     ; absolute positioning
                                      G1 Z50 F4000            
                                      G1 X0 Y0				; 1 point
                                      G30 S-1
                                      set var.z1 =  sensors.probes[0].lastStopHeight
                                      G1 Z50 F4000 
                                      G1 X-154 Y-164 F4000    ; 2 point   
                                      G30 S-1
                                      set var.z2 = sensors.probes[0].lastStopHeight
                                      G1 Z50 F4000
                                      G1 X-63 Y214 F4000      ; 3 point   
                                      G30 S-1
                                      set var.z3 = sensors.probes[0].lastStopHeight
                                      G1 Z50 F4000
                                      G1 X217 Y-52 F4000      ; 4 point   
                                      G30 S-1
                                      set var.z4 = sensors.probes[0].lastStopHeight
                                      G1 Z50 F4000
                                      echo >>"testFile.csv" "datetime", var.z1, var.z2, var.z3, var.z4
                                      G28
                                      
                                      
                                      achrnundefined 1 Reply Last reply Reply Quote 0
                                      • achrnundefined
                                        achrn @tecno
                                        last edited by

                                        @tecno said in M671 like function for Delta printer:

                                        echo >>"testFile.csv" "datetime", var.z1, var.z2, var.z3, var.z4

                                        echo >>"testFile.csv" state.time, var.z1, var.z2, var.z3, var.z4

                                        tecnoundefined 1 Reply Last reply Reply Quote 1
                                        • tecnoundefined
                                          tecno @achrn
                                          last edited by

                                          @achrn

                                          Is there a way to format output to 0,000 and not 0.000 as this is a language problem?

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

                                            @tecno if the format is CSV then you must use '.' as the decimal separator character, because ',' is used to separate one field from the next. The program you use to import the .csv file should recognise '.' as the decimal separator.

                                            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

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