Shared power "budget" for extruder and bed

Hi. I have printer with an extruder and heating bed and I flashed Repetier firmware into it. Now I'm running into an issue when at the first stages of preparing to print, occasionally there will be a moment when printer shuts itself off. After studying it for awhile it looks that the problem is related to power. The printer came with 200W supply. I measured its power consumption and normally, printer uses around 150W which is ok for this power supply. However, if I turn on the heatbed at full power it alone draws around 190W of power. So, heatbed + extruder could overload power supply of they run at full power simultaneously. 

I already changed SKIP_M190_IF_WITHIN to 0 in Configuration.h and doing so did help a lot. But the problem is not completely gone. It still shuts off sometimes in about the same place. I suspect it has something to do with heat bed PID winding down and still drawing some power when extruder is starting to heat, which overloads power supply.

It doesn't seem right to replace the power supply, because it works just fine while printing. I also tried adding delays in g-code start scripts, but it's not very reliable as it seems that delays should depend on the heat bed temperature.  

It would be very useful to have some sort of "power budget" for the heat bed and extruder, like an additional cap above MAX PID for extruder and MAX PID, so when this budget is exhausted the printer will limit heat bed, so it won't overload power supply.

Is there something like that in Repetier firmware or maybe I should look at this issue from a different angle?



  • No there is no real power management to reduce this effect. In fact all heaters get tuned 100% for PWM at the same time and only depending on PWM they get disabled depending on PWM setting.  Normally no big problem since most devices also have some delay so average would still work.

    What you can do is:
    a) use PDM instead of PWM that gives more random on/off cycles if not at full power.
    b) limit Drive MAX to not use full power.

    But limiting means also you might not reach temperatures you could with enough power.

    What I wonder is why it draws 150W without bed. RAMPS 1.4 board has only a 5A fuse for heaters and motors except bed, so that would be 60W. Also I always wondered why that works since 5 motors using 2A are already 10A but it seems they draw less then expected in reality.
  • Repetier, thanks for the answer!

    Ok, I think there are few more things I should have mentioned.

    The printer is not exactly RAPMS. It's Overlord Pro printer with Atmega2560 custom PCB (it ships with marlin firmware). Extruder heater is 40W, and heated bed is 160W. 4 motors are 10W each max (which is really ~20W in total in my setup). I'm not sure what fuses they have on their board though. Here is one the thing - I measure the power usage with a power meter like this:

    It shows average power draw every second and while printing the machine is doing everything - moving motors, turning on/off the extruder and heated bed occasionally to keep the temperature on, etc. So the power draw value that the meter shows varies from 40W to 150W, which is why I mentioned 150W (which is below 200W power supply is rated for) - it's max average power draw I saw with the meter during regular printing when heated bed was On. So PID was only keeping the temperature, not actively raising it. So theoretically it could shut off while printing too, but haven't seen that happening yet (and which is why having this sort of "power budget" could be useful as it won't let it happen even in theory).

    So far it only being happening in one very specific case - start of the job, M190 is finished and printer starts moving down to turn on the extruder. It turns it on and boom - shutdown.  While it's moving I see that the power draw on the meter is decreasing, but gradually, because heated bed PID is still driving it somewhat, that's why there is a moment when they both may be on for long enough to trigger protection in the power supply. It used to be much worse because SKIP_M190_IF_WITHIN was 3 (default value generated by Repetier firmware web configurator) which exaggerated the issue.

    As for capping the Drive MAX for the heat bed PID, I already tried that (before I learned about SKIP_M190_IF_WITHIN). It had to decreased 30-40% in order to get it work reliably this way (which is quite a lot, so I was even considering replacing the power supply).

    And as for using PDM, I can give it a shot, but which value is it? Here is what I see in Configuration.h:
    Heat manager for heated bed:
    0 = Bang Bang, fast update
    1 = PID controlled
    2 = Bang Bang, limited check every HEATED_BED_SET_INTERVAL. Use this with relay-driven beds to save life time
    3 = dead time control

    I was reading about dead time control and I think it was different. So is it Bang Bang, fast update? Anything else I should setup to make sure that On impulses are not very long? (cause that what will probably trigger the issue)

  • I don't know why you think SKIP_M190_IF_WITHIN would help. It's aim is to not wait for target temperature to be reached if you are by SKIP_M190_IF_WITHIN degree close to it. It does not change when bed goes on or which temperature.

    PDM is set in config tool with this checbox "Enable PDM for heaters (instead of PWM) (PDM_FOR_EXTRUDER)"

    For full power there will be no difference and teh average consumption needed will also not reduce, just the timing when and how often all are drwing in parallel. So I fear in the end you will need a bigger power unit or a smaller heated bed.
  • It turned out that I was already using PDM_FOR_EXTRUDER=1

    SKIP_M190_IF_WITHIN=0 helps because when it's non zero the printer moves on to the next task while heating bed is still drawing quite a lot of power. In my case the next task is "move to Z=0.5 and start heating extruder", so with SKIP_M190_IF_WITHIN=3 both extruder and heating bed are almost certain to turn On simultaneously which would be too much for this power supply and it will shut off by internal overcurrent protection. It just looks like the printer's vendor thought that these two things shouldn't be on full power simultaneously as I never had such issue with their original firmware. I also measured the power draw on the original firmware to check if they are limiting max PID for the heating bed and it didn't look like they do - it drew same amount of power as with Repetier firmware with max PID 255.

    That's why I was thinking about this dynamic "PID budget" thing. A configuration option like *_PID_MAX which applies to both extruder and heating bed, with extruder having a priority, so it will dynamically cap the heating bed PID to whatever left from extruder. I was trying to do something like it today with a code like this in extruder.cpp, Extruder::manageTemperatures(), within act->heatManager == HTR_PID:
    uint8_t _pidMax = act->pidMax;
    if (act->pwmIndex == HEATED_BED_INDEX){ 
    	int16_t ivalue = HEATED_BED_AND_EXTRUDER_MAX_PID;
    	for(uint8_t i = 0; i < NUM_EXTRUDER; i++)
            TemperatureController *c = tempController[i];
    		if (pwm_pos[c->pwmIndex] < ivalue){
    			ivalue -= pwm_pos[c->pwmIndex];
    	if (ivalue < _pidMax){
    		_pidMax = ivalue;
    output = constrain((int)pidTerm, 0, _pidMax);
    but it didn't work for some reason.
  • What should this code do? If a extruder has a lower pwm then bed then you lower the bed by that value?
    Wouldn't it be better to add power consumption.
    So if a extruder has 40W and bed 160W you compute extruder power
    EP = sum(extruder_pwm * 40 / 256)
    Then you can compute how much power you are willing to give to the bed.
    So if you have 180W for heaters
    MaxBedPWM = (140-EP) * 255 / 160
    Then set output to lower value.

    When my 40W heaters are hot they use < 50% just like for bed so that would work at the end if bed is heated first.
  • mplmpl
    edited July 2017
    The code above was indent to do similar thing, only it was expressed in terms of PID_MAX_* values, because that's what I saw in Configuration.h, so I was trying to follow that.

    The idea was to add shared PID_MAX constant for both extruder and heating bed.

    Let's assume that I have these values in the config for extruder and bed
    #define EXT0_PID_MAX 160
    #define HEATED_BED_PID_MAX 255

    I can test with Repetier host (and power meter) that the printer is doing just fine when only heating bed is running. But when extruder is at full power and motors are active (it turned out their power usage should be considered too!) the bed PID should be at capped at no more than 80 PWM or power supply will shut off. So if I set 
    it will cap the heating bed at max PID 80 (only when extruder is running at the same time. If extruder is not running I'd rather have bed running at full 255 PWM).

    So just capping HEATED_BED_PID_MAX to 80 (instead of 255) is not very favorable, as it will make heating bed will very very underpowered. And it's only needed to be done in very specific situation which normally only arises at the very start of the print (although it can also be triggered during the print if target heating bed temperature is raised a lot in the middle of the print, but that's probably not done a lot, although still possible).

    The code above had bugs (the case of initial heating was missed) which I fixed, so now I can run both the extruder, heating bed and move motors - all at the same time and printer no longer shuts off from overcurrent protection!

    I've made a pull request against the latest development branch in case you consider this feature useful.

    Thank you for your answers, Repetier!

Sign In or Register to comment.