Professional Documents
Culture Documents
Author Message
HI
I am looking for a simple pid routine to control a small heater using the pwm output of the pic.
Any hints would be appreciated.
___________________________
This message was ported from CCS's old forum
Original Post ID: 2637
Eric Minbiole Re: Anyone written a simple PID routine for a PIC???
Guest Posted: Sun Feb 17, 2002 7:04 am
:=I am looking for a simple pid routine to control a small heater using the pwm output of the
pic. Any hints would be appreciated.
I recently finished a project that leviated a metal ball using an electromagnet. It used a PIC to
control a PID loop which kept the ball floating stabily.
Here's the code for my PID loop. I'm sure it's not the best PID code out there, but it should give
you a starting point to work from. The only tricky part of the code is in calculating the
differential term. Rather than taking the difference of two adjacent samples, I averaged 4 old
samples, and 4 new samples, and took the difference between the averages. This made the loop
more immune to noisy samples.
Hope it helps!
// terms
float Tp; // proportional term
float Ti; // integral term
float Td; // differential term
1 от 6 01.3.2007 г. 09:14
CCS :: View topic - Anyone written a simple PID routine for a P... http://ccsinfo.com/forum/viewtopic.php?t=9048&highlight=int&...
int8 temp_pos;
signed long prev_ave;
signed long cur_ave;
// **** set the loop constants (Kp, Ki, Kd) to something useful
2 от 6 01.3.2007 г. 09:14
CCS :: View topic - Anyone written a simple PID routine for a P... http://ccsinfo.com/forum/viewtopic.php?t=9048&highlight=int&...
power = 255;
else
power = desired_power;
set_output_power(power); // this could be pwm duty, etc
Joined: 08 Sep 2003 This is turned out to be a really easy way to impliment a PID control. It works good if it's tuned
Posts: 1104
Location: Houston right. I use this to heat a heat exchanger with a variable heat load. My pulse width is 20 seconds
and sampel rate is 5 times per pulse. Any of the number can be changed.
:=HI
:=I am looking for a simple pid routine to control a small heater using the pwm output of the
pic. Any hints would be appreciated.
___________________________
This message was ported from CCS's old forum
Original Post ID: 2658
future wrote:
Joined: 08 Sep 2003
Posts: 1104 Are PWMp, PWMi and PWMd values from 0 to 1?
Location: Houston
I want to use PID to control a stepper motor, so it has to know how many steps and
direction to apply to correct the error.
I can't remember but looking at the formula it looks like between -1 and 1.
thx guys...been looking for this too...I will study the code...
Joined: 20 Dec 2005
Posts: 110
3 от 6 01.3.2007 г. 09:14
CCS :: View topic - Anyone written a simple PID routine for a P... http://ccsinfo.com/forum/viewtopic.php?t=9048&highlight=int&...
I recently finished a project that leviated a metal ball using an electromagnet. It used a PIC
to control a PID loop which kept the ball floating stabily.
Here's the code for my PID loop. I'm sure it's not the best PID code out there, but it should
give you a starting point to work from. The only tricky part of the code is in calculating the
differential term. Rather than taking the difference of two adjacent samples, I averaged 4
old samples, and 4 new samples, and took the difference between the averages. This made
the loop more immune to noisy samples.
Hope it helps!
// terms
float Tp; // proportional term
float Ti; // integral term
float Td; // differential term
// **** set the loop constants (Kp, Ki, Kd) to something useful
4 от 6 01.3.2007 г. 09:14
CCS :: View topic - Anyone written a simple PID routine for a P... http://ccsinfo.com/forum/viewtopic.php?t=9048&highlight=int&...
hi there...
thx
sonic
@Eric Minbiole
Joined: 06 Feb 2006
Posts: 4 can you put the principle how to set the Kp, Ki, Kd ???
andibaciu wrote:
Joined: 24 Jun 2004
Posts: 557 @Eric Minbiole
Location: Edmonton AB can you put the principle how to set the Kp, Ki, Kd ???
Canada
any help is good ....
5 от 6 01.3.2007 г. 09:14
CCS :: View topic - Anyone written a simple PID routine for a P... http://ccsinfo.com/forum/viewtopic.php?t=9048&highlight=int&...
Page 1 of 1
6 от 6 01.3.2007 г. 09:14