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

Finding out names of parameters and variables

Scheduled Pinned Locked Moved
Gcode meta commands
3
10
590
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
    ZipZap
    last edited by 12 Mar 2021, 21:07

    Hello fellow printers,

    i have a beginner question, regarding macros using parameters and variables.
    My System (Duet 2 WiFi; RRF & DWC on 3.2.2) is up to date. There is a new plugin called object model.

    I want to use the set active temperature of a heater (the bed to be specific) for a cooldown macro. Where do i get it? Does the object model help me?
    I am completely new to programming and stuff, please be gentle.

    Greetings from germany,
    Julien

    Most important guide -> Triffid Hunter's Calibration Guide
    HyperCube EVO (derivate) in 250x250x300 - enclosed for ABS - Duet2WiFi - custom watercooling

    1 Reply Last reply Reply Quote 0
    • undefined
      Phaedrux Moderator
      last edited by 12 Mar 2021, 21:12

      Well you may not need to use the object model at all. What exactly do you want to do?

      Have you looked through the object browser plugin? You can see in there what things are available.

      Z-Bot CoreXY Build | Thingiverse Profile

      1 Reply Last reply Reply Quote 0
      • undefined
        ZipZap
        last edited by ZipZap 3 Dec 2021, 21:33 12 Mar 2021, 21:21

        Should run as follows:

        • read active bed temp
        • subtract 1 from active bed temp and wait to reach it
        • dwell a specific time
        • repeat, until active bed temp is below 60°C (in a for-loop or something)

        I thought about someting like this:

        for(i = "temp"; i > 60; i--){
        temp = "temp" - 1; subtract 1°C and wait to reach it
        M109 S"temp"; dwell 60 seconds
        G4 S60;
        }

        In the Model, there is the name "heat.bedHeaters[0]", could this be the active temp? When yes, how do i use this parameter in calculations - do i have to use it as

        • heat.bedHeaters[0] or
        • "heat.bedHeaters[0]" ?

        Most important guide -> Triffid Hunter's Calibration Guide
        HyperCube EVO (derivate) in 250x250x300 - enclosed for ABS - Duet2WiFi - custom watercooling

        undefined 1 Reply Last reply 12 Mar 2021, 22:16 Reply Quote 0
        • undefined
          OwenD @ZipZap
          last edited by OwenD 12 Mar 2021, 22:16

          @ZipZap
          You can learn which object is which by observing the object model browser. You need to refresh it after changes.

          Assuming your bed heater is heater zero then something like this might work
          Note untested and typed on phone.
          Can't remember is active needs to be quoted

          while (heat.heaters[0].active > 60) && (heat.heaters[0].current > 60) && (heat.heaters[0].state = "active")
          M190 R0.1 S{heat.heaters[0].active-1}
          M116
          echo "waiting 60 seconds"
          G4 S60
          echo "cool down finished"

          Edit:
          You may have to set your heating commands to wait for < 1 degree accuracy or use a larger step
          Changed example to use M190

          undefined 1 Reply Last reply 13 Mar 2021, 11:02 Reply Quote 1
          • undefined
            ZipZap
            last edited by 12 Mar 2021, 23:03

            Thanks for the help.
            I found the information about the parameters and testet while refreshing the model.
            I will try it out tomorrow.

            /Julien

            Most important guide -> Triffid Hunter's Calibration Guide
            HyperCube EVO (derivate) in 250x250x300 - enclosed for ABS - Duet2WiFi - custom watercooling

            1 Reply Last reply Reply Quote 0
            • undefined
              ZipZap @OwenD
              last edited by ZipZap 13 Mar 2021, 11:02

              @OwenD said in Finding out names of parameters and variables:

              Changed example to use M190

              And this was the point.
              Your adaption of M190 doesn't work, but: I figured out a solution.
              Taking the subtraction into a seperate variable makes it work. I think, you can't calculate inside a G or M-Command.

              Thanks a bunch to you guys, now i know the syntax, and how to get the parameters and declaring and using variables.
              It would be very helpful, if i wouldn't have overlooked the G-Codes in the Dozuki and the very good PDF-Manual, that is pinned on top of this category (my bad)...

              Here is my working example:

              while (heat.heaters[0].active > 60) && (heat.heaters[0].current > 60) && (heat.heaters[0].state = "active")
              var cooltemp = {heat.heaters[0].active}
              set var.cooltemp = var.cooltemp -1
              M190 P0 R{var.cooltemp}
              echo "wait"
              G4 S60
              echo "cooldown finished"

              I will expand upon it and make it more versatile, ex. add in a real cooldown funktion, that works for ABS.

              Edit: Oh yeah, and i had to update everything to 3.3RC2 or course.

              Most important guide -> Triffid Hunter's Calibration Guide
              HyperCube EVO (derivate) in 250x250x300 - enclosed for ABS - Duet2WiFi - custom watercooling

              undefined 1 Reply Last reply 13 Mar 2021, 22:08 Reply Quote 1
              • undefined
                OwenD @ZipZap
                last edited by 13 Mar 2021, 22:08

                @ZipZap
                the math should work without variables.
                I misread the R value as being a +/- target based on the S value

                undefined 1 Reply Last reply 14 Mar 2021, 20:55 Reply Quote 0
                • undefined
                  ZipZap @OwenD
                  last edited by ZipZap 14 Mar 2021, 20:55

                  @OwenD

                  I know what you mean about M190, but the math does not work properly.
                  I tested it just now: Temperature was 70°C, the macro (your corrected example) was

                  while (heat.heaters[0].active > 60) && (heat.heaters[0].current > 60) && (heat.heaters[0].state = "active")
                  M190 P0 R{heat.heaters[0].active -1}
                  echo "wait"
                  G4 S20
                  echo "cooldown finished"

                  After activating, the [active] drops immediately to 39°C, which makes no sense to me.

                  Calculating the temperatur drop beforehand, doesn't cause this issue:

                  while (heat.heaters[0].active > 60) && (heat.heaters[0].current > 60) && (heat.heaters[0].state = "active")
                  var cooltemp = {heat.heaters[0].active}
                  set var.cooltemp = var.cooltemp -1
                  M190 P0 R{var.cooltemp}
                  echo "wait"
                  G4 S20
                  echo "cooldown finished"

                  Where is the error? Is it really the calculation within commands?

                  Most important guide -> Triffid Hunter's Calibration Guide
                  HyperCube EVO (derivate) in 250x250x300 - enclosed for ABS - Duet2WiFi - custom watercooling

                  undefined 1 Reply Last reply 14 Mar 2021, 23:52 Reply Quote 0
                  • undefined
                    OwenD @ZipZap
                    last edited by 14 Mar 2021, 23:52

                    @ZipZap
                    Actually I also noticed an odd seemingly random number result on one occasion.
                    Perhaps @dc42 can comment?

                    1 Reply Last reply Reply Quote 0
                    • undefined
                      OwenD
                      last edited by 15 Mar 2021, 12:12

                      Looks like the error isn't so random.
                      I can confirm the same results as @ZipZap
                      Oddly, if I replace the R parameter with an S parameter then force it to wait while cooling with M116, I don't get the jump to 39 degrees.
                      And even stranger is that it doesn't always go to 39 degrees. Sometime it reduces by 1 degree as expected.

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