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

    Object model values different programmatically

    Scheduled Pinned Locked Moved
    Gcode meta commands
    3
    9
    291
    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.
    • DonStaufferundefined
      DonStauffer
      last edited by

      When I look at the object model, the axes values are 0, 1, 2:
      AxesModel.png

      But when I run this code:

      var Tool = null
      var Axis = null
      while iterations < #tools
          set var.Tool = iterations
          while iterations < #tools[var.Tool].axes
              set var.Axis = tools[var.Tool].axes[iterations]
              echo "tools["^var.Tool^"].axes["^iterations^"] =", var.Axis
      

      I get 1, 2, 4:
      AxesLog.png
      These numbers seem to be 2 taken to the power of the actual numbers.

      oliofundefined dc42undefined 2 Replies Last reply Reply Quote 0
      • oliofundefined
        oliof @DonStauffer
        last edited by

        @DonStauffer are you sure this isn't from the ^ operator?

        <>RatRig V-Minion Fly Super5Pro RRF<> V-Core 3.1 IDEX k*****r <> RatRig V-Minion SKR 2 Marlin<>

        DonStaufferundefined 1 Reply Last reply Reply Quote 1
        • dc42undefined
          dc42 administrators @DonStauffer
          last edited by

          @DonStauffer tools[n].axes[m] is a bitmap of the machine axes that the user axes are mapped to. It's a bitmap because on IDEX and similar machines you can map a user axis such as X to multiple machine axes.

          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

          DonStaufferundefined 1 Reply Last reply Reply Quote 1
          • DonStaufferundefined
            DonStauffer @dc42
            last edited by

            @dc42 Does that mean the object model plugin is displaying the exponent instead of the value? I'm wondering why it's not the same as the programmatic result.

            1 Reply Last reply Reply Quote 0
            • DonStaufferundefined
              DonStauffer @oliof
              last edited by

              @oliof I'm not sure how. It's not even applied after the =, and I don't see anything wrong. I only used ^ to get the subscripts without the space echo adds if you use a comma. The subscripts are just taken from the iterations of the nested loops, so they are in the expected order. The first subscript comes from the outer loop iterations, so it starts from 0, and does the second subscript from the inner loop, so it goes through 0, 1, 2. Then the outer loop goes up to 1 and the inner loop does 0-, 1, 2 again. Everything to the left of the = is just for clarification. I could have just done echo var.Axis and it would have output:
              1
              2
              4
              1
              2
              4

              oliofundefined dc42undefined 2 Replies Last reply Reply Quote 0
              • oliofundefined
                oliof @DonStauffer
                last edited by

                @DonStauffer yeah but the value of a bitmap at index 2 is 4.

                <>RatRig V-Minion Fly Super5Pro RRF<> V-Core 3.1 IDEX k*****r <> RatRig V-Minion SKR 2 Marlin<>

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

                  @DonStauffer you can index into a bitmap. So tools[0].axes[2][0] will be the first machine axis that the user Z axis is mapped to.

                  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

                  DonStaufferundefined 1 Reply Last reply Reply Quote 0
                  • DonStaufferundefined
                    DonStauffer @dc42
                    last edited by DonStauffer

                    @dc42 That's interesting. I'll have to think about uses for that. I've never seen indexed bitmaps before. Is that only for the object model, or is there a way to do it with regular variables? Besides the obvious which I've already been doing: Divide by powers of 2 and truncate, etc.

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

                      @DonStauffer tools[].axes[] has a bitmap type in the OM, which is essentially a set of values all of which lie within a certain range. RRF meta GCode doesn't really support set types, but in order to allow you to delve into it, RRF lets you use the # operator on it (to ask how many bits are set) and to use the [] indexing operator to retrieve the bit numbers in ascending order.

                      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
                      • First post
                        Last post
                      Unless otherwise noted, all forum content is licensed under CC-BY-SA