Finding out names of parameters and variables
-
Hello fellow printers,
i have a beginner question, regarding macros using parameters and variables.
My System (Duet 2 WiFi; RRF & DWC on 3.2.2) is up to date. There is a new plugin called object model.I want to use the set active temperature of a heater (the bed to be specific) for a cooldown macro. Where do i get it? Does the object model help me?
I am completely new to programming and stuff, please be gentle.Greetings from germany,
Julien -
Well you may not need to use the object model at all. What exactly do you want to do?
Have you looked through the object browser plugin? You can see in there what things are available.
-
Should run as follows:
- read active bed temp
- subtract 1 from active bed temp and wait to reach it
- dwell a specific time
- repeat, until active bed temp is below 60°C (in a for-loop or something)
I thought about someting like this:
for(i = "temp"; i > 60; i--){
temp = "temp" - 1; subtract 1°C and wait to reach it
M109 S"temp"; dwell 60 seconds
G4 S60;
}In the Model, there is the name "heat.bedHeaters[0]", could this be the active temp? When yes, how do i use this parameter in calculations - do i have to use it as
- heat.bedHeaters[0] or
- "heat.bedHeaters[0]" ?
-
@ZipZap
You can learn which object is which by observing the object model browser. You need to refresh it after changes.Assuming your bed heater is heater zero then something like this might work
Note untested and typed on phone.
Can't remember is active needs to be quotedwhile (heat.heaters[0].active > 60) && (heat.heaters[0].current > 60) && (heat.heaters[0].state = "active") M190 R0.1 S{heat.heaters[0].active-1} M116 echo "waiting 60 seconds" G4 S60 echo "cool down finished"
Edit:
You may have to set your heating commands to wait for < 1 degree accuracy or use a larger step
Changed example to use M190 -
Thanks for the help.
I found the information about the parameters and testet while refreshing the model.
I will try it out tomorrow./Julien
-
@OwenD said in Finding out names of parameters and variables:
Changed example to use M190
And this was the point.
Your adaption of M190 doesn't work, but: I figured out a solution.
Taking the subtraction into a seperate variable makes it work. I think, you can't calculate inside a G or M-Command.Thanks a bunch to you guys, now i know the syntax, and how to get the parameters and declaring and using variables.
It would be very helpful, if i wouldn't have overlooked the G-Codes in the Dozuki and the very good PDF-Manual, that is pinned on top of this category (my bad)...Here is my working example:
while (heat.heaters[0].active > 60) && (heat.heaters[0].current > 60) && (heat.heaters[0].state = "active") var cooltemp = {heat.heaters[0].active} set var.cooltemp = var.cooltemp -1 M190 P0 R{var.cooltemp} echo "wait" G4 S60 echo "cooldown finished"
I will expand upon it and make it more versatile, ex. add in a real cooldown funktion, that works for ABS.
Edit: Oh yeah, and i had to update everything to 3.3RC2 or course.
-
@ZipZap
the math should work without variables.
I misread the R value as being a +/- target based on the S value -
I know what you mean about M190, but the math does not work properly.
I tested it just now: Temperature was 70°C, the macro (your corrected example) waswhile (heat.heaters[0].active > 60) && (heat.heaters[0].current > 60) && (heat.heaters[0].state = "active") M190 P0 R{heat.heaters[0].active -1} echo "wait" G4 S20 echo "cooldown finished"
After activating, the [active] drops immediately to 39°C, which makes no sense to me.
Calculating the temperatur drop beforehand, doesn't cause this issue:
while (heat.heaters[0].active > 60) && (heat.heaters[0].current > 60) && (heat.heaters[0].state = "active") var cooltemp = {heat.heaters[0].active} set var.cooltemp = var.cooltemp -1 M190 P0 R{var.cooltemp} echo "wait" G4 S20 echo "cooldown finished"
Where is the error? Is it really the calculation within commands?
-
-
Looks like the error isn't so random.
I can confirm the same results as @ZipZap
Oddly, if I replace the R parameter with an S parameter then force it to wait while cooling with M116, I don't get the jump to 39 degrees.
And even stranger is that it doesn't always go to 39 degrees. Sometime it reduces by 1 degree as expected.