Happy HolidaySs Giveaway - Winners Re-Re-Re-Drawn - 24 hours to Claim!

Get your HBT Growlers, Shirts and Membership before the Rush!


Home Brew Forums > Home Brewing Beer > DIY Projects > Fermenters > DIY PID controller - beginner Arduino project
Reply
 
LinkBack Thread Tools
Old 05-29-2012, 01:36 AM   #11
bolts
HBT_LIFETIMESUPPORTER.png
Feedback Score: 0 reviews
Recipes 
 
Join Date: Sep 2009
Location: Portland, OR
Posts: 306
Liked 8 Times on 7 Posts
Likes Given: 3

Default

If you decide to get PCBs made, take a look at http://dorkbotpdx.org/wiki/pcb_order. He's local (to me) and the boards are quite good. Prices are good for hobby sized batches too.

__________________
bolts is offline
 
Reply With Quote Quick reply to this message
Old 05-29-2012, 07:19 PM   #12
crane
Feedback Score: 0 reviews
Recipes 
 
Join Date: Sep 2011
Location: San Diego, CA
Posts: 317
Liked 34 Times on 27 Posts
Likes Given: 1

Default Intelligent 3 output PWM

One way to implement this would be to manually implement all 3 outputs with a timer ISR. Set up the timer at 100Hz for a 1 second PWM period. If you wanted a 3 second PWM period then go with 33Hz. Have a function that gets triggered from the ISR. In this function do the following:

count++; // increment our counter. There are 100 counts per period.

// check to see if we are at the end of the PWM cycle
if (count >= 100)
{
// we are at the end so reset everything
count = 0;
output1 = 0;
output2 = 0;
output3 = 0;

// enable the highest priority output that is on
if (duty_cycle1 > 0)
{
output1 = 1;
}
elseif (duty_cycle2 > 0)
{
output2 = 1;
}
elseif (duty_cycle3 > 0)
{
output3 = 1;
}
}
else // we are not at the end of the period
{
//check to see if we are at the end of the first duty cycle
if (count == duty_cycle1)
{
output1 = 0;
// check to see which output to turn on next
if (duty_cycle2 > 0)
{
output2 = 1;
}
elseif (duty_cycle3 > 0)
{
output3 = 1;
}
}

//check to see if we are at the end of the second duty cycle
if (count == (duty_cycle1 + duty_cycle2))
{
output2 = 0;
if (duty_cycle3 > 0)
{
output3 = 1;
}
}

//check to see if we are at the end of the third duty cycle
if (count == (duty_cycle1 + duty_cycle2 + duty_cycle3))
{
output3 = 0;
}
}

There are probably some bugs that need to be ironed out here as I am just coding this on the fly. This assumes that the duty_cycle variables represent a throttle percentage of 0 to 100.

You will probably run into a number of corner cases if you try to change any of the duty cycles in the middle of the period. You could get around this a couple of ways. 1 - pull out the code in the first if statement and create a separate function for it. Call this function inside the if statement as well as any time you change the duty cycle. 2 - have 2 sets of duty cycle variables. One set that is changed by external PID algorithms and one that is only changed by this function. At the end of each period when you reset the outputs assign the values of the external duty cycles to the internal duty cycles.

Either solutions would be easy to implement. The first one might not work very well if you change the duty cycles often.

I am not a SW or FW engineer so there is probably a more elegant way to implement this.

[edit] #$&* editor won't preserve my indentations. Copy and paste to a c editor like notepad++ and you can add the indentations back in to make it readable

__________________

crane is online now
 
Reply With Quote Quick reply to this message
Old 06-03-2012, 12:17 AM   #13
chuckjaxfl
Feedback Score: 1 reviews
Recipes 
 
Join Date: Feb 2010
Location: Jacksonville, FL
Posts: 327
Liked 19 Times on 12 Posts
Likes Given: 23

Default

Made a lot of progress.

I trying to auto tune this keg today.

image-3849939899.jpg   image-1858282115.jpg   image-1145021032.jpg  
__________________
chuckjaxfl is offline
 
Reply With Quote Quick reply to this message
Old 06-03-2012, 02:40 AM   #14
jpalarchio
Feedback Score: 1 reviews
Recipes 
 
Join Date: Jan 2009
Location: Holly, MI
Posts: 562
Liked 50 Times on 41 Posts
Likes Given: 11

Default

Quote:
Originally Posted by crane View Post
#$&* editor won't preserve my indentations. Copy and paste to a c editor like notepad++ and you can add the indentations back in to make it readable
FYI- You can wrap the code in the [ code ] bracket (# icon in the editor) and it works better
__________________
jpalarchio is offline
 
Reply With Quote Quick reply to this message
Old 06-03-2012, 02:16 PM   #15
carlisle_bob
Feedback Score: 0 reviews
Recipes 
 
Join Date: Apr 2012
Location: Carlisle, PA
Posts: 1,205
Liked 27 Times on 26 Posts

Default

Hi

There are a *lot* of places that will do simple PC boards cheap. Some will do overnight processing, others do longer lead for a bit less money.

Bob

__________________
carlisle_bob is offline
 
Reply With Quote Quick reply to this message
Old 06-04-2012, 02:58 AM   #16
chuckjaxfl
Feedback Score: 1 reviews
Recipes 
 
Join Date: Feb 2010
Location: Jacksonville, FL
Posts: 327
Liked 19 Times on 12 Posts
Likes Given: 23

Default

This project was going pretty well, until this weekend. I'm having a bear of a time with the autotune library for Arduino.

At this point, I'm receptive to any tips you guys have.

__________________
chuckjaxfl is offline
 
Reply With Quote Quick reply to this message
Old 09-05-2012, 11:01 AM   #17
Bonj
Feedback Score: 0 reviews
Recipes 
 
Join Date: Jul 2007
Location: Ipswich, QLD, AU
Posts: 10
Default

Sorry to dredge up an old thread, but I am currently fighting with the arduino autotune library and wondered if you made any headway on suitable values for the aTuneStep and aTuneStartValue parameters?

I have built myself a HERMS controller using a custom designed arduino clone and another custom interface board. You may view the build log here. There is also a link to my source code (prior to my attempt to add the auto tune function), and a youtube video of operation.

I'd love some pointers on getting in the ballpark for the aforementioned variables. I'm closing in myself by trial and error, but if someone else has done the hard work already, I'd sure love to benefit from it.

__________________
Mediocrity - It takes a lot less time, and most people won't notice the difference until it's too late.

Hit and Miss Brewery - Ipswich Queensland

On Tap: null
Conditioning: null
In no-chill: null
In Primary: null
In Planning: Vienna / Helles lagery type thing with tettnanger
Bonj is offline
 
Reply With Quote Quick reply to this message
Old 09-06-2012, 05:36 AM   #18
chuckjaxfl
Feedback Score: 1 reviews
Recipes 
 
Join Date: Feb 2010
Location: Jacksonville, FL
Posts: 327
Liked 19 Times on 12 Posts
Likes Given: 23

Default

I have not been out in the garage in forever. I think those pics from June were the last day I was out there. Sorry I'm not more help.

I'm hoping to get back out there again soon and, if I have any success with the autotuner, I'll post it here.

__________________
chuckjaxfl is offline
 
Reply With Quote Quick reply to this message
Old 09-06-2012, 05:40 AM   #19
Bonj
Feedback Score: 0 reviews
Recipes 
 
Join Date: Jul 2007
Location: Ipswich, QLD, AU
Posts: 10
Default

Well, I've been experimenting with it all day, and I finally have it returning some results. The results aren't particularly useful (5.2°C overshoot on a 10°C ramp, compared to a 0.3°C overshoot from my manual tuning), but getting any results at all is still progress!

I'm testing the unit in an electric jug, so not the easiest rig to tune, but all I have until the actual HEX is finished.

__________________
Mediocrity - It takes a lot less time, and most people won't notice the difference until it's too late.

Hit and Miss Brewery - Ipswich Queensland

On Tap: null
Conditioning: null
In no-chill: null
In Primary: null
In Planning: Vienna / Helles lagery type thing with tettnanger
Bonj is offline
 
Reply With Quote Quick reply to this message
Old 09-15-2012, 10:03 PM   #20
chuckjaxfl
Feedback Score: 1 reviews
Recipes 
 
Join Date: Feb 2010
Location: Jacksonville, FL
Posts: 327
Liked 19 Times on 12 Posts
Likes Given: 23

Default

Well, I am making another attempt at it today. I will let everyone know if I come up with anything useful.

I am really starting to lose my faith in the usefulness of PID for this project. I am starting to think I might just be better off writing my own control script from scratch.

image-1992494086.jpg  
__________________
chuckjaxfl 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
Arduino Kegerator Temperature Controller luke_l Kegerators and Keezers 9 07-30-2013 01:39 PM
New Open Source Arduino Based PID Controller Released bendiy Brew Stands 9 02-11-2013 09:33 AM
Arduino questions (mash temp controller) Beezer94 Brew Stands 3 06-12-2012 03:53 PM
Arduino+XBee Dual-stage Temp Controller Chuginator Fermenters 65 12-18-2011 09:44 AM
Project Box for Arduino BulldogBrewer Brew Stands 0 09-30-2010 09:27 PM



Newest Threads

LATEST SPONSOR DEALS