top of page

Projects

Search

Controlling DC motor with sensors

  • Writer: Mohamed Khaled
    Mohamed Khaled
  • Oct 8, 2018
  • 12 min read

Updated: Oct 21, 2018

This task is to control a DC motor (move forward, move backward, and make it stop) using a sensor (LDR), by using LDR, Transistors, Relay, and a DC motor our circuit will be done.

Defining the circuit component:


What is transistor?


A transistor is a semiconductor device used to amplify or switch electronic signals and electrical power. It is composed of semiconductor material usually with at least three terminals for connection to an external circuit. A voltage or current applied to one pair of the transistor's terminals controls the current through another pair of terminals. Because the controlled (output) power can be higher than the controlling (input) power, a transistor can amplify a signal. Today, some transistors are packaged individually, but many more are found embedded in integrated circuits.


Most transistors are made from very pure silicon or germanium, but certain other semiconductor materials can also be used. A transistor may have only one kind of charge carrier, in a field effect transistor, or may have two kinds of charge carriers in bipolar junction transistor devices. Compared with the vacuum tube, transistors are generally smaller, and require less power to operate. Certain vacuum tubes have advantages over transistors at very high operating frequencies or high operating voltages. Many types of transistors are made to standardized specifications by multiple manufacturers.


How to use the Transistor as an amplifier?

Amplifier circuit, common-emitter configuration with a voltage-divider bias circuit.

The common-emitter amplifier is designed so that a small change in voltage (Vin) changes the small current through the base of the transistor; the transistor's current amplification combined with the properties of the circuit means that small swings in Vin produce large changes in Vout.


Various configurations of single transistor amplifier are possible, with some providing current gain, some voltage gain, and some both.


From mobile phones to televisions, vast numbers of products include amplifiers for sound reproduction, radio transmission, and signal processing. The first discrete-transistor audio amplifiers barely supplied a few hundred mill watts, but power and audio fidelity gradually increased as better transistors became available and amplifier architecture evolved. Modern transistor audio amplifiers of up to a few hundred watts are common and relatively inexpensive.


How to use transistor as a Switch?

BJT used as an electronic switch, in grounded-emitter configuration.

Transistors are commonly used in digital circuits as electronic switches which can be either in an "on" or "off" state, both for high-power applications such as switched-mode power supplies and for low-power applications such as logic gates. Important parameters for this application include the current switched, the voltage handled, and the switching speed, characterized by the rise and fall times.


In a grounded-emitter transistor circuit, such as the light-switch circuit shown, as the base voltage rises, the emitter and collector currents rise exponentially. The collector voltage drops because of reduced resistance from collector to emitter. If the voltage difference between the collector and emitter were zero (or near zero), the collector current would be limited only by the load resistance (light bulb) and the supply voltage. This is called saturation because current is flowing from collector to emitter freely. When saturated, the switch is said to be on.


Providing sufficient base drive current is a key problem in the use of bipolar transistors as switches. The transistor provides current gain, allowing a relatively large current in the collector to be switched by a much smaller current into the base terminal. The ratio of these currents varies depending on the type of transistor, and even for a particular type, varies depending on the collector current. In the example light-switch circuit shown, the resistor is chosen to provide enough base current to ensure the transistor will be saturated.


In a switching circuit, the idea is to simulate, as near as possible, the ideal switch having the properties of open circuit when off, short circuit when on, and an instantaneous transition between the two states. Parameters are chosen such that the "off" output is limited to leakage currents too small to affect connected circuitry; the resistance of the transistor in the "on" state is too small to affect circuitry; and the transition between the two states is fast enough not to have a detrimental effect.


Advantages

The key advantages that have allowed transistors to replace vacuum tubes in most applications are

  • no cathode heater (which produces the characteristic orange glow of tubes), reducing power consumption, eliminating delay as tube heaters warm up, and immune from cathode poisoning and depletion;

  • very small size and weight, reducing equipment size;

  • large numbers of extremely small transistors can be manufactured as a single integrated circuit;

  • low operating voltages compatible with batteries of only a few cells;

  • Circuits with greater energy efficiency are usually possible. For low-power applications (e.g., voltage amplification) in particular, energy consumption can be very much less than for tubes;

  • complementary devices available, providing design flexibility including complementary-symmetry circuits, not possible with vacuum tubes;

  • very low sensitivity to mechanical shock and vibration, providing physical ruggedness and virtually eliminating shock-induced spurious signals (e.g., microphonic in audio applications);

  • Not susceptible to breakage of a glass envelope, leakage, outgassing, and other physical damage.


Limitations

Transistors have the following limitations:

  • silicon transistors can age and fail

  • high-power, high-frequency operation, such as that used in over-the-air television broadcasting, is better achieved in vacuum tubes due to improved electron mobility in a vacuum;

  • solid-state devices are susceptible to damage from very brief electrical and thermal events, including electrostatic discharge in handling; vacuum tubes are electrically much more rugged;

  • sensitivity to radiation and cosmic rays (special radiation-hardened chips are used for spacecraft devices);

  • vacuum tubes in audio applications create significant lower-harmonic distortion, the so-called tube sound, which some people prefer


Light Dependent Resistor (LDR)/ Photoresistor :

A photoresistor (or light-dependent resistor, LDR, or photocell), shown in the figure below, is a light-controlled variable resistor. The resistance of a photoresistor decreases with increasing incident light intensity; in other words, it exhibits photoconductivity. A photoresistor can be applied in light-sensitive detector circuits, and light- and dark-activated switching circuits.

A photoresistor is made of a high resistance semiconductor. In the dark, a photoresistor can have a resistance as high as several megohms (), while in the light, a photoresistor can have a resistance as low as a few hundred ohms. If incident light on a photoresistor exceeds a certain frequency, photons absorbed by the semiconductor give bound electrons enough energy to jump into the conduction band. The resulting free electrons (and their hole partners) conduct electricity, thereby lowering resistance. The resistance range and sensitivity of a photoresistor can substantially differ among dissimilar devices. Moreover, unique photoresistors may react substantially differently to photons within certain wavelength bands.


Variable Resistor/ Potentiometer

A potentiometer is a three terminal resistor in which the resistance is manually varied to control the flow of electric current.

It consists of three terminals among which two are fixed and one is variable. The two fixed terminals of the potentiometer are connected to both ends of the resistive element called track and third terminal is connected to the sliding wiper, as shown in the figure below. The wiper that moves along the resistive element varies the resistance of the potentiometer. The resistance of the potentiometer is changed when the wiper is moved over the resistive path. The resistive element of the potentiometer is either flat or angled. If the resistive element is flat, the wiper moves linearly. On the other hand, if the resistive element is angled, the wiper moves in a rotary manner.

The materials used to construct the resistive element of the potentiometer include: carbon particles in plastic, graphite, resistive wires, and cermets (combination of ceramics and metals). Potentiometers are also sometimes referred as pots. Increasing or decreasing the resistance of the potentiometer controls the flow of electric current. If we increase the resistance of the potentiometer, large amount of electric current is blocked and only a small amount of electric current is allowed. On the other hand, if we reduce the resistance of the potentiometer, a large amount of electric current is allowed and only a small amount of electric current is blocked. Applications

  • Potentiometers are used to control volume in audio equipments, frequency attenuation, changing loudness, and changing other characteristics of audio signals.

  • Potentiometers are used in televisions and computers to control the picture contrastand brightness.


Relay

A relay is an electrically operated switch. Many relays use an electromagnet to mechanicallyoperate a switch, but other operating principles are also used, such as solid-state relays. Relays are used where it is necessary to control a circuit by a separate low-power signal, or where several circuits must be controlled by one signal. The first relays were used in long distance telegraph circuits as amplifiers: they repeated the signal coming in from one circuit and re-transmitted it on another circuit. Relays were used extensively in telephone exchanges and early computers to perform logical operations. A type of relay that can handle the high power required to directly control an electric motoror other loads is called a contactor. Solid-state relays control power circuits with no moving parts, instead using a semiconductor device to perform switching. Relays with calibrated operating characteristics and sometimes multiple operating coils are used to protect electrical circuits from overload or faults; in modern electric power systems these functions are performed by digital instruments still called "protective relays". Magnetic latching relays require one pulse of coil power to move their contacts in one direction, and another, redirected pulse to move them back. Repeated pulses from the same input have no effect. Magnetic latching relays are useful in applications where interrupted power should not be able to transition the contacts. They can also have either single or dual coils. On a single coil device, the relay will operate in one direction when power is applied with one polarity, and will reset when the polarity is reversed. On a dual coil device, when polarized voltage is applied to the reset coil the contacts will transition. AC controlled magnetic latch relays have single coils that employ steering diodes to differentiate between operate and reset commands. Since relays are switches, the terminology applied to switches is also applied to relays; a relay switches one or more poles, each of whose contacts can be thrown by energizing the coil. Normally open (NO) contacts connect the circuit when the relay is activated; the circuit is disconnected when the relay is inactive. Normally closed (NC) contacts disconnect the circuit when the relay is activated; the circuit is connected when the relay is inactive. All of the contact forms involve combinations of NO and NC connections, as shown in the figure below.

DC Motor

A DC Motor is an electric motor designed to be run from a direct current (DC) power source. It has been more than 100 years that Brushed DC Motors are used in industry, and domestic applications. A DC motor is an electrical machine and operates on the principle “Whenever a current carrying conductor is placed in magnetic field it experience a force”. The simplest form of a Brushed DC motor is a two pole motor design like the one shown in the figure below. This design is the best to understand the forces and rotation.

The force is given by the formula:  F = B * I * L


Where F represents force, B magnetic field, I current and L is for length of the conductor. As the force is a vector quantity it must have a direction too. For finding direction of this force we apply Fleming’s left hand rule. If we know the magnitude as well as direction then we can get useful work from a DC Motor.


The main components of DC Motors are Windings,  Magnets, Rotors, Brushes, Stator and the source of direct current as shown in the figure below. When the armature is placed in a magnetic field generated by the magnets or field windings and the armature is rotated by using direct current it results in the generation of mechanical force according to the above statement. We can utilize this force for doing any type of particular work that we want.

When the armature rotates in the magnetic field and it cuts the magnetic lines of force then an emf is induced in the system. This emf is termed as back emf as it opposes the armature current. Due to this back emf some energy is lost in the process. But a back emf is also required to make the dc motor work regularly without a back emf we can’t put load to the motor and hence getting the work done from motor becomes pretty difficult for us.


Hobby Plastic Gear Motors

For our application, we used this small plastic DC geared motor, shown in the figure below, which operates at 6V. At a lower cost than metal gearmotors, these motors with plasticgearboxes can be the ideal drive system for a small robot and for the use in prototype circuits. The gears are typically long lasting nylon and the motors fit a range of different wheels.

Steps of making our circuit

Now that we have introduced our components, lets discuss and show in details the exact steps that we went through to accomplish our group task. The task was divided into three main and consecutive steps which included:

(a) Working on the circuit design.

(b) Making the circuit design and PCB board on EAGLE.

(c) Implementing the circuit in hardware.


a) Working on the circuit design:

In this first step, we come up with the idea of our circuit design by simply free-hand sketching our circuit along with all the required components that we will be using and the necessary connections between them as shown in the figure below. The circuit connections will be discussed in more details later in this section.

Here is a table showing all the required components along with their assigned numbers on the figure above, their functions, and the quantity of each component that we used.

And here is also a detailed bulleted list of all the connections for each component in the circuit. Connections:

  • Transistor 2N2222: this acts as the switch transistor; we have two of them and each has three legs (Ct - Bt - Et), the collector (Ct) to which the load is connected, which in this case are the relays as they are connected to the actual load (DC motor), so it connects to the relay's first coil end (coil end 1) to provide the input signal originally coming from the LDR sensor in addition to being connected to the amplifier transistor's collector (Ca) too, the base (Bt) is connected to both the LDR sensor and the potentiometer, and the emitter (Et) is connected to the amplifier transistor's base (Ba).

  • LDR Sensor: we have two of them and each has two terminals, one is connected to the Vcc (5V) while the other is connected to the switch transistor's base (Bt).

  • Transistor BC547: this acts as the amplifier transistor; we have two of them and each also has three legs (Ca - Ba - Ea), the collector (Ca) also connects to the relay's first coil end (coil end 1) to amplify the input signal originally coming from the LDR sensor in addition to being connected to the switch transistor's collector (Ct) too, the base (Ba) is connected to switch transistor's emitter (Et), and the emitter (Ea) is directly connected to the ground.

  • Potentiometer B10k: we have two of them and each also has three legs, one of the side legs is connected to the switch transistor's base (Bt) and the middle leg is directly connected to the ground.

  • Relays: we have two of them and each has five legs (NO - NC - C - coil end 1- coil end 2), the normally open (NO) switch legs in the two relays are both connected to each other with a common junction/ node connected to the Vcc (5V), the normally closed(NC) switch legs in the two relays are also both connected to each other but with a common junction/ node connected to the ground, the common (C) legs in both relays are connected to the two motor terminals, the first coil end (coil end 1) in both relays is connected to both the switch transistor's collector (Ct) and the amplifier transistor's collector (Ca) at the same time, and finally the second coil end (coil end 2) in both relays is directly connected to the Vcc (5V). (Note: There must be a potential difference between the two ends of a relay's coil so that current would flow in the coil magnetizing it in order for the relay to latch properly.)

  • DC Motor: as discussed in the relays' connections, the motor has its two terminals connected to the commons (C) of the relays.

  • 9V Battery: its positive terminal is connected to the positive Vcc line of the breadboard and its negative terminal is connected to the negative ground line of the board to close the circuit and supply power to it.


b) Making the circuit design and PCB board on EAGLE:

This was our second encounter with "EAGLE", so we already had enough experience to know the program tools that can be used to make schematic circuit designs and printed circuit boards (PCBs). Plus, the program is really simple and interesting to work with in addition to having an immense library that includes various electronic components. The steps of working on EAGLE were as follows:


c) Implementing the circuit in hardware:

The third and final step was to implement the circuit in hardware, however we had to connect the circuit on stages to make sure that every component is doing its job and working perfectly. We first connected the relay (without the load/ motor) with the switch transistor, the amplifying transistor, the LDR sensor, the potentiometer, and the power supply (battery) just to ensure that the relay is actually receiving a signal and latching accordingly as shown in the figure below.

Again, we did this for the other relay also connecting it with both transistors (the switch and amplifier), the LDR sensor, and another potentiometer for resistance adjustment.


And here is a video showing our test circuit working and the relay latching properly as we press on the LDR sensor:

Finally, it was time to test the circuit with the actual DC motor as shown in the figure below.

Here is a final video showing the whole circuit working and the DC motor rotating properly in both directions and stopping too:


Readings and Measurements:

As a bonus to our original work, we wanted to obtain some readings from the circuit, for later use to prove some of the transistor's equations, which we measured using a digital multimeter. However, for the readings we used Arduino as a power supply instead of the 9V battery and the readings were as follows:

  • Voltage on motor/load: 4V

  • Resistance of potentiometer (Threshold Resistance): 1.86kΩ

  • Voltage on base of amplifier and its LDR:

  • LDR ON: 0.8 V

  • LDR OFF: 0.44 V

  • Voltage on the collector of amplifier/switch with Vcc-Battery (Vc): 4.12V

  • Voltage on the collector of amplifier/switch with Ground (Vce): 0.7 V


Conclusion


To sum up, this task was really helpful in making us understand the basic fundamentals of electronics and how electronic circuits operate in general through practically working with various components and learning the theory of operation for each of them individually to perform our simple application. So, we encourage you to come visit us at FabLab in New Cairo (FLiNC) where you can learn and work with many types of electronics and start making your own unique application using electronics! :D

 
 
 

Comments


Giza systems.

Education Found

FabLab New Cairo.

  • Facebook Clean Grey
  • LinkedIn Clean Grey

© 2018 by Mohamed Khaled.

mm.png
bottom of page