Anyone here understand tuning PID controllers?

Subjects that don't have their own home
User avatar
jack
Thermionic Monk Status
Posts: 5493
Joined: Wed Dec 29, 2010 8:58 pm
Location: ɐılɐɹʇsnɐ oʇ ƃuıʌoɯ ƃuıɹǝpısuoɔ
Contact:

#1 Anyone here understand tuning PID controllers?

Post by jack »

I'm experimenting with a PID-based controller for warming honey, but the controller is oscillating round the set point.

The controller I'm using is a MyPin TD4 - very common controller but not in this scenario.

I'm using 2 x 40W incandescent bulbs for my heating element and an old fridge as my insulated warming cabinet - the bulbs go in the bottom....

As expected, close to the set point, the heating goes on or off as appropriate but it oscillates a bit on about a one second cycle.

I've no experience in tuning PID controllers... anyone here have a clue?

Ta!

PXL_20230603_162929975_copy_1008x756.jpg
PXL_20230603_162929975_copy_1008x756.jpg (177.46 KiB) Viewed 4378 times
PXL_20230603_162919836_copy_1008x756.jpg
PXL_20230603_162919836_copy_1008x756.jpg (125.25 KiB) Viewed 4378 times
PXL_20230603_163617033_copy_1008x756.jpg
PXL_20230603_163617033_copy_1008x756.jpg (195.88 KiB) Viewed 4378 times
Vivitur ingenio, caetera mortis erunt
User avatar
Nick
Site Admin
Posts: 15707
Joined: Sun May 06, 2007 10:20 am
Location: West Yorkshire

#2 Re: Anyone here understand tuning PID controllers?

Post by Nick »

Turn I and D to 0. turn up P until it just starts to oscillate. back P down 25%. Then turn I up until it starts to overshoot. Turn down 20%. Turn up D just so you feel you are getting your moneys worth, but in my experience unless you have a fast system with a rapidly moving setpoint it won;t matter that much. Can work to allow increased I without as much overshoot so get closer to setpoint quicker.

There are several algorithms to derive optimum values based on the systems response to step functions, but IME unless its a system you have written yourself, or the tuning alg is on the device you are using, you will never know exactly how the units of the derived values map to the controller you are using.

Also depends on what matters to you, accurate tracking of a fast moving setpoint, quickest settling, lowest total energy use. IME the biggest problem (and its why we often ended up writing out own PID loops with limits and things like preventing the integral term from overloading the system) is when you have a asymmetric system, say 100% will warm up up 1C in a different time 0% will cool 1C.

As it happens the last time I wrote a PID loop was in the software that controlled that direct drive turntable I brought to Owston some time ago (its still ongoing) that had two PID loops, frequency one based on the speed of the platter against a internal reference and the second to lock the platter to the phase of the reference. The second came into effect when the first was within 2.5% of the target speed.

Control theory was beyond my limit when I was doing it, its way way past that point now when I occasionally look at the learning algorithms that are all the rage (it seems) now.
Whenever an honest man discovers that he's mistaken, he will either cease to be mistaken or he will cease to be honest.
User avatar
Nick
Site Admin
Posts: 15707
Joined: Sun May 06, 2007 10:20 am
Location: West Yorkshire

#3 Re: Anyone here understand tuning PID controllers?

Post by Nick »

Also, given that I assume you only have a on off output (I finally read the rest of your post), 50% output is going to look like what you describe. Maybe work using more I than P in those situations, but that will tend to make the output waver around the setpoint. I would think about using some metal clad resistors or similar as the heating element so the switching of the output doesn't kill the bulbs. Maybe a 200w 680R, The cost of the R would pay for itself soon in 40W bulbs.
Whenever an honest man discovers that he's mistaken, he will either cease to be mistaken or he will cease to be honest.
User avatar
jack
Thermionic Monk Status
Posts: 5493
Joined: Wed Dec 29, 2010 8:58 pm
Location: ɐılɐɹʇsnɐ oʇ ƃuıʌoɯ ƃuıɹǝpısuoɔ
Contact:

#4 Re: Anyone here understand tuning PID controllers?

Post by jack »

Good call on the Arcol resistors - 2 x HS100 330R is about 8 quid cheaper than 1 x HS200 680R as HS200s are a bit pricy...

I'll stick those on a decent heat sink ank that should do nicely.

The TD4 controller has a "learn" mode that auto-tunes... Not much documentation on it, but I'm using one of my nice Agilent/Keysight DMMs to datalog the temperature over the next 12 hours...
Vivitur ingenio, caetera mortis erunt
brig001
Old Hand
Posts: 550
Joined: Sat Nov 13, 2010 9:56 pm
Location: Back home in Preston now

#5 Re: Anyone here understand tuning PID controllers?

Post by brig001 »

One second sounds way faster than any parameters you would have for a heating controller
Can I suggest that maybe it is supposed to do that?
Even a mechanical central heating thermostat will pulse width modulate around setpoint, so maybe that is what it is doing

Brian
User avatar
jack
Thermionic Monk Status
Posts: 5493
Joined: Wed Dec 29, 2010 8:58 pm
Location: ɐılɐɹʇsnɐ oʇ ƃuıʌoɯ ƃuıɹǝpısuoɔ
Contact:

#6 Re: Anyone here understand tuning PID controllers?

Post by jack »

Yup it's a sort of PWM.

Thanks Nick for the tuning advice - Ive seen similar on the web, but with slightly different approaches, e.g. Back off 50% rather than 20-something. I'll give your approach a go tomorrow.

I've used a smart plug to monitor the power usage as it approaches set point.

You can see the average per-minute power consumption slowly dropping towards an equilibrium of maybe about 25W. This is a bit high as the door of the fridge is slightly leaky due to wires going in between the door and fridge as the magnetic seal isn't particularly flexible. I need to sort that out in some way. Currently there is the power to the lights, the type K food grade thermocouple plus an additional type K bead thermocouple for the DMM monitor.

I should have the big resistors on Monday.

Screenshot_20230603-220430.png
Screenshot_20230603-220430.png (149.9 KiB) Viewed 4327 times
Vivitur ingenio, caetera mortis erunt
User avatar
Nick
Site Admin
Posts: 15707
Joined: Sun May 06, 2007 10:20 am
Location: West Yorkshire

#7 Re: Anyone here understand tuning PID controllers?

Post by Nick »

The TD4 controller has a "learn" mode that auto-tunes
That will be using one of the algorithms I mentioned. I would let it try that and use the parameters it finds as a starting point. It will probably turn the output on and let it ramp up way past the setpoint, so make sure there is nothing in the space that will be worried by overtemp.
Whenever an honest man discovers that he's mistaken, he will either cease to be mistaken or he will cease to be honest.
User avatar
Nick
Site Admin
Posts: 15707
Joined: Sun May 06, 2007 10:20 am
Location: West Yorkshire

#8 Re: Anyone here understand tuning PID controllers?

Post by Nick »

The worst thing we had to control was pressure of argon in a 3m * 5m * 2m pressure vessel. This was on the plattens of a hydraulic press heated up to 600C (the platterns had three racks full of pid controllers and thyristor power controllers controlling the individual zones). The input valve was tiny, small amounts of input gas at room temperature would be injected and of course expand hugely. The pressure in the thing had to follow a pressure against time profile up to 42Bar. It was fun trying to do that without just letting the gas pass straight through the thing. The output valve had to be huge by comparison so we could vent the thing in the case of a e-stop before the hydraulic pressure was lost and couldn't keep the top on the vessel (it floated on a big o-ring), and the hydraulics was controlled as the pressure varied to keep the top in place to less than 1mm.

The job of that press was to blow the tail fin of the F16 out of Aluminium Lithium for General Dynamics.

It was fun commissioning that press. My lost youth :-)
Whenever an honest man discovers that he's mistaken, he will either cease to be mistaken or he will cease to be honest.
User avatar
jack
Thermionic Monk Status
Posts: 5493
Joined: Wed Dec 29, 2010 8:58 pm
Location: ɐılɐɹʇsnɐ oʇ ƃuıʌoɯ ƃuıɹǝpısuoɔ
Contact:

#9 Re: Anyone here understand tuning PID controllers?

Post by jack »

Ah! The wonders of the Internet rabbit holes.... Al/Li alloys... fascinating!

The PID controller hasn't destroyed the bulbs yet, but I feel like I might have my first epileptic fit if I keep watching it - very disturbing, the fridge having a glass door and all that... will probably put a heat spreader in there (baking tray) and have put a few more jars in for the test.

There's no ventilation for the SSR - they generate 1W - 1.5W per switched Amp, so I think that the big block SSR I'm using will be just fine in that plastic box. The box is an old project box - new back panel made from an FR4 offcut, SSR I had left over from another project (I would have preferred something smaller!), fused IEC 320 inlet & output and DPST mains switch from my "it'll be useful someday" pile of salvaged bits.

WhatsApp Image 2023-06-03 at 20.05.07.jpg
WhatsApp Image 2023-06-03 at 20.05.07.jpg (246.47 KiB) Viewed 4214 times
Last edited by jack on Sun Jun 04, 2023 3:44 pm, edited 2 times in total.
Vivitur ingenio, caetera mortis erunt
User avatar
Nick
Site Admin
Posts: 15707
Joined: Sun May 06, 2007 10:20 am
Location: West Yorkshire

#10 Re: Anyone here understand tuning PID controllers?

Post by Nick »

Looking at the manual online, looks like setting a longer "Control Cycle Time" might slow the flashing.
Whenever an honest man discovers that he's mistaken, he will either cease to be mistaken or he will cease to be honest.
User avatar
jack
Thermionic Monk Status
Posts: 5493
Joined: Wed Dec 29, 2010 8:58 pm
Location: ɐılɐɹʇsnɐ oʇ ƃuıʌoɯ ƃuıɹǝpısuoɔ
Contact:

#11 Re: Anyone here understand tuning PID controllers?

Post by jack »

Nick wrote: Sun Jun 04, 2023 10:37 am Looking at the manual online, looks like setting a longer "Control Cycle Time" might slow the flashing.
In my best Lady Bracknell voice: "A MANUAL!! I only have a Chinglish A4 sheet...
Vivitur ingenio, caetera mortis erunt
User avatar
Nick
Site Admin
Posts: 15707
Joined: Sun May 06, 2007 10:20 am
Location: West Yorkshire

#12 Re: Anyone here understand tuning PID controllers?

Post by Nick »

Whenever an honest man discovers that he's mistaken, he will either cease to be mistaken or he will cease to be honest.
User avatar
jack
Thermionic Monk Status
Posts: 5493
Joined: Wed Dec 29, 2010 8:58 pm
Location: ɐılɐɹʇsnɐ oʇ ƃuıʌoɯ ƃuıɹǝpısuoɔ
Contact:

#13 Re: Anyone here understand tuning PID controllers?

Post by jack »

Nick wrote: Sun Jun 04, 2023 10:52 am The internet found this:

https://koss.iyong.com/swift/v1/iyong_p ... 099343.pdf
Yep - that's the one I have - lots of things in it are far from clear. However, that said, last night I put it in auto mode and since then it's been pretty happy. In a slightly psychotic lighting sort of way...
Vivitur ingenio, caetera mortis erunt
User avatar
Nick
Site Admin
Posts: 15707
Joined: Sun May 06, 2007 10:20 am
Location: West Yorkshire

#14 Re: Anyone here understand tuning PID controllers?

Post by Nick »

Yep, it talks about setting the cycle time to 20 seconds with a relay output to protect the contacts, I think the same will apply to your bulb's (and state of mind).
Whenever an honest man discovers that he's mistaken, he will either cease to be mistaken or he will cease to be honest.
User avatar
jack
Thermionic Monk Status
Posts: 5493
Joined: Wed Dec 29, 2010 8:58 pm
Location: ɐılɐɹʇsnɐ oʇ ƃuıʌoɯ ƃuıɹǝpısuoɔ
Contact:

#15 Re: Anyone here understand tuning PID controllers?

Post by jack »

I've set Ctl to 30. It's slowed the cycle down a bit, but certainly not to 30 seconds - maybe 5 at best.

It was set to 1 (the default for SSR versions), so the change certainly has had some effect. Makes sense really.

Beginning to get to grips with PID. Like you, did a whole bunch of control theory at uni, but that was nearly 45 years ago and I've never used it since.

Readings differ slightly as TCs are in different places. Close enough to give me confidence in the setup.

PXL_20230604_110821134_copy_1008x756.jpg
PXL_20230604_110821134_copy_1008x756.jpg (124.68 KiB) Viewed 4179 times

Also managed to get the idling power usage down a bit.

Screenshot_20230604-121904.png
Screenshot_20230604-121904.png (194.81 KiB) Viewed 4178 times

For some idiotic reason i still have some of my uni texts....

PXL_20230604_115556420_copy_806x604.jpg
PXL_20230604_115556420_copy_806x604.jpg (178.94 KiB) Viewed 4169 times
Vivitur ingenio, caetera mortis erunt
Post Reply