Logical And Function

It is surprising that despite all of the different solutions people have offered you in this thread you chose to install and use a node that was last updated nearly 7 years ago.
I have no idea if it is compatible with the current versions of Node-red or node.js.

Your best bet is to try the contrib node that @Colin, @E1cid and @craigcurtin recommended.
There is nothing more that I can do to help.
Untitled 4

[{"id":"c52af6352be3bd5a","type":"rbe","z":"39a6bd7ef2286e65","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"amp","x":870,"y":120,"wires":[["94a0724cdf7b7618","751c9164ba677e74"]]},{"id":"e67b914464cf267c","type":"rbe","z":"39a6bd7ef2286e65","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"arc","x":870,"y":180,"wires":[["6a0766367991330c","751c9164ba677e74"]]},{"id":"5bde12cc53890d7b","type":"debug","z":"39a6bd7ef2286e65","name":"event","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1230,"y":140,"wires":[]},{"id":"94a0724cdf7b7618","type":"debug","z":"39a6bd7ef2286e65","name":"amp event","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1050,"y":100,"wires":[]},{"id":"6a0766367991330c","type":"debug","z":"39a6bd7ef2286e65","name":"arc event","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1040,"y":260,"wires":[]},{"id":"88c986d802a6409f","type":"comment","z":"39a6bd7ef2286e65","name":"This Flow does not work as expected","info":"","x":360,"y":80,"wires":[]},{"id":"e34dd8125e221d9b","type":"comment","z":"39a6bd7ef2286e65","name":"And (2) Node always show unknown ","info":"","x":1120,"y":200,"wires":[]},{"id":"e9e99f5e61cfac23","type":"inject","z":"39a6bd7ef2286e65","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"805","payloadType":"num","x":90,"y":120,"wires":[["12dc3d72de43c2d1"]]},{"id":"fa2e0ad1bb87646a","type":"inject","z":"39a6bd7ef2286e65","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"795","payloadType":"num","x":90,"y":180,"wires":[["12dc3d72de43c2d1"]]},{"id":"44cdd53e0470dace","type":"inject","z":"39a6bd7ef2286e65","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":90,"y":260,"wires":[["aaa0b54c99a79c9f"]]},{"id":"8670cfd1422be895","type":"inject","z":"39a6bd7ef2286e65","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":90,"y":320,"wires":[["aaa0b54c99a79c9f"]]},{"id":"751c9164ba677e74","type":"BooleanLogic","z":"39a6bd7ef2286e65","name":"","operation":"AND","inputCount":2,"topic":"result","x":1060,"y":140,"wires":[["5bde12cc53890d7b"]]},{"id":"2ff476ad83936390","type":"group","z":"39a6bd7ef2286e65","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["f24d695a4931d365","ad27bef6115b4c61","aaa0b54c99a79c9f","12dc3d72de43c2d1","9b8a7de322bdd0b6"],"x":334,"y":79,"w":392,"h":242},{"id":"f24d695a4931d365","type":"change","z":"39a6bd7ef2286e65","g":"2ff476ad83936390","name":"True above 800 Amps","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"amp","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":120,"wires":[["c52af6352be3bd5a"]]},{"id":"ad27bef6115b4c61","type":"change","z":"39a6bd7ef2286e65","g":"2ff476ad83936390","name":"False below 800 Amps","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"amp","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":160,"wires":[["c52af6352be3bd5a"]]},{"id":"aaa0b54c99a79c9f","type":"change","z":"39a6bd7ef2286e65","g":"2ff476ad83936390","name":"Topic = arc","rules":[{"t":"set","p":"topic","pt":"msg","to":"arc","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":200,"wires":[["e67b914464cf267c"]]},{"id":"12dc3d72de43c2d1","type":"switch","z":"39a6bd7ef2286e65","g":"2ff476ad83936390","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"800","vt":"num"},{"t":"lt","v":"800","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":410,"y":120,"wires":[["f24d695a4931d365"],["ad27bef6115b4c61"]]},{"id":"9b8a7de322bdd0b6","type":"comment","z":"39a6bd7ef2286e65","g":"2ff476ad83936390","name":"See the nodes in the boxed area","info":"","x":530,"y":280,"wires":[]}]

Tell us which boolean node you are using (node-red-contrib-???).
Show us what you see in the amp and arc events debug.

It was a reply to HansZnarf

jbudd: Please excuse my ignorance about the age of the node I am trying to use. Being a nebie at Node-Red I have a lot to learn. My past programming experience involves logic blocks / nodes. Those I understand and the Node-Red nodes appear to work in some cases. I am not understanding the solutions being presented to me by others on the forum. If little more explanation will help. Would hope that others would gently assist people. Sorry to hear that I am frustrating others with my obvious lack of Node-Red experience.

Thanks: Will examine this code to see if I can understand how it works.

Colin: Have been told that the logic nodes I have been trying to use are very old. Is there a board or agency that can warn us when nodes may not be viable? The BOOL blocks work well in testing with inject node but for some reason they do not work when I applied them to live data.
Thanks, Hans

There is no problem with lack of knowledge. We all start out as beginners.

Pick one of the suggestions. node-red-contrib-boolean-logic-ultimate is a good starting point.
Try it.
Show us what you did and where you encountered difficulties.
People will help explain where you went wrong.

1 Like

Frida: This flow works flawlessly with the "antique" BOOL block that I understand. Your changes fixed my program. Many thanks for the team sticking with me through the process. Node-Red programming is a side project. Appreciate all the help.

Frida: Thanks - it did appear to be a data format issue between the 16Bit Split and the filter. Would you have the time to explain how the difference between msg.payload and msg.topic in the change node fixed the flow? If not can you provide a link to help me understand this difference?
Sincerely, Hans.

What is the name of your "16bit split", because I don't know it.
I'll try to explain. What comes out of "16bit split" is probably only true or false in the payload. (no topic).
What "node-red-contrib-boolean-logic" needs is a different topic for each input that comes to it.
Since you had no (topic) on any of your inputs, the logic node perceived it as 1 input.
Therefore, I added topic in the framed nodes so that the logic node could see 2 inputs. (amp and arc).
You had it right in your test further down the page.
Hope it can be used.

Poul Borg: That makes sense since the 16Bit Split node does not have a place to put in a topic for each bit.
I just do not understand the difference between msg.payload and msg.topic. Flow attached

flows (3).json (8.26 KB)

I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

1 Like

Colin:

Many thanks, will view and see what can be learned. Part of my issue is unlearning years of industrial / commercial programming systems and seeing how Node-Red does things.

Sincerely,

Hans

Learning new things is the spice of life! :sunglasses:

1 Like

Yes learning is fun

Let me see if I can put a spin on it. Node-RED is message flow programming, not ladder rung logic. While you can do the same things in either, the approach is different.

Messages can contain strings, boolean, multiple items, objects, arrays, structures, and you can add and subtract as well as modify any and all of the values as you pass the message from one node to another. "payload" , "topic", are only the comon elements of a message. A message can contain pretty much anything you want. These can be string, boolean, or any data type.

For boolean logic example, lets take this approach... lets construct a message with variables. Lets call them "IN 1" and "IN 2". on the first input "IN 1" = true, the next node input gets "IN 2" = false. Stop. The message has 2 values that it is carying. Logical inputs if you will. At this point you can evaluate the content of the message to AND,, OR, or whatever. If you cary 3, 4, 5 or many more at the point where you accumulate the values in your input variables, once you have the inputs all satisfied for your logical evaluation, you apply the programming to evaluate the variables. This can be with an expression in javascript in a function node, for example.

1 Like

I'd like to add to the comment earlier.

Rung logic represents "current state" always. That's what a PLC does. It constantly evaluates inputs, rung logic and the outputs.

In order to program or convert PLC logic into flow logic you must consider the overhead a PLC does by it's nature.

Message logic is ONLY when messages are passed. You can have a program run for years and some message paths will never run. So, you must check conditions in flow logic to ensure that you have valid states. You may need to force messages with defaults to initialize logic. And then, of course, a state change.

PLC programming, you need to consider what all your logic does at all times. then you also need to apply conditions to properly block evaluation to control unintended results. Message Flow programming does not need to consider what is NOT going on in time. You do not need to consider paths which are irrelevant, only those which are presently working to produce results. The logical thought process is completely different.

Consider your assumptions on how the machine works. Unknowns, and assumptions will get you every time.

For example timing is assumed Left to Right in PLC logic. This can cause issues how rungs are evaluated. Left to Right. Top to bottom. Allen Bradley vs. Modicon. Placement of rung logic elements in rungs before or after evaluation are critical depending on how rung logic is evaluated.

1 Like

hp-apcc: Many thanks for the detailed explanation. I have done some PLC programming during my career. My main background has been in 3 phase electrical power monitoring software with data HMI functions and Industrial / Large Commercial - Institutional lighting control systems.

What I am attempting in Node-Red is to mimic / mine data from Protective Relays / PLCs to make local Dashboards and move data around. All control will happen at the Hardware Level in the Relays / PLCs. Sometimes this requires simple logic to tie two events together to create an alarm.

In my example we need a high current and arc flash (light 50k lux) event to both occur before we alarm. The protective relay will do the work at the gear level. Node-Red will provide an HMI and/or push events to another application for humans to use.

The attached block (believe you wrote it) changes what goes into it into something the AND node can use. The concept is clear but how it works internally to do this is a bit foggy.

How subject / variable names are handled in Node-Red is something I am very weak in knowledge.

Thanks, Hans

MakeTopic.json (581 Bytes)

Have you watched the essentials videos I posted earlier?