EV3 basics course. Programming motor from EV3-G on the computer (part 4)

First time programming the motors of the robot using the EV3-G software installed on a computer. We would explore how to move forward/backward and turn with the robot.

  • #131
  • 30 Sep 2015
  • 11:32

Find more videos about programming searching for "Programming". 

English

After we've learned that we can program the robot from the brick, now it's time for us to go and check out the software. Now, these bricks, they can be programmed in many different languages and LEGO provided an environment that's suitable for students at all ages and that's a very interesting environment it's called EV3G. It's EV3 graphic so it's a programming language. For you to program this brick with the computer you need an USB cable. So we need the USB cable and we connect the USB cable right here on the PC port or we can use a Bluetooth connection, so it depends on what you have. Do you have Bluetooth connection or you need to use the USB cable and most of the time I prefer to use the USB cable. Let's have a look at the program.

In the previous video we built an EV3 robot called The Easy Robot, The Easy Bot and we stopped at programming with the EV3 software. This here is the EV3 software, you start the program and you get this screen open. And on this screen you develop the program for the robot. The goal is to give certain instructions to the robot that will be executed in an order and this is how the robot actually is programmed and how it behaves, so you give instructions then you start the program and the instructions are executed. Now, this here is very powerful and very interesting graphic environment and in this graphic environment you don't program the robot using the keyboard and typing some kind of code, you do this with blocks but it is again a very complete programming language and you'll see in the next couple of videos that you can do very complex things with this environment. In the EV3G software you have the main screen and you have here a palate a palate with different properties and different blocks and some of you that've used the previous NXT version might find this a little different from the NXT. For those of you that are only using the EV3 version of the MINDSTORMS sets, you won't have any difficulties because you don't have any legacy from NXT. Now in the software what we would like to do today is to stop just at moving the robot. Just at controlling some of the motors. How do we control the motors, we have different blocks and we drag and drop these blocks in the program Like this and these are different blocks for moving Now as you may see some of the blocks have different color For example, this one here this is because currently this block is not part of the program in order to add this block as part of the program you must attach it to the main line of the program. Like this Ok, you can delete with the delete key if you make a mistake and what I want t do now is to program the robot, especially port D and I would like to move the motor that's on port D and I'll take one of these blocks Large motor and in this block I can configure several things For example, I can configure which port am I controlling which means actually which motor because I have the two motors connected on port A and port D and I can say that I would like to control the motor on port D, that is the first thing. Next thing is what would you like the motor to do. Currently I would like the motor to rotate forward so I'm rotating the motor forward with a certain power and this power is a percentage, so the motors have minimal power: 0 and a maximum power: 100 and this here is actually the percentage of the maximum power I would like this motor to move with 50% of it's power and I would like this motor to move for one rotation so rotate the motor only once, not the robot, but the motor the motor will rotate once and the third property is what would you like the motor to do when the motor stops would you like the motor to stop exactly after one rotation or this here is the break option or we would like the motor to coast so this means it will have some inertia and it will continue we'll see different options Let's leave this to break now. And now as we have the first instruction we must run it on the robot and see if it works. How do we run this block We have a few options right here down in the corner, the lower right corner we can Download the program to the robot or we can Download and run the program or we can just Run selected. The option that I'll use is download and run. I'll now switch the camera and we'll download the program to the robot.

This here is the robot, it's connected with the USB cable to the laptop and let's now download and run the program

Let's do this again. Download and run What you can see is that motor D it's this one here motor D connected to port D. This motor rotates for one rotation. One full rotation of the motor and that's different from one full rotation of the robot. One full rotation of the motor will take us - here and in order to make a full rotation with the robot we need to continue rotating the motor. So probably for, I don't know, 3 or 5 rotations. So this will be one full rotation of the robot and one full rotation of the motor is just this.

OK, let's try to add additional blocks to our program. Other thing that we can do in our program is of course to control other motors. For example, let's also include motor A and I'll again use a Large motor and I'll configure it to rotate motor A and I'll like motor A to rotate for one rotation again but this time I would like motor A to rotate in reversed direction. So by adding minus to the power we rotate the motor in reverse.

Let's see how the program goes. And now downloading and running the program.

Again, let's see what happens.

First move with motor D and we move forward and then we move with motor A and we move backward. Again. Both of the motors are moving for one rotation and it's one rotation of the motor not the robot. How can we do this but let's move the motors simultaneously In this program both blocks are executed one after the other so we first have motor D and then motor A. Now I would like to move both motors simultaneously. So while moving motor D also to move motor A and there are a couple of solutions. First, there's another block called Move Tank and this block gives us the following options, we can I'll delete this one, no I won't I'll leave them here so that we can have them as a solution.

This block is Move Tank and we can control OK we want to move the first motor, motor A forward with power 50 and the second motor D backward with the power of 50, -50 and let's do this for 2 rotations and this will move A and D simultaneously. Let's check this.

Now I download and run the program.

And we see that the robot moves with motor A and motor D and motor A is moving forward and motor D is moving backward Again.

Both motors are moving for 2 rotations and very important these are rotations of the motor, these are not rotations of the robot. Of course, there are many more things we can do with moving the motors and we'll explore them in the next video.