I am working on a project with n (n is approx 9 in this case) wood working tools in a woodshop where each of them has a vacuum hose to suck away the sawdust. There is a central vacuum where the pipes return to through a network and along this hose network there are m (is approx 7) blast gates that open/close and you pick the right combination of open/close to provide the vacuum suction to the tool in use. you then turn on the vac, turn on the tool and use it to cut/process the wood material.
We are using Sonoff S31 on the tools to detect the tool turning on; these send MQTT status into Node Red and so those events then trigger the need to activate servos on each blast gate to open/close them as needed.
So with n tools and m blast gates, there are nxm matrix that describes the gate config for the tools. Now, we are going to want to throw in some prioritization of tools, so if one is turned on when a higher priority tool is already on (some tools produce more dust than others) so that adds additional complexity and the network of nodes is going to grow and grow.
I was thinking there could be a node where the gates and tools are defined or we have some kind of parameter file that the flow opens and there must be some sort of ability to set up a generic event trap to detect any tool turning on (or off) and then take the process through based on a set of parameters for each of the n tools.
how would you go about this challenge?
While I'm no expert in such things, this sounds like a job for possibly a Finite State Machine. And there are certainly nodes that implement such a thing in node-red.
I am sure you do not need a matrix of nodes, I am confident it can be handled in a much better way.
You say there is a matrix of nxm for the gates against tools. Is that just a row for each tool and a column for each gate, with each entry indicating whether a gate should be open or closed?
You mentioned that some tools have higher priority that others, but apart from that can multiple tools be on at once? If so then how are the contents of the two rows in the matrix to be combined?
yea multiple tools can be on at once but its not typical. I am definitely going to start simple with a "last tool turned on" approach and ignore the fact that there might be other tools that are on, that would be super easy, but if i do want to progress into prioritization etc, that becomes trickier.
What is a good approach for keeping a config here? One thought that crossed my mind was to have the configuration saved as JSON objects in persistent MQTT messages. I could have a few nodes that i can manually trigger to write out the config, and read the config on start and load it in to arrays in NodeRed. Is that overkill - what other options are there?
While I agree you have, in theory, a matrix (9 X 9 or whatever)... it is more likely you actually have a 1:1 mapping between tool & waste gate. This assumes that you are not PHYSICALLY routing the hoses into a matrix. Why not set the control logic to active each waste-gate when you turn on each tool?
Prioritization / airflow is (almost) a separate issue: if there is not a low-enough vacuum then swarf will not be removed efficiently enough, leading to some clogging issues.
I'd add air-pressure meters (especially near the 'biggest' devices) and rely on them indicating an issue.
Other than that: turn on a tool - gate gets activated & vacuum gets activated. Turn off a tool - reverse.