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

    What is the correct syntax for string operations?

    Scheduled Pinned Locked Moved
    General Discussion
    3
    9
    425
    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.
    • appjawsundefined
      appjaws
      last edited by

      This is the line I want to display on the screen.
      M291 P"auto bed levelling using 3 Z motors completed deviation " ^ move.calibrationDeviation.deviation ^ "mm"
      this is the error
      Error: Bad command: M291 P"auto bed levelling using 3 Z motors completed deviation " ^ move.calibrationDeviation.deviation ^ "mm"
      and then I thought that it needed a ","
      M291 P"auto bed levelling using 3 Z motors completed deviation ", ^ move.calibrationDeviation.deviation ^ "mm"
      this is the error
      Error: Bad command: M291 P"auto bed levelling using 3 Z motors completed deviation ", ^ move.calibrationDeviation.deviation ^ "mm"
      Not knowing much about code, I am stuck.

      appjaws - Core XYUV Duet Ethernet Duex5
      firmware 3.5.0-rc.4 Web Interface 3.5.0-rc.4
      Ormerod 1-converted to laser engraver, Duet wifi
      OpenSCAD version 2024.03.18
      Simplify3D 5.1.2

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

        When using an expression in place of a parameter, the expression must be enclosed in { }. Example:

        M291 P{"2+2 is " ^ 2+2}

        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

        1 Reply Last reply Reply Quote 0
        • appjawsundefined
          appjaws
          last edited by

          @dc42, thank you for your response. I still cant get this to work, your example works but my line fails with
          "Error: Bad command: M291 P{"Repeating calibration, Deviation is " ^ move.calibrationDeviation.deviation ^ "mm"}

          M291 P{"2+2 is " ^ 2+2}
          M291 P{"Repeating calibration, Deviation is " ^ move.calibrationDeviation.deviation ^ "mm"}

          Do I need to add something when using an object?

          appjaws - Core XYUV Duet Ethernet Duex5
          firmware 3.5.0-rc.4 Web Interface 3.5.0-rc.4
          Ormerod 1-converted to laser engraver, Duet wifi
          OpenSCAD version 2024.03.18
          Simplify3D 5.1.2

          dc42undefined 1 Reply Last reply Reply Quote 0
          • appjawsundefined
            appjaws
            last edited by

            Sorry, just to let you know I am using Firmware 3.01-beta2

            appjaws - Core XYUV Duet Ethernet Duex5
            firmware 3.5.0-rc.4 Web Interface 3.5.0-rc.4
            Ormerod 1-converted to laser engraver, Duet wifi
            OpenSCAD version 2024.03.18
            Simplify3D 5.1.2

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

              @appjaws said in What is the correct syntax for string operations?:

              M291 P{"Repeating calibration, Deviation is " ^ move.calibrationDeviation.deviation ^ "mm"}

              When I run that, the command works (the message box pops up) BUT it also reports bad command. Whereas:

              M291 P{"2+2 is " ^ 2+2}

              doesn't report an error. I will look into it.

              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

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

                Interesting.
                I get both the expected popup and an error.
                screenshote.jpg

                Firmware version
                version.jpg

                1 Reply Last reply Reply Quote 0
                • appjawsundefined
                  appjaws
                  last edited by

                  I am using a Duet2 with expansion board Duex5 connected by ethernet
                  M115
                  FIRMWARE_NAME: RepRapFirmware for Duet 2 WiFi/Ethernet FIRMWARE_VERSION: 3.01-beta2 ELECTRONICS: Duet Ethernet 1.02 or later + DueX5 FIRMWARE_DATE: 2020-01-23b1

                  This is the console output

                  27/01/2020, 07:48:50
                  M98 P"0:/macros/Conditional/Auto_Bed_Levelling.g"
                  Leadscrew adjustments made: -0.029 0.021 0.005, points used 3, (mean, deviation) before (-0.019, 0.015) after (-0.000, 0.000)
                  iteration = 0
                  Repeating calibration because initial deviation (0.015mm) must be < 0.01
                  and (0.000mm) must be within 0.005 of initialDeviation
                  Error: Bad command: M291 P{"Repeating calibration, Deviation is " ^ move.calibrationDeviation.deviation ^ "mm"}

                  This is my macro

                  ; Conditional auto bed levelling using 3 Z motors

                  M561 ; clear any existing bed transforms

                  ;if heat.heaters[0].current <60
                  M291 P"Preheating to bed to 65 and nozzle to 195 for accurate probing"
                  M140 S60 ; Set bed temperature to 60
                  M116 ; waiting for bed to reach temperature
                  if heat.heaters[0].current <65 || heat.heaters[1].current <190
                  M140 S65 ; Set bed temperature to 65
                  G10 S195 ; Set current tool temperature to 195C
                  M116 ; waiting for bed and nozzle to reach temperature

                  ; If the printer hasn't been homed, home it
                  if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed
                  G28

                  G1 Z5

                  ;Run an initial 3-point Probe

                  M291 P"auto bed levelling using 3 Z motors started"

                  M98 P"0:/macros/Conditional/bedlevel.g"

                  while true
                  if iterations = 5
                  abort "Too many auto calibration attempts"
                  echo "iteration = ", iterations
                  if move.initialDeviation.deviation < 0.01
                  if move.calibrationDeviation.deviation < move.initialDeviation.deviation + 0.005
                  if move.calibrationDeviation.deviation > move.initialDeviation.deviation - 0.005
                  break
                  echo "Repeating calibration because initial deviation (" ^ move.initialDeviation.deviation ^ "mm) must be < 0.01"
                  echo "and (" ^ move.calibrationDeviation.deviation ^ "mm) must be within 0.005 of initialDeviation"
                  M291 P{"Repeating calibration, Deviation is " ^ move.calibrationDeviation.deviation ^ "mm"}
                  M291 P{"2+2 is " ^ 2+2}
                  M98 P"0:/macros/Conditional/bedlevel.g"

                  echo "Auto calibration successful, deviation", move.calibrationDeviation.deviation ^ "mm"
                  echo "Auto calibration successful, initialDeviation", move.initialDeviation.deviation ^ "mm"
                  M291 P{"2+2 is " ^ 2+2}
                  ;M291 P{"auto bed levelling using 3 Z motors completed, Initial Deviation is " ^ move.initialDeviation.deviation ^ "mm"}
                  ;M291 P{"auto bed levelling using 3 Z motors completed, Deviation is " ^ move.calibrationDeviation.deviation}

                  M140 S0 ; Set bed temperature to 0C
                  G10 S0 ; Set current tool temperature to 0C
                  G1 X150 Y100; Move to bed centre
                  G30; reset Z0

                  G1 X50 Y230 F24000 ; move the head to park
                  M291 P"auto bed levelling using 3 Z motors completed"

                  appjaws - Core XYUV Duet Ethernet Duex5
                  firmware 3.5.0-rc.4 Web Interface 3.5.0-rc.4
                  Ormerod 1-converted to laser engraver, Duet wifi
                  OpenSCAD version 2024.03.18
                  Simplify3D 5.1.2

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

                    I found the problem and it will be fixed in the next internal build. Meanwhile, here is the workaround. Where an object model string starts with the letter g, m or t, make sure that the character immediately before it isn't a space or tab. The following both work:

                    M291 P{"Repeating calibration, Deviation is " ^move.calibrationDeviation.deviation ^ "mm"}
                    M291 P{"Repeating calibration, Deviation is " ^ (move.calibrationDeviation.deviation) ^ "mm"}

                    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

                    1 Reply Last reply Reply Quote 0
                    • appjawsundefined
                      appjaws
                      last edited by

                      @dc42 said in What is the correct syntax for string operations?:

                      M291 P{"Repeating calibration, Deviation is " ^move.calibrationDeviation.deviation ^ "mm"}

                      @dc42 Worked like a charm, thank you so much.

                      appjaws - Core XYUV Duet Ethernet Duex5
                      firmware 3.5.0-rc.4 Web Interface 3.5.0-rc.4
                      Ormerod 1-converted to laser engraver, Duet wifi
                      OpenSCAD version 2024.03.18
                      Simplify3D 5.1.2

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