{"id":1264,"date":"2015-12-05T11:07:47","date_gmt":"2015-12-05T03:07:47","guid":{"rendered":"http:\/\/handsontec.com\/?page_id=1264"},"modified":"2015-12-05T11:28:26","modified_gmt":"2015-12-05T03:28:26","slug":"pulse-width-modulation","status":"publish","type":"page","link":"https:\/\/handsontec.com\/index.php\/pulse-width-modulation\/","title":{"rendered":"Pulse Width Modulation"},"content":{"rendered":"<h3 style=\"text-align: justify;\"><span style=\"color: #ff6600;\">There are many different ways to control the speed of motors but one very simple and easy way is to use <strong>Pulse Width Modulation (PWM)<\/strong>. But before we start looking at the in\u2019s and out\u2019s of pulse width modulation we need to understand a little more about how a DC motor works.<\/span><\/h3>\n<p style=\"text-align: justify;\">Next to stepper motors, the Permanent Magnet DC Motor (PMDC) is the most commonly used type of small direct current motor available producing a continuous rotational speed that can be easily controlled. Small DC motors ideal for use in applications were speed control is required such as in small toys, models, robots and other circuits.<\/p>\n<p style=\"text-align: justify;\">A DC motor consist basically of two parts, the stationary body of the motor called the \u201cStator\u201d and the inner part which rotates producing the movement called the \u201cRotor\u201d. For D.C. machines the rotor is commonly termed the \u201cArmature\u201d. Generally in small light duty DC motors the stator consists of a pair of fixed permanent magnets producing a uniform and stationary magnetic flux inside the motor giving these types of motors their name of \u201cpermanent-magnet direct-current\u201d (PMDC) motors. The motors armature consists of individual electrical coils connected together in a circular configuration around its metallic body producing a North-Pole then a South-Pole then a North-Pole etc, type of field system configuration. The current flowing within these rotor coils producing the necessary electromagnetic field. The circular magnetic field produced by the armatures windings produces both north and south poles around the armature which are repelled or attracted by the stator\u2019s permanent magnets producing a rotational movement around the motors central axis as shown.<\/p>\n<h3 class=\"h3txt\"><span style=\"color: #ff6600;\">2-Pole Permanent Magnet Motor<\/span><\/h3>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1265 aligncenter\" src=\"http:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-1.png\" alt=\"pwm-controller-1\" width=\"534\" height=\"266\" srcset=\"https:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-1.png 534w, https:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-1-200x100.png 200w, https:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-1-300x149.png 300w\" sizes=\"(max-width: 534px) 100vw, 534px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">As the armature rotates electrical current is passed from the motors terminals to the next set of armature windings via carbon brushes located around the commutator producing another magnetic field and each time the armature rotates a new set of armature windings are energised forcing the armature to rotate more and more and so on. So the rotational speed of a DC motor depends upon the interaction between two magnetic fields, one set up by the stator\u2019s stationary permanent magnets and the other by the armatures rotating electromagnets and by controlling this interaction we can control the speed of rotation.<\/p>\n<p style=\"text-align: justify;\">The magnetic field produced by the stator\u2019s permanent magnets is fixed and therefore can not be changed but if we change the strength of the armatures electromagnetic field by controlling the current flowing through the windings more or less magnetic flux will be produced resulting in a stronger or weaker interaction and therefore a faster or slower speed. Then the rotational speed of a DC motor (<span class=\"ntxt\">N<\/span>) is proportional to the back emf (<span class=\"ntxt\">V<sub>b<\/sub><\/span>) of the motor divided by the magnetic flux (which for a permanent magnet is a constant) times an electromechanical constant depending upon the nature of the armatures windings (<span class=\"ntxt\">K<sub>e<\/sub><\/span>) giving us the equation of: <span class=\"ntxt\">N\u00a0\u221d\u00a0V\/K<sub>e<\/sub>\u03d5<\/span>.<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-1266\" src=\"http:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-2.png\" alt=\"pwm-controller-2\" width=\"166\" height=\"159\" \/><\/a>So how do we control the flow of current through the motor. Well many people attempt to control the speed of a DC motor using a large variable resistor (Rheostat) in series with the motor as shown. While this may work, it generates a lot of heat and wasted power in the resistance. One simple and easy way to control the speed of a motor is to regulate the amount of voltage across its terminals and this can be achieved using \u201c<strong>Pulse Width Modulation<\/strong>\u201d or PWM. As its name suggests, pulse width modulation speed control works by driving the motor with a series of \u201cON-OFF\u201d pulses and varying the duty cycle, the fraction of time that the output voltage is \u201cON\u201d compared to when it is \u201cOFF\u201d, of the pulses while keeping the frequency constant.<\/p>\n<p style=\"text-align: justify;\">The power applied to the motor can be controlled by varying the width of these applied pulses and thereby varying the average DC voltage applied to the motors terminals. By changing or modulating the timing of these pulses the speed of the motor can be controlled, ie, the longer the pulse is \u201cON\u201d, the faster the motor will rotate and likewise, the shorter the pulse is \u201cON\u201d the slower the motor will rotate.<\/p>\n<p style=\"text-align: justify;\">In other words, the wider the pulse width, the more average voltage applied to the motor terminals, the stronger the magnetic flux inside the armature windings and the faster the motor will rotate and this is shown below.<\/p>\n<h3 class=\"h3txt\"><span style=\"color: #ff6600;\">Pulse Width Modulated Waveform<\/span><\/h3>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1268 aligncenter\" src=\"http:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-3.png\" alt=\"pwm-controller-3\" width=\"562\" height=\"195\" srcset=\"https:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-3.png 562w, https:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-3-200x69.png 200w, https:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-3-300x104.png 300w\" sizes=\"(max-width: 562px) 100vw, 562px\" \/><\/a>The use of pulse width modulation to control a small motor has the advantage in that the power loss in the switching transistor is small because the transistor is either fully \u201cON\u201d or fully \u201cOFF\u201d. As a result the switching transistor has a much reduced power dissipation giving it a linear type of control which results in better speed stability. Also the amplitude of the motor voltage remains constant so the motor is always at full strength. The result is that the motor can be rotated much more slowly without it stalling. So how can we produce a <em>pulse width modulation<\/em> signal to control the motor. Easy, use an Astable 555 Oscillator circuit as shown below.<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1269 aligncenter\" src=\"http:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-4.png\" alt=\"pwm-controller-4\" width=\"591\" height=\"423\" srcset=\"https:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-4.png 591w, https:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-4-200x143.png 200w, https:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/pwm-controller-4-300x215.png 300w\" sizes=\"(max-width: 591px) 100vw, 591px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">This simple circuit based around the familiar NE555 or 7555 timer chip is used to produced the required pulse width modulation signal at a fixed frequency output. The timing capacitor <span class=\"ntxt\">C<\/span> is charged and discharged by current flowing through the timing networks <span class=\"ntxt\">R<sub>A<\/sub><\/span> and <span class=\"ntxt\">R<sub>B.<\/sub><\/span> The output signal at pin 3 of the 555 is equal to the supply voltage switching the transistors fully \u201cON\u201d. The time taken for <span class=\"ntxt\">C<\/span> to charge or discharge depends upon the values of <span class=\"ntxt\">R<sub>A<\/sub><\/span>, <span class=\"ntxt\">R<sub>B<\/sub><\/span>. The capacitor charges up through the network <span class=\"ntxt\">R<sub>A<\/sub><\/span> but is diverted around the resistive network <span class=\"ntxt\">R<sub>B<\/sub><\/span> and through diode <span class=\"ntxt\">D<sub>1<\/sub><\/span>. As soon as the capacitor is charged, it is immediately discharged through diode <span class=\"ntxt\">D<sub>2<\/sub><\/span> and network <span class=\"ntxt\">R<sub>B<\/sub><\/span> into pin 7. During the discharging process the output at pin 3 is at 0V and the transistor is switched \u201cOFF\u201d. Then the time taken for capacitor, <span class=\"ntxt\">C<\/span> to go through one complete charge-discharge cycle depends on the values of <span class=\"ntxt\">R<sub>A<\/sub><\/span>, <span class=\"ntxt\">R<sub>B<\/sub><\/span> and <span class=\"ntxt\">C<\/span> with the time <span class=\"ntxt\">T<\/span> for one complete cycle being given as:<\/p>\n<p class=\"cntr\" style=\"text-align: center;\">The time, <span class=\"mtxt\">T<sub>H<\/sub><\/span>, for which the output is \u201cON\u201d is: <span class=\"mtxt\">T<sub>H<\/sub>\u00a0=\u00a00.693(R<sub>A<\/sub>).C<\/span><\/p>\n<p class=\"cntr\" style=\"text-align: center;\">The time, <span class=\"mtxt\">T<sub>L<\/sub><\/span>, for which the output is \u201cOFF\u201d is: <span class=\"mtxt\">T<sub>L<\/sub> = 0.693(R<sub>B<\/sub>).C<\/span><\/p>\n<p class=\"cntr\" style=\"text-align: center;\">Total \u201cON\u201d-\u201cOFF\u201d cycle time given as:\u00a0\u00a0<span class=\"mtxt\">T = T<sub>H<\/sub> + T<sub>L<\/sub><\/span>\u00a0\u00a0with the output frequency being <span class=\"mtxt\">\u0192\u00a0=\u00a01\/T<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">With the component values shown, the duty cycle of the waveform can be adjusted from about 8.3% (0.5V) to about 91.7% (5.5V) using a 6.0V power supply. The Astable frequency is constant at about 256 Hz and the motor is switched \u201cON\u201d and \u201cOFF\u201d at this rate. Resistor <span class=\"ntxt\">R<sub>1<\/sub><\/span> plus the \u201ctop\u201d part of the potentiometer, <span class=\"ntxt\">VR<sub>1<\/sub><\/span> represent the resistive network of <span class=\"ntxt\">R<sub>A<\/sub><\/span>. While the \u201cbottom\u201d part of the potentiometer plus <span class=\"ntxt\">R<sub>2<\/sub><\/span> represent the resistive network of <span class=\"ntxt\">R<sub>B<\/sub><\/span> above. These values can be changed to suite different applications and DC motors but providing that the 555 Astable circuit runs fast enough at a few hundred Hertz minimum, there should be no jerkiness in the rotation of the motor. Diode <span class=\"ntxt\">D<sub>3<\/sub><\/span> is our old favourite the flywheel diode used to protect the electronic circuit from the inductive loading of the motor. Also if the motor load is high put a heatsink on the switching transistor (2N3055) or MOSFET (HUF75545P3).<\/p>\n<p style=\"text-align: justify;\">Complete PWM Controller Board Based on the above design topology:<\/p>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/handsontec.com\/wp-content\/uploads\/2015\/12\/PWM-Controller-schematic.pdf\" class=\"pdfemb-viewer\" style=\"\" data-width=\"max\" data-height=\"max\" data-toolbar=\"bottom\" data-toolbar-fixed=\"off\">PWM-Controller-schematic<\/a><\/p>\n<p style=\"text-align: justify;\"><strong><em>Pulse width modulation<\/em><\/strong> is a great method of controlling the amount of power delivered to a load without dissipating any wasted power. The above circuit can also be used to control the speed of a fan or to dim the brightness of DC lamps or LED\u2019s. If you need to control it, then use <strong>Pulse Width Modulation<\/strong> to do it.<\/p>\n<h3 style=\"text-align: justify;\"><span style=\"color: #ff6600;\">Additional Related Information<\/span><\/h3>\n<ul>\n<li>\n<p class=\"product_title entry-title\"><a href=\"http:\/\/handsontec.com\/index.php\/product\/dc10-60v20a-pwm-controller-board\/\" target=\"_blank\">HK1227: Motor Speed Control Board<\/a><\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>There are many different ways to control the speed of motors but one very simple and easy way is to use Pulse Width Modulation (PWM). But before we start looking at the in\u2019s and out\u2019s of pulse width modulation we need to understand a little more about how a DC motor works. Next to stepper [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1274,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/handsontec.com\/index.php\/wp-json\/wp\/v2\/pages\/1264"}],"collection":[{"href":"https:\/\/handsontec.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/handsontec.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/handsontec.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/handsontec.com\/index.php\/wp-json\/wp\/v2\/comments?post=1264"}],"version-history":[{"count":6,"href":"https:\/\/handsontec.com\/index.php\/wp-json\/wp\/v2\/pages\/1264\/revisions"}],"predecessor-version":[{"id":1276,"href":"https:\/\/handsontec.com\/index.php\/wp-json\/wp\/v2\/pages\/1264\/revisions\/1276"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/handsontec.com\/index.php\/wp-json\/wp\/v2\/media\/1274"}],"wp:attachment":[{"href":"https:\/\/handsontec.com\/index.php\/wp-json\/wp\/v2\/media?parent=1264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}