So first, a little explanation for non-coders. PWM means Pulse Width Modulation. In laymans terms think of turning a light switch on and off thousands of times per second. If you had an “old fashioned” incandescent light bulb, if you were able to flick the switch that fast, the light would appear dim - it’s only getting electricity part of the time. In an Arduino (the ‘brain’ of the controller board for your TAZ) there are PWM pins. You set it a value between 0 (off) and 255 (on all the time), and anything in between ‘flickers’ at a frequency. This is used in many things, but can also be used to ‘dim’ certain components.
Now, the Arduino pins that have PWM capability both cannot produce the amount of current the heated bed requires, and are reserved for things that require true PWM (servo controllers etc).
So there is a thing called software PWM, where the controller literally turns the ‘switch’ on or off thousands of times per second, at whatever frequency is required, simulating PWM, which is plenty good enough for a heating element.
So, when you see soft_pwm below, thats what it’s referring to - the software PWM value. Ready? Ok!
In the Marlin source code, temperature.cpp (visible at https://github.com/MarlinFirmware/Marlin/blob/RC/Marlin/temperature.cpp)
First, the lines of code that turn the heater on:
There is a loop that is called based on the hardware timer inside the controller. Inside that function at line 1447, the heater is turned on or off based on the soft_pwm value:
#if HAS_HEATER_BED
soft_pwm_BED = soft_pwm_bed;
WRITE_HEATER_BED(soft_pwm_BED > 0 ? 1 : 0);
#endif
For the non-coder, that says, if your config.h has said that you HAS_HEATER_BED, set the variable soft_pwm_BED to equal soft_pwm_bed (No clue why, that line seems unnecessary).
The next line is a macro to send an arduino write command to the bed heater pin, to turn it on or off. If the soft_pwm_BED is greater than zero, send a 1 (on), otherwise, send a 0 (off).
Other code adjusts that on/off value depending on if it should be on or off at the time, and that frequency is controlled by that soft_pwm_bed value.
Where does that value come from? Well at line 261, this is the pid auto-tuning function - where the machine figures out the most efficient way to keep your bed or extruders at the right temperature:
#if HAS_PID_FOR_BOTH
if (extruder < 0)
soft_pwm_bed = bias = d = (MAX_BED_POWER) / 2;
else
soft_pwm[extruder] = bias = d = (PID_MAX) / 2;
#elif ENABLED(PIDTEMP)
soft_pwm[extruder] = bias = d = (PID_MAX) / 2;
#else
soft_pwm_bed = bias = d = (MAX_BED_POWER) / 2;
#endif
It runs the PWM pin at MAX_BED_POWER / 2.
Then, later at line 798, where it’s actually figuring out what the soft_pwm_bed value is when turned on full tilt to heat:
soft_pwm_bed = current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP ? (int)pid_output >> 1 : 0;
pid_output is set earlier to be the bed’s max power, 206, as written in the config for the TAZ. The >> 1 is sorta-complicated-to-explain computer math function, but in essence, it says divide by 2 and drop any decimal. In effect, just halve the pid_output.
And lastly, if you turn your bed on, then run a M105 command to get a report of the statuses, it will show B@103, meaning the bed is heating at PWM value 103.
From everything I can see, the bed is being heated at about 40% of the available power, slowing down the heating considerably.
After I finish breakfast I’m going to take my multimeter to the bed and read the current draw and see what it says.