0% found this document useful (0 votes)
76 views

Wireless Control of DC Motor.: (Type Text)

This document proposes a wireless speed control system for a DC motor using Wi-Fi technology. A NODE MCU microcontroller generates a Wi-Fi hotspot that can be accessed from a mobile phone or computer to control the speed of the DC motor. The NODE MCU interfaces with a driver module that controls the motor speed and direction based on PWM pulse inputs from the NODE MCU, which are determined by the user controls on the connected mobile device. An IR sensor measures the motor RPM for display on the mobile screen.

Uploaded by

pnkjinamdar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

Wireless Control of DC Motor.: (Type Text)

This document proposes a wireless speed control system for a DC motor using Wi-Fi technology. A NODE MCU microcontroller generates a Wi-Fi hotspot that can be accessed from a mobile phone or computer to control the speed of the DC motor. The NODE MCU interfaces with a driver module that controls the motor speed and direction based on PWM pulse inputs from the NODE MCU, which are determined by the user controls on the connected mobile device. An IR sensor measures the motor RPM for display on the mobile screen.

Uploaded by

pnkjinamdar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 33

Wireless Control of DC motor.

Abstract

Motors are being used everywhere in the industry. The need for automation in this
segment in increasing day by day. Thus wireless operation is gaining importance.
Wireless speed control uses many technologies like Blue tooth, Infrared, radio
communication etc.

In this project we hereby propose you the wireless operation of DC motors Using Wi-Fi
technology. Here the speed of DC motor is controlled by controlling the PWM pulse. The
pulse is controlled using Wi-Fi. The interface which we are using to control is called
NODE MCU. This is a microcontroller which has wireless capability. This can be
effectively used for this project.

[Type text] Page 1


Wireless Control of DC motor.

Introduction.
Wireless control is gaining importance. May it be motor or any other applications.
The speed and direction control of DC motor is very important for various kinds of uses.
Through all these years, there have been various attempts in finding different efficient
solutions for the speed and direction control of the DC motor. History will recognize the vital
role played by DC motors in the development of industrial power transmission systems. The
DC machine was the first practical device to convert electrical power into mechanical power,
and vice-versa in its generator form. Inherently straight forward operating characteristics,
flexible performance and high efficiency encouraged the widespread use of DC motors
in many types of industrial drive applications. DC motors have been long been the primary
means of Electrical traction. DC motor is considered as a SISO system having torque/speed
characteristics compatible with most mechanical loads. Hence, DC motors are always a good
ground for advanced theories because the theory is extendable to other types of motors.
Wireless communication is the transfer of information between two or more points that are
not physically connected. Distances can be short, such as a few meters for television remote
control, or as far as thousands or even millions of kilometers. Among the various wireless
technologies like IR (Infra Red), Bluetooth and WLAN, we have chosen WLAN technology,
the main reason being it has a very long range of 3 KHz-5GHZ. It is also not affected by any
obstructions. Commercial applications for wireless are door announcers, security and access
systems, gate control, remote activation, score board and paging systems.
In this project we will be controlling the motor wirelessly. The interface used is called
NODE MCU. Node MCU is microcontroller having wireless connectivity capability over
Wi-Fi.

[Type text] Page 2


Wireless Control of DC motor.

Methodology.

In the first place we will be programming the NODE MCU so as to receive inputs
from the mobile phones via Wi-Fi. The NODE MCU generates the hotspot. This hotspot
can be accessed by a mobile or a computer with Wi-Ficapability. Next the NODE MCU also
acts as an interface for the driver module. Driver module receives inputs from NODE MCU
to control speed and direction of DC motor connected. The actual operation of motor can be
viewed on mobile display.

Block Diagram

Control Unit Driver unit DC Motor.


Power Supply L298

RPM sensor.
NODE MCU
ESP8266 Module

Mobile connected to NoDE


MCU

[Type text] Page 3


Wireless Control of DC motor.

Components
The main components of the projects include

1. NODE MCU
NodeMCU is an open-source firmware and development kit that helps
you to prototype or build IoT product. It includes firmware which runs on the
ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on
the ESP-12 module. The firmware uses the Lua scripting language. It is based
on the eLua project, and built on the Espressif Non-OS SDK for ESP8266.
Hardware typically used is a circuit board functioning as a dual in-line
package (DIP) which integrates a USB controller with a smaller surface-mounted
board containing the MCU and antenna. The choice of the DIP format allows for easy
prototyping on breadboards. The design was initially was based on the ESP-12
module of the ESP8266, which is a Wi-Fi SoC integrated with a Tensilica Xtensa
LX106 core, widely used in IoT applications

 The ESP8266 chip requires 3.3V power supply voltage. It should not be powered
with 5 volts like other arduino boards.
 NodeMCU ESP-12E dev board can be connected to 5Vusing micro USB connector
or Vin pin available on board.
 The I/O pins of ESP8266 communicate or input/output max 3.3V only. i.e. the pins
are NOT 5V tolerant input.

Figure 1: NODE MCU ESP8266

[Type text] Page 4


Wireless Control of DC motor.

Pinouts

General-purpose input/output (GPIO) is a pin on an IC


(Integrated Circuit). It can be either input pin or output pin,
whose behavior can be controlled at the run time.
NodeMCU Development kit provides access to these GPIOs of
ESP8266. The only thing to take care is that NodeMCU Dev kit
pins are numbered differently than internal GPIO notations of
ESP8266 as shown in below figure and table. For example, the
D0 pin on the NodeMCU Dev kit is mapped to the internal
GPIO pin 16 of ESP8266.

Below table gives NodeMCU Dev Kit IO pins and ESP8266 internal GPIO pins mappin

Pin Names on NodeMCU ESP8266 Internal GPIO Pin


Development Kit number
D0 GPIO16
D1 GPIO5
D2 GPIO4
 
D3 GPIO0
D4 GPIO2
D5 GPIO14
D6 GPIO12
D7 GPIO13
D8 GPIO15
D9/RX GPIO3
D10/TX GPIO1
D11/SD2 GPIO9
D12/SD3 GPIO10

[Type text] Page 5


Wireless Control of DC motor.

Features
 Finally, programable WiFi module.
 Arduino-like (software defined) hardware IO.
 Can be programmed with the simple and powerful Lua programming language or
Arduino IDE.
  USB-TTL included, plug & play.
 10 GPIOs D0-D10, PWM functionality, IIC and SPI communication, 1-Wire and
ADC A0 etc. all in one board.
 Wifi networking (can be used as access point and/or station, host a web server),
connect to internet to fetch or upload data.
 Event-driven API for network applications.
 PCB antenna.

[Type text] Page 6


Wireless Control of DC motor.

2. Sensors.

Sensors are sophisticated devices that are frequently used to detect and respond to
electrical or optical signals. A Sensor converts the physical parameter (for example:
temperature, blood pressure, humidity, speed, etc.) into a signal which can be measured
electrically. Let’s explain the example of temperature. The mercury in the glass
thermometer expands and contracts the liquid to convert the measured temperature which
can be read by a viewer on the calibrated glass tube.

Criteria to choose a Sensor


There are certain features which have to be considered when we choose a sensor. They are as
given below:
1.     Accuracy
2.     Environmental condition – usually has limits for temperature/ humidity
3.     Range – Measurement limit of sensor
4.   Calibration – Essential for most of the measuring devices as the readings changes with
time
5.     Resolution – Smallest increment detected by the sensor
6.     Cost

[Type text] Page 7


Wireless Control of DC motor.

7.     Repeatability – The reading that varies is repeatedly measured under the same
environment 
Classification of Sensors
The sensors are classified into the following criteria:
1.     Primary Input quantity (Measurand)
2.     Transduction principles (Using physical and chemical effects)
3.     Material and Technology
4.     Property
5.     Application

In this project we will be using IR sensors to measure the RPM

This device emits and/or detects infrared radiation to sense a particular phase in the
environment. Generally, thermal radiation is emitted by all the objects in the infrared
spectrum. The infrared sensor detects this type of radiation which is not visible to human eye.
A Typical IR sensor is shown below.

Figure 2: IR sensor/ RPM sensor.

Working
The basic idea is to make use of IR LEDs to send the infrared waves to the object. Another
IR diode of the same type is to be used to detect the reflected wave from the object. The
diagram is shown below.

[Type text] Page 8


Wireless Control of DC motor.

When IR receiver is subjected to infrared light, a voltage difference is produced across the
leads. Less voltage which is produced can be hardly detected and hence operational
amplifiers (Op-amps) are used to detect the low voltages accurately.
 
Measuring the distance of the object from the receiver sensor: The electrical property of IR
sensor components can be used to measure the distance of an object. The fact when IR
receiver is subjected to light, a potential difference is produced across the leads.

[Type text] Page 9


Wireless Control of DC motor.

3. L-298 driver.
The L298 Driver is a high voltage, high current dual ful bridge driver designed to
accept standard TTL logic levels and drive inductive loads such relays, solenoids, DC
and stepping motors. Two enable inputs are provided to enable or disable the device
independently of the input signals. The emitters of the lower transistors of each bridge
are connected together the corresponding external terminal can be used for the
connection of an external sensing resistor.

FEATURES
 Operating supply voltage up to 46 V
 Total DC current up to 4 A
 Low saturation voltage
 Two motor direction indicator LEDs
 Logical "0" input voltage upto1.5 V (HIGH NOISE IMMUNITY)
 Over temperature protection.
 Schottky EMF-protection diodes
 An onboard user-accessible 5V low-dropout regulator
]

[Type text] Page 10


Wireless Control of DC motor.

Driver Circuit Diagram.

This driver is used to control speed of DC motor. The driver receives the inputs from
NODE MCU.

SPECIFICATIONS
Operating Voltage - Up to 46v
DC Current - 4A

[Type text] Page 11


Wireless Control of DC motor.

Pin Details

Pin No Name Detail


1 ISEN-A Current sensing Motor-1
2 OUT-1 Output to Motor-1
3 OUT-2 Output to Motor-1
4 VS Reference Voltage
5 IN-1 Direction of Motor-1
6
7 IN-2 Direction of Motor-1
8 Ground Ground
9 VSS Supply Voltage -5V
10 IN-3 Direction of Motor-2
11 EN-1 Motor controlling-1
12 IN-4 Direction of Motor-2
13 OUT-3 Output to Motor-2
14 OUT-4 Output to Motor-2
15 ISEN-B Current sensing Motor-2

[Type text] Page 12


Wireless Control of DC motor.

4. DC motor.

Almost every mechanical development that we see around us is accomplished by an


electric motor. Electric machines are a method of converting energy. Motors take electrical
energy and produce mechanical energy. Electric motors are utilized to power hundreds of
devices we use in everyday life.Electric motors are broadly classified into two different
categories: Direct Current (DC) motor and Alternating Current (AC) motor. In this article we
are going to discuss about the DC motor and its working. And also how a gear DC motors
works.

A DC motor is an electric motor that runs on direct current power. In any electric motor,
operation is dependent upon simple electromagnetism. A current carrying conductor
generates a magnetic field, when this is then placed in an external magnetic field, it will
encounter a force proportional to the current in the conductor and to the strength of the
external magnetic field.It is a device which converts electrical energy to mechanical energy.
It works on the fact that a current carrying conductor placed in a magnetic field experiences a
force which causes it to rotate with respect to its original position.
Practical DC Motor consists of field windings to provide the magnetic flux and armature
which acts as the conductor.

DC motor basically consist two main parts. The rotating part is called the rotor and the
stationary part is also called the stator. The rotor rotates with respect to the stator.
[Type text] Page 13
Wireless Control of DC motor.

The rotor consists of windings, the windings being electrically associated with the
commutator. The geometry of the brushes, commutator contacts and rotor windings are such
that when power is applied, the polarities of the energized winding and the stator magnets are
misaligned and the rotor will turn until it is very nearly straightened with the stator’s field
magnets.

As the rotor reaches alignment, the brushes move to the next commutator contacts and
energize the next winding. The rotation reverses the direction of current through the rotor
winding, prompting a flip of the rotor’s magnetic field, driving it to keep rotating.

[Type text] Page 14


Wireless Control of DC motor.

Connecting DC Motor with Microcontroller


Microcontrollers can’t drive the motors directly. So we need some kind of drivers to control
the speed and direction of motors. The motor drivers will acts as interfacing devices
between microcontrollers and motors. Motor drivers will act as current amplifiers since they
take a low current control signal and provide a high current signal. This high current signal is
used to drive the motors. Using L298 chip is the easy way for controlling the motor using
microcontroller. It contains two H-bridge driver circuits internally.
This chip is designed to control two motors. L298 has two sets of arrangements where 1 set
has input 1, input 2, output1,output 2, with enable pin while other set has input 3, input 4,
output 3, output 4 with other enable pin.

[Type text] Page 15


Wireless Control of DC motor.

Working

Circuit Diagram

The circuit operated and controlled by a NODE MCU. This Wi-Fi capable unit is connected
with the driver unit. By enabling the pins of the driver the motors are controlled. The driver
[Type text] Page 16
Wireless Control of DC motor.

is used to control the speed and direction of the motor. The driver has total of 6 pin for
controlling. Set of 3 pins for one motor and other set for another motor.

The speed of the motor is controlled by a method called Pulse width modulation. So the
rotational speed of a DC motor depends upon the interaction between two magnetic fields,
one set up by the stator’s stationary permanent magnets and the other by the armatures
rotating electromagnets and by controlling this interaction we can control the speed of
rotation.

The magnetic field produced by the stator’s 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 (N) is proportional to the back emf (Vb) 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 (Ke) giving
us the equation of: N ∝ V/KeΦ. 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, as it does with Scalextric slot car racing, 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 “Pulse
Width Modulation” or PWM. As its name suggests, pulse width modulation speed control
works by driving the motor with a series of “ON-OFF” pulses and varying the duty cycle, the
fraction of time that the output voltage is “ON” compared to when it is “OFF”, of the pulses
while keeping the frequency constant.

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 “ON”, the faster the motor will rotate and likewise, the shorter the
pulse is “ON” the slower the motor will rotate.

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.

Pulse Width Modulated Waveform

PWM, or pulse width modulation is a technique which allows us to adjust the average value
of the voltage that’s going to the electronic device by turning on and off the power at a fast

[Type text] Page 17


Wireless Control of DC motor.

rate. The average voltage depends on the duty cycle, or the amount of time the signal is ON
versus the amount of time the signal is OFF in a single period of time.

So depending on the size of the motor, we can simply connect an Arduino PWM output to
the base of transistor or the gate of a MOSFET and control the speed of the motor by
controlling the PWM output. The low power Arduino PWM signal switches on and off the
gate at the MOSFET through which the high power motor is driven.

[Type text] Page 18


Wireless Control of DC motor.

H-Bridge DC Motor Control

On the other hand, for controlling the rotation direction, we just need to inverse the direction
of the current flow through the motor, and the most common method of doing that is by using
an H-Bridge. An H-Bridge circuit contains four switching elements, transistors or MOSFETs,
with the motor at the center forming an H-like configuration. By activating two particular
switches at the same time we can change the direction of the current flow, thus change the
rotation direction of the motor.

So if we combine these two methods, the PWM and the H-Bridge, we can have a complete
control over the DC motor. There are many DC motor drivers that have these features and the
L298N is one of them.

The module have an onboard 5V regulator which is either enabled or disabled using a
jumper. If the motor supply voltage is up to 12V we can enable the 5V regulator and the 5V
pin can be used as output, for example for powering our Arduino board. But if the motor
voltage is greater than 12V we must disconnected.

[Type text] Page 19


Wireless Control of DC motor.

The Enable A and Enable B pins are used for enabling and controlling the speed of the
motor. If the pin is enabled then , the motor will run at maximum speed. These pins also act
as PWM inputs for the driver. Next, the Input 1 and Input 2 pins are used for controlling the
rotation direction of the motor A, and the inputs 3 and 4 for the motor B. Using these pins we
actually control the switches of the H-Bridge inside the L298N IC. If input 1 is LOW and
input 2 is HIGH the motor will move forward, and vice versa, if input 1 is HIGH and input 2
is LOW the motor will move backward. In case both inputs are same, either LOW or HIGH
the motor will stop. The same applies for the inputs 3 and 4 and the motor B.

To control these pins via NODE MCU we need to define the pins of NODE MCU in the
program. The programming is done is Embedded C language.

The additional feature of the project being the display of speed of each motor on the mobile
screens. This is done by using a IR sensor. An infrared sensor is an electronic instrument
which is used to sense certain characteristics of its surroundings by either emitting and/or
detecting infrared radiation. Infrared sensors are also capable of measuring the heat being
emitted by an object and detecting motion.

The wavelength region which ranges from 0.75 to 3µm is known as the near infrared regions.
The region between 3 and 6µm is known as the mid-infrared and infrared radiation which has
a wavelength greater higher than 6µm is known as far infrared.

An IR sensor consists of an IR LED and an IR Photodiode; together they are called as Photo–
Coupler or Opto–Coupler. As said before,the Infrared Obstacle Sensor has builtin IR
transmitter and IR receiver.Infrared Transmitter is a light emitting diode (LED) which emits
infrared radiations. Hence, they are called IR LED’s. Even though an IR LED looks like a
normal LED, the radiation emitted by it is invisible to the human eye. Infrared receivers are
also called as infrared sensors as they detect the radiation from an IR transmitter. IR receivers
come in the form of photodiodes and phototransistors. Infrared Photodiodes are different
from normal photo diodes as they detect only infrared radiation. When the IR transmitter
emits radiation, it reaches the object and some of the radiation reflects back to the IR
receiver. Based on the intensity of the reception by the IR receiver, the output of the sensor is
defined.

[Type text] Page 20


Wireless Control of DC motor.

Features
1. Operating Voltage: 3.0V – 5.0V
2. Detection range: 2cm – 30cm (Adjustable using potentiometer)
3. Current Consumption:at 3.3V : ~23 mA,at 5.0V: ~43 mA
4. Active output level: Outputs Low logic level when obstacle is detected
5. On board Obstacle Detection LED indicator

[Type text] Page 21


Wireless Control of DC motor.

Program

1. #include <ESP8266WiFi.h>
2. const char WiFiPassword[] = "12345678";
3. const char AP_NameChar[] = "Ready to connect" ;

4. WiFiServer server(80);

5. String header = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n";


6. String html_1 = "<!DOCTYPE html><html><head><meta
name='viewport' content='width=device-width, initial-scale=1.0'/><meta
charset='utf-8'><style>body {font-size:100%;} #main {display: table;
margin: auto; padding: 0 10px 0 10px; color:#5F5FF8; } h2,{text-
align:center;} .button { padding:10px 10px 10px 10px; width:30%;
background-color: #AAF1A2; font-size: 100%; margin-right:10px; }
</style><title>CAR CONTROL</title></head><body><div
id='main'><center><h2>Hello You<br><br>I am Happy to move by your
android</h2></center>";

7. String html_2 = "<center><form><input formaction='M1-FW'


class='button' type='submit' value='M1-FW' > <input formaction='M1-
BW' class='button' type='submit' value='M1-BW'
></form></center><br>";

8. String html_3 = "<center><form><input formaction='M1-DOWN'


class='button' type='submit' value='M1-DOWN' > <input
formaction='M1-UP' class='button' type='submit' value='M1-UP'
></center></form><br>";

[Type text] Page 22


Wireless Control of DC motor.

9. String html_4 = "<center><form><input formaction='STOP'


class='button' type='submit' value='STOP' ></center></form><br>";
10. String html_5 = "<center><form><input formaction='M2-FW'
class='button' type='submit' value='M2-FW' > <input formaction='M2-
BW' class='button' type='submit' value='M2-BW'
></form></center><br>";

11. String html_6 = "<center><form><input formaction='M2-DOWN'


class='button' type='submit' value='M2-DOWN' > <input
formaction='M2-UP' class='button' type='submit' value='M2-UP'
></center></form>";

12. String html_7 = "</div></body></html>";

13. String request = "";


14. uint8_t Pwm1 = D1; //Nodemcu PWM pin
15. uint8_t Pwm2 = D2; //Nodemcu PWM pin

//Seven segment pins attachecd with nodemcu pins


16. int a0 = D5; //Gpio-15 of nodemcu esp8266
17. int a1 = D6; //Gpio-13 of nodemcu esp8266
18. int a2 = D7; //Gpio-12 of nodemcu esp8266
19. int a3 = D8; //Gpio-14 of nodemcu esp8266
20. const int changeStep = 51.2;// 10 is 10% every time button is pushed
21. int outPutValue1 = 614.4;// variable holding the light output vlaue (initial
value) 40 means 40%
22. int outPutValue2 = 614.4;
23. const int motorMinimumSpeed=256;

24. int dataIN = D0; //IR sensor INPUT


25. const int N = 2; // No. of arms/reference points

[Type text] Page 23


Wireless Control of DC motor.

26. unsigned long prevmillis; // To store time


27. unsigned long duration; // To store time difference
28. unsigned long lcdrefresh; // To store time for LCD refresh

29. int rpm; // RPM value

30. boolean currentstate; // Current state of IR input scan


31. boolean prevstate; // State of IR sensor in previous scan

32. int dataIN1 = D4; //IR sensor INPUT

33. unsigned long prevmillis1; // To store time


34. unsigned long duration1; // To store time difference
35. unsigned long lcdrefresh1; // To store time for LCD refresh

36. int rpm1; // RPM value

37. boolean currentstate1; // Current state of IR input scan


38. boolean prevstate1; // State of IR sensor in previous scan

39. void setup() {


40. Serial.begin(9600);
41. pinMode(a0, OUTPUT);
42. pinMode(a1, OUTPUT);
43. pinMode(a2, OUTPUT);
44. pinMode(a3, OUTPUT);
45. pinMode(dataIN,INPUT);
46. prevmillis = 0;

[Type text] Page 24


Wireless Control of DC motor.

47. prevstate = LOW;


48. pinMode(dataIN1,INPUT);
49. prevmillis1 = 0;
50. prevstate1 = LOW;

51. boolean conn = WiFi.softAP(AP_NameChar, WiFiPassword);


52. server.begin();

53. }

54. void loop() {


55. currentstate = digitalRead(dataIN); // Read IR sensor state
56. if( prevstate != currentstate) // If there is change in input
57. {
58. if( currentstate == HIGH ) // If input changes only from LOW to HIGH
59. {
60. duration = ( micros() - prevmillis )*N; // Time difference between
revolution in microsecond
61. prevmillis = micros(); // store time for nect revolution calculation
62. rpm = (60000000/duration); // rpm = (1/ time millis)*1000*1000*60;

63. }
64. }

65. prevstate = currentstate; // store this scan (prev scan) data for next scan

66. currentstate1 = digitalRead(dataIN1); // Read IR sensor state


67. if( prevstate1 != currentstate1) // If there is change in input
68. {
69. if( currentstate1 == HIGH ) // If input changes only from LOW to HIGH
70. {

[Type text] Page 25


Wireless Control of DC motor.

71. duration1 = ( micros() - prevmillis1 )*N; // Time difference between


revolution in microsecond
72. prevmillis1 = micros(); // store time for nect revolution calculation
73. rpm1 = (60000000/duration1); // rpm = (1/ time millis)*1000*1000*60;

74. }
75. }

76. prevstate1 = currentstate1; // store this scan (prev scan) data for next scan

// Check if a client has connected


77. WiFiClient client = server.available();
78. if (!client) { return; }

// Read the first line of the request


79. request = client.readStringUntil('\r');

80. int Ms1=0,dir1=0,Ms2=0,dir2=0,Pw=0;

// Match the request


81. if (request.indexOf("M1-FW") > 0 ) {
82. analogWrite(Pwm1, outPutValue1); //Pwm duty cycle 75%
83. digitalWrite(a0, HIGH); //Start first motor
84. digitalWrite(a1, LOW);

85. dir1=1;
86. }

87. if (request.indexOf("M1-BW") > 0 ) {


88. analogWrite(Pwm1, outPutValue1); //Pwm duty cycle 75%
89. digitalWrite(a0, LOW); //Change First motor rotation direction

[Type text] Page 26


Wireless Control of DC motor.

90. delay(5000); //5 seconds delay


91. digitalWrite(a1, HIGH);

92. dir1=0;
93. }

94. if (request.indexOf("STOP") > 0 ) {


95. digitalWrite(a0, LOW); //Stop first motor
96. digitalWrite(a1, LOW);

97. digitalWrite(a2, LOW); //Stop second motor


98. digitalWrite(a3, LOW);

99. }

100. if (request.indexOf("M2-FW") > 0 ) {


101. analogWrite(Pwm2, outPutValue2); //Pwm duty cycle 75%
102. digitalWrite(a2, HIGH); //Start second motor
103. digitalWrite(a3, LOW);

104. dir2=1;
105. }

106. if (request.indexOf("M2-BW") > 0 ) {


107. analogWrite(Pwm2, outPutValue2); //Pwm duty cycle 75%
108. digitalWrite(a2, LOW); //Change Second motor rotation direction
109. delay(5000); //5 seconds delay
110. digitalWrite(a3, HIGH);
111. dir2=0;
112. }

[Type text] Page 27


Wireless Control of DC motor.

113. if (request.indexOf("M1-DOWN") > 0 ) {

114. outPutValue1 -=changeStep;

115. if(outPutValue1 < motorMinimumSpeed)


116. {
117. outPutValue1 = motorMinimumSpeed;
118. }
119. analogWrite(Pwm1, outPutValue1);
120. }

121. if (request.indexOf("M1-UP") > 0 ) {


122. outPutValue1 +=changeStep;

123. if(outPutValue1 > 1023)


124. {
125. outPutValue1 =1023;
126. }
127. analogWrite(Pwm1, outPutValue1);
128. }

129. if (request.indexOf("M2-DOWN") > 0 ) {

130. outPutValue2 -=changeStep;

131. if(outPutValue2 < motorMinimumSpeed)


132. {
133. outPutValue2 = motorMinimumSpeed;
134. }
135. analogWrite(Pwm2, outPutValue2);
136. }

[Type text] Page 28


Wireless Control of DC motor.

137. if (request.indexOf("M2-UP") > 0 ) {


138. outPutValue2 +=changeStep;

139. if(outPutValue2 > 1023)


140. {
141. outPutValue2 =1023;
142. }
143. analogWrite(Pwm2, outPutValue2);
144. }

145. client.flush();

146. client.print( header );


147. client.print( html_1 );
148. client.print( html_2 );
149. client.print( html_3 );
150. client.print( html_4 );
151. client.print( html_5 );
152. client.print( html_6 );
153. client.print( html_7 );

154. delay(5);

155. if( ( millis()-lcdrefresh ) >= 2000 )


156. {
157. Serial.println(rpm);
158. client.println("Motor-1 Details<br/>");
159. client.println("RPM = " );
160. client.println(rpm);

[Type text] Page 29


Wireless Control of DC motor.

161. if(dir1==1){
162. client.println("<br/>Motor rotating in FORWARD direction<br/>" );
163. }
164. else{
165. client.println("Motor rotating in BACKWARD direction<br/><br/>" );
166. }
167. client.println("Motor-2 Details<br/>" );
168. client.println("RPM = " );
169. client.println(rpm1);

170. if(dir2==1){
171. client.println("<br/>Motor rotating in FORWARD direction<br/>" );
172. }
173. else{
174. client.println("Motor rotating in BACKWARD direction<br/>" );
175. }

176. client.println("</html>");
177. delay(1);
178. Serial.println("Client disonnected");
179. Serial.println("");
180. }
181. }

[Type text] Page 30


Wireless Control of DC motor.

Advantages

1. Anywhere, Anytime Work


2. Through wireless communication, working professionals and mobile workers can work
and access the Internet just about anywhere, anytime without the hassles of wires and
network cables.
3. Enhanced Productivity
4. Workers, students, professionals and others need not be constrained by wired Internet
connections or dial-up connectivity. Wireless Internet connectivity options ensures that work
and assignments can be completed anywhere and enhance overall productivity of all
concerned.
5. Remote Area Connectivity

[Type text] Page 31


Wireless Control of DC motor.

Disadvantages.

1. Wireless communications are limited by the range of the transmitter.


2. Cost of wireless communication system and components are high.
3. When transmitting data, users must sometimes send smaller bits of data so the
information moves more quickly. The size of the device that's accessing the
information is also still an issue.
4. Many applications need to be reconfigured if they are going to be used through
wireless connections.
5. Most client/server applications rely on a persistent connection, which is not the case
with wireless.
6. Since radio waves travel through the atmosphere they can be disturbed by electrical
interferences (such as lightning) that cause static.

[Type text] Page 32


Wireless Control of DC motor.

Future scope

[Type text] Page 33

You might also like