10-10-2017 08:47 AM
Dear All
lets say i have 5 boolean inputs and one output.
i want to set output high if and only if all 5 boolean input be high in proper sequence like 1,2,3,4 and then 5.
i inputs do not high in this sequence, output should not be high.
i am having problem doing so.
please help
Thanks
Solved! Go to Solution.
10-10-2017 08:55 AM - edited 10-10-2017 08:55 AM
I would just set up a 5-element FIFO buffer (array), and an event structure that feeds the number of the clicked button into the buffer then compares the buffer value to an array that contains the 'correct' sequence.
10-11-2017 07:57 AM
There are so many ways to do this. Most scalable solutions require a array of input Booleans.
You don't mention if no True Boolean should result in a True or False... I'll assume it's true (all Booleans that are True are in order, even if there are none). Simply because it's easier for me... If at least one should be true, simply AND the result with the first input.
Then, for example:
1) Sort the array of Booleans and reverse. Compare input array with output array. If they match, the order was correct.
2) In a for loop, make a shift register and initialise it with true. Use a compound arithmetic node, with !A NAND B, A being the shift register, B the auto indexed array elements. If the result is false, stop the loop with it's conditional terminal. Output this value (set it to last value). It's true if the Booleans where in order, false if not.
3) Convert the array to number. Add one. Convert back to Boolean array. Convert to 0 or 1. Sub the elements If the result is <=1, the order was correct.
10-12-2017 06:45 AM
how can i set desire sequence of boolean and output should only be true when boolean input must match with set sequence.
Thanks
10-12-2017 06:47 AM
Compare the two?
10-12-2017 08:44 AM
yes.
10-12-2017 08:49 AM - edited 10-12-2017 08:54 AM
@Asif138 wrote:
i inputs do not high in this sequence, output should not be high.
I assume that these are switch action booleans, not latch.
Keep the last six states of all booleans in a 2D boolean array using a shift register.
Create an event for whenever one of the booleans changes, rotate the columns and replace the now oldest state in the first row with the current boolean set..
Compare the 2D array with an array constant containing the following 2D array.
T T T T T (newest of last six states)
T T T T F
T T T F F
T T F F F
T F F F F
F F F F F (oldest of last six states)
If the two arrays are equal, the booleans were switched on in the correct order.
Even easier would be to convert the five booleans into a number and keep a 1D boolean array with 6 elements in a shift register. Compare with the numeric array corresponding to the converted 6 rows above.
10-12-2017 09:08 AM
Asif138 wrote:lets say i have 5 boolean inputs and one output.
Can you maybe clear this up a bit?
I read this as: I have 5 Booleans coming in from somewhere, and want to validate them.
The other interpretation is that you want have an interactive situation, where Booleans are being clicked.
Although the solutions share some parts, for a correct answer it's not clear enough what you mean.
10-12-2017 09:16 AM
@altenbach wrote:
Even easier would be to convert the five booleans into a number and keep a 1D boolean array with 6 elements in a shift register. Compare with the numeric array corresponding to the converted 6 rows above.
Here's what I had in mind.
10-12-2017 09:36 AM
@Asif138 wrote:
yes.
"Compare the two" is the solution. Use Equal?, and right click and select Compare Aggregates. Output is True if the two arrays are equal.