The MEGA has internal pull-up resistors, so if you select active-low for an input, you can switch ground and it will work fine. If you select active high as an input, you should use a pull-down resistor to make sure the input sees ground when the switch (button in your case) is off (not connecting 5V to the input).
That said, you don’t need to use physical buttons and tie up physical inputs - we have a button element you can use in your scripts to control your automation flow. We also have switches. BC was built to use a touchscreen monitor as your user interface - you can use hardware controls if you want to, but these are limiting and can’t be added or moved at will. But it’s flexible, so that’s your call.
I think your plan to “test bed” BC makes great sense. I personally used the BCS, and BruControl was built to overcome that type of system’s shortcomings - I’ll be curious to get your feedback once you become more familiar.
When you get a MEGA connected, the first thing you should do is create a Digital Output in port 13 - that will control the on-board LED.
Ok Port 13 will be easy to test.
The reason I use Physical Switches is that I do not want to touch the computer if I can help it. It is very simple for me to depress my Green Button to go to my next step. You could also simply click on the State in the BCS Interface, but I like the Physical Switch as it is much easier. Several of us Brew at the same time. If I tell someone to "Click the Green Button", they know what I am talking about. They can do it with Gloves. I just simply write it into the script. That One Physical Switch can be used many times. The reason I have more than one in my setup now is that I have concurrent processes running, I envision doing that with the Brucontrol as well as I have my Water Process that I am always using independently during a Brew Day.
Syntax may be wrong:
Print == "Add the Grain"
// Add the Grain manually
// when ready, advance
If "Green Button" value == on
Goto "Start Mash"
// Mash by Time
New Mash_Timer timer
Mash_Timer name == "Mash"
Mash_Timer Value == 1:30:00
// Run the Count Down Timer
If Mash_Timer value == o
Print "Mash Finished, Flush Hermzilla!"
//Flush the Hermszilla
// Need to Advance Manually
If "Green Button" value == on
Goto "Transfer First Run"
[Transfer First Run]
Print == "Transfer 1st Run"
//Open Correct Valves
// Close Some Valves
//Turn on the Blue Pump
and so on.
No need to correct the syntax now as I have not really looked at your example much. Once I actually get the Physical Hardware hooked up, I will be writing some simple scripts to do some controlling or displays. I like to do it in baby steps and then write the real code using cut and paste.
My proposed One Wire Setup.
I would think it best to run a 3 wire from the Mega to a distribution box close to the probes so that the "weight" of the wire is less. Not sure if the resistor should be in the distribution box or near the Mega, or even if it makes a difference.
I found this circuit on Arduino forum regarding Digital Inputs. This looks like a "safe" way to proceed. Any comments:
The active low side is fine, and you can remove the 100 ohm resistor - its meant to limit input current in case you accidentally make the pin an output.
The active high side is not correct. The takeoff point should be at the bottom of the 10k resistor, not above it. Likewise, no 100 ohm resistor is needed, but it wont hurt to have it.
What I had found:
There's a 100Ω resistor we use to connect the input pin to either HIGH or LOW voltage. Why is it there? Well, lets say you accidentally set P2 to be an OUTPUT type pin, but then you connected it to 5V. If you write a LOW to the pin (0V) but its connected to HIGH (5V), you've basically caused a short circuit at that pin. This isn't very good for the pin and could damage it! The 100Ω resistor acts as a buffer, to protect the pin from short circuits.
I have corrected the graphic (and added the schematic I copied. Do I have the High and low reversed or are they correct. I have been trying to find a good explanation on the internet but I do not know enough to even ask the right question.
I think I have my hardware plan down. I think I need to order another TF3 Board so as not to have to rewire our Sensors. They run from the controller to vessels via metal conduit. All are wired as home runs as far as the ground is concerned (each sensor has it own shielded 18 awg twisted pair). The wires go to panel mounted M12 disconnects then patch cables to the vessels. Would be a PITA to change to RTD.
After adding all my widgets and Inputs, I still have 14 Pins available for Digital Out/Ins. # could be PWM and 2 as counters.
I can add 4 RTD Temp probes and may do that.
I can also add a lot of one wire sensors if needed.
I am going to add two latching Push Buttons to control my Gas Burners. I do not like to automatically light them. I have not found a good safety if they do not light. I have thought about a routine where the valves would shut off if the Temp in the Vessel failed to rise after some time, but that may take too long if the gas is on. I may play with it.
I have attached my Port/Pin Out plan.
I thought I had two questions but figured out the first one by myself. I was doing some resting and added a button for Port 13. It would not give me the Option of a Digital Output. As I was playing, I deleted my new button. I found that I already had a "Digital Output" button with the Port 13 assignment, I had named it LED so it was easy to know it was Port 13. BruControl will not allow two of the "same type"with the same Port on the same Workspace. Not an issue but it helped me learn.
The Port 14 is the one I still have the question on. The Firmware install as Serial with RTD. This is a play Mega that has no Ethernet shield that I can do some testing with. I have built me a PCB with LEDS to see if the out comes on, I was testing the board and saw that Port 14 offers PWM where the Interface Wiring Map has only D, R. No P!
I also checked some others like Port 22 and it was offering Duty Cycle, PID and Hysteresis as well. Is this an error or is the end user (me) responsible to make sure that he chooses correctly for the Interface Wiring map?
Correct, you cannot assign the same name to multiple elements. Otherwise, a script would not know which element you are referring to.
I’ll need to check port 14 to see if it is supposed to support PWM. Duty Cycle, PID, and Hysteresis are Digital output types - they fall under ‘D’. The notes in the wiring map should state this, but if not we’ll make it clearer.
I got my Ethernet working! Time to switch the wiring and start scripting.!!!! 😀 😀 😀 😀 😀 😀
I did not quite understand the wiring map because of the BCS background. After re reading I get the following.
Most i/o can be Digital Out, Digital Input, Duty Cycle, Hysteresis, or PID. But Not true PWM. PIDs and Hysteresis should be on PWM Pins? Duty Cycle if period is minimal.
Regardless, I am going to assign my PID and Hysteresis to PWM Pins.
Should be doing a water test by next weekend! (at least Manual Control).