06-04-2022 06:24 AM - edited 06-04-2022 06:27 AM
I wonder how to correctly implement a case change using the touch sensor of the EV3 robot. Unfortunately I don't have access to the VI file right now. So, I will explain what I want to achieve and hopefully you will understand it.
A case structure is contained in a while structure. This case structure has two cases: inactive and active. The initial case which is passed from outside the while loop is inactive. The current/next case is kept in a shift register.
So, what happens first is that the inactive case is executed in which the motors of the robot stop running using brake.
The touch sensor has three options: bumped, pressed and released. Bumped returns the value 1 for a short period of time if the touch sensor was pressed and then released. So, after stopping the motors, a wait-for-block waits for the bumped action and then the next case, the active case, is passed to the shift register on the right.
Now, we are in the active case. In this case a given power/speed is passed to the motors in order to move and simultaneously a check is performed, whether the touch sensor is bumped again. If the touch sensor is not bumped, the next case remains the active case by passing the active case to the shift register on the right.
If the touch sensor is bumped, then the next case is the inactive case by passing the inactive case to the shift register on the right, so that the touch sensor should enable switching between these two states. This is achieved using an if-statement.
But after entering the active case by bumping the touch sensor, the active case is immediately changed to inactive again. The only explanation I have is that the value stays 1 for a short period of time so that after switching to the active case, it is checked whether bumped returns 1 but the case change was so fast that in the active case the value 1 is again returned for bumped which results in an immediate case change.
I tried a lot and played with the different options pressed and released but I still did not solve this problem. Do you have any ideas how to correct this behavior?
I am sorry that I could not provide the VI and hope that the description gives you an overview of what I want to achieve. If not, please tell me so that I can add further information or draw the VI implementation since it contains only few blocks.