“This is a modification and addition to my instructable.com tutorials on DC Motors, and it also includes some information from my tutorial on the ESP32 Tutorial: Touch, Hall, I2C, PWM, ADC, & DAC. The earlier DC motor tutorials were focused on the Arduino UNO, while these tutorials are focused on the ESP32 development board. However, both groups of tutorials include similar, and in some instances identical, information.
Thus, as noted, this tutorial is focused on DC Motors and ESP32 development boards.
DC motors are ubiquitous. They convert electrical/magnetic energy, produced by a wire carrying current in a magnetic field, to motion, and they appear in all sorts of appliances and applications, e.g., they are found in small fans, ceiling fans, air cleaners, solder fume extractors, quadcopters, small helicopters, and other drones, hand-held rotary tools, circular saws, drills, lathes, sanders, cars, robots (where they rotate tires, or move robotic arms, etc.), aquarium air pumps, maker projects, and many other areas.
The most popular motors generally have shafts that are round, or ‘D’-shaped (i.e., flattened on one side), flattened on two sides, or geared (i.e., have gears directly cut into the shaft or mounted on the shaft). See photographs for examples of these popular shaft styles. Although motors can run from DC, AC, and in the case of universal motors from both DC and AC, this tutorial only discusses DC motors in detail.
Electric current and magnetism go hand-in-hand as it is impossible to have one without the other. As can be seen in the photographs current through a wire moves a compass needle owing to the magnetic field generated around the wire by the current passing through it. Hans Christian Oersted, the Danish physicist, identified this connection between electricity and magnetism in the early 1800’s. [Some interesting but not essential information: The ‘Oe’ in the name shown here, can be replaced by a single capital Danish O (i.e., ) and on occasion one sees his name as rsted].
Magnetism produced by current flowing through a single wire is weak. If this wire is wound into a coil the magnetic field becomes stronger. If this coil is then wrapped around a ferrite core its magnetic field becomes even stronger.
The theory of DC motors is not difficult to understand, if we recall that for magnets opposite poles attract and similar poles repeal. A DC motor works by having the poles of a rotor through which current flows, thereby producing a magnetic field, subjected to another magnetic field which attracts the magnetic field of the rotor. It is interesting to learn that the opposite is also true. That is, as a motor rotates the interaction of the magnetic fields produces a voltage. This can be seen in the video above where a NEMA-17 stepper motor is turned to produce a voltage and light an LED, i.e., where the motor is used as a generator.
In this tutorial we will discuss several types of DC motors, although there are many other types of motors. However, DC motors are probably the most popular motors used with microcontrollers. Here we use these motors with the ESP32 microcontroller development board.
An ESP32 development board contains an ESP32-WROOM-32 module, made by Espressif Systems of Shangai, China.
The W in the name is silent. So, WROOM is pronounced as room. Sadly, many on-line presenters mispronounce this chip’s name, pronouncing the ‘W’, which should be silent. I checked with Espressif to confirm that the ‘W’ is silent as in the English words wren, write, wrist, wrong, wrest, wrestling, wrinkle, wreck, etc. Espressif confirmed that “WROOM” is correctly pronounced with a silent ‘W’.
Motors are devices that can impart motion, i.e., movement, to our projects. You can see two of my prior Instructables where this occurs: Personal, portable, lightweight, air conditioner: An inexpensive and effective DIY project, and Making a Hypnotic disk using an Arduino and small DC motor. They provide examples of DC motors that were used in Arduino projects. Some other Arduino projects using motors are BlackStar Vveks, Arduino based humanoid robot using servo motors, Arduino + K’nex Motors by link2_thepast, martinboltons Arduino+Stepper Motor Camera Slider, etc. In fact, many Instructables can be found that use one or more motors.Fortunately, with DC motors used by Makers, we need not be too concerned with voltage (although we need to be sure a motor is designed to work at the voltage we have available). However, current is a different matter as almost all motors take more current than is available, from an ESP32 development board pin. Thus. we need to insure that we can provide an appropriate device to produce the current needed.
Our main concerns with motors are speed and torque. Speed for motors is measured, unlike it is when we measure the speed of a car in miles per hour or kilometers per hour, in rotations per minute (RPM) or radians/sec, e.g., 3,000 RPM or 450 rad/sec. Note, these are but two examples of how motor speed might be represented. They are not meant to imply that 3,000 RPM is equal to 450 rad/sec; it is not. Fortunately, it is easy to covert from RPM to radians/sec or degrees/sec, or the reverse.
Speed is represented by the Greek letter omega, . Sir Isaac Newton’s second law of motion is: Force equals mass multiplied by Acceleration, where Force and Acceleration are directional, although mass is not.
Torque is a “twisting/turning force”. Force is frequently measured in Newton (N). When we multiply force by length we get torque, e.g., Newton-meters (N-m), Newton-centimeters (N-cm), or ounce-inches (oz-in). In a motor the torque is always tangent to a circle centered on the shaft, i.e., it is at a right angle to a diameter. The symbol designating torque is the lowercase Greek letter tau, , and less frequently the English capital letter T. Datasheets for DC motors usually provide speed in both RPM, and radians or degrees/sec.
Torque is often presented in datasheets in several forms (e.g., as peak torque, stall torque (more on this later), and rated torque, etc. DC motor datasheets are usually quite comprehensive and present other motor parameters as well. It should be noted that motors can have the same power capability, but different speed and torque, as it is possible to exchange speed for torque.
Mass and weight are not the same. Although they are often interchanged in informal conversations. For example, on the moon a motor would have the same mass it does on Earth, but its weight would be different.
The supplies needed are discussed in each step having a sketch, as it is not necessary to get some supplies if a sketch will not be implemented by the reader.”