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

    Global variables stopped working

    Scheduled Pinned Locked Moved Solved
    Gcode meta commands
    3
    7
    406
    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.
    • baird1faundefined
      baird1fa
      last edited by

      Hello. I have a program running on my duet 3 6HC running the stable release of 3.4 and it was working using a variable called global.loop. Then I tried to change my touch screen rotation and now the variables don’t seem to work.

      Set global.loop = true
      

      Just give me an error saying “error: unknown variable ‘global.loop’.

      Everything was working.

      Any thoughts?

      Thanks.

      Nightowlundefined 1 Reply Last reply Reply Quote 0
      • Nightowlundefined
        Nightowl @baird1fa
        last edited by Nightowl

        @baird1fa

        Have you confirmed it's showing in the Object Model Browser?

        It would be in ObjectModel.Global node.

        I'm not sure if this makes a difference or helps, but my global variables are configured like this (there's no "." between global and PausePress, for example):

        ; Variable definition
        global savedSpindleSpeed = 0
        global PausePress = false
        

        Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
        I'm still on my learning curve, so take everything I say with caution!

        RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

        baird1faundefined 1 Reply Last reply Reply Quote 0
        • baird1faundefined
          baird1fa @Nightowl
          last edited by

          @nightowl999 I think I figured it out. I'm not too good with the doccumentation and I must have enabled it at somepoint using the

          global loop = false
          

          I thought the doccumentaion said you just needed to

          set global.loop=false
          

          so I have added the global loop = false to my config.g so it is there when it starts up.

          fcwiltundefined Nightowlundefined 2 Replies Last reply Reply Quote 0
          • fcwiltundefined
            fcwilt @baird1fa
            last edited by fcwilt

            @baird1fa said in Global variables stopped working:

            @nightowl999 I think I figured it out. I'm not too good with the doccumentation and I must have enabled it at somepoint using the

            global loop = false
            

            I thought the doccumentaion said you just needed to

            set global.loop=false
            

            so I have added the global loop = false to my config.g so it is there when it starts up.

            Before you can use a variable you have to declare it like this:

            global some_variable_name or var some_variable_name

            Notice there is a space character (or tab) between the two words but not a period character.

            To set the value of a variable you use this:

            set global.some_variable_name = 123

            Notice the word set and the period character.

            To use the value of the variable you use the same pair of words with the period character.

            if global.some_variable_name = 123

            Frederick

            Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

            baird1faundefined 1 Reply Last reply Reply Quote 0
            • Nightowlundefined
              Nightowl @baird1fa
              last edited by

              @baird1fa

              You could set the variable within the config.g file, once the variable has been defined, but you'd usually set the variable within a macro.

              So for example, I've defined the variable in config.g here...

              ; Variable definition
              global PausePress = false
              

              ...then set the variable in the macro file like this...

              set global.PausePress = true
              

              ...which in this case changes the value from 'false' to 'true'.

              Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
              I'm still on my learning curve, so take everything I say with caution!

              RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

              1 Reply Last reply Reply Quote 0
              • baird1faundefined
                baird1fa @fcwilt
                last edited by

                @fcwilt @Nightowl999

                These would make excellent additions to the documentation on how to use variables. The examples of how to use them are not the clearest. For instance the use of the space rather than the "." I really struggled with this. I ended up assuming that I needed to use set for global variables whether declaring them or just using them. I kept getting an error for G (lobal) not a valid command.

                fcwiltundefined 1 Reply Last reply Reply Quote 0
                • fcwiltundefined
                  fcwilt @baird1fa
                  last edited by

                  @baird1fa said in Global variables stopped working:

                  @fcwilt @Nightowl999

                  These would make excellent additions to the documentation on how to use variables. The examples of how to use them are not the clearest. For instance the use of the space rather than the "." I really struggled with this. I ended up assuming that I needed to use set for global variables whether declaring them or just using them. I kept getting an error for G (lobal) not a valid command.

                  I forgot to mention: I put all of my global variables in config.g so they are ready to use right after the printer is powered up or reset.

                  Frederick

                  Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

                  1 Reply Last reply Reply Quote 0
                  • dc42undefined dc42 marked this topic as a question
                  • dc42undefined dc42 has marked this topic as solved
                  • First post
                    Last post
                  Unless otherwise noted, all forum content is licensed under CC-BY-SA