Welcome! Log In Create A New Profile

Advanced

Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)

Posted by julianh72 
Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 06, 2015 07:49PM
So I've taken the plunge, and I'm playing with the current stable release of Marlin on my Prusa Mendel with RAMPS 1.4 and a PCB Heat Bed, powered by an ATX Power Supply. (I've been on a 2012 build of Sprinter until now.) I've tried activating PID Temperature Control to both the Hot End and the Heat Bed, and it works very nicely - it keeps the temperatures of both MUCH more stable than my old Bang-Bang temperature control.

The nozzle will quickly get up to any temperature that I am interested in (I'm printing with PLA or ABS, nothing too exotic yet), but I can't get the Heat Bed to go any higher than about 100 degrees C, and when I monitor the echo output in the Pronterface UI, it seems it won't push the PID PWM to go any higher than 127 on either the Nozzle or the Heat Bed. At a continuous 127 PWM reading, the Heat Bed won't seem to go any higher than about 100 degrees C. (Does that sound typical?)

I've looked and looked through the Marlin code for somewhere that I might have inadvertently set the maximum duty-cycle to 50%, but I can't find it. Have I overlooked something, or is there a limit of 50% duty cycle when you drive both heaters with PWM PID control?

Thanks for any assistance!


Follow my Mendel Prusa build here: [julianh72.blogspot.com]
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 07, 2015 03:05AM
#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
...
#define PID_BED_INTEGRAL_DRIVE_MAX MAX_BED_POWER //limit for the integral term
These two lines seem to indicate that max PWM is "reserved" for the integral value of the PID.
The P value can´t be 255, because there has to be headroom for the I value.

100°C Is a good temp. Many printers only reach so far with some tricks, like:

insulating the bottom of the bed,
using an enclosure around the printer,
using thicker wires
using better MOSFets
using 24V PSU with dc/dc solidstate relais

If you haven´t done all the tricks, there´s room for improvement.
-Olaf
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 07, 2015 03:16PM
I have this exact same problem. I have been printing in PLA for weeks, now I'm getting ready to print in ABS only to find that my bed doesn't get full power. 127 max. This causes PID tuning of the bed to fail due to timeout. Considering that my electronics are fully capable of running my bed at full current, is there a way to modify the Marlin configuration to let it run at 255? Using better MOSFETS or thicker wires isn't going to help anything if you aren't pushing any more current or overheating the current ones and switching to a higher powered PSU seems completely unneccesary when the one I've got is perfectly capable. The firmware is simply limiting me to half my available power. Also, I don't actually have a define for "PID_BED_INTEGRAL_DRIVE_MAX MAX_BED_POWER" unless it is somewhere other than Configuration.h.

Edited 1 time(s). Last edit at 09/07/2015 03:25PM by thedoktorj.
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 07, 2015 03:31PM
Out of curiosity I tried bang-bang mode and have the same issue. Max of 127 PWM.
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 07, 2015 03:50PM
Julian, are you sure that you are not just stumbling over the fact that Marlin does not show the PWM (as one would expect!) from 0 - 255, but somehow only from 0-127 - i.e. the least significant bit is lost. So if you see "...B@:127" in pronterface, this means you have a full 100% duty cycle.
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 07, 2015 04:05PM
Thanks Enif!

So... Is the fact that Marlin only reports PWM out of 127 (rather than 255) documented somewhere, or is it a bug? It sure confused the heck out of me!

It seems that if I'm getting full PWM power cycles, I'll have to investigate other options to get my bed temperature higher. (Eg better bed insulation, an enclosure, etc)

Thanks for the feedback everybody!


Follow my Mendel Prusa build here: [julianh72.blogspot.com]
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 07, 2015 04:23PM
Wow, that's super confusing. I had no idea that 127 was actually 255. Not sure how anyone would figure that out without reading all the code. Disregard my previous messages.
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 07, 2015 07:13PM
It seems the issue has been around a while - after reading enif's helpful post, I did a bit more googling, and found this Google Groups thread from 2012 where Joel Chia explains it in a bit more detail.
[groups.google.com]

As he says in his post from 07 May 2012:
I've gotten used to reading it as "heater is on for xxx ms every 127 ms"

That's a nice geeky way of thinking about it - I can live with that, now that I know what's going on. thumbs up

Edited 1 time(s). Last edit at 09/07/2015 07:15PM by julianh72.


Follow my Mendel Prusa build here: [julianh72.blogspot.com]
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 08, 2015 02:16AM
As for getting the heatbed to higher temperatures, here is what I did:

- use a piece of corkboard as insulation directly underneath the heatbed
- cover the heatbed with a piece of thick corrugated cardboard while heating up
- increase the output of the 12V PSU to 13.3V

WIth that I can get the heatbed in reasonable time (~4min) up to 120 C.
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 08, 2015 03:20AM
I've already got cork-board under the PCB, and the acrylic platform underneath doesn't seem to get too hot.

Putting some insulation on top during heat-up is a good idea - I'll give it a try and report back soon.

I don't know how to hack my ATX Power Supply to 13.3 volts output, so I'll park that idea for now.


Follow my Mendel Prusa build here: [julianh72.blogspot.com]
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 10, 2015 03:30PM
i was having similar issues, i decided to save myself the headacheand get a heated silicon pad and aluminum bed, should heat up in about 2 minutes once i get it all set up. whole setup only cost me like $75(cad)

also i got the 120v AC version to take pressure off my PSU

Edited 1 time(s). Last edit at 09/10/2015 03:31PM by t3rry.
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 21, 2015 07:36AM
In addition to some insulation (I'm using pressed cotton) to reduce conducted heat, also put a sheet of aluminum foil to reflect back the radiated heat. Don't short anything out though.

Also, my Marlin shows 255, not 127:


============================= PID > Bed Temperature Control ===============

#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current

Edited 1 time(s). Last edit at 09/21/2015 07:36AM by RRuser.
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 21, 2015 11:14PM
Quote
RRuser
In addition to some insulation (I'm using pressed cotton) to reduce conducted heat, also put a sheet of aluminum foil to reflect back the radiated heat. Don't short anything out though.

Also, my Marlin shows 255, not 127:


============================= PID > Bed Temperature Control ===============

#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current

Have you monitored the output on Pronterface or similar? I have the same line in my configuration.h:

#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current

However, when I monitor the behaviour on the Pronterface screen, it shows 127 as a maximum - this was the source of my original post. However, as enif said in their post above:

Marlin does not show the PWM (as one would expect!) from 0 - 255, but somehow only from 0-127 - i.e. the least significant bit is lost.


Follow my Mendel Prusa build here: [julianh72.blogspot.com]
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 22, 2015 02:15AM
Quote
julianh72
However, when I monitor the behaviour on the Pronterface screen, it shows 127 as a maximum - this was the source of my original post. However, as enif said in their post above:

Marlin does not show the PWM (as one would expect!) from 0 - 255, but somehow only from 0-127 - i.e. the least significant bit is lost.

Right. I don't know why but I guess Hosts will interpret this correctly.

temperature.cpp
// Check if temperature is within the correct range
soft_pwm[e] = current_temperature[e] > minttemp[e] && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0;


Triffid Hunter's Calibration Guide --> X <-- Drill for new Monitor Most important Gcode.
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
September 22, 2015 03:47AM
I don't have a host; I just run from Marlin and the SD card. And there is lots of power to the bed.
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
October 06, 2015 10:59AM
Maybe firmware divides PWM in two, one for the thermistor and the other for Bed. I have S3D and it shows "@127" too.

I'll try with the bed disabled and see if that gets the PWM at 255.
Re: Marlin firmware - Heat Bed PID PWM won't go higher than 127 (50% duty cycle)
October 07, 2015 04:16AM
It shouldn't because

(int)pid_output >> 1

">>" means rightshift or "/2"


Triffid Hunter's Calibration Guide --> X <-- Drill for new Monitor Most important Gcode.
Sorry, only registered users may post in this forum.

Click here to login