• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

Linear PID max output scaling based on temperature

Scheduled Pinned Locked Moved
Tuning and tweaking
4
10
353
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    MikeS
    last edited by 23 Apr 2020, 13:10

    Hello everyone,

    i'm thinking about switching from my 2014 Rambo Board on a Rostock Max V2 to a Duet 2 Wifi. RIght now i'm using nearly stock Marlin Firmware 1.1.X but i've a minor edit that i need to know if is already present in RRF.

    My printer is born with 12V power supply but i've switched to 24V (25V actually) for getting the heated bed to reach stable 110/120°C in about 10 minutes. The problem i've faced is that my onyx heated bed was not correctly designed and its resistency is lower than it should be to work at reasonable current at 24VDC. If i run it directly connected to the PS at 25VDC i get around 22Amps but, as you all know, resistance is greater at higher temperature, ending with a current of 11/12 Amps at 100°C. What i did in marlin is an horrible hack that allows me to run the heated bed at 25VDC limiting the max PID output based on the current bed temperature. I attach the edit here for better comprension:

    int min_temp = 20;
    int max_temp = 80;
    int min_output = 190;
    int max_output = 255; 
    if (current_temperature_bed >= min_temp && current_temperature_bed <=max_temp) 
      SCALED_MAX_BED_POWER = map(current_temperature_bed,min_temp,max_temp,min_output,max_output);
    else if (current_temperature_bed < min_temp)
      SCALED_MAX_BED_POWER = min_output;
    else if (current_temperature_bed > max_temp)
      SCALED_MAX_BED_POWER = max_output;
    

    SCALED_MAX_BED_POWER will replace MAX_BED_POWER variable on the PID calculations.
    Don't blame me for the rough code, i'm not a professional developer!

    With this "trick" i can get nearly costant 14Amps on my heated bed at every temperature (15A max power from my board).
    Duet2 can hold up to 18A that is not enough for a cold start for my setup. Within RRF does already exist this type of feature or is something i can easily add my own like i did in Marlin?

    Thanks all

    1 Reply Last reply Reply Quote 0
    • undefined
      MikeS
      last edited by 23 Apr 2020, 13:15

      Also noticed that a " Firmware developers " section exists. If a mod could move that topic there would be nice! Sorry!

      1 Reply Last reply Reply Quote 0
      • undefined
        dc42 administrators
        last edited by dc42 23 Apr 2020, 14:07

        RRF doesn't have that facility built-in. However, I think you could implement it in the daemon.g file supported by RepRapFirmware 3.01, by writing a simple loop that watches the bed temperature and adjusts the maximum PWM accordingly.

        Duet WiFi hardware designer and firmware engineer
        Please do not ask me for Duet support via PM or email, use the forum
        http://www.escher3d.com, https://miscsolutions.wordpress.com

        1 Reply Last reply Reply Quote 0
        • undefined
          MikeS
          last edited by 23 Apr 2020, 14:16

          So basically i can write code that runs on a different thread that updates the value right? This would be great and allow me to not replace my old bad made bed!

          1 Reply Last reply Reply Quote 0
          • undefined
            MikeS
            last edited by 14 Sept 2020, 20:36

            @dc42 Hello David, finally i got my Duet2 Wifi connected to my printer (only missing daughter board for E3D PT100). I've created the script in daemon.g and it's working (still missing variable declaration and set btw, any ETA on this?). My problem actually is that UI is reporting a warning at every script execution so basically it's flooding my UI with this message: "Warning: Heater 0 appears to be over-powered. If left on at full power, its temperature is predicted to reach 365C". I undertand that this is caused by BED with too low resistance and not engineered for 24VDC but i know what i'm risking and want to disable the warning. Is it possible?

            Also i leave my script for anyone that maybe will need it:

            ;Actual code without variables
            
            if sensors.analog[0].lastReading >= 20.0 && sensors.analog[0].lastReading <= 80.0
            	M307 H0 S{(sensors.analog[0].lastReading  - 20.0) * (1 - 0.745) / (80.0- 20.0) + 0.745}
            elif sensors.analog[0].lastReading < 20.0
            	M307 H0 S0.745
            elif sensors.analog[0].lastReading > 80.0
            	M307 H0 S1
            
            ;Future code when variables will be implemented
            
            var minTemp = 20.0
            var maxTemp = 80.0
            var minOutput = 0.745
            var maxOutput = 1.0
            var bedTemperature = sensors.analog[0].lastReading
            
            if bedTemperature >= minTemp && bedTemperature <= maxTemp
            	var pidMaxPWM = (bedTemperature  - minTemp ) * (maxOutput - minOutput ) / (maxTemp - minTemp ) + minOutput
            elif bedTemperature < minTemp 
            	var pidMaxPWM = minOutput 
            elif bedTemperature > maxTemp 
            	var pidMaxPWM = maxOutput
            
            M307 H0 S{pidMaxPWM}
            ;echo "PID max PWM set to {pidMaxPWM}
            

            Thank you for the great work!

            1 Reply Last reply Reply Quote 0
            • undefined
              Phaedrux Moderator
              last edited by Phaedrux 14 Sept 2020, 21:00

              Nothing about any of this is recommended. Just replace the bed.

              However, if you insist, you may be able to have the warnings suppressed by using a M143 for the bed that sets the max temp closer to the temp given by the warning message.

              Please use a thermal cutout fuse on the bed power in case there is a fault situation leading to runaway heating.

              Z-Bot CoreXY Build | Thingiverse Profile

              undefined 1 Reply Last reply 14 Sept 2020, 21:23 Reply Quote 0
              • undefined
                MikeS @Phaedrux
                last edited by 14 Sept 2020, 21:23

                @Phaedrux i've already installed an 140°C fuse in series with bed power supply (the one that you find on irons) so not worried about my home get on fire 😊 So if i understand i have also to set the max temperature reachable by the bed closer to the one of the warning correct?

                undefined 1 Reply Last reply 14 Sept 2020, 21:28 Reply Quote 0
                • undefined
                  Phaedrux Moderator @MikeS
                  last edited by 14 Sept 2020, 21:28

                  @MikeS Correct.

                  Well just in case anyone else reads this in the future. It's not recommended and ensure you have some thermal protection.

                  The warning is there to inform you of the risks. It's up to you how you deal with them.

                  https://duet3d.dozuki.com/Wiki/FAQ#Section_M307_Heater_1_appears_to_be_over_powered_If_left_on_at_full_power_its_temperature_is_predicted_to_reach_521C

                  Z-Bot CoreXY Build | Thingiverse Profile

                  1 Reply Last reply Reply Quote 0
                  • undefined
                    MikeS
                    last edited by 14 Sept 2020, 23:02

                    @Phaedrux I confirm that now it isnot throwing the warning anymore. Thank you for your assistance...i'll change the bed as soon as i can find one that fits well with my Rostock Max V2 and it is not made in USA cause of import fees and low quality (already bought 3 of them of various revision and always had something wrong 😢 )

                    1 Reply Last reply Reply Quote 0
                    • undefined
                      oliof
                      last edited by 16 Sept 2020, 12:47

                      I have a 250mm 240VAC heated delta bed (6mm aluminum tool plate with a permanent print surface) I never installed on a delta I have scrapped since. It should about fit the Rostock Max V2. Send me a private message to sort out of we can strike a deal if you're interested in getting it shipped from Germany.

                      <>RatRig V-Minion Fly Super5Pro RRF<> V-Core 3.1 IDEX k*****r <> RatRig V-Minion SKR 2 Marlin<>

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Unless otherwise noted, all forum content is licensed under CC-BY-SA