Custom M104 macro or Edit Existing M104 macro
-
We are building a large 3D printer which uses multiple industrial temperature controllers for Preheating the plastic pallets. There are 3 final heaters that we would like under the control of a Duet3 6XD. We would like to create a custom M104 macro or edit the existing one so a simple digital out would turn on the industrial temperature controllers. Once they are up to temperature they send an 'All OK' signal (which are all in series). This signal then turns on an input on the Duet and then the macro would continue to heat three heaters that are under it's control.
I noticed that G10 is used in some slicers but believe that this would not be able to be edited?So how might one create or edit the M104 macro?
Any comments are welcomed,.
Thanks Mark
-
@machinemark its not possible to override the behaviour of existing gcode commands with a custom macro.
Is there a reason you cannot run the preheat control in one macro and then hand over control to the Duet 3 controlled macro?
Can you explain the control requirements in more detail.
-
Thank you for your reply.
Yes I could create another custom macro called MXXX (nothing naughty) and then add it to the slicers start g code so that it runs it first followed by the M104 etc but was hoping to consolidate the extra requirements in the same M104 macro.
The idea is to start the industrial controllers from the macro by turning on a GPIO (Only had luck turning on OUT0 but no joy trying to turn on io1.out IO_8)(Another problem). Then once the heaters come to temperature they bring on one of the Duets inputs (Another problem - I have created the input but it never registers with the macro ( I am asking in another post)) on where the macro has been waiting in a while loop. Then continue in a traditional sense heating and controlling 3 heaters in the same hot end (Hopefully using PID). All 7 heaters are basically 1 hot end. Hope this helps clarify the challenge.
Thanks Mark
-
For the Industrial heaters with their own controller - is the Duet just toggling a binary On/Off pin to control them - with no temperature feedback to the Duet, just a simple digital feedback line (at temp/not at temp)?
Can you link a datasheet for the industrial heater controller ?
-
Yes. Duet turns a digital output on which brings on a small relay that pulls in a large contactor that powers up the heater controllers. Once the heaters are up to temperature they close a relay. Then this is used to send 3v3, 5v or GND to an input on the duet or could use 24 volt into an opto isolated input. Then the macro can continue. The temperature controllers are made by Omron (do not have a model number with me at the moment) but they are pretty generic. Hope this helps clear the scenario.
Thanks Mark
-
@machinemark ok so to be clear the requirement at the start of a print job are
- Turn on 4 digital outputs (which turn on the industrial heaters),
- Turn on the 3 Duet controlled heaters.
- Wait for 4 digital inputs to be switched by the industrial heater controllers, one all 4 are switched to the "temp good" state, then proceed.
- wait for the duet heaters to come to temperature.
- proceed with the job
Of course the Duet heater may get there first, or not, it does not matter for the logic.
If that's the case then I would have a macro to turn on the industrial heaters, and you can alias that macro to a unused gcode command if you like, (say M1040.g).
I would have a different macro to wait for them (say M1160.g)
Then use the following in the start gcode for the job:
M1040 ; turn on industrial heaters M568 S200 ; set the active tool to 200C M1060 ; wait for the industrial heaters M116 ; wait for all temperatures controlled by the duet to be within tolerance.
Note I used M568 for the tool heater control as its preferred to G10, which in turn is preferred from the old M104 command. Modern slicers normally allow you to override the start gcode to have better control of the commands.
Also note there is no requirement to alias the macros if you don't want to you could use the macros directly:
M98 P"0:sys/heatup.g"
-
Hi Tony,
Thanks for your reply. I was thinking on similar lines but incremental ie in the slicer set start g code to run M180
Then the Duet runs M180 which turns on the output, runs a while loop waiting for an input to change ie Heaters change voltage of an input on the duet board or powers one of the opto isolated inputs once they are up to temperature. Then the while loop is broken and can continue, Assume
T0 M568 S200
T1 M568 S220
T2 M568 S240
T3 M568 S250This of coarse is simplified, there would be a few safety interlocks and checks.
In your example M1040, M568, M1060 run in parallel? The question would be bringing on outputs and checking inputs. I still having issues with both. I seem to have had success declaring outputs and inputs in the config.g file but only had success turning on the heater outputs from a macro. No luck turning on GPIO outputs or checking GPIO inputs. Any ideas or examples?
Thanks Mark
-
@machinemark said in Custom M104 macro or Edit Existing M104 macro:
In your example M1040, M568, M1060 run in parallel?
M1040 starts the heating of the industrial heaters, the 4 industrial heaters are assumed to be safe to heat in parallel. M568 would heat all the 3 duet heaters associated with the tool at once. So the 7 heaters would be heating in parallel.
You can wait for either set first, as they all need to be at temperature to continue. The while loop for the industrial heater "ok" inputs I put in a macro called M1160.g once all the industrial heater inputs are at "ok" then check the Duet controller heaters are Ok using M116 , then execution continues.
You said earlier that all 7 heaters were on the same tool so you would set the tool definition to have all three heaters on the Duet associated with it so only a single M568 command would be needed.
See:
https://docs.duet3d.com/en/User_manual/Reference/Gcodes#m563-define-or-remove-a-toolSomething like:
M563 P0 D0 H1:2:3
I am not sure what you are aiming for by setting progressively higher temperatures for the tool in your example? .
If you want the three duet heaters on the tool to be at different temperatures then you use an array when setting the temperature in M568:
https://docs.duet3d.com/en/User_manual/Reference/Gcodes#m568-set-tool-settings
In tools with multiple heaters the temperatures for them all are specified thus: R100.0:90.0:20.0 S185.0:200.0:150.0 .
-
@machinemark said in Custom M104 macro or Edit Existing M104 macro:
No luck turning on GPIO outputs or checking GPIO inputs. Any ideas or examples?
Will address those in the separate thread