Countdown Timer in Start G-Code
 
Notifications
Clear all

Countdown Timer in Start G-Code  

  RSS
cTallakson
(@ctallakson)
Active Member
Countdown Timer in Start G-Code

I have a semi custom one cubic meter large format printer that uses some pretty large components. Due to the general size of everything I need a significant preheat at the beginning of my prints. I am going to enforce a preheat period that will end with a user prompt to start the bed squaring, mesh leveling, purge, then first layer. Since the preheat period will be a significant amount of time I want to use a loop that can present a new M117 message on the screen to keep the user updated on how much time is left in the temp stabilization time.

Here is what I have now:

global StabilizingSeconds = 3600
global RemainingStabilizingSeconds = global.StabilizingSeconds

while true
  G4 S1
  M117 Time Remaining: {global.RemainingStabilizingSeconds}S
  if iterations = global.StabilizingSeconds
    break
  set global.RemainingStabilizingSeconds = global.remainingStabilizingSeconds - 1
  M400

PrusaSlicer is not happy about my use of the variable in the M117 line. I attached the error code I get with the current code below. I am sure I am missing something simple here. Can someone clue me in?

I know there are other ways to do the same thing so if I am overcomplicating it I am all ears. Also aware the global variables are probably overkill.

Posted : 11/07/2024 4:34 pm
Neophyl
(@neophyl)
Illustrious Member
RE: Countdown Timer in Start G-Code

I think its the fact that PS doesnt know what your global variables are.  It only knows about the ones that are part of its programming, you can't just use anything you want.  Variables are specific to settings within the software.   It isnt a normal code parser.  I don't think it handles while true either or the break.  It is VERY limited in what is allowed.

Normally advanced stuff like that is done in something like Klipper (if you run klipper as printer firmware/host) and not part of the slicer at all.

Posted : 11/07/2024 4:57 pm
cTallakson
(@ctallakson)
Active Member
Topic starter answered:
RE:

This is going onto a Duet/reprap printer so I have conformed that functionally the while true loop works on that machine and prusaslicer doesn't complain about it. I think you are right on the variables but it seems like if prusaslicer didn't recognize it that it should just not process it rather than throw an error.

This version of the code both works on my machine and does not raise an error on when slicing in prusaslicer:

M117 Stabilizing Temperatures

while true
  G4 S1
  if iterations = 3600
    break
  M400

But using that code the user is left in the dark as to how long is left on the wait time. Maybe I can just add a call to a macro on the duet machine and have the machine handle the variables for the message output.

This post was modified 3 weeks ago by cTallakson
Posted : 11/07/2024 7:38 pm
cTallakson
(@ctallakson)
Active Member
Topic starter answered:
RE: Countdown Timer in Start G-Code

Interestingly, I also get an error message if the line is commented out.

Posted : 11/07/2024 7:50 pm
Neophyl
(@neophyl)
Illustrious Member
RE: Countdown Timer in Start G-Code

The PS Github is really the place to research this and ask questions directly of the devs, for example https://github.com/prusa3d/PrusaSlicer/issues/10364  

I take it you have been through https://github.com/prusa3d/PrusaSlicer/wiki/PrusaSlicer-Macro-Language   ?

Posted : 11/07/2024 8:45 pm
cTallakson
(@ctallakson)
Active Member
Topic starter answered:
RE: Countdown Timer in Start G-Code

I had not! Can't believe I didn't think to go to github. I was mostly referencing the reprap and duet gcode and meta gcode pages. I'll check it out and post back if/when I find a solution.

Posted : 11/07/2024 9:00 pm
ssmith liked
Share: