Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to do a PID control using a relay?

Status
Not open for further replies.

wakaka

Full Member level 4
Full Member level 4
Joined
Dec 7, 2005
Messages
237
Helped
10
Reputation
20
Reaction score
6
Trophy points
1,298
Activity points
2,931
Hi guys, i would to build a small temperature controller project using microcontroller (PIC), a temperature sensor(lm35) and a on/off relay.

But i dun really know how to do a PID control using a relay as it cant really be applied with the PID equations.
Can anyone show me the methods? or some explainations on how to adapt the equations to on and off the relay to stabilize at the setpoint temperature.

If possible, i need autotune for this method as well(using relay), thankx.....
 

pid relay

Your relay is a binary device, i.e. On/Off. PID control is analogue.
PID control will not work for relay output, no matter what formula you use. I suggest getting yourself some comparator logic, (Op-amp etc) and use threshold levels (e.g. 10% to switch On the relay and 90% to switch Off).

If you really want to use PID control, you will have to use something like thyristor controlled heater bank or something similar. Again, something a relay simply cannot do.
 
pid relays

The easiest way is to run two separate periodic threads:

PID loop
This thread acquires temperature from the LM35 and then runs the pid computation. The result of the pid computation represents the amount of power you must deliver to the heater. For example, the pid might output a value in the range 0 to 100, representing 0 to 100 percent power applied to the heater. Note that this thread is not concerned with whether the heater power is being controlled with with a relay or some other, more analog form of power control.

Power controller
This thread controls the heater power. This thread runs at a frequency that is dictated by the type of control (linear vs. digital). If you were to use an analog power controller (e.g., power transistor operating in its linear region) then this thread could run at the same rate as the first thread (in fact, it could be combined into a single thread). If you are using a solid state relay then this thread should run at some multiple of the line frequency. If you are using a mechanical relay or you don't need transitions to occur at line power zero crossings then this thread's execution frequency need not be a multiple of line frequency, although it must run at a sufficiently high frequency to provide the required duty cycle resolution.
 

pid control with on/off device

Hi lambtron, can u be more specific on the power controller part??
Looks like it is possible for a on/off relay output. Wat i plan to use is a normal mechanical relay, which cant really perform high freq switching.
Plz advice, thanx
 
ebay.fr triac pid/triac s

There are various ways to do this, but here's one simple way:

First decide upon the maximum rate at which you can toggle your mechanical relay. For example, you might choose a max rate of one toggle per second. This is the rate at which the power controller thread will run (once per second).

Next choose a time interval over which you will measure the relay's average duty cycle. For example, you might choose an averaging interval of 100 seconds. Note that you would like this to be a large multiple of the max toggle rate for best accuracy. In this case, the power controller thread must "remember" the relay states that were in effect for the last 100 seconds.

Each time the power controller thread runs, it averages the previous 100 relay states (which must always be "remembered") to determine the average amount of power applied during the last 100 seconds. So for example, if the relay was turned on for 30 of the last 100 seconds then the average applied power is 30%. During each pass through the power controller thread, the average applied power is compared to the target power demanded by the PID loop thread; if applied power is less than demanded power, the relay is switched on for the next second, and if applied is greater than demanded then the relay is switched off for the next second.

Note that the values used in the above example are good for illustrating this algorithm, but you may not want to use these values in your application.
 
pid solid state relay not switching

This is a good tutorial on PID design
www.parallax.com/dl/docs/prod/sic/Web-PC-v1.0.pdf

Better yet go to ebay and search for PID temperature controller and buy one for $35
I've bought several off ebay, their RTD or thermocouple controlled and work great
 

pid control using relay output

wakaka, before going for relay - check relay parameters for max number of operation the relay can perform before malfunction. Yet this parameter will be dependent on working mode which could differ for conditions specified in data sheet.
 

pid control of heater bank

its just a normal SPDT relay. I'm doing this is just for fun actually, and wan to learn for PID in relay......
 

pid tuning relay

PID can work with SSR(solid state relay),triac or SCR devices not mechanical relay since PID outputs variable on-off (phase control). Unless you are working with DC load.
 

pid tuning

Meaning i cant really do this using a mechanical relay rite??
Then i think i'll just switch to a Mosfet or triac using PWM control then....
 

use normal relay pid

usage of relay dependent on controlled environment characteristics (inertials) and shortest relay switching time . Relay can be used in PID for slow processes. You just have to convert pid output to relay one bit output. The simplest is just aka pwm regulation.
 

aka controls france

see att
 

heater power control using pid

wakaka said:
Meaning i cant really do this using a mechanical relay rite?
Wrong! You can use a mechanical relay, even if it switches an ac load. For ac loads, however, you should use a snubber to help protect the relay and reduce switching transients. And if you are powering an inductive dc load, you should include a reverse-biased diode in parallel across the load, and possibly a snubber as well.
 

relay PID tuning

can any one give me idea to convert pid output to relay one bit output , i m using avr controller and controlling single heater with relay . i m using pencil type heater and j type sensor. can any one help me?
 

relay PID tuning

Hi,
For me its not more as a relay driver: means an NPN transistor; Base driven trough a serial resistor(i.e. 1KOhm or more, depending on your driving level), Emitter is on GND & your realy is between Collektor and Positiv Supply(i.e. 5V or 12V)...
DONT FORGET a Diode on the realy=cathoden on Plus supply & Anode on the Collector, but tighst at the relay coil!
K.

Added after 4 minutes:

Remember pls; a Relay has max. so 1 millions(with power maybe at 100`000!) switches, reeds up to 10 mills ...after that is life cycle end arrived...
 

relay PID tuning

hi
thanks for he reply
i m sorry. i forgate to tell u that i need c code to convert analoge pid output to one bit relay output
 

relay PID tuning

To use a relay for a proportional output you must use time. So, you pick a timebase, which could be several minutes and adjust the on/off time to adjust the power output.

For example if to pick 60 seconds as you timebase, for half power you would turn on for 30 seconds, off for 30. For 10% power you would be on for 6 seconds, off for 54. You need to pick a time which keeps the number of relay operations sensible. My heating controller works this way and the time period is 10 minutes.

Keith
 

relay PID tuning

Yea,
this is fine, but a relay as (el.)mechanical switcher (todays) isnot a wise selection-sorry..
OK, as "opto relay" i.e. from Crydom; its welcome :)...
K.
 

relay PID tuning

A relay is fine if you calculate the number of operations and ensure it will last. A typical relay will be 100k to 10M operations. At 6 cycles per hour a good relay would last for many years. Honeywell PID heating controllers for central heating use a relay.

Keith
 

relay PID tuning

Hi,
I wrote the same in these topic at 28.febr:)...
Anyway, its indiscutable no more actuell, a calculated life cycle is enormous longer by not mechanical switches...
You should know; I do design in in my electronics relais too, but not for a regulator stage.
K.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top