EV3 basics course. Touch sensor. Non-intuitive, but logical (part 3)

The way sensors and programs work in a robotics system is sometimes not-intuitive for a beginner, but nevertheless very logical. Building a program for a touch sensors for "Press->Go->Press->Stop" using the EV3-G software could be quite challenging at the beginning even for experienced teachers, students and robot builders.

  • #140
  • 09 Oct 2015
  • 7:41

In the field of STEM many times the experiment shows not what we expect and the programs are behaving in strange ways. This is one of the simplest examples of this scenario. If you could understand this, you have made your first step into the field of technical science and STEM.

Previous video tutorials:

English

After we looked at the properties of the touch sensor and that we can press, release and bump the sensor. And that we can control different motors. Now I would like to enter into probably one of the most basic concepts in the field of robotics. And I'll first set the problem, then we'll do the program and then we would think about why is it happening like this. So actually the program is the following, we would like to program the robot to move when I touch - start, when I touch again - stop. That's the goal of our current program.

Let's look at the program. We would like to program the robot to do the following thing. First, we wait until we press the sensor, attached to port 1, then we start moving the robot not with the steering I would like to move it with the Tank block. So, I wait until we press the touch sensor, then we start moving the robot, but we move this for undefined amount of time, so it's just on and we move, then we wait again until we press the sensor again. So it's touch sensor, state, and the state is 1. This is how the program should work. First, we press, then we start, we move, then when we press again, the robot stops. And here I'll add a stop block.

We add a stop block here. And that's the program. Let's see how the program works. Downloading the program. Download. We wait until the sensor is pressed and we go forward. Nothing happens. Let's download the program again.

What is happening here is that the program is not behaving as we would expect. Something is happening and understanding this is crucial for you. To know why the program doesn't work and what happens in the program. Again. Nothing happens. The robot is not moving forward. Let's take a look back at the program. What is actually happening here is the following. We wait until the sensor is pressed, we start the motors and then we wait until the sensor is pressed again and then we stop. But while we are pressing the sensor and we enter into this block we detect that the sensor is pressed, we start the motors and before we lift our finger from the sensor the next wait block detects that the sensor is again pressed. The brick is so fast that this happens in milliseconds. We start the motor only for a number of milliseconds and we haven't removed our finger from the sensor, so it stays stopped. Again what happens, we press and we start the motors, but before we lift our finger from the sensor the next block detects that we have pressed the sensor and stops the motors. How do we fix this. There are a number of solutions. The easiest solution is the following. To wait for let's say one second. So we press we wait for one second so that we can lift our finger from the sensor then we start the motors, then we wait again until we press the sensor and then we stop. Let's check the program. Start, the program's running, I'll now press the sensor wait for a second the robot moves and when it reaches my hand it stops. Let's start the program again. Touch the sensor, wait for a second, move, stop. So it's working as expected. Can we fix this in another way so that we don't have to wait for a second?

We are losing one second here. We don't have to wait for a second. Let's see a solution. What if we don't wait for a second, how can we implement this? We delete the block and what we would like to do is to wait for the touch sensor to move from pressed to released. We add another block, we wait until the touch sensor is in the state - released.

Let's see the program now. First we wait until the touch sensor is pressed, then we wait until the touch sensor is released, the moment we release the touch sensor is released we start the motor, so there's no delay for a second,

then we move with the motors until we press the sensor again and we stop both motors. Let's check the program. Download. Run. Here's the robot, now I press, then we wait for a releasing of the sensor the robot moves forward, until we press again.

this is how, the robot should be working and this was the goal of our video. To program this sensor so that we can press, release, move, than press release and stop. I know that this behavior might be little strange, but it's perfectly logical. If you have any questions or suggestions for how we can explain it even clearly leave a comment below and we'll try to do it. In the next video we'll enter in more details for the touch sensor. Then we'll use the knowledge of the touch sensor to introduce the other sensors in the EV3 set.

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for EV3 Basic Course. Introduction to robot programming, construction and sensor use
  • 38
  • 193:26
  • 30
Image for Touch Sensor
  • 4
  • 0
  • 4
  • 3d_rotation 0
Image for Instructors Remote Training
  • 136
  • 280:11
  • 156
Image for Touch Sensor Theory and Practice
  • 3
  • 0
  • 0
  • 3d_rotation 0
Image for Instructors Remote Training
  • 136
  • 280:11
  • 156
Image for Touch Sensor
  • 6
  • 0
  • 6
  • 3d_rotation 0