So I’m doing a simple elevator project where there are two buttons on every floor for going up and down. So I have created a case structure to handle the states of the elevator: moving up, down and the waiting state.
The problem is that if I simply place the structure ( together with the event structure that handles the pressing of the buttons ) inside a while loop, the results I get is very bizarre: it does nothing unless I press at least a couple buttons to call the elevator, it doesn’t execute but the third one in the queue ( or actually the array where I store the floors) and it doesn’t delete the processed floors either.
Now I placed the structure inside another while loop and it works just fine, however it only executes the first elements of the array( one button from where the elevator was called and one destination floor) and then it is stuck in the waiting state even if the array is being filled. I believe it it because the shift registers inside the inner while loop take the version of the array from the last iteration and dont update it from the event structure. So I thought I could somehow reset the inner while loop if the elevator is waiting for more than a couple seconds. How could I do that ? Or is there anything else I can do?
Here is the block diagram (https://i.sstatic.net/YjHJmEGx.png)](https://i.sstatic.net/pz1ERaIf.png)
I tried adding some sort of timer to stop the inner loop after a couple seconds of being in the waiting state but I realize now it’s gonna stop it and not restart it. Besides it once again behaved incredibly weird it broke my floors system, as the elevator was now going to negative levels
Ana Ci is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.