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

    expression inside expression

    Scheduled Pinned Locked Moved
    Gcode meta commands
    3
    14
    614
    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.
    • K01571N3Nundefined
      K01571N3N
      last edited by

      Hi. is this a bug or am i just not able to do it right?

      this is my homeall macro.

      ; homeall.g
      ; X, Y, Z, C-axis homing
      ; 15.06.2021 23:57
      
      
      set global.LEDModeMemory = {global.LEDMode}
      set global.CurrentToolMemory = {state.currentTool}
      set global.LEDMode = "Homing"	; LEDMode = Homing
      
      
      if state.currentTool = -1	; If there is not a tool in a ToolHead
        M291 R"Kaikkien akseleiden kotiinajo" P"C-akseli" S1 T10	; Message
        G91						; Relative coordinate
        M913 C60					; C-axis motors current 60%
        G1 H2 C-260 F2000			; Home C-axis against the hard end
        G90						; Absolute coordinate
        G92 C-121.6				; Set C-axis zeropoint
        M913 C100					; C-axis motors current 100%
        G53 G1 C0 F5000			; C-axis open = C0
        M291 R"Kaikkien akseleiden kotiinajo" P"X- ja Y-akselit" S1 T40	; Message
        G91						; Relative coordinate
        G1 H2 Z5 F1000			; Lower bed 5mm
        G1 H1 Y-1000 F10000		; Home Y-axis first time
        G1 H1 X-1000				; Home X-axis first time
        G1 X5 Y5 F20000			; Move X- and Y-axis 5mm away
        G1 H1 Y-20 F300			; Home Y-axis second time slower
        G1 Y10 F20000				; Move Y-axis 10mm away
        G1 H1 X-20 F300			; Home X-axis second time slower
        G1 X10 F20000				; Move X-axis 10mm away
        M291 R"Kaikkien akseleiden kotiinajo" P"Z-akseli" S1 T200	; Message
        G90						; Absolute coordinate
        G53 G1 X183 Y180 F20000	; Move X- and Y-axis to the center of the bed
        G91						; Relative coordinate
        G1 H1 Z-1000 F300			; Home Z-axis first time
        G4 P100					; 100ms time delay
        G1 H2 Z2					; Move Z-axis 2mm away
        G4 P100					; 100ms time delay
        G1 H1 Z-20 F50			; Home Z-axis second time slower
        G4 P100					; 100ms time delay
        G90						; Absolute coordinate
        G92 Z0					; Set Z-axis zeropoint
        G91						; Relative coordinate
        G1 Z10 F1000				; Lower bed 10mm
        G90						; Absolute coordinate
      
      else						; If there is a tool in a Toolhead
        M564 H0					; Allow movement without homing(for Z-axis)
        M291 R"Kaikkien akseleiden kotiinajo" P"X- ja Y-akselit, työkalu paikallaan  " S1 T40	; Message
        G91						; Relative coordinate
        G1 H2 Z5 F1000			; Lower bed 5mm
        G1 H1 Y-1000 F5000		; Home Y-axis first time
        G1 H1 X-1000				; Home X-axis first time
        G1 X5 Y5 F5000			; Move X- and Y-axis 5mm away
        G1 H1 Y-20 F300			; Home Y-axis second time slower
        G1 Y10 F20000				; Move Y-axis 10mm away
        G1 H1 X-20 F300			; Home X-axis second time slower
        G1 X10 F20000				; Move X-axis 10mm away
        G90						; Absolute coordinate
        T-1						; Tool remove
        G53 G1 X183 Y180 F20000	; Move X- and Y-axis to the center of the bed
        M291 R"Kaikkien akseleiden kotiinajo" P"C-akseli" S1 T10	; Message
        G91						; Relative coordinate
        M913 C60					; C-axis motors current 60%
        G1 H2 C-260 F2000			; Home C-axis against the hard end
        G90						; Absolute coordinate
        G92 C-121.6				; Set C-axis zeropoint
        M913 C100					; C-axis motors current 100%
        G53 G1 C0 F5000			; C-axis open = C0
        G291 R"Kaikkien akseleiden kotiinajo" P"Z-akseli" S1 T200	; Message
        G90						; Absolute coordinate
        G53 G1 X183 Y180 F20000	; Move X- and Y-axis to the center of the bed
        G91						; Relative coordinate
        G1 H1 Z-1000 F300			; Home Z-axis first time
        G4 P100					; 100ms time delay
        G1 H2 Z2					; Move Z-axis 2mm away
        G4 P100					; 100ms time delay
        G1 H1 Z-20 F50			; Home Z-axis second time slower
        G4 P100					; 100ms time delay
        G90						; Absolute coordinate
        G92 Z0					; Set Z-axis zeropoint
        G91						; Relative coordinate
        G1 Z10 F1000				; Lower bed 10mm
        G90						; Absolute coordinate
      
      
      
      ; Problem starts here!!
      
      
      
      if global.CurrentToolMemory != -1
        T{global.CurrentToolMemory}
        set global.TCurrentParkX = {global.T{state.currentTool}ParkX}
        set global.TCurrentParky = {global.T{state.currentTool}ParkY}
        G53 G1 X{global.TCurrentParkX} Y{global.TCurrentParky} F20000	; ToolHead to the center
        M291 R"Kaikkien akseleiden kotiinajo" P"Kotiinajo valmis" S1 T1	; Message
        
        
      else
        M291 R"Kaikkien akseleiden kotiinajo" P"Kotiinajo valmis" S1 T1	; Message
        G53 G1 X183 Y320 F20000	; ToolHead to the center
      
      
      set global.LEDModeLast = {global.LEDModeMemory}
      set global.LEDMode = {global.LEDModeLast}	; LEDMode = Last
      

      problem is this, it says=
      Error: {global.T{state.currentTool}ParkX}unknown variable 'T' of homeall.g

      i tried to write to the console

      echo {global.T{state.currentTool}ParkX}
      

      it will show just what i want to see. but in this homeall macro, it wont work.

      what is this about?

      Thanks in advance!

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

        @k01571n3n no, a variable name can't be an expression. What you really want is an array-valued global variable, but they are not implemented yet.

        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

        K01571N3Nundefined 2 Replies Last reply Reply Quote 0
        • K01571N3Nundefined
          K01571N3N @dc42
          last edited by

          @dc42 okay.

          i fixed it with this

          if global.CurrentToolMemory = 0
            T0
            G53 G1 X{global.T0ParkX} Y{global.T0ParkY} F20000	; ToolHead to the center
            M291 R"Kaikkien akseleiden kotiinajo" P"Kotiinajo valmis" S1 T1	; Message
          
          elif global.CurrentToolMemory = 1
            T0
            G53 G1 X{global.T1ParkX} Y{global.T1ParkY} F20000	; ToolHead to the center
            M291 R"Kaikkien akseleiden kotiinajo" P"Kotiinajo valmis" S1 T1	; Message
          
          elif global.CurrentToolMemory = 2
            T0
            G53 G1 X{global.T2ParkX} Y{global.T2ParkY} F20000	; ToolHead to the center
            M291 R"Kaikkien akseleiden kotiinajo" P"Kotiinajo valmis" S1 T1	; Message
          
          elif global.CurrentToolMemory = 3
            T0
            G53 G1 X{global.T3ParkX} Y{global.T3ParkY} F20000	; ToolHead to the center
            M291 R"Kaikkien akseleiden kotiinajo" P"Kotiinajo valmis" S1 T1	; Message
          
          else
            M291 R"Kaikkien akseleiden kotiinajo" P"Kotiinajo valmis" S1 T1	; Message
            G53 G1 X183 Y320 F20000	; ToolHead to the center
          
          

          when those array-valued variables will come?

          1 Reply Last reply Reply Quote 0
          • K01571N3Nundefined
            K01571N3N @dc42
            last edited by

            @dc42 and i noticed that this does not work because of "ä" letter.

            It says Error: M291: control character in string

            M291 R"Filamentin lataus" P{"Kuumapään lämmittäminen " ^global.Temperature^ "-asteeseen"} S1 T3
            

            Like this it works:

            M291 R"Filamentin lataus" P{"Kuumapaan lammittaminen " ^global.Temperature^ "-asteeseen"} S1 T3
            

            Also this doesnt work. If i change "ä" to "a" it will work like it should.

            M291 R"Filamentin lataus" P"Kuumapään lämmittäminen asteeseen"S1 T3
            

            b3132e8a-5942-4017-a146-c32a324d5b7e-image.png

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

              @k01571n3n accented characters in strings should work provided that you save the file in UTF8 format.

              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

              K01571N3Nundefined 1 Reply Last reply Reply Quote 0
              • K01571N3Nundefined
                K01571N3N @dc42
                last edited by

                @dc42 how can i do that? Its not working in console or any macros if i make them in dwc.

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

                  @k01571n3n does this work for you:

                  echo "Kuumapään lämmittäminen asteeseen"

                  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

                  dc42undefined K01571N3Nundefined 2 Replies Last reply Reply Quote 0
                  • dc42undefined
                    dc42 administrators @dc42
                    last edited by

                    PS I just entered this in the DWC console:

                    M291 R"Filamentin lataus" P"Kuumapään lämmittäminen asteeseen"S1 T3

                    and it worked.

                    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

                    K01571N3Nundefined 1 Reply Last reply Reply Quote 0
                    • K01571N3Nundefined
                      K01571N3N @dc42
                      last edited by

                      @dc42 echo works but that other one doesn't. I don't understand what it could be due to

                      1 Reply Last reply Reply Quote 0
                      • K01571N3Nundefined
                        K01571N3N @dc42
                        last edited by

                        @dc42 echo {"Kuumapään lämmittäminen " ^ global.Temperature ^ "-asteeseen"}

                        this works also like it should. there is a some problem with that m291 comment

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

                          @k01571n3n it works OK for me.

                          43f245ad-2eb5-4bde-9293-c07141f3eab3-image.png

                          This is the macro file: M291 accented character test.g

                          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

                          K01571N3Nundefined 1 Reply Last reply Reply Quote 0
                          • K01571N3Nundefined
                            K01571N3N @dc42
                            last edited by

                            @dc42 interesting 🤔 🤔

                            chrishammundefined 1 Reply Last reply Reply Quote 0
                            • chrishammundefined
                              chrishamm administrators @K01571N3N
                              last edited by chrishamm

                              @k01571n3n I can reproduce this in SBC mode and I am looking into it.

                              PS: I've got a fix ready for this which will be included in the next versions.

                              Duet software engineer

                              K01571N3Nundefined 1 Reply Last reply Reply Quote 0
                              • K01571N3Nundefined
                                K01571N3N @chrishamm
                                last edited by

                                @chrishamm thats nice! i forgot to mention that i got a raspberry with duet...

                                1 Reply Last reply Reply Quote 0
                                • Mark_XYZundefined Mark_XYZ referenced this topic
                                • First post
                                  Last post
                                Unless otherwise noted, all forum content is licensed under CC-BY-SA