Bài 2: Lập trình robot giáo dục KC-Bot di chuyển

Kidscode STEM
12 người theo dõi
252 Lượt xem video·21 thg 11, 2023
---------- ★ ----------
* Website: http://kidscode.edu.vn/
* Email: [email protected]
* Hotline: 0888 424 222.
---------- ★ ----------
Our topic is STEM Robots and Autonomous Vehicles.
In the previous lecture, we discussed the goals of science as well as the content of science and the tools.
We also finished the first lesson, which is a summary of the field of robots.
Today, we will move on to the second lesson, which is mobile robots.
From our point of view, a robot is like a self-driving electric vehicle in 4.0.
We will teach robots step by step.
It is a self-driving electric vehicle.
In the first step, we need to program the robot to be able to move.
As Nona said, robots are starting to learn how to run.
This is the first lesson.
In this lesson, we will learn two main parts.
First, we will learn the knowledge related to engines.
Second, we will carry out the program to control the mobile robot.
As you already know,
humans have long been able to use simple mechanisms such as cables,
rotating cables, or circular circuits
to transform the energy of humans or nature into different modes of life.
For example, this is an example of a circular circuit.
Through the development of technology, we have developed engines.
I would like to give some general concepts.
For example, an engine is a device that transforms a type of energy,
either natural or man-made, into a motor.
That is the general concept of an engine.
Another concept is an electric motor.
An electric motor transforms energy into a motor.
In our lesson, we also limit the range of electric motors.
As you know, besides electric motors, there are also other types of fuel engines.
Engines have many different applications in everyday life.
It can be said that almost everywhere there is automation, we all need engines.
For example, in electronics, CNC machines, robots, or cutting machines.
I would like to show you a picture of Boston Dynamics,
a company that specializes in robot manufacturing since 2005.
Its current number is 28.
They are manufacturing many different types of robots to serve many different fields.
There are also military-service robots such as Wildcat or Atlas.
First of all, let's take a look at some of its applications.
This is a presentation by V&A Express about the equipment we need.
What you see on the screen is a CNC machine manufactured by my department.
This machine uses a high-performance version.
Some universities around the world have also shared it.
You can see the engine right away, right?
The engine is flashing.
This is to create pressure for us to push air into our lungs.
This is a very timely news.
In addition, as you may know, there are some other applications.
For example, in the automatic door.
When we step near a door, the engine will automatically open.
The sensor detects that someone is approaching and the engine will open for us.
In general, an automated system, we only need a sensor and an engine.
We already have the automation of the machine.
I would like to continue with the slides.
As you can see on the screen, there are many types of engines.
In the field of electric engines, we already have many types.
The first is the rotary engine.
The next is the one-axis engine.
In the one-axis engine, we have the non-propellant engine, the stepper engine, and the reverse engine.
The reverse engine is an engine that can run one-axis electricity and one-axis rotary electricity.
The next is the servo engine.
We also have many different applications of this engine.
I would like to go deeper into the application of this engine.
The purpose of this engine is to create robots.
These are the engines we use to create robots.
You can see a yellow engine here, right?
This is the one-axis engine.
There is a tooth inside. I will analyze it later.
The next is the servo engine.
These are the images of the engines we use.
Let's go deeper into an engine.
If you have a robot, you can observe it.
This is the engine.
Its name is not unified.
If you search Google, you can use the keywords GNO, Gear, Motor.
It is an engine with a yellow tooth.
This is its technical parameters.
The operating voltage is from 3 to 9V.
But the best operation is about 6 to 8V.
Zero discharge is about 70mA.
Max is 250mA when discharged.
The transfer rate is 1 divided by 48.
With this engine, when the voltage is 3V, it can have a speed of 125 revolutions per minute.
With 5V, it is about 208 revolutions per minute.
We can attach it to a 65mm diameter wheel.
It has a pulling force of 0.5kg per cm.
This is the outer diameter.
The diameter is 22mm.
The length is 17mm.
The height is 28mm from the ground.
This is the image of the engine.
If you have the conditions, you can see it.
There are 2 parts inside.
The first part is a DC motor.
The second part is a gear.
Attaching a DC motor to this gear will slow down the speed of this engine.
But it will increase the power for us.
If we don't have this gear,
we will not be able to run the robot.
With 2 parts like this,
we will see the principle of operation of each part.
The first principle is the principle of operation of a 1-axis motor.
You have learned it in the program.
But I also want to share a video that is very beautiful and easy to watch.
You can watch it on YouTube.
The key word is DC motor.
The armature, which is the rotating part, is a simple coil.
The armature is connected to a DC power source through a pair of commutator rings.
When the current flows through the coil,
an electromagnetic force is induced on it according to the Lorentz law.
So the coil will start to rotate.
You will notice that as the coil rotates,
the commutator rings connect with the power source of opposite polarity.
As a result, on the left side of the coil,
the electricity will always flow away.
And on the right side, electricity will always flow towards.
This ensures that the torque action is also in the same direction throughout the motion,
so the coil will continue rotating.
But if you observe the torque action on the coil closely,
you will notice that when the coil is nearly perpendicular to the magnetic flux,
the torque action nears zero.
As a result, there will be irregular motion of the rotor.
If you run such a DC motor.
Here is the trick to overcoming this problem.
Add one more loop to the rotor with a separate commutator pair for it.
In this arrangement, when the first loop is in the vertical position,
the second loop will be connected to the power source.
So a motive force is always present in the system.
Moreover, the more such loops, the smoother will be the motor rotation.
In a practical motor, moreover,
there will be an electric current flowing through the rotor.
And this electric current under the magnetic flux will rotate the rotor.
In terms of technology, people have added more loops
so that the motor can run smoother.
This is a basic principle of a 1-axis motor.
This 1-axis motor is then attached to the gear
so that we have a yellow motor.
I call it the yellow motor of the gear.
Let's go back to the slide.
And depending on the speed of the gears on this gear,
how much the speed of the motor will decrease and how much it will increase.
We can also watch a short video about the inside of the motor
that we use in our robot today.
You and I can test the gears to calculate the speed of the gear.
And we can also adjust the speed of the motor.
You can see more in this video.
So we will conclude that the motor we use in our robot
is a speed reduction motor.
It is different from the 1-axis motor where it has more gears.
The 1-axis motor is usually called DC motor.
And our motor is called yellow gear motor.
Now, let's move on to the 2nd part,
which is the operation of this motor.
You and I will open the computer
and we will open two softwares,
Qiskode and Proteon.
You and I will download our lesson file today
on the class room.
Phuong is downloading this file on the class room.
While Phuong is downloading the file,
we will simulate this motor first.
Later, we will go to the class room to download the file.
Here, I have already opened the Proteus software.
To get this motor in Proteus,
you can press the P key.
P means Pick.
Pick the motor.
We press and hold the P key.
As you can see here,
there is the word Picks Devices.
And we have the word Motor.
You and I can see Simple DC Motor.
Here is Step Motor.
There are many types.
Here we use Simple DC Motor.
You can double click.
It will open the window.
Like this.
The first step for any programming class,
we need to find the object we want to program.
Today, our object is a 1-way motor
or a motor with wheels.
Its operation is the same.
It's just different in power and speed.
As you can see here,
a motor has two legs.
If we connect the power to it,
it will rotate.
If you have a circuit,
you can get the power right on this circuit.
This is VCC.
However, in this class room,
it does not have a power cord.
Instead, I will get a power source
on the side.
As you can see,
right where I move here,
it's called Terminal Mode.
We click it.
We will see Power and Ground.
We will take these two signals out.
I took it before.
Next is Ground.
We take it out.
We haven't programmed anything yet.
We will supply the motor.
We press the Play key here.
Or press the F12 key.
I will press F12 to run the simulation.
We see the motor is rotating.
What happens when we connect the motor
to a circuit like the image below?
The image below is the image
that we will plug into the motor.
It's actually like this.
One leg will go in.
One leg in 3V, right?
And one leg in 5V.
In this simulation, we don't have it.
So I replaced the 5V with this one
with these two sources.
Like this.
And we observe the phenomenon.
If we plug in the source like this,
the motor rotates, right?
At least it rotates.
Let's go back to the question.
Most of you choose the rotating motor.
I would like to answer.
How does it rotate?
It's entirely due to these two legs.
These two legs are facing each other.
That is, it does not distinguish between
one direction and the other.
If we connect the wires in the opposite direction,
what will happen to the motor?
It will rotate in the opposite direction.
At first, we don't know which leg is
the left leg and which leg is the right leg.
When we plug in a motor,
we plug in those two legs.
The correct answer is that the motor rotates.
We don't know which direction it goes in.
If we plug in a motor like this,
it rotates in the opposite direction.
If we plug in a motor like this,
it rotates in the opposite direction.
So the correct answer is that the motor rotates.
Similarly, I will look at the second question.
What happens when the position is changed?
The motor rotates in the opposite direction
when the position or wire of the motor is changed.
As I explained,
and as you can see on the imitation,
if the motor does not rotate,
it will not rotate in the opposite direction.
The nature of the motor is a wire.
So when the power is turned on,
a current will flow through that wire.
If we change the direction of the current,
the current will flow in the opposite direction.
We will see that the motor rotates in one direction.
The correct answer is that the motor rotates in the opposite direction
when the position or wire of the motor is changed.
The third question is how to increase the speed of rotation?
Most of us answer by increasing the power supply of the motor.
There are 3 answers to this question.
Actually, I just came up with this question to have enough answers,
so I didn't expect you to choose it.
In fact, we just need to increase the power for the engine.
Let's try to see if we can increase the power in one room.
We stop here.
We will double click here.
We write 12V.
It seems to run faster by eye, right?
If you don't believe me, we will try to reduce it.
We add 3V.
As you can see, the engine runs very slowly, right?
Reduce it.
So our answer is,
according to the simulation,
and it is probably true in reality,
if we want to increase the engine speed,
we will increase the power for the engine.
And so, through the 3 previous questions,
the whole class has understood the principle of controlling this engine.
The two legs of the engine are not polar.
When we supply power to the engine,
the engine will rotate in a certain direction.
And when we turn the two wires of the engine,
the engine will rotate backwards.
And to increase the engine speed,
we will increase the power for the engine.
Those are the things that make up the conclusion of the first experiment.
And now we will move on to the second part.
With the first part,
we have understood the nature of the engine.
Now we will move on to the second part,
which is the simulation to control the engine.
If you can't keep up with this speed,
maybe if we observe, that's it.
Then we will discuss.
I will also do it in detail for everyone to see.
Let's open the Qiskode software.
You will click on this file here.
It's called Component Mode,
which is to switch to the mode, look at the files.
I always say that the software rotates a little bit.
This is the instrument panel.
You can see, for example,
here we can switch to the position,
that is, Selection Mode,
so we can choose the object.
We can pull.
The second choice is Component Mode,
which is the component mode.
Here you will see the motor,
a transtor, a loader,
a stem education.
You take this stem education board out,
and I will turn off the stem board.
The stem board we put here.
We take 2 engines,
to fight like this.
I will do it again from the beginning to make it easier.
Take the engine.
The principle of the block,
this is a block called the engine control block.
But in our workshop, we have to do it,
so this engine just runs.
So the whole class just needs to understand that
to control this engine,
if outside the frame,
we just have to fight like this,
from the motor M1 here.
We fight straight into this engine.
Leg M2.
We also fight straight into the other leg of the engine.
However, in the workshop,
we have to make a block,
called a block like this.
Its principle is still the same.
You can see this is In A,
and this is AO1,
and this is another leg,
and AO2, B1, B2,
respectively.
Instead of fighting straight into the engine,
now we fight like this.
M1, leg number 7,
we fight into In A1.
M2, M1, leg number 2,
we fight into BWMI.
Leg out,
we fight into the engine.
This is the end of our simulation.
Now we will proceed with the program, right?
In the program, we will go to the KISCO software.
In the KISCO software,
there are many different components,
and we do it step by step,
so we will explore more.
Here we are working with the Kasebot robot,
so we will choose Kasebot.
We will choose the starting block,
between control and scroll
to make this block bigger.
There is the first command here,
which is to install the M1 engine,
temperature 100.
Depending on the block,
the M1 engine will also respond.
At the moment, we are only controlling the M1 engine.
After we have completed this program,
we want to create a hack, right?
At the beginning, you asked me.
You just need to click here.
Click on the letter V,
which is the name of the program.
Click here.
The essence of this program is
to check the old code of the program,
and if there is no code,
it will create a file at the beginning
called the hack file.
The hack file is the extension of the hash file,
which is the 16th column.
Because the essence of this file
contains all the numbers 010101
and this file is shown
as the 16th column.
After you click on this
and it shows that the program is successful,
we will have some ways
to get the hack file.
The first way,
you go to the main page
and search for the hack file.
You have to edit it first,
then you can search for it.
For example, I will search for it
on a screen.
For example, I set it
as the engine name.
I will turn off the engine name.
mt1
search
After we have edited
the hack file,
we will move on to the imitation part.
We scroll down
to zoom in
and zoom out
to zoom out.
You can see here
the program file,
which is the program guide.
We will click here
and we will find the screen
to find the task we just created,
which is mt.
We double click on it.
OK
Click here
and press F12
Oh, it's recording.
Maybe these two engines are reversed.
If so, let's try
to pull the engine m2
and see if it runs.
In the program, I will copy
this block, create a file,
choose this as m2
and we will translate the program.
OK
These are the two engines.
Now I will
If we do it this way,
every time we do it,
we get x1
x2
x3
x4
x5
x6
x7
x8
x9
x10
x11
x12
x13
x14
x15
x16
x17
x18
x19
x20
x21
x22
x23
x24
x25
x26
x27
x28
x29
x30
x31
x32
x33
x34
x35
x36
x37
x38
x39
x40
x41
x42
x43
x44
x45
x46
x47
x48
x49
x50
x51
x52
x53
x54
x55
x56
x57
x58
x69
x70
x71
x72
x73
x74
x75
x76
x77
x78
x79
x80
x81
x82
x83
x84
x85
x86
The second step is to create a filehack to run the simulation.
You can see that both M1 and M2 are running.
So we have successfully run the simulation.
If you want to run the simulation, you have to wait for a while.
Then you will see the code.
Please note that when we run the simulation without any input,
the program will determine that the simulation will be repeated forever.
So if we wait for a while,
then you double-click on M1 and M2,
and stop these two engines,
you will not see the engine stop because it will repeat forever.
You will add a command after the stop command.
Then you will see the engine stop for a second.
Now you will see the engine stop for a second.
Then you will see the engine stop for a second.
Now, if we want the engine to run for a second and then stop,
then you will go to the function box,
take the first run arrow and loop the arrow forever.
You will put this command inside the first run arrow.
Then our program will run only once.
Now we will run the simulation again.
You open the simulation and run it again.
As you can see here,
our two engines only run for a second and then stop.
That's the simulation part.
Next, you know 2 ways to get the hack files.
The first way is to create a history of hack files.
Each file is a different program.
The second way is to get the hack files in StoryHack.
Now you will see this program.
We load it into the bot so you can observe it directly.
Now we will load the program.
After writing the program,
we are running a robot to load it.
You can choose the next button.
Instead of the hack file,
we will click on the triangle button.
This button will create the hack file.
The second button will send the hack file to the robot.
In this process, we call it loading the program.
This is the program that I will let the engine run in a square shape.
Basically, today you have learned about engines
and how to control the engine in StoryHack.
In the next video, I will show you how to load the engine in StoryHack.
