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.

[PIC] PID control using PIC16f877A

Status
Not open for further replies.

missphysics1988

Newbie level 3
Joined
Aug 17, 2016
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
35
Hello, plx help me!
I have to develop a PID control setup to control the temperature using PIC16f877A controller. The temperature is rise by the AC controlled heater so for PID control I have to control the AC power supplied to the heater. Kindly provide me the mikro c code for PID controller using pic16f877a. Also if possible help in determining the PID gains of a system. Thanks
 


I want to do it using PIC16f877a as i have already developed my hardware using this PIC16. Kindly help me in designing PID system using PIC16f877a.
 

The basic PID C code isn't specific to PIC16, only some details about chip initialization and ADC control. You can start with the C code posted by Easyrider83 or many other web sources.

Also if possible help in determining the PID gains of a system.
Do you mean how to analyze the control system response or how to set PID parameters? For the latter, manual tuning with Ziegler-Nichols method is still popular.
 

Yes i want to know that how could i measure the gains like Kp, Kd and Ki of my system. Presently my system is working on the ON/OFF strategy. I enter the setpoint and when the set point is reached the AC heater supply is cut off using relay or triac and when the temperature gets below the setpoint the heater supply is restored. So plz tell me that how can i determine the PID gains(kp,kd and ki) for my system. Thanks for the time and help.
 

I want to do it using PIC16f877a as i have already developed my hardware using this PIC16. Kindly help me in designing PID system using PIC16f877a.

PID is a algorithm not a part of MCU registers program. You can use pre-written code every where C language use.

See Easyrider83 #3 post.
 

KP, KI, KD are controller parameters, not measureable parameters of the control process. A linear control process can be described by a gain and poles (= low pass time constants) plus possibly true delay (dead time).

The control process (plant) characteristic can be represented in frequency domain as bode or nyquist diagram. There are simple graphical design methods to fit a controller to a given bode diagram.

In time domain, the control process behavior is often displayed as step response. It can be easily obtained e.g. for a heater. Parameters gain, dead time and rise time can be derived from the step response and optimal PID parameters estimated. Find details in control theory text books.
 

pic18f452 and pic16f877a should be pin to pin compatible
more space, more speed, and new chip !
broken link removed
broken link removed
 
Last edited by a moderator:

It's O.K. to suggest upgrades to more recent processors. But at the present project state, there's nothing against setting up a basic PID controller on the PIC16 platform. Switching to a more powerful processor could be necessary if your code doesn't fit the PIC16 program memory.

I expect that a basic PID does fit PIC16, even when using float arithmetic.
 

My problem is to know that depending on the PID final value obtained how i have to divide AC cycle that is at what instant should i fire the triac?
 

Hi,

you need to find out a mathematical relationship between phase angle and heating power...
You could do this with tests / measurement or by a known mathematical / physical relationship.

We don´t know what your input to the PID control loop is:
* is it voltage
* is it current
* is it apparent power
* is it true power
* is it anything else..

And it seems your PID output is the phase angle for phase control.

But i bet it is far away from being linear.

The unlinearities make a control loop difficult, because it´s hard to make an unlinear control loop stable.
One solution is to make it slow. Not with additional delays, but with low feedback. Especially at the I and P part. (here I don´t think you need the D part at all).

The other solution is to compensate the unlinearities. This needs to analyze your whole regulation system loop. Form each step into mathematical formulas and build the inverse function of the formulas.
Really a lot of mathematics. With sine, square, integrals, logarithm, differential equations, and square root.... (I think in this order).

****

I´ve done this before for a very precise and fast phase control system. A lot of work. Weeks of physics and mathematics.
A lot of software for the linearisation.
But in the end it works incredibly good. Fast and precise. (Btw: controlled by an ATMeaga128).
But the result was a constant loop gain of the whole system. Independent of setpoint, phase control angle and load resistance.
It is mathematically predictable stable for every situation (i can think of).

****

In your case it seems you have an about predictable laod resistance. This makes - at least one part - easy.

Instead of mathematics you could make some tests and find out:
* heating power
* rise in temperature
for phase angle from 0 to 180° in steps of 5° (the smaller the steps the more precise)

Analyze the curve. There are steep parts and flat (almost horizontal) parts.
Your system needs to be stable from the flat parts to the steep parts. (Either by beeing slow and unprecise or by continously adjusting the P I D parameters)
Decide how you want to manage this.

Klaus
 
My problem is to know that depending on the PID final value obtained how i have to divide AC cycle that is at what instant should i fire the triac?
Heater control is expected to use full packet switching rather than phase angle control, review power quality standard IEC 1000-3-2. It has the advantage of achieving a linear control characteristic without extra effort.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top