expression inside expression
-
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.gi 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!
-
@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.
-
@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?
-
@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
-
@k01571n3n accented characters in strings should work provided that you save the file in UTF8 format.
-
@dc42 how can i do that? Its not working in console or any macros if i make them in dwc.
-
@k01571n3n does this work for you:
echo "Kuumapään lämmittäminen asteeseen"
-
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.
-
@dc42 echo works but that other one doesn't. I don't understand what it could be due to
-
@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
-
@k01571n3n it works OK for me.
This is the macro file: M291 accented character test.g
-
@dc42 interesting
-
@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.
-
@chrishamm thats nice! i forgot to mention that i got a raspberry with duet...
-