{"id":530,"date":"2025-10-14T09:11:34","date_gmt":"2025-10-14T07:11:34","guid":{"rendered":"https:\/\/avlos.gr\/wpress\/?p=530"},"modified":"2025-10-14T09:39:18","modified_gmt":"2025-10-14T07:39:18","slug":"dc-motor","status":"publish","type":"post","link":"https:\/\/avlos.gr\/wpress\/en\/dc-motor\/","title":{"rendered":"DC motor"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Direct current motor<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There are different types of motors used in small and medium sized robotics projects.&nbsp;These can generally be classified into categories<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Step motors<\/li>\n\n\n\n<li>Servo motors<\/li>\n\n\n\n<li>DC motors<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">They come in a wide variety of sizes and capabilities and are used in different sized applications.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Stepper motors and servomotors are designed in such a way that we can control their position.&nbsp;We can control the steps forward and backward.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Servo motors can generally be moved from 0 to 180 degrees.&nbsp;Therefore you can move your motor in any position between 0 and 180. Similarly, in stepper motors, you can control the steps accurately.&nbsp;This is why stepper motors are used in CNC machines, 3D printers, etc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here we will deal with direct current motors (DC motors).&nbsp;DC motors are often used in robotics applications and are quite different from stepper motors and servomotors.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So these three types of engines have different construction and different purpose of use.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When a DC motor is started, it immediately starts to spin, and spins continuously. You can not exactly check its position without using a specific technique. Again you can not 100% control its position in a DC motor as you do with the Stepper motor and Servo. But if you add an encoder to the continuous engine then it really changes the whole game. By adding an encoder, you can track the engine speed, distance traveled and thus create a nice feedback system that can be used to control the DC motor. You can then stop the DC motor in the position where you want it to stop.Note here that the reversal of polarity in the motor power supply causes it to move in the opposite direction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using a coder to control the DC motor is not such a simple matter. You can not just start adding a codec to the DC motor to start controlling it. To use an encoder you will need a controller, and a program that will guide the controller. The controller will read the encoder and then test the DC motor accordingly according to the pre-defined instructions written by the programmer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The speed of rotation of the DC motor is usually controlled by supplying it with a PWM (Pulse-width modulation) waveform.&nbsp;A PWM waveform, as shown in the following figure, is actually a periodic waveform that has two parts.&nbsp;The ON part in which the waveform has its maximum value and the OFF part in which it has the value zero.&nbsp;The ON segment is called the Duty Cycle and is measured in either time units (ms, us, etc.) or as a percentage (%) over the period (Period).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"612\" height=\"165\" src=\"https:\/\/avlos.gr\/wpress\/wp-content\/uploads\/2025\/10\/DC_motor_1.jpg\" alt=\"\" class=\"wp-image-531\" style=\"width:319px;height:auto\" srcset=\"https:\/\/avlos.gr\/wpress\/wp-content\/uploads\/2025\/10\/DC_motor_1.jpg 612w, https:\/\/avlos.gr\/wpress\/wp-content\/uploads\/2025\/10\/DC_motor_1-300x81.jpg 300w\" sizes=\"auto, (max-width: 612px) 100vw, 612px\" \/><figcaption class=\"wp-element-caption\">PWM waveform<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">By applying a PWM waveform to the power supply of a load we manage to control the percentage of power that falls on the load.&nbsp;In case the load is an engine this implies control of the engine speed.&nbsp;In the figure below you can see such a DC motor power connection.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"561\" height=\"410\" src=\"https:\/\/avlos.gr\/wpress\/wp-content\/uploads\/2025\/10\/DC_motor_2.jpg\" alt=\"\" class=\"wp-image-532\" style=\"width:326px;height:auto\" srcset=\"https:\/\/avlos.gr\/wpress\/wp-content\/uploads\/2025\/10\/DC_motor_2.jpg 561w, https:\/\/avlos.gr\/wpress\/wp-content\/uploads\/2025\/10\/DC_motor_2-300x219.jpg 300w\" sizes=\"auto, (max-width: 561px) 100vw, 561px\" \/><figcaption class=\"wp-element-caption\">DC motor power supply<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Control DC motor with encoder<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;Beginners in microcontroller programming are usually more comfortable using the Arduino Uno or Arduino mega or Arduino Nano.&nbsp;For this reason in the constructions &#8211; examples I will use the Arduino Uno.&nbsp;You can try the same programs on both Arduino Nano and Arduino Mega.<br>To get started, you will need:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.circuito.io\/blog\/arduino-uno-pinout\/\" target=\"_blank\" rel=\"noreferrer noopener\">an Arduino Uno<\/a>&nbsp;,<\/li>\n\n\n\n<li>a DC power supply for the motor,<\/li>\n\n\n\n<li>an&nbsp;engine drive&nbsp;<a href=\"https:\/\/www.handsontec.com\/dataspecs\/module\/7A-160W%20motor%20control.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">controller&nbsp;<\/a>,<\/li>\n\n\n\n<li>and a DC motor with an encoder adapted to its construction.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><br>The steps we will follow will be the following.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>We will first get acquainted with the use of the encoder by moving the motor manually.<\/li>\n\n\n\n<li>We will then power the engine using a controller to control the direction of movement and its speed.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">DC motor with encoder (&nbsp;<a href=\"http:\/\/www.avlos.gr\/index.php\/el\/rompotiki\/kodikopoiitis-kinitira-dc\" target=\"_blank\" rel=\"noreferrer noopener\">DC motor &#8211; Encoder&nbsp;<\/a>)<\/h2>\n","protected":false},"excerpt":{"rendered":"<p>Direct current motor There are different types of motors used in small and medium sized robotics projects.&nbsp;These can generally be classified into categories They come in a wide variety of sizes and capabilities and are used in different sized applications.&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,75],"tags":[73],"class_list":["post-530","post","type-post","status-publish","format-standard","hentry","category-home","category-robotics","tag-robotics"],"_links":{"self":[{"href":"https:\/\/avlos.gr\/wpress\/wp-json\/wp\/v2\/posts\/530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/avlos.gr\/wpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/avlos.gr\/wpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/avlos.gr\/wpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/avlos.gr\/wpress\/wp-json\/wp\/v2\/comments?post=530"}],"version-history":[{"count":2,"href":"https:\/\/avlos.gr\/wpress\/wp-json\/wp\/v2\/posts\/530\/revisions"}],"predecessor-version":[{"id":546,"href":"https:\/\/avlos.gr\/wpress\/wp-json\/wp\/v2\/posts\/530\/revisions\/546"}],"wp:attachment":[{"href":"https:\/\/avlos.gr\/wpress\/wp-json\/wp\/v2\/media?parent=530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/avlos.gr\/wpress\/wp-json\/wp\/v2\/categories?post=530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/avlos.gr\/wpress\/wp-json\/wp\/v2\/tags?post=530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}