@Perspective said in Synchronised Bed & Hotend, Homing not required after print.:
1: I would like to know how to set up the duet so i can time the heated bed and hot end so they are both ready at the same time.
I feel you're over thinking it quite a bit.
The traditional and simplest way is to simply turn both heaters on in the start gcode and then put M116 in there so it waits until both are up to the set temp before printing commences.
To try to synchronise the end times while still being able to carry out other tasks wold require you to use daemon.g to monitor the current temps and other variables and you would need to know what the heating rate is for each heater.
As an exercise I tried to do this in a single macro. (I'm an early riser and have only my own company for a couple f hours)
This would NOT work in a print because it would be blocking, so nothing else can happen at the same time.
I suppose you could start it homing etc in the same macro ![:thinking_face: 🤔](https://forum.duet3d.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f914.png?v=m5joaec4b84)
However there are myriad complications such as one or both heaters may be turned off during probing.
In the object model we can find heat.heaters[0].model.heatingRate
Which is said to be the heating rate for the heater in Kelvins per second
I tried to use that to calculate how long to get from one temperature to another in seconds, but found it didn't give me anything like the real times I experienced. I suspect there is a lot more going on in the background when that value is used.
I then decided to just do a rudimentary measurement of how many degrees per second temp increase I was getting on the heater with a macro like this
M80
M291 R"Bed" P"Enter bed target temp" S5 L{floor(heat.heaters[0].current)} H{floor(heat.heaters[0].max)} F{max(60,floor(heat.heaters[0].current))}
var bedTarget = input
M140 S{var.bedTarget}
var lastheat = heat.heaters[0].current
while (heat.heaters[0].current < var.bedTarget - 1) && (heat.heaters[0].state = "active")
G4 S1
echo "Rate is " ^ heat.heaters[0].current - var.lastheat
set var.lastheat = heat.heaters[0].current
M140 S-275
When you run it, you will notice that the heat increase varies during the process because the PID algorithm is making sure you don't over shoot dramatically. Plus it takes more energy to get a cold block/bed to start to increase.
And again, if homing or bed mesh was going on then the heater may be turned off during probe moves.
But if you settle on a value, this macro would calculate the delay needed.
It assumes the bed is heater 0 and the tool is heater 1
M80
M291 R"Bed" P"Enter bed target temp" S5 L{floor(heat.heaters[0].current)} H{floor(heat.heaters[0].max)} F{max(60,floor(heat.heaters[0].current))}
var bedTarget = input
M291 R"Tool" P"Enter tool target temp" S5 L{floor(heat.heaters[1].current)} H{floor(heat.heaters[1].max)} F{max(200,floor(heat.heaters[1].current))}}
var toolTarget = input
var startTime = state.upTime
var bedRate = 0.5 ; how many degrees per second heat increase you measured on average
var toolRate = 1.6 ; how many degrees per second heat increase you measured on average
var bedNow = heat.heaters[0].current
var toolNow = heat.heaters[1].current
var bedDiff = var.bedTarget - var.bedNow
var toolDiff = var.toolTarget - var.toolNow
var bedTime = floor(var.bedDiff / var.bedRate)
var toolTime = floor(var.toolDiff / var.toolRate)
echo "Time to heat bed from " ^ var.bedNow ^ " to " ^ var.bedTarget ^ " is aprox " ^ var.bedTime ^ " seconds"
echo "Time to heat tool from " ^ var.toolNow ^ " to " ^ var.toolTarget ^ " is aprox " ^ var.toolTime ^ " seconds"
var delayStart = var.startTime + abs(var.bedTime - var.toolTime)
if var.bedTime >= var.toolTime
M140 S{var.bedTarget}
echo "Bed heater started"
else
M568 P0 S{var.toolTarget} A2
echo "Tool heater started"
while state.upTime < var.delayStart
echo "Start other heater in " ^ var.delayStart - state.upTime ^ " secs"
G4 S1
echo "Delay time exceeded - both heaters on"
M140 S{var.bedTarget}
M568 P0 S{var.toolTarget} A2
while (heat.heaters[0].current < var.bedTarget-2) && (heat.heaters[1].current < var.toolTarget-2)
echo "Both heaters below target"
G4 S1
while (heat.heaters[0].current < var.bedTarget) || (heat.heaters[1].current < var.toolTarget)
if (heat.heaters[0].current < var.bedTarget)
echo "Still waiting for bed. Should finish in " ^ var.startTime + var.bedTime - state.upTime
if (heat.heaters[1].current < var.toolTarget)
echo "Still waiting for tool. Should finish in " ^ var.startTime + var.toolTime - state.upTime
G4 S1
echo "Both heaters have reached target"
M140 S-275
M568 P0 A0
In a perfect world, both should reach the designated temp at the same time.
If you see negative time left you would decrease the heat rate and vise versa
But it's going to also be affected by whether you're starting from ambient temp or not.
A lot of typing to replace M116 ![:shrug: 🤷](https://forum.duet3d.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f937.png?v=m5joaec4b84)