Assistance with logic for flow, please. :)

Hey everyone,
I was hoping to get some direction on how to create this logical flow in NR. It's a system with 2 binary inputs and a camera for still image capture. I have the image capture stuff working already and the input monitoring is already set up and in-use in a much more simple setup than what I'd ultimately like to achieve.
These are the two sequences I'm hoping to create in NR.

Sequence 1:
Input_A goes low -> start frame capture, every 3 seconds until Input_A goes high AND (Input_B is high for 3 seconds OR 20 seconds passes without Input_B going high).
Send images in notification.

Sequence 2:
Input_B goes high -> start frame capture, every 1 seconds until Input_A goes low, then every 3 seconds until Input_A goes high, then 2 more frames.
Send images in notification unless Input_A doesn't go low within 60 seconds -> discard images. (false trigger)

Any examples would be greatly appreciated!

All the best,
Dax.

It might encourage involvement if you show what you already have that works, and explain what you have tried that may not have worked, so as to better understand your question.

Maybe re-word that.

My take:
When Input_A goes low:
capture a frame every 3 seconds until Input_A goes high AND - then it all falls over.

Maybe a Truth table? If possible.

It is just you haven't shown all the other options.
What happens if they aren't met?

Just I feel that without knowing that: it is difficult to work out what you actually want/need.

I'll try it this way:

Once started - taking pictures ever 3 seconds:
Continue until: either Input_A is high AND either Input_B is high for 3 seconds OR 20 seconds passes by.
No need to mention Input_B condition. That only confused silly people like me.

Maybe better worded like this:
(Once started)
continue until:
for 20 seconds OR
Input_A goes hight AND Input_B is hight for >3 seconds

To me that is clearer.

Hey Gunner and Andrew,
Thanks for your replies. The problem is that I don't even know how to start this. The very first 'gate' is actually two choices: Input_A goes low, triggering sequence 1 or Input_B goes high, triggering sequence 2. Once one of those sequences has started, it must follow to the end (which could be the time-out)

These inputs are switches (NC and NO) on GPIO pins.

Does that help at all?

Cheers,
Dax.

How about this?

It is the best I can work out from your description.

[{"id":"9ee519c1.fc7f88","type":"inject","z":"3a01457a.3b59aa","name":"HIGH","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":170,"y":120,"wires":[["9e110a.d1807ef8"]]},{"id":"4851b0f0.7a7488","type":"inject","z":"3a01457a.3b59aa","name":"LOW","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":170,"y":160,"wires":[["9e110a.d1807ef8"]]},{"id":"bb97be99.aa5a8","type":"comment","z":"3a01457a.3b59aa","name":"Input A","info":"","x":160,"y":80,"wires":[]},{"id":"13888054.c319d","type":"inject","z":"3a01457a.3b59aa","name":"HIGH","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":170,"y":280,"wires":[["d47c6d90.701708"]]},{"id":"7a94ae8.ca2245","type":"inject","z":"3a01457a.3b59aa","name":"LOW","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":170,"y":320,"wires":[["d47c6d90.701708"]]},{"id":"9822aad7.d67788","type":"comment","z":"3a01457a.3b59aa","name":"Input B","info":"","x":160,"y":240,"wires":[]},{"id":"9e110a.d1807ef8","type":"switch","z":"3a01457a.3b59aa","name":"LOW?","property":"payload","propertyType":"msg","rules":[{"t":"false"},{"t":"true"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":140,"wires":[["495a8a95.48b55c","662cb4cb.26804c"],["fc41e5b6.40aa68"]]},{"id":"495a8a95.48b55c","type":"change","z":"3a01457a.3b59aa","name":"Start","rules":[{"t":"set","p":"payload","pt":"msg","to":"start","tot":"str"},{"t":"set","p":"A","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":100,"wires":[["a828ad32.a7cc9"]]},{"id":"a828ad32.a7cc9","type":"trigger","z":"3a01457a.3b59aa","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"-3","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":710,"y":100,"wires":[["9efdb5c8.acf3b8"]]},{"id":"3536f3e9.72958c","type":"trigger","z":"3a01457a.3b59aa","name":"","op1":"","op2":"RESET","op1type":"nul","op2type":"str","duration":"3","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":500,"y":270,"wires":[["d6467993.2bb5a8"]]},{"id":"d47c6d90.701708","type":"switch","z":"3a01457a.3b59aa","name":"High?","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":360,"y":300,"wires":[["3536f3e9.72958c"],["f712364.4c25a48"]]},{"id":"9efdb5c8.acf3b8","type":"debug","z":"3a01457a.3b59aa","name":"What you want?","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":100,"wires":[]},{"id":"372f3154.7bbd96","type":"change","z":"3a01457a.3b59aa","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":220,"wires":[["a828ad32.a7cc9"]]},{"id":"f712364.4c25a48","type":"change","z":"3a01457a.3b59aa","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":320,"wires":[["3536f3e9.72958c"]]},{"id":"d6467993.2bb5a8","type":"switch","z":"3a01457a.3b59aa","name":"A True?","property":"A","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":650,"y":270,"wires":[["372f3154.7bbd96"]]},{"id":"fc41e5b6.40aa68","type":"change","z":"3a01457a.3b59aa","name":"","rules":[{"t":"set","p":"A","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":180,"wires":[[]]},{"id":"662cb4cb.26804c","type":"trigger","z":"3a01457a.3b59aa","name":"","op1":"","op2":"TIMEOUT","op1type":"nul","op2type":"str","duration":"20","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":450,"y":220,"wires":[["372f3154.7bbd96"]]}]

Have a look at the Ultimate Boolean nodes - i think they might help here for what you are trying to achieve.

Craig

Does this achieve your Sequence 1?

[{"id":"d00ece9ff8864fe0","type":"group","z":"c5b102c3ffa0250d","name":"Input A low - start capturing for 20s.","style":{"label":true},"nodes":["97954d8e600b218d","3ba14277e31ea3c3","6afc4fe6aee82864","8e3c2228fc93aa9b","383f69ddb8a3eb80","13eb537361594c82","8b4efc3ec3c93845"],"x":14,"y":19,"w":952,"h":162},{"id":"97954d8e600b218d","type":"rpi-gpio in","z":"c5b102c3ffa0250d","g":"d00ece9ff8864fe0","name":"input A","pin":"11","intype":"tri","debounce":"25","read":false,"x":90,"y":60,"wires":[["6afc4fe6aee82864"]]},{"id":"3ba14277e31ea3c3","type":"trigger","z":"c5b102c3ffa0250d","g":"d00ece9ff8864fe0","name":"","op1":"GO","op2":"STOP","op1type":"str","op2type":"str","duration":"20","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":610,"y":60,"wires":[["8e3c2228fc93aa9b"]]},{"id":"6afc4fe6aee82864","type":"switch","z":"c5b102c3ffa0250d","g":"d00ece9ff8864fe0","name":"Low?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":260,"y":60,"wires":[["3ba14277e31ea3c3"]]},{"id":"8e3c2228fc93aa9b","type":"debug","z":"c5b102c3ffa0250d","g":"d00ece9ff8864fe0","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":850,"y":60,"wires":[]},{"id":"383f69ddb8a3eb80","type":"inject","z":"c5b102c3ffa0250d","g":"d00ece9ff8864fe0","name":"Test (0)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":110,"y":100,"wires":[["6afc4fe6aee82864"]]},{"id":"13eb537361594c82","type":"inject","z":"c5b102c3ffa0250d","g":"d00ece9ff8864fe0","name":"Test (1)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":110,"y":140,"wires":[["6afc4fe6aee82864"]]},{"id":"8b4efc3ec3c93845","type":"change","z":"c5b102c3ffa0250d","g":"d00ece9ff8864fe0","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":140,"wires":[["3ba14277e31ea3c3"]]},{"id":"d40c41ec3ba7eac3","type":"group","z":"c5b102c3ffa0250d","name":"Input B high for 3s: stop capture and cancel 20s countdown","style":{"label":true},"nodes":["a7ea1960f76d12e0","43d32d413f9a1b26","fe6b4ce53413e7e8","673c988711b7533b","d39d90269b43ecdc","5217aeaedbbfbadb"],"x":14,"y":199,"w":692,"h":162},{"id":"a7ea1960f76d12e0","type":"rpi-gpio in","z":"c5b102c3ffa0250d","g":"d40c41ec3ba7eac3","name":"input B","pin":"13","intype":"tri","debounce":"25","read":false,"x":90,"y":240,"wires":[["fe6b4ce53413e7e8"]]},{"id":"43d32d413f9a1b26","type":"trigger","z":"c5b102c3ffa0250d","g":"d40c41ec3ba7eac3","name":"","op1":"","op2":"STOP","op1type":"nul","op2type":"str","duration":"3","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":620,"y":240,"wires":[["8e3c2228fc93aa9b","8b4efc3ec3c93845"]]},{"id":"fe6b4ce53413e7e8","type":"switch","z":"c5b102c3ffa0250d","g":"d40c41ec3ba7eac3","name":"High?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":270,"y":240,"wires":[["43d32d413f9a1b26"],["5217aeaedbbfbadb"]]},{"id":"673c988711b7533b","type":"inject","z":"c5b102c3ffa0250d","g":"d40c41ec3ba7eac3","name":"Test (0)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":110,"y":280,"wires":[["fe6b4ce53413e7e8"]]},{"id":"d39d90269b43ecdc","type":"inject","z":"c5b102c3ffa0250d","g":"d40c41ec3ba7eac3","name":"Test (1)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":110,"y":320,"wires":[["fe6b4ce53413e7e8"]]},{"id":"5217aeaedbbfbadb","type":"change","z":"c5b102c3ffa0250d","g":"d40c41ec3ba7eac3","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":260,"wires":[["43d32d413f9a1b26"]]}]

Hey everyone, sorry for the super slow reply, we have a newborn at home, so it's been hard to find a moment to go through these proposed solutions.

I want to sit down and go through them properly so I can a) solve the problem and b) learn from these examples.

@Trying_to_learn and @jbudd, thank you both so much for your time to help me with this.

@craigcurtin, ahh! Those nodes looks awesome. I just read the descriptions; they sound like something I will use a lot. Thank you!!

Speak soon! :smiley:
-Dax.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.