Securitiy Switch for the Heatbed with a Relay

Helo Repetier world...

What happened: I controled my heatbed (24V, ~800W, 33A) over a MOSFET (at the + pole of the Heatbed). This worked fine until this MOSFET beak down (out of an unclear reason). Like all MOSFETS the circuit was closed afterwards, so my headtbed got full power without an ending. Lukily i was present, so I could switch down the printer. With this setting the firmware is not capable do switch the Heatbed down, even if it detects the defect.

My intention: After repairing the MOSFET I'm asking me, how to eliminate the risk of a molten aluminium heatbed if the MOSFET should break again and I am not in the room. So I put a relay between the power source an the heatbet (at the - Pole of the Heatbed). I connected the Pin Nr 9 with the spool of the relais. With the command M42 P9 S255 I can put the relay on and with the command M42 P9 S0 I can switch it off.

My Question: The firmware detects the error, when the Heatbed rises it temperature uncontrolled. Wehre do I have to put the M42 command into the firmware, that the firmware switches off the relay in case of a defect heatbed (or any other defect)?

Thanks for any help, kind regards


  • Probably I found the solution, but I cannot test it:
    In the register ui.h i found the following lines:

                uint8_t eid = NUM_EXTRUDER;    // default = BED if c2 not specified extruder number
                if(c2 == 'c') eid = Extruder::current->id;
                else if(c2 >= '0' && c2 <= '9') eid = c2 - '0';
                    if(eid == 0 && ++beepdelay > 30) beepdelay = 0; // beep every 30 seconds
                    if(beepdelay == 1) BEEP_LONG;
                        addStringP(PSTR(" def "));
                    else if(tempController[eid]->isSensorDecoupled())
                        addStringP(PSTR(" dec "));

    Below the Line [ addStringP(PSTR(" dec ")); ] and above the line [ break; ] I think I can input the Switchoff cmd for the relay. Is that correct? How do I write a M42 Command directly inside of an C++ Program Code? Is there a way to simulate a decoupled heatbed (Simulate a Temperature of 150C° for the Heatbed)?

    Thanks a lot for any tipps...
  • Executing a gcode command is easy:

     GCode::executeFString(PSTR("M42 P9 S0"));

    I would add it in Extruder.cpp around line 320 where you see


    whcih is the better place.
  • There is a even better solution in hardware. You can use a temperature switch that open circuit if temp > some temp. Would not disable but prevent overheating at least.
  • Thank you very much. That's exactly what I didn't know.

    Which temperature switch can switch over 30Ampere by 24Volts?

    You suggest to open the circuit when the temperature rises over a certain value. I think thats a great idea, because it is much faster than my solution. But i have not found the defect temperature of the heatbed by itself. Only the defect Temperature for the extruders. So where can I define a max defect Temperature value for the heatbed? And is the firmware capable to realise this overtemperature?

    Thanks a lot
  • There is no defect temperature special for bed. The values should be choosen such that a short or broken line goes outside these limits. That is defect as we mean it here. In your case the decoupling test should trigger instead. You want to hold temperature and it rises => decoupled. 
Sign In or Register to comment.