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

Global variables between macros

Scheduled Pinned Locked Moved
Beta Firmware
4
5
315
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
    TurtlePrint
    last edited by 13 Feb 2020, 21:36

    Is there currently a way to set a global variable from one macro and check it from another? My current work around is to setup a fake FAN port and set it with an "M106 P5 S255" from one macro and then check "fans[5].actualValue" from the other macro. I'm doing this because after I run my "Filament Unload Macro" I would like my "Filament Load" macro to check if the Unload macro has already been run. My current method seems hackish at best 🙂

    1 Reply Last reply Reply Quote 3
    • undefined
      jens55
      last edited by 13 Feb 2020, 21:49

      Might be hackish but very clever 🙂

      1 Reply Last reply Reply Quote 0
      • undefined
        garyd9
        last edited by garyd9 13 Feb 2020, 23:50

        I love the solution! It's a shame it won't work with DSF (yet?)

        "I'm not saying that you are wrong - I'm just trying to fit it into my real world simulated experience."

        1 Reply Last reply Reply Quote 0
        • undefined
          TurtlePrint
          last edited by TurtlePrint 14 Feb 2020, 03:56

          Found a slightly better way to transfer info between macros. Using the same fake fan port you can change the name with an M106 P5 C"NewName" or even an C{Object.Model} as the name. Then recall that information back in another macro or even later in the same gcode.

          edit:The below example wont work, the M220 command won't accept {fans[5].name} as an input since its been converted to a string. I'm going to leave it here in case anyone has other ideas

          One example I can think of this is storing the current speed factor as a Fan name, setting the speed back to 100, then restoring the speed later in the gcode. I'm sure all this will be much easier once actual variables are implemented but until then this seems like a decent workaround.

          ;Setting up the fake Fan in config.g
          M950 F5 C"duex.fan5"
          M106 P5 C"Fake"

          ;Storing the current print Speed Factor as a fan name
          M106 P5 C{move.speedFactor}

          ;Setting Speed Factor to 100%
          M220 S100

          ;Setting the Speed Factor back to what was stored
          M220 S{fans[5].name}

          edit edit: I think this might work with a fake heater and storing the integer you wanted as the max temp using an M143

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User
            last edited by 14 Feb 2020, 08:32

            I think passing parameters to M98 is on the to-do list, but interesting workaround while we wait. 👍

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