Brewery Programming

The forum for discussing all kinds of brewing paraphernalia.
Fil
Telling imaginary friend stories
Posts: 5229
Joined: Sun Oct 16, 2011 1:49 pm
Location: Cowley, Oxford

Re: Brewery Programming

Post by Fil » Wed May 30, 2012 1:38 pm

Oh dear ive started reading about CT sensors and arduino now, i can guess where this will go..

have you tried the auto tune lib to derive your variable set steve? tho you might need to set the sample time back for that.
ist update for months n months..
Fermnting: not a lot..
Conditioning: nowt
Maturing: Challenger smash, and a kit lager
Drinking: dry one minikeg left in the store
Coming Soon Lots planned for the near future nowt for the immediate :(

Matho

Re: Brewery Programming

Post by Matho » Fri Jun 01, 2012 12:36 pm

Fil wrote:
have you tried the auto tune lib to derive your variable set steve? tho you might need to set the sample time back for that.
Fil, no I haven't, I just think its weird that if I term is there to remove a consistent error why is it let to ramp to 100% of the output and not clamped to a percentage of the output. This PID algorithm might be good for drives that can drive both ways but for heating water we can heat but cooling is going to be slower so if we overshoot the temp takes a longer time to come down. Anyway I have changed the code a bit to clean up the change over from ON to PID

Code: Select all

void PID_HEAT (void){
  if((Setpoint - Input)>5)
  {
    digitalWrite(Heat,HIGH);
    if ((Setpoint - Input)<6)
   {
    myPID.Compute();
    }
   }
  else{
  myPID.Compute();
  unsigned long now = millis();
  if(now - windowStartTime>WindowSize)
  {                                     //time to shift the Relay Window
    windowStartTime += WindowSize;
  }
  if((Output*(WindowSize/100)) > now - windowStartTime) digitalWrite(Heat,HIGH);
  else digitalWrite(Heat,LOW);
  }
}
cheers steve

Matho

Re: Brewery Programming

Post by Matho » Wed Jun 06, 2012 9:03 am

I don't think this needs a new thread so Ill post it here

http://www.mediafire.com/?v9tswo53m22gypd

this is a ZIP of the manuals,eagle files and programs to make a brauduino controller.

cheers steve

User avatar
barneey
Telling imaginary friend stories
Posts: 5423
Joined: Mon Jul 25, 2011 10:42 pm
Location: East Kent

Re: Brewery Programming

Post by barneey » Wed Jun 06, 2012 11:38 am

Steve,

Nice work on the files mate.

Cheers
Hair of the dog, bacon, butty.
Hops, cider pips & hello.

Name the Movie + song :)

Matho

Re: Brewery Programming

Post by Matho » Thu Jun 07, 2012 9:15 am

thanks barneey, hope they make sense
cheers steve

Matho

Re: Brewery Programming

Post by Matho » Tue Jun 19, 2012 8:11 am

hey guys, I have been playing with the PID library for the Arduino and have added a function to clamp ITerm, everything else is the same as the PID_V1 library,

http://www.mediafire.com/?oo9e5b0t7g1l08w

I have loaded it up to my unit and it seems to work the line of code to clamp the ITerm is,

Code: Select all

myPID.SetITermClamp(0,20);
put it in where you load up your pid settings , what it does is stops the ITerm from ramping up to 100% of the output and causing overshoot. I would suggest to set it to the maximum % of the output needed to keep the temperature constant at the highest mash temp needed, I have my output max set at 100 and at 75dec I need about 19% power to hold the temp constant.

cheers steve

claudiobr74

Re: Brewery Programming

Post by claudiobr74 » Tue Jun 26, 2012 12:01 am

Hi Steve,

As an Arduino begginer, I did not understand how you did to change the program to insert the new code (Iterm). Can you help me?

Cheers Claudio

Matho

Re: Brewery Programming

Post by Matho » Tue Jun 26, 2012 8:55 am

hey Claudio,

First thing is you have to put the library into the arduino library folder, then where it says

#include <PID_V1.h>
at the beginning of the code, replace it with this

#include <PID_v1_ITerm_Clamp.h>

next in the "load_PID_settings" function add

myPID.SetITermClamp(0,20);

I ran the library the other day and while it worked OK I wasn't really happy with it, I have been looking at the PID library that the brewtroller uses and it looks a lot better at stopping I windup, I have just changed the library to include the I term windup control so if you wait a bit then I should be able to give it a run and see how it works.

cheers steve

claudiobr74

Re: Brewery Programming

Post by claudiobr74 » Tue Jun 26, 2012 11:43 am

Hi Steve,

I tought that I would have to include the library not change (I'm stupid). I'll be waiting your reply about the test.

Cheers Claudio

claudiobr74

Re: Brewery Programming

Post by claudiobr74 » Tue Jul 03, 2012 12:55 pm

[quote="Matho"]hey Claudio,

First thing is you have to put the library into the arduino library folder, then where it says

#include <PID_V1.h>
at the beginning of the code, replace it with this

#include <PID_v1_ITerm_Clamp.h>

next in the "load_PID_settings" function add

myPID.SetITermClamp(0,20);

I ran the library the other day and while it worked OK I wasn't really happy with it, I have been looking at the PID library that the brewtroller uses and it looks a lot better at stopping I windup, I have just changed the library to include the I term windup control so if you wait a bit then I should be able to give it a run and see how it works.

cheers steve[/quote]



Hi Steve,

Any news?

Matho

Re: Brewery Programming

Post by Matho » Wed Jul 04, 2012 8:11 am

Hi Claudio,

I have been working on the PID library and have made it so if the P is larger than the output max, the ITerm is set to 0 and if P is less than the output min ITerm is reset to 0. I have tried this and it seems to work really well on multiple steps, the other option I tried worked well on the first step but then because ITerm was already wound up a bit from the first step the second step would overshoot. I don't think there is much need to change libraries for the original code because I made it only to use the PID when it was within 5 deg's of the set temperature. You can see it in the PID_heat function

Code: Select all

void PID_HEAT (void){
  if((Setpoint - Input)>5){
    digitalWrite(Heat,HIGH);
    if ((Setpoint - Input)<6)
   {
    myPID.Compute();
    }
  }
  else{
  myPID.Compute();
  unsigned long now = millis();
  if(now - windowStartTime>WindowSize)
  { //time to shift the Relay Window
    windowStartTime += WindowSize;
  }
  if((Output*(WindowSize/100)) > now - windowStartTime) digitalWrite(Heat,HIGH);
  else digitalWrite(Heat,LOW);
  }
}
If you want to use the new library I would suggest deleting the code in the red

void PID_HEAT (void){
if((Setpoint - Input)>5){
digitalWrite(Heat,HIGH);
if ((Setpoint - Input)<6)
{
myPID.Compute();
}
}
else{

myPID.Compute();
unsigned long now = millis();
if(now - windowStartTime>WindowSize)
{ //time to shift the Relay Window
windowStartTime += WindowSize;
}
if((Output*(WindowSize/100)) > now - windowStartTime) digitalWrite(Heat,HIGH);
else digitalWrite(Heat,LOW);
}
}

http://www.mediafire.com/?htzio472x8xbxrl here is the new library there is nothing else to add the the original code except changing the

#include <PID_V1.h>
to
#include <PID_V102.h>

and don't worry about setting the ITerm clamp as its not required.

cheers steve

claudiobr74

Re: Brewery Programming

Post by claudiobr74 » Wed Jul 04, 2012 3:16 pm

Hi Steve,

I'm finishing the project and will try it soon. Thank you again.

cheers Claudio

User avatar
barneey
Telling imaginary friend stories
Posts: 5423
Joined: Mon Jul 25, 2011 10:42 pm
Location: East Kent

Re: Brewery Programming

Post by barneey » Sat Jul 14, 2012 6:13 pm

Thanks to Matho, Ive got my PCB today, do just need to order the components, then I can start building :)

Cheers
Hair of the dog, bacon, butty.
Hops, cider pips & hello.

Name the Movie + song :)

User avatar
barneey
Telling imaginary friend stories
Posts: 5423
Joined: Mon Jul 25, 2011 10:42 pm
Location: East Kent

Re: Brewery Programming

Post by barneey » Sat Jul 14, 2012 7:20 pm

I need help in getting a relay for the project, I can get them from RS but they want to charge an additonal £10.00 for the shipping of the thing!

Part Number G5SB-14-DC12.

Anyone help please?
Hair of the dog, bacon, butty.
Hops, cider pips & hello.

Name the Movie + song :)

Matho

Re: Brewery Programming

Post by Matho » Sun Jul 15, 2012 3:32 am

Hey barneey,

Farnell has them too http://uk.farnell.com/omron-electronic- ... =lookahead

If thats no good they cost me about $2.20 au free delivery from RS australia (the part has to come from the UK, go figure) and post it back (air mail would be $12.50 and sea mail would be $7.75). I picked the relay because it was easy for me to get and a good price too but as with all relays it has a unique footprint. A G5Q will also fit in its place

http://www.components.omron.com/compone ... ABE-6WNT6Y with a bonus of taking 10A instead of 5A

cheers steve

Post Reply