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

Using echo to write segmented values

Scheduled Pinned Locked Moved Solved
Gcode meta commands
3
7
390
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.
  • undefined
    ComedianTF2
    last edited by 8 Aug 2022, 15:56

    Hi all, I've been working on a macro to try and write the results from the PID tuning process automatically to a file, so that you wouldn't be required to amend your config.g manually

    In this, the one piece I can't figure out is how to write a segmented value

    The results from the PID tune in my case were:

    M307 H0 R2.009 K0.289:0.080 D4.65 E1.35 S1.00 B0 V23.9

    This is the code I use to write the file:

    echo >"0:/sys/config_PID_tune_E0.g" "M307 H0 R"^{heat.heaters[0].model.heatingRate}, "K"^{heat.heaters[0].model.coolingRate}, {heat.heaters[0].model.fanCoolingRate}, "D"^{heat.heaters[0].model.deadTime}, "E"^{heat.heaters[0].model.coolingExp}
    echo >>"0:/sys/config_PID_tune_E0.g" "M307 H0 B0 S1.0 V"^{heat.heaters[0].model.standardVoltage}

    Due to the character limit, it had to be executed in 2 lines rather than one, as the full string is around 290 characters long. It can be made into one line using variables, but that's not an issue in my eyes.

    With the K as written in the code snippet it results in the following config_PID_tune_E0.g

    M307 H0 R2.009 K0.289 0.080 D4.7 E1.4
    M307 H0 B0 S1.0 V23.9

    As you can see, there is a space between the two K values (it should be K0.289:0.080

    The K value is the one I can't figure out. With the way the echo command works, it expects either a , or a } at the end of any variable, so I'm not able to write it like I would expect it to need to work:

    "K"^{heat.heaters[0].model.coolingRate, heat.heaters[0].model.fanCoolingRate}

    With that code, I get the following error:
    Error: in file macro line 7 column 124: meta command: expected '}'

    Does anyone have insight on how to properly write the code?

    undefined 1 Reply Last reply 8 Aug 2022, 16:13 Reply Quote 0
    • undefined
      alankilian @ComedianTF2
      last edited by 8 Aug 2022, 16:13

      @comediantf2 said in Using echo to write segmented values:

      "K"^{heat.heaters[0].model.coolingRate}, {heat.heaters[0].model.fanCoolingRate}

      Try:

      "K"^{heat.heaters[0].model.coolingRate},":", {heat.heaters[0].model.fanCoolingRate}

      There will be spaces around the ":" but I don't think that will matter.

      Give it a try and let us know.

      SeemeCNC Rostock Max V3 converted to V3.2 with a Duet2 Ethernet Firmware 3.2 and SE300

      undefined 1 Reply Last reply 8 Aug 2022, 16:30 Reply Quote 1
      • undefined
        ComedianTF2 @alankilian
        last edited by 8 Aug 2022, 16:30

        @alankilian Sadly it looks like the spaces matter.

        The first M307 H0 was with the spaces (so K0.289 : 0.080), the second one without

        a2aca701-0842-4565-abdc-6e05389862ab-image.png

        undefined 1 Reply Last reply 8 Aug 2022, 16:48 Reply Quote 0
        • undefined
          infiniteloop @ComedianTF2
          last edited by 8 Aug 2022, 16:48

          @comediantf2 Don't use a comma, use the caret to concatenate the values:

          "K"^{heat.heaters[0].model.coolingRate}^":"^{heat.heaters[0].model.fanCoolingRate}
          undefined undefined 2 Replies Last reply 8 Aug 2022, 16:51 Reply Quote 2
          • undefined
            alankilian @infiniteloop
            last edited by 8 Aug 2022, 16:51

            @infiniteloop

            Brilliant!

            Where did you find that in the documentation?

            SeemeCNC Rostock Max V3 converted to V3.2 with a Duet2 Ethernet Firmware 3.2 and SE300

            undefined 1 Reply Last reply 8 Aug 2022, 16:55 Reply Quote 0
            • undefined
              infiniteloop @alankilian
              last edited by 8 Aug 2022, 16:55

              @alankilian

              Where did you find that in the documentation?

              In GCode Meta Commands under Binary infix operators - there, the caret is the last entry in the table.

              1 Reply Last reply Reply Quote 3
              • undefined
                ComedianTF2 @infiniteloop
                last edited by 8 Aug 2022, 17:10

                @infiniteloop That did the trick. Much appreciated for that insight.

                Final code:

                echo >"0:/sys/config_PID_tune_E0.g" "M307 H0 R"^{heat.heaters[0].model.heatingRate}, "K"^{heat.heaters[0].model.coolingRate}^":"^{heat.heaters[0].model.fanCoolingRate}, "D"^{heat.heaters[0].model.deadTime}, "E"^{heat.heaters[0].model.coolingExp}
                echo >>"0:/sys/config_PID_tune_E0.g" "M307 H0 B0 S1.0 V"^{heat.heaters[0].model.standardVoltage}

                That macro resulted in this config_PID_tune_E0.g

                M307 H0 R1.990 K0.292:0.075 D4.7 E1.4
                M307 H0 B0 S1.0 V23.9
                1 Reply Last reply Reply Quote 0
                • undefined dc42 marked this topic as a question 8 Aug 2022, 20:38
                • undefined dc42 has marked this topic as solved 8 Aug 2022, 20:38
                3 out of 7
                • First post
                  3/7
                  Last post
                Unless otherwise noted, all forum content is licensed under CC-BY-SA