• Please visit and share your knowledge at our sister communities:
  • If you have not, please join our official Homebrewing Facebook Group!

    Homebrewing Facebook Group

BruControl: Brewery control & automation software

Homebrew Talk

Help Support Homebrew Talk:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
This is probably so simple that I will be embarrassed, but I can't figure out how you do an "if..and..else" statement in Brucontrol. So what I want to say is if x is true and y is also true then do something, otherwise (else) do something else.
Could someone please help me out?
 
When there is an if statement under an if statement its a nested if statement as RiverCityBrewer mentions... here is an example

Code:
if "FV-1 ENABLE" State == true   
    if enable_previous_state == false  
    "FV-1" Target = "FV-1 PRIMARY" Value
    enable_previous_state = true
    endif                     
else  
    if enable_previous_state == true   
        "FV-1 AUTO" State = False
        "FV-1" Enabled == False            
        "FV-1" Background = 2 
        "FV-1 BLACK" Background = 2
         enable_previous_state = false
    endif
endif
 
Thanks so much. I had forgotten to uncomment my second "endif" statement in all my iterations of the script. Because if wasn't ending it just kept plowing on ahead when I stepped through the script. It would be nice to have a Brucontrol "cookbook" that goes into more detail about how to approach problems in scripting such as the comment by RiverCityBrewer and the sample from aeviaanah above. In the meantime, thank you for your patience with my learning curve.
 
Thanks so much. I had forgotten to uncomment my second "endif" statement in all my iterations of the script. Because if wasn't ending it just kept plowing on ahead when I stepped through the script. It would be nice to have a Brucontrol "cookbook" that goes into more detail about how to approach problems in scripting such as the comment by RiverCityBrewer and the sample from aeviaanah above. In the meantime, thank you for your patience with my learning curve.
The user manual has a section or two about scripting.
 
OK, based on the quick success in getting my last query answered, here is another question about Brucontrol scripting that I can't seem to find the answer to:

I'm bringing in the data from 4 iSpindel hydrometers through node red into Brucontrol Data Exchange and storing the data in individual Global elements based on the assigned name of each iSpindel. For example, the global element for Specific gravity for iSpindel0004 is named "SG iSpindel0004" . All that works great. My problem comes when I try to assign a specific iSpindel to a specific fermenter. While it would be simple to permanently assign iSpindel004 to FV4, stuff happens to iSpindels (like low battery or need to recalibrate) or during fermentation and I want to be able to reassign a iSpindel to that fermenter on the fly. Thanks to my previous query above, I wrote a script in brucontrol that goes to two editable global elements ("Select iSpindel by number" and "Select Fermenter by ID") reads the values that are entered and then pushes the data stored from the appropriate iSpindel to the corresponding global elements associated with that FV.

That is fine as long as the global element value is hardwired into the script. For example:

"iSpindel SG FV1" Value = "SG iSpindel0005" Value (which is where the SG value is stored)

Since all my iSpindels have the same naming convention, what I want to do is read the value from "Select iSpindel by number" Global Element and insert that into the "SG iSpindel000x" Value part of the script (above) on the fly.

An abbreviated version of the my approach to the script goes like this:
new string iSpindelNumber
new string iSpindelSelectSG
new string SG

iSpindelNumber = "Select iSpindel by number" Value
iSpindelSelectSG = "SG iSpindel000" + iSpindelNumber
SG = iSpindelSelectSG + " Value"

"iSpindel (SG) FV1" Value = SG

which returns
"iSpindel (SG) FV1" Value = SG iSpindel0004 Value
which is perfect if I could somehow get quotes around the global element name so it looks like this:

"SG iSpindel0004" Value

Other scripting languages have ways to preserve the quote marks in line, but I can't figure out how to do it in Brucontrol. Does anyone have any ideas, or perhaps I am approaching the problem in the wrong way? Thanks in advance for any suggestions
 
I don't think you can use quotes (") on the name of any elements

You can use quotes around the name of an Element in scripts. You would have to use quotes if the Element name has spaces.

If you have a global element named SG iSpindel0004 , you would need to refer it on a script as "SG iSpindel0004". if you use the name SG_iSpindel0004, you can use SG_iSpindel0004 or "SG_iSpindel0004" in a script.

If you name it "SG iSpindel0004" (with the quotes), it will fail in a script.

Perhaps someone with a better understanding can chime in as well.
 
Last edited:
Finally after many years of contemplation and thanks to some extra spare time due to COVID I finally finished the initial stage of my build today. Fired the system up and everything working fine.
429EE114-1697-45B2-B281-18BA0FA46376.jpeg
CC8FA915-6E27-4221-BCCA-B504A1B394EE.jpeg
 
OK, based on the quick success in getting my last query answered, here is another question about Brucontrol scripting that I can't seem to find the answer to:

I'm bringing in the data from 4 iSpindel hydrometers through node red into Brucontrol Data Exchange and storing the data in individual Global elements based on the assigned name of each iSpindel. For example, the global element for Specific gravity for iSpindel0004 is named "SG iSpindel0004" . All that works great. My problem comes when I try to assign a specific iSpindel to a specific fermenter. While it would be simple to permanently assign iSpindel004 to FV4, stuff happens to iSpindels (like low battery or need to recalibrate) or during fermentation and I want to be able to reassign a iSpindel to that fermenter on the fly. Thanks to my previous query above, I wrote a script in brucontrol that goes to two editable global elements ("Select iSpindel by number" and "Select Fermenter by ID") reads the values that are entered and then pushes the data stored from the appropriate iSpindel to the corresponding global elements associated with that FV.

That is fine as long as the global element value is hardwired into the script. For example:

"iSpindel SG FV1" Value = "SG iSpindel0005" Value (which is where the SG value is stored)

Since all my iSpindels have the same naming convention, what I want to do is read the value from "Select iSpindel by number" Global Element and insert that into the "SG iSpindel000x" Value part of the script (above) on the fly.

An abbreviated version of the my approach to the script goes like this:


which returns
"iSpindel (SG) FV1" Value = SG iSpindel0004 Value
which is perfect if I could somehow get quotes around the global element name so it looks like this:

"SG iSpindel0004" Value

Other scripting languages have ways to preserve the quote marks in line, but I can't figure out how to do it in Brucontrol. Does anyone have any ideas, or perhaps I am approaching the problem in the wrong way? Thanks in advance for any suggestions

You could handle this with if/endif blocks. Not super elegant, but would accomplish what you want.
 
Looking for some troubleshooting assistance. I have assembled my hardware and have spent the day doing all my initial testing. Everything is working perfectly except.....my RIMs and HLT LED indicators are on constantly. I have attached my schematic. Basically I turn on the power switch. Then I energize the BruControl relay (this is my software e-stop). This powers the contactor relays and the AC relay (this supplies hot to the 120VAC receptacles). At this point the RIMs and HLT LEDs come alive. My intent is for them to only come on when the element is energized. As an aside, my circuit tester detects voltage all the way out to the elements without the SSR's being energized....is this just leakage? I did measure the voltage at the LEDs and it is 120V.

What am I missing?

Mike
 

Attachments

  • BruControlFlow-AC Enclosure.pdf
    129.7 KB
You could handle this with if/endif blocks. Not super elegant, but would accomplish what you want.
I'm assuming your suggestion refers to the way to solve the overall problem and not a way to add in-line quote marks where I need them. If so, yes that works, as I wrote a script yesterday for FV1. It is a relativly lot of work to script it--not undoable--just kind of a brute force find and replace in notepad++ to get everything working. If you are suggesting you could add the quote marks throungh this method, it is beyond me how you would do this, and I would be delighted to be pointed in the right direction.
 
First off... nice job on the schematic!!

Kinda leakage, but not leakage as you might think it is through the SSR... Since one side of the LED is tied to neutral and the other is tied to red (line 2), when the contactor is closed, the line 2 is live. The element is only 10 ohms, or essentially a very small resistor. The current flows from line 2, through the element to the other side of the element (black wire) where the other side of the LED is connected. If you unplug the element the LED will go out.

More importantly... how to fix? Check that your LEDs are 220V... then move the neutral line of them to line 2 bus. Ideally you should fuse that like you have done the others.

THAT SAID... you just helped me realize we are doing the same thing on the UniCon build... my apologies if that is where you got the wiring. We will need to fix this on our schematic and build. I actually made this mistake on my personal rig when I built it... you would think I would have learned the first time. I absolutely owe you a favor in return!!
 
I'm assuming your suggestion refers to the way to solve the overall problem and not a way to add in-line quote marks where I need them. If so, yes that works, as I wrote a script yesterday for FV1. It is a relativly lot of work to script it--not undoable--just kind of a brute force find and replace in notepad++ to get everything working. If you are suggesting you could add the quote marks throungh this method, it is beyond me how you would do this, and I would be delighted to be pointed in the right direction.

Solve problem yes. Inline quotes... no.
 
First off... nice job on the schematic!!

Kinda leakage, but not leakage as you might think it is through the SSR... Since one side of the LED is tied to neutral and the other is tied to red (line 2), when the contactor is closed, the line 2 is live. The element is only 10 ohms, or essentially a very small resistor. The current flows from line 2, through the element to the other side of the element (black wire) where the other side of the LED is connected. If you unplug the element the LED will go out.

More importantly... how to fix? Check that your LEDs are 220V... then move the neutral line of them to line 2 bus. Ideally you should fuse that like you have done the others.

THAT SAID... you just helped me realize we are doing the same thing on the UniCon build... my apologies if that is where you got the wiring. We will need to fix this on our schematic and build. I actually made this mistake on my personal rig when I built it... you would think I would have learned the first time. I absolutely owe you a favor in return!!

Excellent, thanks. They are 120V LEDs (I had them on hand) which is why I went the neutral route. I’ll pick up a couple 240V ones.
 
I'm sorry, I don't recall saying to use a filter. I'm no expert on serial communications... but I don't think you can use a filter on the signal lines unless it is high pass enough. We want to increase the signal:noise ratio such that it performs as expected. Best ways to do this are good wiring practice.
 
Has anyone used a small PC like a Nuc or zbox to run BruControl? I was thinking of adding one inside my panel and adding a 22 to 24" touch monitor to one of the three cabinets and high voltage in one and low voltage in the other. I also wanted to use Ethernet jacks for the I/O to sensors and wanted to know if that has been done successfully or not.
 
Has anyone used a small PC like a Nuc or zbox to run BruControl?
I am thinking of this myself, but I am not sure how to add DIN rails to the box.

I also wanted to use Ethernet jacks for the I/O to sensors and wanted to know if that has been done successfully or not.
I was going to try this (although, I am nowhere near this step). I am going to do research on the wiring first to make sure there wont be any loss.
 
I think you could use Ethernet jacks and wiring for sensors, but you would be missing out on the benefit of shielding.

I do networking in my day job and I am pretty sure Cat5e and Cat6 are shielded and twisted pair inside so that should cut down the chance of picking up noise don't you think?
 
I am thinking of this myself, but I am not sure how to add DIN rails to the box.


I was going to try this (although, I am nowhere near this step). I am going to do research on the wiring first to make sure there wont be any loss.

I think the general DIN rail adapter will be easy to find once I have a footprint for the PC, I looked at the System Requirements in the BruControl manual and it looks like either the NUC or zbox can be configured to meet those, I'm more concerned on how the RFI/EMF they produce inside the control panel would effect the Arduino MEGA.

The UniCon uses 8 pin I/O's so Ethernet just seems like a logical way to terminate at the control panel but since this is my first time building a BruControl panel, I don't want to assume I am on the right track!
 
If you are more comfortable crimping vs soldering and are ok with the increased costs, I think the shielded patch panel will work fine. Keep in mind that the UniCon has 8 IO, but there are typically more than 8 wires associated with those 8 IO points. For example, the valves I use require 3 wires (power open, power close, and ground). Some valves use 2 wires, and some can use up to 5 if you want feedback from them. For sensors, you will have to get power to them as well as bring the signal back to the controller, so 3 and sometimes 4 wires per sensor.
 
If you are more comfortable crimping vs soldering and are ok with the increased costs, I think the shielded patch panel will work fine. Keep in mind that the UniCon has 8 IO, but there are typically more than 8 wires associated with those 8 IO points. For example, the valves I use require 3 wires (power open, power close, and ground). Some valves use 2 wires, and some can use up to 5 if you want feedback from them. For sensors, you will have to get power to them as well as bring the signal back to the controller, so 3 and sometimes 4 wires per sensor.
I'm not sure I understand, here is the breakdown of each I/O connector that I am working from...
I/O CONNECTOR STANDARD​
PIN 1 - GND​
PIN 2 - +24VDC​
PIN 3 - +5V​
PIN 4 - I/O DRIVER (OUTPUT)​
PIN 5 - I/O PIN​
PIN 6 - ANALOG INPUT​
PIN 7 - ANALOG OUTPUT​
PIN 8 - SPECIAL​

Wouldn't each panel port have the same 8 pin wiring?
 
Hi everyone,

Sorry for redirecting the topic, just want to share couple picture with you.
For past weeks and months, as I was building my setup and silently followed this group.
Finally I am ready, and I did my first PID tuning :) :


1600595410743.png
sqVq0_2ViPkOPHpxEAuyN8neBbT5pOpf5OmakV-3lHmgN1PdY4IXT63ZSEuUTzbIU_zlquYmg0aZ_t721wsgRtkdGv30FCcTBcTK5TfUlg3-_uhJ2WX7dnH31QVeHhW7rmgQsGxbjncvLR7S-e12KbJilSUtR1lNOHujzivA-KS-PBeCucONiKgToSdG7yBoyaozZvQ7iOrdi0bmSWE9E9ahHH2Hz73GU0BZyhA-_YetYPI8Q27LwVtBf7Ua5UO5hBSKo0O1v9p5TQYoA1GxA6Q1ZAGp7Ma2_bluKSzCL3BEIsScoxyAxJ6YxWJ2c_j9YLJZd7VBLY_wQNG-YNnH89uFExEoMK1tRvX-Ff4fS9hUDSNZ9GDA1Tb_acLfGN8J-YPV1niTaudM9eC8lo6HnD7ep-0uHYK4Cc4VtBcUmr1hJ_U8WXEbf9kJ0IMcpbFJpTq5cYzENP_-liRcV-qeb75t_YfKDNOnSArXMHUKDa0LxFgnsnM7eElfsgu-b8ZSH0IY34B9V12dYvQ0yengMYSk709nupRyNdhsUpuoOX6IADHJ9DJ4qSrySFmlXwqc0WzyArID8icLJ8-lOSVZrlPvW3KJOatDZWzhLpTN2CFwZBFRovHojlSDDzDVsr7RbTD60SBA0dHbHV24g9Gk1oCBZOQMJDssvjGj5cunK5q7ZKT7WNdImaYCbERInA=w1833-h1374-no
1600596211735.png
I

I think I should be ok with1st PID tuning - for my setup.
Flow was 2L/minute, 5, 0.1, 0 worked just fine. I am unsure if this is realyl good. Temp is within 0.1 deg from target temp. What do you think?
1600595673921.png


Cheers
 
Back
Top