troyproffitt
-
Posts
4 -
Joined
-
Last visited
Content Type
Forums
Events
3D Prints
Posts posted by troyproffitt
-
-
Can someone please tell me the Python code to grab the keyword cool_fan_speed value?
Is it something like this:
getFanSpeed = global_stack.extruders["0"].getProperty("cool_fan_speed", "value")
-
So if I was able to use the S value off the M106, the formula would be something like this:
(<fan_value>/850)+.4
So if M106 S255 , I'd like to add a row that said
M42 P8 S((255/850)+.4)
-
I am attempting to use a CPAP fan as a parts cooler for my 3d printer. Since it needs a controller to function (ESC), on my Duet WIFI 2, I cannot just plug it into the fan0 port on the controller board. Good news is that I was able to re-purpose one of the heater pins to behave like a servo and then I can use an M42 command to turn on / off the CPAP fan and increase / decrease the fan speed. For example
CPAP fan at 0%
M42 P8 S0.4
CPAP fan at 100%
M42 P8 S0.7
What I am hoping to accomplish is to re-use the post processing script InsertAtLayerChange to convert the fan_speed value from the M106 (or possibly reference the CURA keyword cool_fan_speed) to an M42 command. Here is my math to get the appropriate range:
M42 P8 S({cool_fan_speed}/250)+.4)
I'd like this to be evaluated at every layer. I am not familiar with the Python syntax, but I was hoping someone could help me figure out how to modify the current Insert at Layer Change script to add in this additional functionality.
Here is the original script:
# Copyright (c) 2020 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. # Created by Wayne Porter from ..Script import Script class InsertAtLayerChange(Script): def __init__(self): super().__init__() def getSettingDataString(self): return """{ "name": "Insert at layer change", "key": "InsertAtLayerChange", "metadata": {}, "version": 2, "settings": { "insert_location": { "label": "When to insert", "description": "Whether to insert code before or after layer change.", "type": "enum", "options": {"before": "Before", "after": "After"}, "default_value": "before" }, "gcode_to_add": { "label": "G-code to insert.", "description": "G-code to add before or after layer change.", "type": "str", "default_value": "" } } }""" def execute(self, data): gcode_to_add = self.getSettingValueByKey("gcode_to_add") + "\n" for layer in data: # Check that a layer is being printed lines = layer.split("\n") for line in lines: if ";LAYER:" in line: index = data.index(layer) check_fan_speed = data.index(cool_fan_speed) if self.getSettingValueByKey("insert_location") == "before": layer = gcode_to_add + layer else: layer = layer + gcode_to_add data[index] = layer break return data
Thanks for your help,
-Troy
Convert fan speed to servo movement (post processing script)
in UltiMaker Cura
Posted · Edited by troyproffitt
I ended up figuring out how to create the script on my own. I also added some additional functionality by providing parameters for min / max servo range values and also letting the user provide the pin value on the M42 command.
Hope this helps others that are trying to use a berdair or other servo type air source: