DUET3 any pin to detect poweroff and aid Zbraking?
-
I have a large heavy printbed that had the same problems with dropping unlevel at power off.
Here's how I overcome it:I grabbed a stepper brake design from thingyverse and modified it for use with a solenoid.
Here is the final result:I have these on all 3 Z steppers and they are controlled by a cheap arduino nano.
The nano is used as an interface to be able to control the braking exactly how I want.
It looks for a brake control signal that I set up on the Duet 3 board.By default the brakes are on. When the printer is powered up one of the first commands in config.g is to enable the Z motors. This locks their positions and therefore is now safe to release the brakes without causing any Z movement.
The only downside is that for complete control I have to use my own board reset, e-stop and shutdown macros but this is not a real problem for me.Visually, I no longer see any Z drop but to be safe after every power up I do one quick bed level
which before the upgrade would have not been enough to level the bed accurately.
Now, I see no bed drop and the bed is guaranteed level within seconds of power up.Here is what is required:
In config.g:
; Z brake control
M17 Z ; enable Z motors to hold bed position before brake is released; set up servo brake signal on out5
M950 P5 C"io5.out"
M42 P5 S255 ; brake offMy Macros:
E-Stop:
M42 P5 S0 ; brake on
G4 P500 ; wait 500 milli seconds
M112Reset:
M42 P5 S0 ; brake on
G4 P500 ; wait 500 milli seconds
M999shutdown:
; macro to shutdown printer after hot end has cooled down
; carry out some checks firstG10 S0 R0 ; Set active and standby temps to zero to ensure nothing is on standby
M140 S0 ; heated bed heater off; only shutdown if extruder temperature is below 70
while true if sensors.analog[1].lastReading > 70 ; if hot end temperature is 70 or above then cool down M291 P{"Hot end temperature too high, cooling in progress!" } R"Power Management" S1 T0 ;break ; if not true, go to next command if sensors.analog[1].lastReading < 68 M291 P{"Hot end temperature < 68, shutting down now" } R"Power Management" S0 T4 M42 P5 S0 ; apply Z brakes G4 S2 ; wait 2 seconds M81 ; atx power off
Arduino code:
#include <Servo.h>//Define duet output pin
#define inPin 12#define PUSHED HIGH // look for active high
byte lastState;
unsigned long startMillis; // time variable
Servo servo1;
Servo servo2;
Servo servo3;void setup()
{
servo1.attach(3); // servo 1
servo2.attach(4); // servo 2
servo3.attach(5); // servo 3
pinMode(inPin, INPUT_PULLUP);
//keep brake on at power up (brake arm is at 90 degrees when in off position!)
servo1.write(0); // brake on
servo2.write(0);
servo3.write(0);
delay(10000); // delay for duet initialisation
servo1.write(100); // brake off
servo2.write(100);
servo3.write(100);
delay(10000);}
// duet in control from here onwards
void loop()
{
byte thisState = digitalRead(inPin);//look for changed state?
if (lastState != thisState)
{
//update to the new state
lastState = thisState;
//record time
startMillis = millis();
}
//check for changed state
// if (lastState == PUSHED) {// inPin state must have changed for >= 2 seconds to eliminate false triggers
if (lastState == PUSHED && millis() - startMillis >= 2000UL)
{
servo1.write(100); // brake off if input high
servo2.write(100);
servo3.write(100);
delay(1000);
}
else
{
servo1.write(0); // brake on if input low
servo2.write(0);
servo3.write(0);
delay(1000);
}}
-
@jayt said in DUET3 any pin to detect poweroff and aid Zbraking?:
What I understood from heightmap is its for mesh bed compensation. Even if I reload map using G29, how will it get applied when I resume print after power failure ? Can you elaborate on this for me please?
Just send G29 S1 after you have homed to Z max to load the heightmap
-
@engikeneer said in DUET3 any pin to detect poweroff and aid Zbraking?:
Just send G29 S1 after you have homed to Z max to load the heightmap
As long as the Z0 point is the same when homing with Z max and homing with the probe, this will work just fine.
The best way to ensure this is to have a macro that homes z using the probe and then moves to Z max and sets the actual Z axis length so that when the Z max endstop is used the position is correct.
Example
; 0:/macros/Bed Leveling/0_Set Zmax height.g ; Automates measuring the Zmax height for optical endstop at ~300mm ; M291 P"This will set Z0 and calibrate Zmax height" R"Proceed?" S3 M291 P"Homing all axis" T5 G28 ; Home all G90 ; Absolute positioning M98 P"0:/macros/0_Center Nozzle.g" ; Move nozzle to bed center M291 P"Adjust nozzle height until it's touching bed" Z1 S3 G92 Z0 ; set Z0 M291 P"Bed will now drop to Z300" S3 G1 Z300 ; Move bed down 300mm G1 S3 Z300 F200 M500 ; save m208 value for z axis to config override M291 P"Adjust optical endstop flag until light just turns off" R"Set Zmax=300mm" S3 M291 P"ZMax homing will now be tested, starting with homing Zmin" S3 M291 P"Homing to Zmin" T5 G28 Z M291 P"Ready to test Zmax homing?" R"Proceed?" S3 M291 P"Homing to Zmax" T5 M98 P"0:/macros/2_HomeZMax.g" ; Test Zmax homing M291 P"ZMax homing test complete. Printer will now home all." R"Proceed?" S3 G28 ; Home all M291 "ZMax calibration complete." S3
-
@jayt said in DUET3 any pin to detect poweroff and aid Zbraking?:
What I understood from heightmap is its for mesh bed compensation. Even if I reload map using G29, how will it get applied when I resume print after power failure ? Can you elaborate on this for me please?
I never had a power failure, but fom what I know, the last position is stored on SD.
After homing to Z-max and applying G29 S1 but before hitting the resurrect button, you can direct the nozzle to that position and see if it's reasonable. With a little luck you are somewhere in the infill so it's safe to do minor adjustments to the position if needed.Worst case in a power failure scenario is the bed temp dropping to a point where it's almost certain you'll kick off the part when you continue printing.
If you see power grid failures often where you live, it's probably safer to use a backup battery. (old e-bike or RC hobby LiPo batteries)A more advanced solution would be an automatically compensated counterweight : You'd install two empty buckets as counterweights for the empty bed and during print you fill them with water to compensate for the filament weight. A peristaltic pump parallel to the extruder could do this. Change mixing ratio for different filament density.
...crazy idea, I know -
Thank you for all the replies. I used M569.7 with one of the out signal, so on power off, the bed fall is now quite less. So I donot wish to include counter balance, but instead check if G29 can help.
@phaedrux , @engikeneer :
a) I need a little help to understand what happens when I run G29 S1 on power on, when config is read. From my understanding, this will load the height map, but to perform mesh bed compensation. It does not apply correction to ball screw like we do in bed levelling in one shot right? it will be a correction that will apply at each layer right until taper height?b) Suppose first few layers we applied mesh bed compensation. Now after say Xmm height, power goes off.
Now if I use Zmax homing and resume, will it not resume at proper height? Will there be chances of nozzle hitting the print due to compensation applied?c) @dc42: Is there a way, the way we save heightmap , we can use this to run Auto-level on power up by updating few things in the firmware? I am ready to try if there is a way?
-
@jayt G29 S1 should not be used in config.g. The heightmap should only be loaded after your Z axis has been homed. In the case of power loss resume, the correct place to load it would be in the resurrect-prologue.g file after the Z axis has been rehomed.
-
@phaedrux : ok understood.
Can you clarify one more question, IF we define taper height, and after Zmax home-> resume-> it will again apply correction for defined taper height right?
i.e. if taper height is 10, then on resume if Zprinted is >10mm, it will again apply correction for 10mm ?
(I know this is silly question, but I am new to this topic. ) -
@jayt said in DUET3 any pin to detect poweroff and aid Zbraking?:
it will again apply correction for defined taper height right?
i.e. if taper height is 10, then on resume if Zprinted is >10mm, it will again apply correction for 10mm ?That sounds correct to me.
-
@jayt no, it will only apply correction from z=0 to z=10 (in decreasing amounts). So if you resume a print at z =50, no correction will occur
-
@engikeneer @Phaedrux : Both of yours answers are contradictory
Can you check if you have these settings in place?@dc42 : Any way to apply last learned deviation corrections, after Zmax homing , on power up , by changing RRF? I tried to check few files, in Zleadscrewkinematics.cpp, can we use function: "Write ResumeSetting()" to call function that applies last learned corrections (if saved) ? Do you suggest to do so?
-
@jayt In the original thread you linked, there are photos we posted of an early prototype which used a bank of relays to assist in z-braking. We gave up on that idea and worked with LDO to create a high torque stepper with integrated 24v brake.
We are having great success with these steppers and the new motor brake functionality in the 3.4 betas. We'll be selling these on website as soon as it launches, but please reach out now if you think it could help you as we have them in stock. FYI - the specs are
- class H (high temp)
- 1.8Β° step angle
- 8.5Kg-cm Holding Torque
- 2.0 amp
- 24v 5w electromechanical brake
- 50ms on/off delay
- 6Kg-cm Holding Torque
-
@jayt said in DUET3 any pin to detect poweroff and aid Zbraking?:
@engikeneer @Phaedrux : Both of yours answers are contradictory
Can you check if you have these settings in place?I misread your question. @engikeneer is correct.