Home Brew Forums > Home Brewing Beer > Electric Brewing > Arduino, PID, or other?
Reply
 
LinkBack Thread Tools
Old 03-21-2012, 07:21 AM   #21
ScottSingleton
Feedback Score: 0 reviews
Recipes 
 
Join Date: Feb 2012
Location: Manassas, VA
Posts: 438
Liked 7 Times on 6 Posts
Likes Given: 11

Default

I just started my automation using a NetDuino product which is basically an Arduino that runs Microsoft's .NETMF framework. I just happen to do C# dev and wanted something that I was a bit more familiar with.

I can tell you that I've found code snippets for just about anything I need to do brewery-wise including rooting through the Brewtroller code.

It's definitely more of a hobby.. If I had wanted a no-code system I would have gone with the BCS-460. I've seen that in action and it's really sweet.

I would have gone with the Brewtroller if I hadn't wanted to screw with coding in C# -- but the NETMF hardware I picked up is really nice and has a 4" touch screen I'm using to provide menus and real interactivity.

It's a daunting task. I've been assembling my RIMS, tuning my PID code, and generally working on this thing for a few weeks.

__________________
ScottSingleton is offline
 
Reply With Quote Quick reply to this message
Old 03-21-2012, 04:47 PM   #22
Islandboy85
Feedback Score: 0 reviews
Recipes 
 
Join Date: Nov 2009
Location: Dallas, Texas
Posts: 635
Liked 10 Times on 8 Posts
Likes Given: 1

Default

Quote:
Originally Posted by matho
Islandboy keep your head up, I found it daunting when I started but after a couple of months I have a good idea about programming the arduino. If you want plug and play then go for a PID but if you want to go for the custom look then use the arduino.The good thing about the arduino is you can build what you want, you can add a number of temperature probes( not just one like the PID) and you can control a number of outputs Here is a simple code for a thermostat that is PID controlled, it has all the building blocks you will need.

the code is in deg c because that's what we use down here so you will have to use a formula to change it to deg F.

cheers steve
Wow, thanks for the help. A guy I grew up with who is a computer geek extraordinaire recommended I start with writing out a pseudo code. This is what I've got so far...any thoughts?

Brewery pseudo code

HOT LIQUOR TANK:
-User inputs set temperature using control panel buttons and initiates program start.
-Arduino check float switch status: if switch is open it is an unsafe condition to heat. Sound alarm for one second every minute. Display and flash "FLOAT" on LCD display in the bottom row and flash the HLT actual temp <H set 175 act 100> on the first row and <FLOAT> on the lowest row. If float switch is closed continue to next program step.
-Compare set temp to actual temp. If set temp is higher than actual temp by 1 degree outpost to pin ( ) to cycle heating element on at 80% duty cycle. Recompare set and actual temp. If set>actual continue to heat. Loop until set temp is achieved. When set temp is achieved sound alarm for 1 second and flash actual temp on the LCD display on and off once a second for 15 seconds. Maintain temp of HLT. Until canceled by control panel buttons or float switch opens.

MASH LAUTER TUN:
-User inputs set temperature using control panel buttons and initiates program start.
-Arduino checks for voltage to pump relay. If there is voltage present it is safe to heat.
if switch is open it is an unsafe condition to heat. Sound alarm for one second every minute. Display and flash "FLOAT" on LCD display in the bottom row and flash the MLT actual temp <M set 175 act 100> on the second row and <PUMP> on the lowest row.
-Compare set temp to actual temp. If set temp is higher than actual temp by 1 degree outpost to pin ( ) to cycle heating element on a 2 second duty cycle. Recompare set and actual temp. If set>actual continue to heat. Loop until set temp is achieved. When set temp is achieved sound alarm for 1 second and flash actual temp on the LCD display on and off once a second for 15 seconds. Maintain temp of MLT .Until canceled by control panel buttons or pump relay is deenergized.

BOIL KETTLE:
-User inputs set temperature using control panel buttons and initiates program start.
-Arduino check float switch status: if switch is open it is an unsafe condition to heat. Sound alarm for one second every minute. Display and flash "FLOAT" on LCD display in the bottom row and flash the BK actual temp <B set 175 act 100> on the third row and <FLOAT> on the lowest row. If float switch is closed continue to next program step.
-Compare set temp to actual temp. If actual temp is lower than 205degree outpost to pin ( ) to cycle heating element on at 90% duty cycle. Recompare set and actual temp. Loop until set temp is reaches 200 degrees. At this point change duty cycle to 80% duty cycle until 205 degrees. At this point cycle heat on for two seconds and recompare set/actual temps. When set temp is achieved sound alarm for 1 second and flash actual temp on the LCD display on and off once a second for 15 seconds. Maintain temp of BK Until canceled by control panel buttons or float switch opens.
__________________
Islandboy85 is offline
 
Reply With Quote Quick reply to this message
Old 03-21-2012, 05:07 PM   #23
ScottSingleton
Feedback Score: 0 reviews
Recipes 
 
Join Date: Feb 2012
Location: Manassas, VA
Posts: 438
Liked 7 Times on 6 Posts
Likes Given: 11

Default

Quote:
Originally Posted by Islandboy85 View Post
Wow, thanks for the help. A guy I grew up with who is a computer geek extraordinaire recommended I start with writing out a pseudo code. This is what I've got so far...any thoughts?
I would change the way you're activating you heating elements. Look into PID algorithms. Just having an On/Off based around a target temp will cause you to bounce up and down around the target. I tried doing this at first with my MLT RIMS and was all over the page temperature-wise. and a matter of 5 degrees in the MLT does matter.

This is one of the harder things I had to wrap my head around but the basic principle is that the PID Algorithms will adjust the duty cycle to a variable the will lead you into your target temp with the goal of landing right on it, then maintain it.

The tricky part is tuning it for your exact hardware setup; but there are some decent guides on how to do that out there.

I actually based mine off of the PID code in the Brewtroller software and it's been working excellent.

-Scott
__________________
ScottSingleton is offline
 
Reply With Quote Quick reply to this message
Old 03-21-2012, 05:13 PM   #24
trigger
Feedback Score: 0 reviews
Recipes 
 
Join Date: Aug 2010
Location: portland
Posts: 628
Liked 6 Times on 6 Posts
Likes Given: 2

Default

First thought is that you may want to reconsider the float switch. I've got one wired through one of the signal legs on the SSR controlling the element power. {Then tie the positive signal terminal to the input pin you've designated on your arduino through a 100k pulldown resistor.} That way your SSR is directly dependent on the float switch state, so bad code can't cause an unintentional misfire. You could do this with a leading edge triggering since your SSR won't always be on. In other words, at the beginning of your code look for the leading edge of a ms pulse through the SSR. If the float is open it won't see it, and that can trigger your alarm. If it is closed all is fine and move through the program.

As far as the temperature control, try using the PID library on arduino.cc.

For the pump relay bit that's just a bit of Boolean. If pump != HIGH trigger the alarm and heat = LOW.

For the boil you won't want to go with temperature. You want to use PWM control, which can be based by setting up a timer, then adjusting the proportion of the time that the element recieves heat. Just make sure that you keep in mind that the load waveform is 60 Hz. You want at least 0.5 periods to pass in the minimum power setting, assuming you're using a zero crossing SSR. This means if your minimum power is 5% (I used 5% increments) that should correspond to 1/120th of a second.

looks like your on your way though!

edit {thermo final today caused me to come up with a bit of bad wiring}

__________________

The power to tax, once conceded, has no limits; it contains until it destroys. I was not joking when I told them to dig into their own pouches. It may not be possible to do away with government — sometimes I think that government is an inescapable disease of human beings. But it may be possible to keep it small and starved and inoffensive — and can you think of a better way than by requiring the governors themselves to pay the costs of their antisocial hobby?

R. A. Heinlein

trigger is offline
 
Reply With Quote Quick reply to this message
Old 03-21-2012, 05:14 PM   #25
ScottSingleton
Feedback Score: 0 reviews
Recipes 
 
Join Date: Feb 2012
Location: Manassas, VA
Posts: 438
Liked 7 Times on 6 Posts
Likes Given: 11

Default

Here's my Basic pseudo code for my MLT, I don't have a float:

Alert user to connect MLT hoses, wait for user input
Activate Recirc Pump
Wait 30 secs
Activate PID to ramp temp to desired temperature
when mean temperature of MLT is at target for more than 3 minutes alarm user that mash-in can begin
When user confirms shut down PID and Recirc Pump
Prompt user to press button when mash in complete
start recirc pump and wait two minutes for clearing
resume PID on Ramp Schedule to re-hit target temp
when target temp re-aquired start visual mash timer
...

It's something like that. I'm at work but that's the basic jist.

Note that I manually direct fire my MLT to get it within RIMS range before I start the process.

I've only done test water batches so far; my whole automation process is far from complete but I've got the MLT code down pretty good.

__________________
ScottSingleton is offline
 
Reply With Quote Quick reply to this message
Old 03-21-2012, 06:25 PM   #26
Islandboy85
Feedback Score: 0 reviews
Recipes 
 
Join Date: Nov 2009
Location: Dallas, Texas
Posts: 635
Liked 10 Times on 8 Posts
Likes Given: 1

Default

Quote:
Originally Posted by ScottSingleton

I would change the way you're activating you heating elements. Look into PID algorithms. Just having an On/Off based around a target temp will cause you to bounce up and down around the target. I tried doing this at first with my MLT RIMS and was all over the page temperature-wise. and a matter of 5 degrees in the MLT does matter.

This is one of the harder things I had to wrap my head around but the basic principle is that the PID Algorithms will adjust the duty cycle to a variable the will lead you into your target temp with the goal of landing right on it, then maintain it.

-Scott
I'll look into that. I knew when I was writing the pseudo code this could be an issue, bu didn't know how to get around the overshooting issue. Thanks I'll look into that.
__________________
Islandboy85 is offline
 
Reply With Quote Quick reply to this message
Old 03-21-2012, 06:27 PM   #27
Islandboy85
Feedback Score: 0 reviews
Recipes 
 
Join Date: Nov 2009
Location: Dallas, Texas
Posts: 635
Liked 10 Times on 8 Posts
Likes Given: 1

Default

Quote:
Originally Posted by trigger
First thought is that you may want to reconsider the float switch. I've got one wired through one of the signal legs on the SSR controlling the element power. {Then tie the positive signal terminal to the input pin you've designated on your arduino through a 100k pulldown resistor.} That way your SSR is directly dependent on the float switch state, so bad code can't cause an unintentional misfire. You could do this with a leading edge triggering since your SSR won't always be on. In other words, at the beginning of your code look for the leading edge of a ms pulse through the SSR. If the float is open it won't see it, and that can trigger your alarm. If it is closed all is fine and move through the program.

edit {thermo final today caused me to come up with a bit of bad wiring}
You're correct. After I read what you wrote it made sense since now the float switch isn't as much part of the circuit logic as is it an actual mechanical safety if you will.
__________________
Islandboy85 is offline
 
Reply With Quote Quick reply to this message
Old 03-21-2012, 06:36 PM   #28
Islandboy85
Feedback Score: 0 reviews
Recipes 
 
Join Date: Nov 2009
Location: Dallas, Texas
Posts: 635
Liked 10 Times on 8 Posts
Likes Given: 1

Default

Quote:
Originally Posted by ScottSingleton
Here's my Basic pseudo code for my MLT, I don't have a float:

Alert user to connect MLT hoses, wait for user input
Activate Recirc Pump
Wait 30 secs
Activate PID to ramp temp to desired temperature
when mean temperature of MLT is at target for more than 3 minutes alarm user that mash-in can begin
When user confirms shut down PID and Recirc Pump
Prompt user to press button when mash in complete
start recirc pump and wait two minutes for clearing
resume PID on Ramp Schedule to re-hit target temp
when target temp re-aquired start visual mash timer
...

It's something like that. I'm at work but that's the basic jist.

Note that I manually direct fire my MLT to get it within RIMS range before I start the process.

I've only done test water batches so far; my whole automation process is far from complete but I've got the MLT code down pretty good.
What kind of display are you using? I've only been able to find 20 x 4 LCD displays. That is limiting me to display like this
Line one: HLT set 175 act 175
Line two: MLT set 150 act 150
Line three BK set 212 act 212
Line four: <fault messages>

I suppose I could have the alert messages like "hook up the pump" displayed there. I wonder if it would be better to have a second 20 x 2 LCD to display the fault and user action required messages on, but two displays sounds like it could get REALLY furry.
__________________
Islandboy85 is offline
 
Reply With Quote Quick reply to this message
Old 03-21-2012, 06:42 PM   #29
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

In my switch from propane to electric and Brewtroller to Arduino Mega, I'm looking at giving this LCD a try: http://www.adafruit.com/products/438 (just ordered it last night).

Right now my Brewtroller uses a 20x4 character display and it takes some creativity to get everything you want on it. You can always use an optical encoder to switch between "screens".

What I want to try and do with the new LCD is operate with a blue backlight normally and then use the RGB backlight to flash the backlight red when an action or alarm is occuring.

Definitely checkout what's going on over on the Brewtroller site, it may give you some ideas too.

__________________
jpalarchio is offline
 
Reply With Quote Quick reply to this message
Old 03-21-2012, 06:50 PM   #30
ScottSingleton
Feedback Score: 0 reviews
Recipes 
 
Join Date: Feb 2012
Location: Manassas, VA
Posts: 438
Liked 7 Times on 6 Posts
Likes Given: 11

Default

Quote:
Originally Posted by Islandboy85 View Post
What kind of display are you using? I've only been able to find 20 x 4 LCD displays. That is limiting me to display like this
Line one: HLT set 175 act 175
Line two: MLT set 150 act 150
Line three BK set 212 act 212
Line four: <fault messages>

I suppose I could have the alert messages like "hook up the pump" displayed there. I wonder if it would be better to have a second 20 x 2 LCD to display the fault and user action required messages on, but two displays sounds like it could get REALLY furry.
I'm using a 3.5" color LCD touch screen.

The exact device I'm using is here: http://www.ghielectronics.com/catalog/product/136

My basic end-game is to try and have a Brew-Magic type of system where I just send up my Beersmith recipe, it does all the steps/calcs, then reports back with actuals.
__________________
ScottSingleton 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 driving an SSR thomashp Electric Brewing 4 11-08-2010 07:00 AM



Newest Threads

LATEST SPONSOR DEALS