Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 20 Next »

Basic Principle

  • If an electric charge moves, it generates its own magnetic field, which interacts with the original field (from permanent magnets)
  • Hence, a magnetic field exerts a force on a moving electric charge
  • A DC motor uses a permanent magnet to exert a force on a current-carrying coil of wire
  • The direction in which the coil of wire moves can be found using Fleming’s left hand rule
  • Easy DIY DC Motor https://www.youtube.com/watch?v=DsZCW34LktU
  • DC motors are used in applications which require good energy efficiency, but only imprecise control. Control, if necessary, has to be achieved through some external control mechanism
  • Used in fans, drills, traction etc.



Here is a good interactive tutorial on DC motors - https://nationalmaglab.org/education/magnet-academy/watch-play/interactive/dc-motor

Torque and Speed

  • The equivalent of force for rotation is called Torque
  • Higher torque applied to the wheel = better ability to overcome obstacles / friction, climb up a slope etc.
  • Usual DC motors run at very high rpm, but produces very low torque – typically not enough to run a robot
  • We use gears to increase the torque, but this comes at the expense of speed

  • Torque x rotational speed = power drawn by the motor
  • Power drawn by the motor depends on the a number of factors, the most important being the duty cycle (in PWM)
  • Duty cycle can be controlled using analogWrite()

Motor Driver

  • An Arduino pin can deliver only ~40mA current.
  • DC motors like the one we use draw several 100s of mA when loaded.
  • We need a switch/ current amplifier to drive the motor based on the signals from the Arduino.
    • Arduino -> Driver -> Motor.
  • A motor driver allowing bidirectional drive is called an H-bridge

  • L293D is a popular motor driver.
    • L293D has 4 switches (half H-bridges). This can be used to drive 4 motors unidirectionally or 2 motors bidirectionally
    • Note that the enables for inputs 1 & 2 are combined (you probably won’t need it, but enable should be high for the PWM signal from Arduino to have any effect). Ditto for enables of inputs 3 & 4
    • L293D has freewheeling/flyback diodes already connected inside the chip and need not be connected externally

Image courtesy : https://www.ti.com/lit/ds/symlink/l293.pdf

Pin Number

Pin Function

Description

1

Enable 1,2

This pin enables the input pin Input 1(2) and Input 2(7). Usually connected to 5V of Arduino; can also be controlled from your program by connecting it to an Arduino digital output pin.

2

Input 1

PWM control for Output 1 pin. From an Arduino pin supporting analogWrite()

3

Output 1

Connected to one end of  Motor 1

4

Ground

Ground pins are connected to ground of circuit (0V)

8

Vcc2 (Vs)

Connected to the power source for running motors (4.5V to 36V)

16

Vcc1 (Vss)

Connected to +5V of Arduino to enable IC function

Unidirectional Control


void setup()
{
  pinMode(6, OUTPUT);
}
 
void loop()
{
  analogWrite(6, speed);
  delay(10); 
}
/* speed is between 0 and 255 depending on the desired speed / power */]] ></ac:plain-text-body></ac:structured-macro><h3>Bidirectional Control</h3><p><strong><ac:image ac:height="250"><ri:attachment ri:filename="image2019-12-28_18-35-2.png" /></ac:image></strong></p><ac:structured-macro ac:name="code" ac:schema-version="1" ac:macro-id="bc9bf6fb-2d06-4970-a24e-1df4b8108b2f"><ac:parameter ac:name="language">cpp</ac:parameter><ac:parameter ac:name="theme">Confluence</ac:parameter><ac:plain-text-body><![CDATA[void setup()
{
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
}
 
void loop()
{
  analogWrite(5, dir2speed);
  analogWrite(6, dir1speed);
  delay(10);
}
/*dir1speed and dir2speed should be between 0 and 255. Effective speed will be (dir1speed-dir2speed). 
For rotation in direction 1, dir1speed is set to the desired speed and dir2speed is set to 0 (and vice versa) */]] ></ac:plain-text-body></ac:structured-macro><h3>DC Motor with Battery</h3><p><strong><ac:image ac:height="250"><ri:attachment ri:filename="image2019-12-28_18-36-12.png" /></ac:image></strong></p><ul><li>It is better to power the motor directly from the battery rather than the 5V terminal of the Arduino.</li><li>The Arduino 5V pin might not be able to give sufficient current.</li><li>Pin 8 of L293D is connected directly to the +ve of the battery.</li><li>Here, Arduino board is purely a controller for the motor, and does not power it.</li><li>The -ve of the battery and GND of the Arduino have to be connected together.</li><li>The battery can also power the Arduino, allowing it to operate without the USB connection to the computer. Simply connect the +ve of the battery to Vin.<ul><li>Omit this connection when Arduino is connected to computer via the USB cable. Note that the GND and the -ve of the battery should be connected in any case.</li></ul></li></ul><h3>Current / Power Issues</h3><p>The vast majority of the issues students face are power-related.&nbsp;A DC motor requires A LOT of current.</p><p>The current drawn increases significantly with the mechanical load. To reduce the mechanical load,&nbsp;</p><ul><li>Keep your robot light.</li><li>Use gear ratios that give high torque (usually at the expense of speed) where possible.</li><li>Make sure the driven wheels are properly aligned.</li><li>Lubricating the gearbox can help too.&nbsp;</li></ul><p>Another usual reason why you don't get sufficient current is bad batteries. A battery that shows good voltage in isolation (i.e., when not loaded) doesn't necessarily deliver a good current - the voltage drops significantly when you try to draw more current. Checking the battery voltage when unloaded using a voltmeter or checking if the battery can power an LED isn't good enough - that doesn't guarantee the current delivered is good.&nbsp;The battery generally drains faster than you think it does, especially if the mechanical load is high. Adding more batteries in parallel (not series, assuming the overall voltage of the combination is at least 6 volts) can help with current, but they also add to the weight.&nbsp;</p><p>A third reason is that you are driving more motors from the same L293D output. L293D also has limits on the amount of current available from each output pin. Where possible, drive only one pin from each L293D output. The same control input from Arduino pin can be used as inputs to two different L293 inputs (assuming the motors are supposed to run at the same speed), as the current to run the motor isn't drawn from Arduino - however, be mindful of the fact that two motors might not be identical with respect to friction - one is likely to run faster than the other if you do so.&nbsp;</p><p>Caution: an overloaded L293D can heat up to 140<sup>o</sup> Celsius, so be careful.</p><p>Debugging tip: Write a simple program to turn the wheels without dependence on sensor (e.g. ultrasonic) readings. If it still doesn't work, lift the robot such that the wheels are not loaded. Sometimes, the wheel might need you to give it some help to overcome static friction.&nbsp;If the wheels eventually turn, it's a power-related issue.</p><h3>Screencast</h3><p><ac:structured-macro ac:name="widget" ac:schema-version="1" ac:macro-id="68672be6-2cb9-47e3-8fcf-b365b2f0d95e"><ac:parameter ac:name="url"><ri:url ri:value="http://youtube.com/watch?v=pIoBLng4Yno" /></ac:parameter></ac:structured-macro></p><p><br /></p>
  • No labels