Ss Brewing Technologies Giveaway!

Home Brew Forums > Home Brewing Beer > Equipment/Sanitation > Temperature Controller
Reply
 
LinkBack Thread Tools
Old 11-30-2008, 10:26 PM   #1
Jared311
Feedback Score: 0 reviews
Recipes 
 
Join Date: Feb 2008
Location: Columbia, MD
Posts: 512
Liked 1 Times on 1 Posts

Default Temperature Controller

Sorry for the long post, you might want to top off your beer again before sitting down to this one. I have a habit of confusing others with my poor wording.

So I have designed my first revision of a temperature controller board. It connects to 8 mini temperature sensor boards I designed. Each one sits in a custom made thermal well that can be threaded into a 1/2" coupling that has been welded into the keg wall. This is going to allow me to monitor the mash temperature and see any temperature differentials. Yeah, I know... its overkill, but I actually enjoy building custom hardware. My board communicates with my laptop via USB and I have already wrote software that takes in the temperatures and determines what duty cycle the heating element should be running at. Then the computer talks back to the temperature controller and tells it what duty cycle it should generate. This is where I am stuck. I am not sure yet what frequency I want to pulse width modulate the 220VAC relay which will apply power to my heating element. I was thinking of starting around 1Hz and seeing how well that works. However I am worried that I will burn out my relays pretty fast if I am firing them twice a second. Anyone know what frequency their PID controllers work at?

__________________

Sláinte,
Jared311

Jared311 is offline
 
Reply With Quote Quick reply to this message
Old 11-30-2008, 10:26 PM   #2
Jared311
Feedback Score: 0 reviews
Recipes 
 
Join Date: Feb 2008
Location: Columbia, MD
Posts: 512
Liked 1 Times on 1 Posts

Default

Opps, can a mod please move this into the DIY section? Thanks!

__________________

Sláinte,
Jared311

Jared311 is offline
 
Reply With Quote Quick reply to this message
Old 12-01-2008, 12:21 AM   #3
LooyvilleLarry
Feedback Score: 0 reviews
Recipes 
 
Join Date: Aug 2008
Location: Louisville,KY
Posts: 988
Liked 4 Times on 4 Posts
Likes Given: 2

Default

I use an Arduino board with a PID algorithm. The PID algorithm uses a 10 sec calculation window (right now-may go longer).

Every second, I do some calculation and find out if the power should be on or off. This next step is important - If the state doesn't change, don't change the output.

I would not try and PWM the SSR's. I think you would find the life pretty short. Instead, think duty cycle.

__________________
LooyvilleLarry is offline
 
Reply With Quote Quick reply to this message
Old 12-01-2008, 12:44 AM   #4
slimer
Feedback Score: 0 reviews
 
slimer's Avatar
Recipes 
 
Join Date: Oct 2007
Location: Westmont, IL
Posts: 723
Default

Quote:
Originally Posted by lrr81765 View Post
I use an Arduino board with a PID algorithm. The PID algorithm uses a 10 sec calculation window (right now-may go longer).

Every second, I do some calculation and find out if the power should be on or off. This next step is important - If the state doesn't change, don't change the output.

I would not try and PWM the SSR's. I think you would find the life pretty short. Instead, think duty cycle.
Did your brew day work well with the program? Still interested in finding out more about your RIMS.
__________________
slimer is offline
 
Reply With Quote Quick reply to this message
Old 12-01-2008, 02:45 AM   #5
Jared311
Feedback Score: 0 reviews
Recipes 
 
Join Date: Feb 2008
Location: Columbia, MD
Posts: 512
Liked 1 Times on 1 Posts

Default

Quote:
Originally Posted by lrr81765 View Post
Every second, I do some calculation and find out if the power should be on or off. This next step is important - If the state doesn't change, don't change the output.
So what kind of calculations are you doing?
__________________

Sláinte,
Jared311

Jared311 is offline
 
Reply With Quote Quick reply to this message
Old 12-01-2008, 11:56 PM   #6
LooyvilleLarry
Feedback Score: 0 reviews
Recipes 
 
Join Date: Aug 2008
Location: Louisville,KY
Posts: 988
Liked 4 Times on 4 Posts
Likes Given: 2

Default

pid.Compute(); ///This sets the hltPower to a value between 0 (off) and 10000 (On for 10 secs)

//turn the output pin on/off based on pid output millis() is the #ms it has been running.

if(millis()-windowStartTime>PID_INTERVAL) windowStartTime+=PID_INTERVAL;

if( (hltPower > millis()-windowStartTime ) || (hltPower >= PID_INTERVAL) )
{
if ( hltHeatLastState != HIGH)
{
digitalWrite(hltHeatPin,HIGH);
lcd.print("ON",1,13);
hltHeatLastState=HIGH;

}
}
else
{
if ( hltHeatLastState != LOW )
{
hltHeatLastState = LOW;
digitalWrite(hltHeatPin,LOW);
lcd.print("OFF",1,13);
}
}

__________________
LooyvilleLarry is offline
 
Reply With Quote Quick reply to this message
Old 12-02-2008, 03:13 AM   #7
kladue
Senior Member
HBT_LIFETIMESUPPORTER.png
Feedback Score: 0 reviews
Recipes 
 
Join Date: Dec 2006
Location: Turner, Oregon, Oregon most of the time now
Posts: 2,308
Liked 47 Times on 43 Posts

Default

That looks like a simple proportional control routine, where is the integral and derivative functions. Here is part of the PID program in the phase 2 control program for an example

public int CalculateGain (double position) {
System.out.println("pos: " + position + "setpoint: " + Setpoint);
double error = Setpoint - position;
System.out.println("error: " + error);
ErrorSum += error ;
System.out.println(ErrorSum);
if (ErrorSum >(IntegralLimit / KIntegral)) {
ErrorSum = (IntegralLimit / KIntegral);
}
System.out.println("KP: " + KProportional + ", error: " + error);
ProportionalGain = KProportional * error;
IntegralGain = KIntegral * ErrorSum;
if (java.lang.Math.abs(IntegralGain) > IntegralLimit) {
if(IntegralGain > IntegralLimit)
IntegralGain = IntegralLimit;
else
IntegralGain = -IntegralLimit;
}
DifferentialGain = KDifferential * ( error - PrevError );
PrevError = error;
Gain = ProportionalGain + IntegralGain + DifferentialGain;
System.out.println("P: " + ProportionalGain + ", I: " + IntegralGain + ", D: " + DifferentialGain);
return (int)Gain;
}

__________________
kladue is offline
 
Reply With Quote Quick reply to this message
Old 12-02-2008, 12:35 PM   #8
LooyvilleLarry
Feedback Score: 0 reviews
Recipes 
 
Join Date: Aug 2008
Location: Louisville,KY
Posts: 988
Liked 4 Times on 4 Posts
Likes Given: 2

Default

Yes, kladue, that is right. We are probably using nearly identical code for that portion. The return specifies the number of seconds out of the period to be on, my timer math just figures out how whether to turn it on or off.

For the uninformed, a PID circuit works like a cruise control in your car, providing a proportionate amount of power to maintain a set speed. When it falls off by 2 mph, add 3% power instead of full throttle.

kladue- What are you using for t-couples? If using the LM34, did you use a fixed value like analogRead(hltTempPin) * .488, or did you find that each one had some variance in temperature readings?

__________________
LooyvilleLarry is offline
 
Reply With Quote Quick reply to this message
Old 12-02-2008, 01:29 PM   #9
kladue
Senior Member
HBT_LIFETIMESUPPORTER.png
Feedback Score: 0 reviews
Recipes 
 
Join Date: Dec 2006
Location: Turner, Oregon, Oregon most of the time now
Posts: 2,308
Liked 47 Times on 43 Posts

Default

I use opto22 hardware for thermocouple and PT100 RTD interface, then apply a scale and offset value to the result to correct any calibration problems. The scale and offset values are reached through a hardware settings GUI in the control application for on the fly calibration. The PID control loops each have a calibration GUI for initial tuneup and values are retained in the SQL database for later use in manual/auto control modes.

__________________
kladue is offline
 
Reply With Quote Quick reply to this message
Old 12-02-2008, 02:40 PM   #10
Jared311
Feedback Score: 0 reviews
Recipes 
 
Join Date: Feb 2008
Location: Columbia, MD
Posts: 512
Liked 1 Times on 1 Posts

Default

Thanks lrr81765 and kladue for posting your algorithms. I am in the process of researching PID algorithms to get a better feel for them and then I am going to read through your codes. I will keep you guys updated as I get around to it and let you know if I made any significant changes.

__________________

Sláinte,
Jared311

Jared311 is offline
 
Reply With Quote Quick reply to this message
Reply



Quick Reply
Message:
Options
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Johnson Analog Temperature Controller Temperature Profile Coastarine Equipment/Sanitation 4 10-11-2010 03:58 PM
temperature controller chemman14 Equipment/Sanitation 10 09-05-2009 05:15 PM
For Sale - WTB: Temperature Controller gruversm For Sale 10 08-25-2009 04:27 AM
what temperature controller should I use? ohad DIY Projects 3 08-06-2009 02:10 PM
temperature controller trainfever Bottling/Kegging 6 09-21-2008 05:01 PM