Forum

Fermenter/Freezer C...
 
Notifications
Clear all

Fermenter/Freezer Code

9 Posts
2 Users
0 Likes
7,117 Views
(@pbruno3)
Reputable Member Admin
Joined: 7 years ago
Posts: 343
Topic starter  

Hi, per request here is my current script for my dispensing (kegerator) and fermenting freezers:

[start]
"Dispenser Temp" Enabled = true
"Fermenter Temp" Enabled = true
"Dispenser Control" Enabled = true
"Fermenter Control" Enabled = true
new value dtarget
new value ftarget
new bool trigger
reset "Refrigeration Timer"
trigger = false

[loop]
dtarget = "Dispenser Control" Target
ftarget = "Fermenter Control" Target
dtarget += 7
ftarget += 7
if "Dispenser Control" Connected == false
	trigger = true 
endif
if "Fermenter Control" Connected == false
	trigger = true
endif
if "Dispenser Temp" Value > dtarget
	trigger = true
endif
if "Fermenter Temp" Value > ftarget
	trigger = true 
endif
if trigger == true
	trigger = false
	if "Refrigeration Alarm" Active == false
		"Refrigeration Alarm" Active = true
		reset "Refrigeration Timer"
		start "Refrigeration Timer"
	endif
else
"Refrigeration Alarm" Active = false
endif

sleep 30000
goto loop


   
Quote
(@tracer)
Active Member
Joined: 7 years ago
Posts: 11
 

BD  Would you explain what each step in your script is doing? I'm thick headed and do not quite see what each step is doing.

Thanks  Tom 


   
ReplyQuote
(@pbruno3)
Reputable Member Admin
Joined: 7 years ago
Posts: 343
Topic starter  

OK, let me know if this gives you enough detail or you would like further explanation on something.

Note there are 6 Elements this script evaluates/changes. The device elements are the Dispenser Temperature, the Fermenter Temperature, the Dispenser Control (hysteresis), and the Fermenter Control (hysteresis). The alarm element is "Refigeration Alarm" and the timer element is "Refrigeration Alarm". 

The start section makes sure the device elements are enabled and creates variables for the script's use. It also resets the timer. The loop section sets variables for the dispenser and fermenter 7 degrees above their current targets (setpoints). For example, if my dispenser is set to 33 degrees, dtarget becomes 40, so if the temp goes above that an alarm will be enabled. The next for if statements check to make sure the devices are connected, meaning communicating with the physical interface and check the temperature thresholds. If any of these are true, trigger is made true. The last if statement checks is trigger is true, and if so turns the alarm on. This alarm is audible but also emails me (set in the element). The script is paused for 30 seconds, then is executed from the loop section again. Therefore, the connections and temps are checked twice a minute, which is often enough for refrigeration systems.

[start]
"Dispenser Temp" Enabled = true                	// enables dispenser temp sensor device
"Fermenter Temp" Enabled = true                	// enables fermenter temp sensor device
"Dispenser Control" Enabled = true             	// enables dispenser hysteresis device
"Fermenter Control" Enabled = true             	// enables fermenter hysteresis device
new value dtarget				// creates a new dispenser variable named dtarget
new value ftarget				// creates a new fermenter variable named ftarget
new bool trigger				// creates a new true/false variable named trigger
reset "Refrigeration Timer"			// reset the timer
trigger = false					// set the variable trigger to false

[loop]
dtarget = "Dispenser Control" Target		// set the variable dtarget to the dispenser target
ftarget = "Fermenter Control" Target		// set the variable ftarget to the fermenter target
dtarget += 7                                    // increase variable dtarget 7 degrees
ftarget += 7                                    // increase variable ftarget 7 degrees
if "Dispenser Control" Connected == false     	// set variable trigger to true if disconnected
   trigger = true
endif
if "Fermenter Control" Connected == false     	// set variable trigger to true if disconnected
   trigger = true
endif
if "Dispenser Temp" Value > dtarget           	// set trigger to true if dispenser temp above dtarget
   trigger = true
endif
if "Fermenter Temp" Value > ftarget           	// set trigger to true if fermenter temp above ftarget
   trigger = true 
endif
if trigger == true                             	// handle if variable trigger was set to true above
   trigger = false                             	// reset trigger variable to be false
   if "Refrigeration Alarm" Active == false   	// check if alarm is off, if so...
       "Refrigeration Alarm" Active = true    	// ...turn alarm on
       reset "Refrigeration Timer"		// ... reset the timer
       start "Refrigeration Timer"		// ... and start the timer (shows when alarm occured)
   endif
else
"Refrigeration Alarm" Active = false          	// turn off alarm if trigger variable is not true
endif

sleep 30000                                    	// wait 30 seconds
goto loop					// continue execution from [loop] section above

   
ReplyQuote
(@tracer)
Active Member
Joined: 7 years ago
Posts: 11
 

Thanks for the reply. I thought it was a some sort of ferment schedule, not an alarm setup.

It makes more sense now.  

Thanks  Tom     


   
ReplyQuote
(@pbruno3)
Reputable Member Admin
Joined: 7 years ago
Posts: 343
Topic starter  

Oh, sorry if I left that impression. Anyway, fermentation schedules are easy to do. Here would be an example. This one waits for a day at a time, then changes the temp. There are lots of ways to skin this cat but here is a simple-ish one:

[start]
"Fermenter Temp" Enabled = true			// enables fermenter temp sensor device
"Fermenter Control" Enabled = true		// enables fermenter hysteresis device
new value daycounter				// creates a new variable named daycounter
reset "Refrigeration Timer"			// reset the timer (to its default of 0:00:00)
start "Refrigeration Timer"			// start the timer running
daycounter = 0					// set the variable daycounter to zero
"Fermenter Control" Target = 63			// set the starting fermentation temperature

[loop]
wait "Refrigeration Timer" Value >= 23:59:55		// wait for a day to elapse
reset "Refrigeration Timer" // reset the timer (to default of 0:00:00) daycounter += 1 // increase the variable daycounter by 1 if daycounter == 7 // if the 7th day, change the fermentation temp "Fermenter Control" Target = 65 // increase for diacetyl rest endif if daycounter == 8 // if the 8th day, change the fermentation temp "Fermenter Control" Target = 67 // increase for diacetyl rest endif if daycounter == 9 // if the 9th day, change the fermentation temp "Fermenter Control" Target = 69 // increase for diacetyl rest endif if daycounter == 14 // if the 14th day, change the fermentation temp "Fermenter Control" Target = 33 // decrease for cold crash endif goto loop // go back to loop and wait again

   
ReplyQuote
(@tracer)
Active Member
Joined: 7 years ago
Posts: 11
 

That doesn't look too hard to do so maybe I cat get a grip on doing a script.

I currently have a Brew Troller dx1 board and it's starting to give me problems after several years of use.

I bought the new Phoenix  board that the new owner of Brew Troller had made in China.

 He had  the wrong chip put in it and it wont up load the program its suppose to.

So I'm interested in your program.

Every step I currently do is automated except for the batch sparge. The valves are automated but I have to enter the sparge in and out manually. You say you can fully automate with your program.

I have four three way and one on and off valves that are ran by Brew Troller. Do you have a built in valve program to set up the valves or would I have to write a script each one?

Tom

 

  


   
ReplyQuote
(@pbruno3)
Reputable Member Admin
Joined: 7 years ago
Posts: 343
Topic starter  

Hi tracer,

As you know, we don't use proprietary hardware, so no problem getting or replacing boards. The recommended Arduino MEGA runs as little as $11!

First, a little overview/discussion. BruControl is setup to be as manual or automated as you like. You create Device Elements which represent the devices they are actually connected to. You can control those as an operator by interacting with them directly - this makes for a regular, albeit digital, control panel. That requires no scripting. Changes states or values by editing the Device Element, and it is immediately reflected in actual hardware.

When you want the device elements (and others) to change or make decisions on their own, you write a script (like above). This does not lock out the operator, preventing them from making changes on the fly (unless you want it that way), which means the automation can be guided and it doesn't "take over" if you don't want it to.

You can have one script that runs an entire process, or you can break out sections into separate scripts. Our suggestion is anything you want to run serially, or "in order" should be done in one script. It is much easier to write and debug physical hardware interaction/automation this way. However, anything you want done in parallel, or in a multi-tasking manner, should be done in multiple scripts. My brewery (seen in the brew day video here: ), which is fully automated, has a single script that is currently 343 lines long. It is not commented yet but I will post it in another thread here.

BruControl has no "rules" with respect to automation. It does not know (or care) that your equipment controls a brewery. This makes it completely flexible - as you do not need to work within the rules of a traditional brewery controller, which for example might expect you to have an HLT, a MLT, and a BK. Traditional controllers have profiles or layouts which expect you to adhere to. BruControl is wide open, but still easy to set up. If you wanted a 5 vessel brewery, go for it. You decide how many devices you want to have and control, set them up in the software, then automate their operation via script as you see fit.

Regarding your sparge, I am not sure what you mean by entering the sparge manually. Bottom line is, if you can electronically control your valves to control your sparge, we can automate that. Regarding your last question, your script tells each device what to do and when. So if you wanted a valve named 'Valve 2' to open, the line in the script for example might be: '"Valve 2" State = on'.  So yes, you need to write script for each operation individually (it wouldn't know when to open on its own), but this is as simple as this.

In terms of hardware, there will need be some integration, as a MEGA only has 5V outputs - we would need to control your valves by adding a relay in between. If you have more details on your system, pass them along and we can help understand how the wiring would work.

Sorry this is a long diatribe but we wanted to hopefully provide some additional flavor on how it works and how you can easily automate your rig. Let us know if you have additional questions or concerns. 


   
ReplyQuote
(@tracer)
Active Member
Joined: 7 years ago
Posts: 11
 

Thanks for taking the time to explain things for me. Hope you don't get tired of me asking questions when I buy the program.

Tom

    


   
ReplyQuote
(@pbruno3)
Reputable Member Admin
Joined: 7 years ago
Posts: 343
Topic starter  

Don't be silly - that's what we are here for! FYI I just posted my brewery code in this forum. It is not commented, but you can see it and probably work through it easily.


   
ReplyQuote
Share: