-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemon_bed_fans_monitor.cfg
814 lines (612 loc) · 40.5 KB
/
demon_bed_fans_monitor.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
###################################################
#######>>>>>>>>>> 3DPrintDemon <<<<<<<<<<<#######
####### https://github.com/3DPrintDemon #######
# IF YOU USE & LIKE THESE MACROS PLEASE CONSIDER SUPPORTING MY EFFORTS AT
# https://ko-fi.com/3dprintdemon
######################################################################################################
# INSTRUCTIONS:
# For this macro to work you need....
# A Voron 2.4 Printer (or similar!)
# Some installed & correctly set up bed fans.
# A printer with a simple chamber temp sensor or a temp controlled chamber cooling fan.
# You will need to create a dummy output pin on a spare/unused pin on your mainboard.
# This can be anything, even a pin on the EXP display socket/s if you're NOT using them.
# This dummy pin is used as a manual override within Mainsail to disable/enable the bed fans at any point during print once it
# has finished the PRINT_START macro. The system will monitor the position of this switch during the print.
# It is automatically reset once the current print has ended.
######################################################################################################
# Paste this into your printer.cfg file:
######################################################################################################
# [fan_generic Bed_Fans]
# pin: *** <<<< Insert your own pin HERE!
# max_power: 1.0
# shutdown_speed: 0
# kick_start_time: 0.5
# off_below: 0.19
# [output_pin DISABLE_BED_FANS]
# pin: *** <<<< Insert your own pin HERE!
######################################################################################################
# Be sure to remove the hashes (#) & enter your chosen pin numbers or this will not work!
######################################################################################################
# CHAMBER TEMP SENSOR OR TEMP CONTROLLED CHAMBER COOLING FAN
# The macros now automatically recognise which you have
# You'll then need to go to your printer.cfg & set up the sensor there.
# Be sure to call it: [temperature_sensor Chamber_Temp]
# Then add the rest of the settings for your sensor there so it will work & the macro can read chamber temps.
# See this link for help: https://www.klipper3d.org/Config_Reference.html#temperature-sensors
# For a Chamber fan you need to call it [temperature_fan chamber]
# Also make sure "variable_chamber_fan_enable" is set True!
# Then add the rest of the settings for your sensor there so it will work & the macro can monitor chamber temps.
# See this link for help: https://www.klipper3d.org/Config_Reference.html#temperature_fan
# If you use this macro as a stand alone system:
# If you have only a chamber temp sensor & not a chamber fan you'll need to "ctrl+F" "temperature_fan chamber"
# & replace all instances EXCEPT the two in the _BED_FANS_HELPER macro with "temperature_sensor Chamber_Temp"
# Also make sure "variable_chamber_fan_enable" is set False!
######################################################################################################
# This Macro set has been designed to be used with the Demon Essentials Unified Macro pack
# Downloading & installing the whole pack is recommended as it provides a fuller experience.
# https://github.com/3DPrintDemon/Demon_Klipper_Essentials_Unified
######################################################################################################
# To install the system:
######################################################################################################
# Place the file into your printer's config folder & add [include ./demon_bed_fans_v1.1.cfg] in your printer.cfg file.
# Or as mentioned install the full Demon macro pack!
# Create the required printer.cfg sections as described above.
# Add your chosen pins to it.
# Save & Restart.
# You may need to PID tune the bed with the fans on if you get heating errors while in use.
######################################################################################################
# USAGE OPTION 1: Inside the Demon Essentials Macro Pack
######################################################################################################
# Its all set up, just set your sensors & pins in the printer.cfg
# Then set your choices in the demon_user_settings.cfg file
# You're done!
######################################################################################################
# USAGE OPTION 2: Stand-alone Macro - NOT used inside the Demon Essentials Macro Pack
######################################################################################################
# Set your sensors & pins in the printer.cfg as shown above.
# Add the below command to anywhere in your start macro (after your bed temp has been set) where you
# want your macro to set the fans. This can be used more than once.
# _BED_FAN_SET
# VERY IMPORTANT! Be sure to enable the Bed Fans Monitor at the very end of your start macro by
# adding the below command to the last line of your start macro:
# UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=1
# RESPOND TYPE=COMMAND MSG="Bed Fans Monitor Active"
# The monitor will do the rest during the print.
######################################################################################################
# Be sure to remove the hashes (#) & enter your chosen pin numbers or this will not work!
######################################################################################################
######################################################################################################
# SETUP:
######################################################################################################
# There's 2 ways to this, if using the full Demon macro pack then these settings are set in the
# demon_user_settings.cfg file.
# If using this as a stand-alone cfg use the variables in the _BED_FAN_VARS macro below.
# DO NOT CHANGE the last 4 variables or you'll confuse the macro & it will NOT work correctly.
# Set "chamber_threshold" to your minimum chamber printing temp for your filament.
# This is the temp at which the Bed Fans will shift down from "high speed" to "low speed".
# Set "chamber_fan" even if you don't have one to your maximum chamber printing temp for your filament.
# This is the temp at which the bed fans will turn off.
# Set the "variable_high" for high speed setting to around 0.50-0.70 DO NOT SET 1!! Thats too much!
# Set the "variable_low" for low speed setting to around 0.2-0.3, this is good.
# Be sure to set "variable_enable" to True if you wish to use the system!! <<<<<<<<<<<<<<<<<< IMPORTANT!!
# Set the "variable_cool" to True if you wish to use the bed fans to cool the bed & chamber when finished
# Also set the "variable_cool_temp" to the temperature to cool down to.
######################################################################################################
# TESTING:
######################################################################################################
# To test the one-time _BED_FAN_SET macro system:
# In the Console paste: _BED_FAN_READ
# It will return the default settings.
# To enable the system paste in the Console: SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=enable VALUE=True
# Set a bed target temp to begin heating - if you do NOT do this it will not work.
# Then paste in: _BED_FAN_SET
# This will activate the portion of the system used in the PRINT_START macro one time.
# When up to temp &/or over temp run it again to see/test different outcomes.
######################################################################################################
# To test the _BED_FAN_MONITOR system:
# Enable the system by making sure the "variable_enable" is set True
# If using the full Demon Essentials Macro Pack set the above options in the demon_user_settings.cfg
# Be sure you have UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=1 at the end of your start code.
# If using the full Demon Essentials Macro Pack this is already done.
# Start a quick test print & wait for your start macro to finish & for the printer to start the print proper.
# This is when the monitor comes online & it will modify the bed fans according to print conditions.
######################################################################################################
# MONITORED CONDITIONS:
# Bed temperature
# Bed target temperature
# Bed Fans speed settings
# Manual speed change
# Live adjustment macro use
# Live fans slider use
# Chamber heat Threshold - low temp
# Chamber cooling fan - high temp
# Manual target change
# Printer's current state
# [output_pin DISABLE_BED_FANS]
######################################################################################################
# PRINTING & MANUAL ADJUSTMENTS
######################################################################################################
# There are 2 ways to control this system, by using the BED_FANS_SET_SPEED macro or BED_FAN slider!
# Adjusting the CHAMBER_FAN target during the print also effects the macro, as it is also monitored.
# The BED_FAN_MONITOR is configured to be smart & adaptive, it monitors what the system is doing & also what you
# are doing during the print! The macro knows if you pause or cancel the print, it knows if you change
# the Chamber Fan target, or if you change the Bed Fans speed!
# It can even knows if the system changed things or if you did!
# You can change the fan speeds during the print while the Monitor is running directly with the BED_FAN_SET_SPEED macro.
# Or by using the BED_FANS slider!!
# If you set the slider during a print to a value below 50% then that value is automatically
# stored for use as your LOW_SPEED setting. If you move the slider to any number over
# 50% it will be stored & used as your high speed setting.
# This can be done at any point during actual printing, even when the BED_FANS are not running!
# This adjustment is reset after the print finishes, returning to file defaults.
# If cooling is on the printer will use the bed fans to gently cool the bed & chamber until the cooling temp is reached or
# you change the printer's state back to standby by resetting the print status in Mainsail web interface.
# NOTE THE MONITOR ONLY RUNS AFTER YOUR START MACRO HAS FINISHED!
# This why we use the _BED_FAN_SET command in the Start macro itself.
###################################################
#######>>>>>>>>>> 3DPrintDemon <<<<<<<<<<<#######
####### https://github.com/3DPrintDemon #######
# IF YOU USE & LIKE THESE MACROS PLEASE CONSIDER SUPPORTING MY EFFORTS AT
# https://ko-fi.com/3dprintdemon
######################################################################################################
# IF USING THIS SYSTEM WITH THE DEMON ESSENTIALS MACRO PACK....
# THESE VARIABLES ARE USED BY THE SYSTEM - DO NOT EDIT DIRECTLY!
# TO CHANGE VARIABLES EDIT THE "demon_user_settings.cfg" FILE, NOT HERE!
# IF YOU'RE USING THIS FILE ONLY & NOT THE WHOLE DEMON MACRO PACK YOU MAY EDIT HERE
[gcode_macro _BED_FAN_VARS]
variable_chamber_threshold: 22 # Set this to your minimum printing temp
variable_chamber_fan: 33 # Set this to your maximum printing temp
variable_high: 0.55 # Set your high speed bed fan setting
variable_low: 0.22 # Set your low speed bed fan setting
variable_cool: True # Use bed fans to help cool the bed & chamber atfer printing
variable_cool_temp: 25 # Temperature to cool down to
variable_enable: False # Enable bed fan use True/False
variable_chamber_fan_enable: True # Monitor Chamber fan target True/False
variable_floating_monitor: True # Set the fan monitor to use floating fan speeds against a mid point chamber temp during printing
variable_floating_max_speed: 0.50 # Set the floating fan's calculated max speed percentage between the high & low speed values (0.0-1.0)
###################################################
## DO NOT CHANGE THESE! You will confuse the macro!
variable_readback_value: 0
variable_previous_readback_value: 10
variable_previous_chamber_temp: 0 ###
variable_mid_point_temp: 0 ###
variable_mid_point_fan: 0
variable_current_fan_speed: 0.0
variable_previous_floating_fan: 0
variable_macro_used: False
###################################################
gcode: # LEAVE THIS SECTION EMPTY
# DON'T PLAY WITH STUFF UNDER THIS LINE!
######################################################################################################
[gcode_macro _FLOATING_FAN]
gcode:
{% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
{% set start_vars = printer["gcode_macro _START_VARIABLES"] %}
{% set core_vars = printer["gcode_macro _CORE_VARS"] %}
{% if core_vars.chamber_thermal_sensor == 0 %}
{action_raise_error("This error is caused by no correctly named chamber_sensor or temperature controlled chamber_fan being available to the system! Check the system is setup correctly!")}
{% elif core_vars.chamber_thermal_sensor == 1 %}
{% set thermal_sensor = printer["temperature_fan chamber"].temperature %}
{% elif core_vars.chamber_thermal_sensor == 2 %}
{% set thermal_sensor = printer["temperature_sensor Chamber_Temp"].temperature %}
{% endif %}
{% if bed_vars.readback_value == bed_vars.previous_readback_value %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=previous_readback_value VALUE={bed_vars.readback_value}
# {% if start_vars.bed_fans_settings_readback == True %}
# RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, mode readback value equals previous readback value"
# {% endif %}
{% if printer["fan_generic Bed_Fans"].speed|float < bed_vars.low|float - 0.01 or printer["fan_generic Bed_Fans"].speed|float > bed_vars.mid_point_fan|float + 0.01 %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, fan speed outside floating fans range detected"
{% if bed_vars.previous_floating_fan == 0 %}
SET_FAN_SPEED FAN=Bed_Fans SPEED={bed_vars.low}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, resetting to low fan speed"
{% elif bed_vars.previous_floating_fan >= bed_vars.low and bed_vars.previous_floating_fan <= bed_vars.mid_point_fan %}
SET_FAN_SPEED FAN=Bed_Fans SPEED={bed_vars.previous_floating_fan}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, resetting to previous fan speed"
{% elif bed_vars.previous_floating_fan > bed_vars.mid_point_fan %}
SET_FAN_SPEED FAN=Bed_Fans SPEED={bed_vars.mid_point_fan}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, resetting to floating fan max speed"
{% elif bed_vars.previous_floating_fan < bed_vars.low %}
SET_FAN_SPEED FAN=Bed_Fans SPEED={bed_vars.low}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, resetting to low fan speed"
{% endif %}
{% else %}
{% if thermal_sensor <= bed_vars.mid_point_temp|float - 0.1 %}
{% if start_vars.bed_fans_settings_readback == True %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, chamber is colder than mid point target temp"
{% endif %}
{% if thermal_sensor < bed_vars.previous_chamber_temp|float %}
{% if start_vars.bed_fans_settings_readback == True %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, chamber is colder than previous run"
{% endif %}
{% if printer["fan_generic Bed_Fans"].speed < bed_vars.mid_point_fan %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=previous_floating_fan VALUE={("%.2f " % (printer["fan_generic Bed_Fans"].speed))}
SET_FAN_SPEED FAN=Bed_Fans SPEED={printer["fan_generic Bed_Fans"].speed|float + 0.01}
{% if start_vars.bed_fans_settings_readback == True %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, under mid point target, increasing floating fan speed"
{% endif %}
{% endif %}
{% endif %}
{% elif thermal_sensor >= bed_vars.mid_point_temp|float + 0.1 %} # is it hotter than target?
{% if start_vars.bed_fans_settings_readback == True %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, chamber is warmer than mid point target temp"
{% endif %}
{% if thermal_sensor > bed_vars.previous_chamber_temp|float %} # is it hotter than last run?
{% if start_vars.bed_fans_settings_readback == True %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, chamber is warmer than previous run"
{% endif %}
{% if printer["fan_generic Bed_Fans"].speed > bed_vars.low %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=previous_floating_fan VALUE={("%.2f " % (printer["fan_generic Bed_Fans"].speed))}
SET_FAN_SPEED FAN=Bed_Fans SPEED={printer["fan_generic Bed_Fans"].speed|float - 0.01}
{% if start_vars.bed_fans_settings_readback == True %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, over mid point target, reducing floating fan speed"
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% else %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=previous_readback_value VALUE={bed_vars.readback_value}
{% if start_vars.bed_fans_settings_readback == True %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, mode readback value does not equal previous readback value"
{% endif %}
{% if thermal_sensor < bed_vars.mid_point_temp|float %}
SET_FAN_SPEED FAN=Bed_Fans SPEED={bed_vars.mid_point_fan}
{% if start_vars.bed_fans_settings_readback == True %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, chamber under mid point target, setting floating fans to scaled maximum"
{% endif %}
{% else %}
SET_FAN_SPEED FAN=Bed_Fans SPEED={bed_vars.low}
{% if start_vars.bed_fans_settings_readback == True %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans, chamber under over point target, setting floating fans to low speed scaled minimum"
{% endif %}
{% endif %}
BED_FANS_THERMAL_INFO
{% endif %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=macro_used VALUE=False
# [gcode_macro set_mid]
# gcode:
# # {% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
# # {% if printer["fan_generic Bed_Fans"].speed|float >= printer.configfile.config["fan_generic Bed_Fans"].off_below|float and printer["fan_generic Bed_Fans"].speed|float <= bed_vars.high|float %}
# # m118 yep
# # {% endif %}
# # SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=mid_point_temp VALUE={(bed_vars.chamber_threshold + bed_vars.chamber_fan) / 2|float}
# SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE=0.28
# SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=mid_point_temp VALUE=20
# SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=previous_floating_fan VALUE=0.33
# SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=previous_chamber_temp VALUE=20
[gcode_macro BED_FANS_THERMAL_INFO]
description: Display chamber low & high temperature thresholds & target temp
gcode:
{% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
RESPOND TYPE=COMMAND MSG="Bed Fans theraml thresholds. Mid point chamber target temp {("%.0fc" % (bed_vars.
mid_point_temp))}. Minimum threshold is {("%.0fc" % (bed_vars.chamber_threshold))}, maximum threshold is {("%.0fc" % (bed_vars.chamber_fan))}."
[gcode_macro BED_FANS_SET_SPEED_INFO]
description: Display Bed Fans low & high power settings as well as Floating Fan
gcode:
{% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
RESPOND TYPE=COMMAND MSG="Bed Fans power range. Low power {("%.0f" % (bed_vars.low|float * 100))}% to floating fans Max Speed {("%.0f" % (bed_vars.
mid_point_fan|float * 100))}% if active. High speed boost of {("%.0f" % (bed_vars.high|float * 100))}%. Use macro button BED FANS SET SPEED to adjust LOW & HIGH settings"
[gcode_macro FLOATING_FANS_MAX_SPEED_INFO]
description: Display info on how to use Floating Fans Max Speed SCALED_POWER
gcode:
{% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans Max Speed, use macro button for real-time adjustment within set range, this button uses a 0-100% range scaled between your Bed_Fans current low speed value of {("%.0f" % (bed_vars.
low|float * 100))}%, & your high speed value of {("%.0f" % (bed_vars.high|float * 100))}%. Your current Floating Fans Max Speed is {("%.0f" % (bed_vars.
mid_point_fan|float * 100))}%. This means your FLOATING FANS MAX SPEED macro button SCALED_POWER setting is {("%.0f" % (bed_vars.floating_max_speed|float * 100))}% of this scaled range."
[gcode_macro _FLOATING_INFO]
gcode:
{% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
RESPOND TYPE=COMMAND MSG="Floating Fans Max Speed. SCALED_POWER value is {("%.0f" % (bed_vars.floating_max_speed|float * 100))}% which equals {("%.0f" % (bed_vars.
mid_point_fan|float * 100))}% on the BED_FANS slider."
# [gcode_macro BED_FANS_THERMAL_INFO]
# description: Display chamber low & high temperature thresholds & target temp
# gcode:
# {% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
# RESPOND TYPE=COMMAND MSG="Bed Fans theraml thresholds. Mid point chamber target temp {("%.2fc" % (bed_vars.
# mid_point_temp))}. Minimum threshold is {("%.2fc" % (bed_vars.chamber_threshold))}, maximum threshold is {("%.2fc" % (bed_vars.chamber_fan))}."
# [gcode_macro BED_FANS_SET_SPEED_INFO]
# description: Display Bed Fans low & high power settings as well as Floating Fan
# gcode:
# {% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
# RESPOND TYPE=COMMAND MSG="Bed Fans power range. Low power {("%.2f " % (bed_vars.low|float * 100))} to floating fans Max Speed {("%.2f " % (bed_vars.
# mid_point_fan|float * 100))} percent if active. High speed boost of {("%.2f " % (bed_vars.high|float * 100))} percent. Use macro button BED FANS SET SPEED to adjust LOW & HIGH settings"
# [gcode_macro FLOATING_FANS_MAX_SPEED_INFO]
# description: Display info on how to use Floating Fans Max Speed SCALED_POWER
# gcode:
# {% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
# RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Floating Fans Max Speed, use macro button for real-time adjustment within set range, this button uses a 0-100 percent range scaled between your Bed_Fans current low speed value of {("%.2f"% (bed_vars.
# low|float * 100))}, & your high speed value of {("%.2f"% (bed_vars.high|float * 100))}. Your current Floating Fans Max Speed is {("%.2f"% (bed_vars.
# mid_point_fan|float * 100))} percent. This means your FLOATING FANS MAX SPEED macro button SCALED_POWER setting is {("%.2f " % (bed_vars.floating_max_speed|float * 100))} percent of this scaled range."
# [gcode_macro _FLOATING_INFO]
# gcode:
# {% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
# RESPOND TYPE=COMMAND MSG="Floating Fans Max Speed. SCALED_POWER value is {("%.2f " % (bed_vars.floating_max_speed|float * 100))} which equals {("%.2f " % (bed_vars.
# mid_point_fan|float * 100))} percent on the BED_FANS Slider."
[gcode_macro FLOATING_FANS_MAX_SPEED]
description: Set the max speed made available to your Floating Bed Fans during the print
gcode:
{% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
{% set float_max_speed = params.SCALED_POWER|default(65)|float %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=macro_used VALUE=True
{% if bed_vars.floating_monitor == True %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=floating_max_speed VALUE={float_max_speed / 100|float}
# _FLOATING_INFO
{% else %}
RESPOND TYPE=error MSG="Floating fans are not enabled, no changes made. Please check your Demon_user_settings file to enable!"
{% endif %}
[gcode_macro BED_FANS_SET_SPEED]
description: Set Bed Fans High & Low speeds during the print
gcode:
{% set start_vars = printer["gcode_macro _START_VARIABLES"] %}
{% set low_speed = params.LOW_SPEED_PERCENT|default(25)|float %}
{% set high_speed = params.HIGH_SPEED_PERCENT|default(65)|float %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=macro_used VALUE=True
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=low VALUE={low_speed / 100|float}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=high VALUE={high_speed / 100|float}
[gcode_macro _BED_FAN_READ]
gcode:
{% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
RESPOND TYPE=COMMAND MSG="Bed fans threshold {bed_vars.chamber_threshold}c"
RESPOND TYPE=COMMAND MSG="Bed fans upper limit {bed_vars.chamber_fan}c"
RESPOND TYPE=COMMAND MSG="Bed fans high setting {bed_vars.high}"
RESPOND TYPE=COMMAND MSG="Bed fans low setting {bed_vars.low}"
RESPOND TYPE=COMMAND MSG="Bed fans Post print cooling {bed_vars.cool}"
RESPOND TYPE=COMMAND MSG="Bed fans Post print cooling temp {bed_vars.cool_temp}c"
RESPOND TYPE=COMMAND MSG="Bed fans enable for filament {bed_vars.enable}"
RESPOND TYPE=COMMAND MSG="Bed fans readback value {bed_vars.readback_value}"
RESPOND TYPE=COMMAND MSG="Bed fans previous readback value {bed_vars.previous_readback_value}"
RESPOND TYPE=COMMAND MSG="Bed fans current fan {bed_vars.current_fan_speed}"
RESPOND TYPE=COMMAND MSG="Bed fans actual speed {printer["fan_generic Bed_Fans"].speed}"
RESPOND TYPE=COMMAND MSG="Bed fans temp mid point {bed_vars.mid_point_temp}c"
RESPOND TYPE=COMMAND MSG="Bed fans previous fan {bed_vars.previous_floating_fan}"
RESPOND TYPE=COMMAND MSG="Bed fans prev chamber temp {bed_vars.previous_chamber_temp}c"
RESPOND TYPE=COMMAND MSG="Bed fans max floating fan {bed_vars.floating_max_speed}"
RESPOND TYPE=COMMAND MSG="Bed mid point fan {bed_vars.mid_point_fan}"
[gcode_macro _BED_FAN_HELPER]
gcode:
{% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
{% if bed_vars.readback_value == bed_vars.previous_readback_value %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=previous_readback_value VALUE={bed_vars.readback_value}
{% if bed_vars.chamber_fan_enable == True %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=chamber_fan VALUE={printer["temperature_fan chamber"].target}
{% endif %}
{% if bed_vars.macro_used == True %}
RESPOND TYPE=COMMAND MSG="Macro used to change Bed Fan speed"
{% else %}
{% if printer["fan_generic Bed_Fans"].speed|float == bed_vars.current_fan_speed %}
{% elif printer["fan_generic Bed_Fans"].speed|float != bed_vars.current_fan_speed %}
{% if printer["fan_generic Bed_Fans"].speed|float == 0 %}
RESPOND TYPE=error MSG="The ZERO percent value can NOT be set or modified. To set fans to off use DISBALE_BED_FANS button!"
{% elif printer["fan_generic Bed_Fans"].speed|float > 0.1 and printer["fan_generic Bed_Fans"].speed|float < 0.5 %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE={printer["fan_generic Bed_Fans"].speed|float}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=low VALUE={printer["fan_generic Bed_Fans"].speed|float}
RESPOND TYPE=COMMAND MSG="Manual slider speed change of under 0.5 detected, applying to LOW_SPEED setting"
{% elif printer["fan_generic Bed_Fans"].speed|float >= 0.5 %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE={printer["fan_generic Bed_Fans"].speed|float}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=high VALUE={printer["fan_generic Bed_Fans"].speed|float}
RESPOND TYPE=COMMAND MSG="Manual slider speed change of over 0.5 detected, applying to HIGH_SPEED setting"
{% endif %}
{% endif %}
{% endif %}
{% elif bed_vars.readback_value != bed_vars.previous_readback_value %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=previous_readback_value VALUE={bed_vars.readback_value}
{% if bed_vars.chamber_fan_enable == True %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=chamber_fan VALUE={printer["temperature_fan chamber"].target}
{% endif %}
_MONITOR_MESSAGE_READ
{% endif %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=macro_used VALUE=False
[gcode_macro _MONITOR_FAN_SET]
gcode:
{% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
{% if bed_vars.readback_value in [1, 4, 5, 7, 8, 9] %}
SET_FAN_SPEED FAN=Bed_Fans SPEED=0
{% elif bed_vars.readback_value == 2 %}
SET_FAN_SPEED FAN=Bed_Fans SPEED={bed_vars.high}
{% elif bed_vars.readback_value == 3 %}
SET_FAN_SPEED FAN=Bed_Fans SPEED={bed_vars.low}
{% elif bed_vars.readback_value == 6 %}
SET_FAN_SPEED FAN=Bed_Fans SPEED={bed_vars.low}
{% endif %}
[gcode_macro _MONITOR_MESSAGE_READ]
gcode:
{% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
{% if bed_vars.readback_value == 1 %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Printing, too cold fans set to off while bed heats"
{% elif bed_vars.readback_value == 2 %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Printing, temp under chamber threshold fans set to high speed {bed_vars.high * 100}%"
{% elif bed_vars.readback_value == 3 %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Printing, fans set to low speed {bed_vars.low * 100}%"
{% elif bed_vars.readback_value == 4 %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Printing, fans off due to high chamber temp >{bed_vars.chamber_fan|int}c"
{% elif bed_vars.readback_value == 5 %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Paused, fans auto paused"
{% elif bed_vars.readback_value == 6 %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Cooling post print, fans on low until <{bed_vars.cool_temp|int}c or printer state is changed to Standby"
{% elif bed_vars.readback_value == 7 %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Stopped, fans off"
{% elif bed_vars.readback_value == 8 %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Override on, fans manually paused"
{% elif bed_vars.readback_value == 9 %}
RESPOND TYPE=COMMAND MSG="Bed Fans Monitor: Stopped, fans off, Override off"
{% endif %}
[gcode_macro _BED_FAN_SET]
gcode:
{% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
{% set core_vars = printer["gcode_macro _CORE_VARS"] %}
{% if core_vars.chamber_thermal_sensor == 0 %}
{action_raise_error("This error is caused by no correctly named chamber_sensor or temperature controlled chamber_fan being available to the system! Check the system is setup correctly!")}
{% elif core_vars.chamber_thermal_sensor == 1 %}
{% set thermal_sensor = printer["temperature_fan chamber"].temperature %}
{% elif core_vars.chamber_thermal_sensor == 2 %}
{% set thermal_sensor = printer["temperature_sensor Chamber_Temp"].temperature %}
{% endif %}
{% if bed_vars.enable == True %}
{% if printer.heater_bed.temperature < printer.heater_bed.target|int -40 %}
{% if thermal_sensor <= bed_vars.chamber_fan %}
SET_FAN_SPEED FAN=Bed_Fans SPEED={bed_vars.low}
RESPOND TYPE=COMMAND MSG="Bed fans set to low while bed heats"
{% elif thermal_sensor > bed_vars.chamber_fan %}
SET_FAN_SPEED FAN=Bed_Fans SPEED=0
RESPOND TYPE=COMMAND MSG="Bed fans set to off due to high chamber temp >{bed_vars.chamber_fan}c"
{% endif %}
{% elif printer.heater_bed.temperature >= printer.heater_bed.target|int -40 %}
{% if thermal_sensor <= bed_vars.chamber_threshold %}
SET_FAN_SPEED FAN=Bed_Fans SPEED={bed_vars.high}
RESPOND TYPE=COMMAND MSG="Bed fans set to high speed for Heat Soak {bed_vars.high|float * 100.00}%"
{% elif thermal_sensor > bed_vars.chamber_threshold %}
{% if thermal_sensor <= bed_vars.chamber_fan %}
SET_FAN_SPEED FAN=Bed_Fans SPEED={bed_vars.low}
RESPOND TYPE=COMMAND MSG="Bed fans set to low speed {bed_vars.low|float * 100.00}%"
{% elif thermal_sensor > bed_vars.chamber_fan %}
SET_FAN_SPEED FAN=Bed_Fans SPEED=0
RESPOND TYPE=COMMAND MSG="Bed fans set to off due to high chamber temp >{bed_vars.chamber_fan}c"
{% endif %}
{% endif %}
{% endif %}
{% else %}
RESPOND TYPE=COMMAND MSG="Bed Fans disabled in settings"
{% endif %}
[delayed_gcode _BED_FAN_MONITOR]
gcode:
{% set bed_vars = printer["gcode_macro _BED_FAN_VARS"] %}
{% set core_vars = printer["gcode_macro _CORE_VARS"] %}
{% if core_vars.chamber_thermal_sensor == 0 %}
{action_raise_error("This error is caused by no correctly named chamber_sensor or temperature controlled chamber_fan being available to the system! Check the system is setup correctly!")}
{% elif core_vars.chamber_thermal_sensor == 1 %}
{% set thermal_sensor = printer["temperature_fan chamber"].temperature %}
{% elif core_vars.chamber_thermal_sensor == 2 %}
{% set thermal_sensor = printer["temperature_sensor Chamber_Temp"].temperature %}
{% endif %}
{% if bed_vars.enable == True %}
{% if printer["output_pin DISABLE_BED_FANS"].value == 0 %}
{% if printer.print_stats.state == "printing" %}
{% if thermal_sensor < bed_vars.chamber_threshold %}
{% if printer.heater_bed.temperature <= printer.heater_bed.target|int -5 %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=readback_value VALUE=1 ##
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE=0
_BED_FAN_HELPER ##
_MONITOR_FAN_SET
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=10
# RESPOND TYPE=COMMAND MSG="Bed is too cold, fans set to off to warm up!"
{% else %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=readback_value VALUE=2 ##
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE={bed_vars.high}
_BED_FAN_HELPER ##
_MONITOR_FAN_SET
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=10
# RESPOND TYPE=COMMAND MSG="Bed fans monitor printing, temp under chamber threshold fans set to high speed {bed_vars.high}"
{% endif %}
{% elif thermal_sensor >= bed_vars.chamber_threshold %}
{% if printer.heater_bed.temperature <= printer.heater_bed.target|int -5 %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=readback_value VALUE=1 ##
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE=0
_BED_FAN_HELPER ##
_MONITOR_FAN_SET
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=10
# RESPOND TYPE=COMMAND MSG="Bed is too cold, fans set to off to warm up!"
{% elif thermal_sensor <= bed_vars.chamber_fan %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=readback_value VALUE=3 ##
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE={bed_vars.low}
{% if bed_vars.floating_monitor == True %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=mid_point_fan VALUE={("%.2f " % (((bed_vars.high - bed_vars.low) * bed_vars.floating_max_speed) + bed_vars.low|float))}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=mid_point_temp VALUE={(bed_vars.chamber_threshold + bed_vars.chamber_fan) / 2|float} ###
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=previous_chamber_temp VALUE={thermal_sensor|float} ###
{% if bed_vars.chamber_fan_enable == True %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=chamber_fan VALUE={printer["temperature_fan chamber"].target}
{% endif %}
_FLOATING_FAN
{% else %}
_BED_FAN_HELPER ##
_MONITOR_FAN_SET
{% endif %}
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=10
# RESPOND TYPE=COMMAND MSG="Bed fans monitor printing, fans set to low speed {bed_vars.low}"
{% elif thermal_sensor > bed_vars.chamber_fan %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=readback_value VALUE=4 ##
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE=0
_BED_FAN_HELPER ##
_MONITOR_FAN_SET
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=20
# RESPOND TYPE=COMMAND MSG="Bed fans monitor printing, fans off due to high chamber temp >{bed_vars.chamber_fan}"
{% else %}
M118 oops
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=10
{% endif %}
{% endif %}
{% elif printer.print_stats.state == "paused" %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=readback_value VALUE=5 ##
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE=0
_BED_FAN_HELPER ##
_MONITOR_FAN_SET
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=0
# UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=10
# RESPOND TYPE=COMMAND MSG="Bed fans monitor paused, fans paused"
{% elif printer.print_stats.state in ["complete", "cancelled", "error"] %}
{% if bed_vars.cool == True and thermal_sensor >= bed_vars.cool_temp %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=readback_value VALUE=6 ##
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE={bed_vars.low}
_BED_FAN_HELPER ##
_MONITOR_FAN_SET
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=10
# RESPOND TYPE=COMMAND MSG="Bed fans monitor cooling post print, fans low"
{% else %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=readback_value VALUE=7 ##
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE=0
_BED_FAN_HELPER ##
_MONITOR_FAN_SET
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=0
# RESPOND TYPE=COMMAND MSG="Bed fans monitor stop, fans off"
{% endif %}
{% elif printer.print_stats.state == "standby" %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=readback_value VALUE=7 ##
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE=0
_BED_FAN_HELPER ##
_MONITOR_FAN_SET
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=0
# RESPOND TYPE=COMMAND MSG="Bed fans monitor stop, fans off"
{% endif %}
{% elif printer["output_pin DISABLE_BED_FANS"].value == 1.0 %}
{% if printer.print_stats.state in ["printing", "paused"] %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=readback_value VALUE=8 ##
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE=0
_BED_FAN_HELPER ##
_MONITOR_FAN_SET
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=10
# RESPOND TYPE=COMMAND MSG="Bed fans monitor override on, fans paused"
{% elif printer.print_stats.state in ["complete", "cancelled", "error"] %}
{% if bed_vars.cool == True and thermal_sensor >= bed_vars.cool_temp %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=readback_value VALUE=6 ##
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE={bed_vars.low}
_BED_FAN_HELPER ##
_MONITOR_FAN_SET
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=10
SET_PIN PIN=DISABLE_BED_FANS VALUE=0.00
# RESPOND TYPE=COMMAND MSG="Bed fans monitor cooling post print, fans low"
{% else %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=readback_value VALUE=9 ##
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE=0
_BED_FAN_HELPER ##
_MONITOR_FAN_SET
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=0
SET_PIN PIN=DISABLE_BED_FANS VALUE=0.00
# RESPOND TYPE=COMMAND MSG="Bed fans monitor stop, fans off, Override off"
{% endif %}
{% elif printer.print_stats.state == "standby" %}
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=readback_value VALUE=9 ##
SET_GCODE_VARIABLE MACRO=_BED_FAN_VARS VARIABLE=current_fan_speed VALUE=0
_BED_FAN_HELPER ##
_MONITOR_FAN_SET
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=0
SET_PIN PIN=DISABLE_BED_FANS VALUE=0.00
# RESPOND TYPE=COMMAND MSG="Bed fans monitor stop, fans off, Override off"
{% endif %}
{% else %}
UPDATE_DELAYED_GCODE ID=_BED_FAN_MONITOR DURATION=10
# RESPOND TYPE=COMMAND MSG="Monitor going round again"
{% endif %}
{% else %}
RESPOND TYPE=error MSG="Bed Fans disabled in settings"
{% endif %}