<blockquote>
  <p>What command would I enter to make this a bang-bang PID controller</p>
</blockquote>

<p>There's no such thing as a "bang-bang PID controller". "bang bang" is mutually exclusive of PID. The M301 command is only good for fine-tuning the parameters of the PID controller, but it won't let you switch to bang bang. Unfortunately, you must update the firmware if you wish to use bang bang.</p>

<p>You could try setting all values to 0, except P, which you set to an as high value as possible. This will cause the output to be fully on when the temperature is lower than the setpoint, and fully off when higher than the setpoint. However, this can still cause rapid clicking of the relay when the temperature is hovering around the setpoint. Bang bang has some hysteresis built-in (i.e., there is a margin around the setpoint in which the relay will never be toggled); there's no way to emulate this with PID.</p>

CC BY-SA 4.0
2019-11-10T17:09:10.647Z
There must be a way to make it as close to bang bang as possible
K Mmmm
CC BY-SA 4.0
2019-11-10T18:00:56.407Z
@steveantwan No, there isn't. To drink red wine from a white wine glass you have to empty the glass first.
Trish
CC BY-SA 4.0
2019-11-10T19:47:37.170Z
@steveantwan I added something on emulating bang bang with PID.
Tom van der Zanden
CC BY-SA 4.0
2019-11-10T22:24:06.610Z
Thanks. It is possible to emulate hysteresis as well if you are only trying to heat something. For example: `M109 S105; M109 S95; M109 S105; M109 S95 ... (repeated)` would keep the heat roughly centered around 100 degrees - it would work well with your suggestion for modifying PID. You'd still get some clicking i think for a few seconds each time during the "watch temp" period............ But i decided to just bend over backwards to flash the arcane firmware to enable bang-bang
K Mmmm
CC BY-SA 4.0
2019-11-11T07:29:21.227Z
If you use an SSR, you could just use the PID as-is.

Other than that, the Printrboard is also just an AVR based board and still supported in Marlin 2.0 as `PRINTRBOARD` or `PRINTRBOARD_REVF`
towe
CC BY-SA 4.0
2019-11-11T23:36:38.990Z
RevF uses Teensy2.0 ++ though, and I was having trouble finding the right way to get everything to work. It turns out the Marlin pins.h file for the printrboard has pretty good instructions, along with the reprap wiki for flashing from linux
K Mmmm
CC BY-SA 4.0
2019-11-10T16:47:50.920Z
2019-11-10T19:47:21.510Z
2019-11-10T19:47:21.510Z
Tom van der Zanden
<p>I'd like to have the 12V PID output of an old Printrboard hotend control a relay that attaches to a 120V crockpot for something I'm making. I have everything working fine using a relay, but because the hotend heater is using PID control, the relay clicks about 3 times per second each time it needs to heat up the crockpot. </p>

<p>Not only is this sound annoying, but it will likely reduce the life of the relay significantly. I need the crockpot temperature controlled, so the programmatic thermistor control on an old 3D printer board is a huge help, and probably cheaper than the alternatives. Especially since this board has an SD slot built in and can run any code on power-up. In "bang-bang" control, there would be less clicking as the crockpot heats up, and the relay wouldn't be damaged.</p>

<p>I can't update the firmware on my board to use a different pin because it is a really old Printrbot board. All the required software is almost 5 years old and is really difficult to find. Fortunately the Printrboard does support <code>M301</code>. So, I should be able to use this command to switch from PID control to bang-bang.</p>

<p>In <a href="http://marlinfw.org/docs/gcode/M301.html" rel="nofollow noreferrer">Marlin's documentation</a>, it describes a command called M301, along with a lot of variables for using this command. The problem is, I don't know what any of these variables mean. </p>

<pre><code>M301 [C&lt;value&gt;] [D&lt;value&gt;] [E&lt;index&gt;] [I&lt;value&gt;] [L&lt;value&gt;] [P&lt;value&gt;] 
</code></pre>

<pre><code>
[C&lt;value&gt;]  

C term (requires PID_EXTRUSION_SCALING)

[D&lt;value&gt;]  

Derivative value

[E&lt;index&gt;]  

Extruder index to set. Default 0.

[I&lt;value&gt;]  

Integral value

[L&lt;value&gt;]  

Extrusion scaling queue length (requires PID_EXTRUSION_SCALING)

[P&lt;value&gt;]  

Proportional value
</code></pre>

<p>About the only thing I know for sure is that the extruder index is 0. </p>

<p>What command would I enter to make this a bang-bang PID controller, so that I don't damage my relay long-term?</p>

CC BY-SA 4.0
2019-11-11T08:44:18.887Z
I have a Printrboard. Updating the firmware is in fact quite easy, even nowadays. In the time it takes you to adapt M301 you'll already have a new firmware.
FarO
CC BY-SA 4.0
2019-11-11T23:38:38.200Z
Yea, the Marlin pins.h file for printrboard helped a lot. It was the search engine that was spitting out irrelevant stuff
K Mmmm
<marlin><heat-management>
What are the variables for PID control? How to use M301? How to use this command to switch from PID to bang-bang?
K Mmmm
# What are the variables for PID control? How to use M301? How to use this command to switch from PID to bang-bang?

(Asked by: username_0 on 2019-11-10)

I'd like to have the 12V PID output of an old Printrboard hotend control a relay that attaches to a 120V crockpot for something I'm making. I have everything working fine using a relay, but because the hotend heater is using PID control, the relay clicks about 3 times per second each time it needs to heat up the crockpot. 
Not only is this sound annoying, but it will likely reduce the life of the relay significantly. I need the crockpot temperature controlled, so the programmatic thermistor control on an old 3D printer board is a huge help, and probably cheaper than the alternatives. Especially since this board has an SD slot built in and can run any code on power-up. In "bang-bang" control, there would be less clicking as the crockpot heats up, and the relay wouldn't be damaged.
I can't update the firmware on my board to use a different pin because it is a really old Printrbot board. All the required software is almost 5 years old and is really difficult to find. Fortunately the Printrboard does support M301. So, I should be able to use this command to switch from PID control to bang-bang.
In Marlin's documentation, it describes a command called M301, along with a lot of variables for using this command. The problem is, I don't know what any of these variables mean. 
M301 [C] [D] [E] [I] [L] [P] 


[C]  

C term (requires PID_EXTRUSION_SCALING)

[D]  

Derivative value

[E]  

Extruder index to set. Default 0.

[I]  

Integral value

[L]  

Extrusion scaling queue length (requires PID_EXTRUSION_SCALING)

[P]  

Proportional value

About the only thing I know for sure is that the extruder index is 0. 
What command would I enter to make this a bang-bang PID controller, so that I don't damage my relay long-term?

**Tags:** marlin, heat-management
> **Comments:**
> **username_1**: I have a Printrboard. Updating the firmware is in fact quite easy, even nowadays. In the time it takes you to adapt M301 you'll already have a new firmware.  
> **username_0**: Yea, the Marlin pins.h file for printrboard helped a lot. It was the search engine that was spitting out irrelevant stuff  

---

## 1 answers

### Answer by username_2 on 2019-11-10. Score: 4 | Accepted answer

> What command would I enter to make this a bang-bang PID controller

There's no such thing as a "bang-bang PID controller". "bang bang" is mutually exclusive of PID. The M301 command is only good for fine-tuning the parameters of the PID controller, but it won't let you switch to bang bang. Unfortunately, you must update the firmware if you wish to use bang bang.

You could try setting all values to 0, except P, which you set to an as high value as possible. This will cause the output to be fully on when the temperature is lower than the setpoint, and fully off when higher than the setpoint. However, this can still cause rapid clicking of the relay when the temperature is hovering around the setpoint. Bang bang has some hysteresis built-in (i.e., there is a margin around the setpoint in which the relay will never be toggled); there's no way to emulate this with PID.

> **Comments:**
> **username_0**: There must be a way to make it as close to bang bang as possible  
> **username_3**: @steveantwan No, there isn't. To drink red wine from a white wine glass you have to empty the glass first.  
> **username_2**: @steveantwan I added something on emulating bang bang with PID.  
> **username_0**: Thanks. It is possible to emulate hysteresis as well if you are only trying to heat something. For example: `M109 S105; M109 S95; M109 S105; M109 S95 ... (repeated)` would keep the heat roughly centered around 100 degrees - it would work well with your suggestion for modifying PID. You'd still get some clicking i think for a few seconds each time during the "watch temp" period............ But i decided to just bend over backwards to flash the arcane firmware to enable bang-bang  
> **username_4**: If you use an SSR, you could just use the PID as-is.  Other than that, the Printrboard is also just an AVR based board and still supported in Marlin 2.0 as `PRINTRBOARD` or `PRINTRBOARD_REVF`  
> **username_0**: RevF uses Teensy2.0 ++ though, and I was having trouble finding the right way to get everything to work. It turns out the Marlin pins.h file for the printrboard has pretty good instructions, along with the reprap wiki for flashing from linux  

---

