07-02-2021 02:18 AM
Hi and thank you for your time and help in advance.
I have a system that consists of two connected aquarium tanks (tank A and tank B) with two lasers between them. When the fish goes from e.g. tank A to tank B it will trigger laser B last and my system will let me know that the fish has chosen to go into another tank. However, I would like to add a function that delays my system so that when the fish goes from tank A to tank B, the system will not register it until 10 sec after it has triggered laser B, and if the fish within that 10 sec goes back into the tank A from tank B, i.e., triggers laser A last, nothing will have happened.
I have tried many different combinations with an elapsed time VI and shift registers. But I can't make it work.
See the attached VI below.
07-02-2021 02:39 AM
I apologize, uploaded the wrong file, here is the correct one. This is as far as I have gotten. And just to clarify: when the fish goes from tank A to tank B I want the system to still think it's in tank A and switch only when 10 seconds have passed. There cannot be a period where the system does not "know" where the fish is.
07-02-2021 07:26 AM
Due also to an incoming headache, I'm unable to follow your code in all boolean manipulations. Plus, I never used the Elapsed Time express vi so I'm not familiar with it.
I attach two working versions. The first uses boolean as well, but mainly with Case Structures. Not elegant, indeed, but it works.
However, if we go beyond booleans and use a threefold state machine, the code becomes much more simpler and easy to read and maintain.
07-02-2021 02:21 PM
Thank you so much!
I am not to experienced with state machines but am starting to learn and yours make a lot of sense. However, I need it to be continues thing where the fish can keep going back and forth between A and B and every time it changes tank there needs to be that delay/wait until it actually registers it in the opposite tank. Would that just mean I add an additional state that says from B to A?
07-02-2021 05:53 PM
It would be polite to give a link to the code template you were using, especially since I wrote it. 😄
07-02-2021 06:20 PM - edited 07-02-2021 06:21 PM
Here's a quick modification that can hopefully give you some ideas. Modify as needed.
07-03-2021 10:57 AM
@Math808 ha scritto:
Thank you so much!
I am not to experienced with state machines but am starting to learn and yours make a lot of sense. However, I need it to be continues thing where the fish can keep going back and forth between A and B and every time it changes tank there needs to be that delay/wait until it actually registers it in the opposite tank. Would that just mean I add an additional state that says from B to A?
Yes, you can add a state "B to A" which is the symmetrical of "A to B".