You are on page 1of 6

Instrumentation and Control of a DC Motor

through the Ubidots Platform

Jackson Rios, jackson.rios@unillanos.edu.co, Universidad de los Llanos. Cesar A


Romero,cesar.romero@unillanos.edu.co, Universidad de los Llanos, Diego
Molina,diego.molina@unillanos.edu.co, Universidad de los llanos

and pOSItIOn of a DC motor (actuator), uses a quadrature


Abstract-How to control and monitor devices when I'm not at encoder sensor, and Ubidots platform for displaying,
home? It is a question that until the last century did not have an managing and storing sensor data. In addition, we use the
overwhelming answer from the engineeringjield. The technological
TM4C1294 Connected Texas Instruments Launchpad card as
deelopment of recent years has allowed us to perform this task by
uSing software and hardware tools: monitoring different devices
hardware element for the controller and the transmission of
from our smartphone comes down to simply downloading an app or data in real time.
entering a website. This article presents an application that can be
example of how to answer the aforementioned question. II. ELECTRONIC LEVEL
This level of design focuses on programming the
Keywords- Digital control, programming, implementation, microcontroller TM4C1294NCPDT from the Tiva C series
programming tools. manufactured by Texas Instruments. The main features of thi
microcontroller are: a core ARM Cortex M4F operating at
I. INTRODUCTION 120MHz with a flash memory of lO24 KB [3]; two 12 bit
ADC modules with a maximum sampling rate of 2 MSPS; a
eople have in their houses or work places different
P variables they would like to monitor constantly such as
temperature, the presence of smoke, etc. Checking the
GPIO 15 for acquiring physical blocks of digital signals; and
an Ethernet lO/100 MAC interface with IEEE1588 support.
The TM4C1294NCPDT can be programmed in C language
state of those variables from their mobile devices would


by means of these development tools: Code Composer Studio
provide these people certain degree of tranquility.


(CCStudio) IDE, IAR Systems, KEIL ARM Tools by,
There is a need for accessible and affordable tools that
Sourcery Codebench from Mentor Embedded GNU
enable people to monitor various kinds of devices in order to
Atollic TrueSTUDIO and Energia.nu. This variety of tools
contribute to energy saving, comfort, and remote control of
gives the developer the ability to adapt to any application.
domestic facilities.
Regarding the electrical characteristics required by the
The progress of information and communication
analog or digital signals to be properly acquired and processed
technologies (lCT), and their penetration in practically all
by the microcontroller, they must meet the same technical
areas of life have generated frequent conversations about
specifications, which define that the nominal input voltage
intelligent buildings and smart houses driven by three main
should be 3.3V GPIO and the current should be in the range
factors: technological development, social changes and
of 2mA to 12mA depending on the type of configuration used
business opportunities [1].
by the GPIO pin. Regarding the use of the ADC, the analog
The home automation devices are counted in large numbers
signals should be in the range of OV to VDDA to operate in
and have a high degree of heterogeneity. Additionally, the
full scale with internal reference voltage, and in the range of
constant technological improvement and the frequent
2.4V to VDDA to operate in full scale and external reference
innovations introduce constant changes in these devices.
voltage.
These are the reasons for us to present in this article an
intuitive and more general classification of home automation
devices, distinguishing four categories: sensors, actuators,
III. DOMOTICS
smart appliances, and electronic equipment [2, p.20].
To show the usefulness of cloud services and home The Spanish association of automation defines "Domotics" as
automation in the comfort of users, we show the design of a the addition of simple technology to houses and buildings in
system that allows for the control and monitoring of the speed rde to manage their devices and systems (heating, washing,
hghtmg, etc [1, p.5] in an energy efficient, safe and
comfortable way for the user. Domotic devices are classified
978-1-5090-0228-3/15/$31.00 @2015 IEEE
in four main categories:
physical systems. In this case, the behavior of the systems are
A. Sensors represented by a set of state variables, showing how the state
The sensors or detectors are devices capable of collecting of the system evolves. For a linear system, the compact
information about various parameters and transmit it notation that represents the system is formed by a state
information for its processing. differential equation or state equation and an output equation.
The state equation describes the rate of change of the system
B. Actuators state and the input signals given at time t. [5, p. l]
Actuators are devices capable of receiving an order from a
control system and perform an action that changes the state of dx
a particular equipment or system: on or off, up or down, = Ax + Bu (1)
dt
opening or closing. For example, at nightfall you can Y = ex + Du (2)
automatize the closing of a blinder. A control system can emit
a signal a signal to a relay to turn on the engine that makes the
Input
blinder close. Plant: Output
.,.

C. Appliances U(s) G(S) Y(s)


Traditional appliances are electromechanical devices that
perform routine chores such as cleaning dishes, baking, food
preservation, etc. In this section we consider the white goods,
that is, those linked to the kitchen and household cleaning.
I State

D. Intelligent Electronic Devices Fig. I. System Control of Modern theory


Consumer electronics dedicated primarily to recreational
activities and entertainment. These devices, the result of B. Digital control
continuous improvement in digital technology, incorporate The digital control is a branch of control theory that uses
advanced features that enable communication among devices computers, microcontrollers, or embedded computers to
and access to external services, without disregarding an operate a system. In this case the computer can be used as a
improved picture and sound quality with respect to their controller and the information going into or coming out of it
traditional counterparts. In order to communicate each other, should be discrete.
these devices use the multimedia networks installed in the When the system processes digital and analog signals
house, greater bandwidth than conventional data networks and simultaneously, it will be necessary to provide a mechanism to
automatic capacity detection of the connected devices and convert from one format to the other, as required by the
their associated functions [2 p.51- 55] system. A device that converts analog signals to digital signals
converter is called analog to digital converter (ADC). On the
IV. CONTROL THEORY other hand, a device that converts digital signals to analog is
called digital to analog converter (DAC).
Control theory is defined as an interdisciplinary field that
In the analog to digital conversion, the analog signal is first
studies the behavior of systems. In the second half of the
sampled and then converted into a sequence of binary digits.
nineteenth century, thanks to advances in mathematics
In this case, using the Laplace transform to analyze the system
(Laplace transform and Fourier transform), control theory
becomes a little bit difficult, so we need to use a method such
started to settle as well as the design of the first control
as z-transform, to describe and analyze the system
systems used in telephone systems, power plants , stabilization
performance. The z-transform is a mathematical method
of airplanes, etc.
which allows to transform difference equations to linear
Due to the large number of independent elements
algebraic equations, which can be easily solved [3, p.75].
constituting a control system and the difficulty of representing
them by a set of differential equations, it was difficult to
Analog Reference r--___----=l
Dig
design flawless control systems. ital Analogr--_...,Process
Digital
In the late 1940s, WR Evans presented a simple method to System
computer
Ecuation
find the roots of the characteristic equation of a system,
method called root locus. This method indicates how the poles
and zeros should be modified in the open loop so that the
response meets the specifications of system behavior, which
Fig. 2 System Control Digital.
significantly simplifies the analysis of systems [3, p. l]

A. Control systems in modern control theory. C. Types of Controllers


Additionally, the control uses modem set theory and linear
algebra to pose, in the time domain, mathematical models of
The purpose of a control system is to achieve, through the reaction of the current error. The integral generates a signal
manipulation of the control variables, domain over the output proportional to the sum of the error correction. The derivative
variables, so that they reach a predetermined values. determines the reaction time in which the error occurs [4, page
There are several classifications within control systems. 1-15].
Depending on their nature are analog, digital or mixed; by The equation (1) represents the PID's continuous behavior
number of inputs and outputs can be classic control or modern Transfer function is:
control. The main classification of control system considers
J.t d
two large groups, which are:
Open loop system: The output has no effect on the control
Vc(t) = Kpe(t) + Ki 0 e(t)dt + Kp -e(t)
1 it d
dt (3)
action. This system is characterized by the fact that the Vc(t) = Kce(t) + Ti 0 e(t)dt + T(d) e(t) (4)
information or the variable that controls the process goes in dt
only one direction, from control system to the process;
therefore, the control system does not receive confirmation
that the actions were successful.
Closed loop system: The output has a direct effect on the
control action. It is characterized by the feedback from the
process to the control system through sensors. The control
system receives confirmation of the correct execution of its
orders.

comparator ,-----,-----,
Input
Signal
__M -

If-----.. I Process Output
Signal Fig. 4. PID Control
. '

Sensor V. UBIDOTS

Fig. 3. System Closed Loop Control


Ubidots is a cloud service that offers a friendly and intuitive
interface where the users can interact with a variety of devices,
ranging from a cell phone or a computer, to an embedded
To establish a system or control loop, first we need to system such as a microcontroller system. In short, Ubidots is a
determine the desired value of a variable or property, which is platform that allows to link different types of devices to a
called reference (input signal) and can be constant or variable cloud database and save variables that can represent them in a
depending on the needs of the system. Secondly, we must simple and fast way.
have information about what is happening in the process, by For example you could have a temperature sensor
measuring or observing the chosen variable (known as process connected to the microcontroller, which could send the current
variable) by means of a sensor suitable for this purpose. Third, temperature provided by the sensor every 10 seconds. With
a process will have to compare the information sent by the such a setting the Ubidots database would contain a variable
sensor with the desired reference in order to calculate the indicating the temperature, a temperature table ( 0 C) would be
control error. This action is performed by a controller element, displayed with respect to time (s) and a graph would show
which determines the action to take in order to minimize the how the change has been in time.
control error. The last element, the actuator, is in charge of The reason for using a cloud database is to monitor the
closing the control loop; it receives the information from the engine speed and to change it only by directly entering to the
controller, and executes the required control action to generate Ubidots website.
the necessary changes in the system.
There are several controllers or control systems, widely used
in industrial processes. Among them the most outstanding is
the proportional integral derivative controller or PID for short
[5, P 567]

1. Proportional integral derivative (PID).


A PID is a feedback control mechanism, which calculates e
the deviation or error between a measured value and the value ..
-
--_ _-
-
,--_. __ ....
.

to be obtained, to implement the corrective action to adjust the


process. The calculation algorithm of the PID control is given
to the sum of three different parameters: the proportional, Fig. 5. Ubidots web site
integral, and derivative. The proportional value determines the
VI. MATERIALS Il Syst.em Identification - Untitled
File Options Window Help
Motor 12V DC
Quadrature encoder
Connected Launchpad TM4Cl294
Bridge H WB29111

VII. DESIGN DC MOTOR CONTROLLER

For the design of the DC motor driver the following steps


were followed: o TIme plOt
Iwor!p30011 LTI : WOf I D Mooeloutput 0 Transientresp 0 NonlnearARX

DOataspectra D MlXlelresil:ls D Frequency resp D HallYTl-Wiener

>[ D
UFrequencyfunction UZerosandpoles

____
_ ____
D_ ata
It ____
Caracterization
____________-J
Trash
V&IIirbtlnn nl;l
DNoiSespectrum

Matematical model
Fig. 8. Tool TDENTT

IDENT can import the system data, perform a pre-processing


of data and estimate the second order transfer function that
best represents the data obtained with the least error possible.
We must keep in mind that the IDENT tool requires knowing
Controler D esing the sampling time of the signal to calculate the best transfer
function model.
Fig 6: steps for the controller desing

By performing this process the following mathematical model


A. Data of the motor data was obtained (3):
For characterizing the plant the system was set to run in
open loop with a step function as input. The speed of the 7,859
engine and the time taken for the system to stabilize was 0,0148852 + 0.2445 + 1 (5)
registered. In this case the input step of the system was 12V
and the time during which the data was taken was 5 sec. The Which is converted back to discrete time with a sampling
response was: time of 0,20s using MATLAB tool c2d (C), which generated
IPl Figure 1 l...,.l.a the following equation (4).
File Edit View Insert Tools Desktop Window Help .

OeJliiIQ.I 4 1 "\"O /.I Ii!. I DI l!:::!I


0,09474Z + 0,08493
100
e Z2 1,698Z + 0,7205 (6)
_

90

80

70
C. Controller Design
60

50
Sisotool MATLAB is a tool that allows for the construction
40
of the mathematical models of dynamic systems from Input
30
Output data, facilitating the design of control systems.
20 This Toolbox has a graphical interface that uses the root locus
10 (LGR) method, allowing for the variations of the system
a response to be displayed in real-time when the user makes
a 1 2 3 4 5 6
changes to the poles and zeros of the system.
Fig. 7. DC motor Graphical Step response

B. Plant Characterization
The IDENT MATLAB tool allows getting the transfer
function of a system without knowing it, since only the C_>O '!M!rn'!_! .. .II ModI Yarn'_our", "M'<I_ ....... .

experimental data obtained from the plant are required. I 1-ocpca>1'9r ...... I'Ho"pdas...,

I
conf9.1.odd'I..-qofa

,_...o._.._.

I s.. _ .. n ..... c:onv.n"'" . I _ ... ....., ... """'of__ "T>.

Fig. 9. SISOTOOL
The first thing we must have is the transfer function of the point value the difference equation is evaluated. The necessary
plant, since this is the basis for the design of the controller. code can be found in [17].

Once the tool has the design parameters of the controller IX. ELECTRONIC CIRCUIT
(settling time, overshoot percentage) and the equation of the
With selected materials, we designed an electronic circuit to
discretized plant, and the PID controller has been tuned, it
control the speed and rotation of the motor through a H bridge
yields the following result: acting as power driver, a RJ-45 connector for Ethernet and
1
Kp + Ki* + Kd*(z-l) (7)
-- encoder connection.
z-l
Kp 0,551 Ki -0,021 Kd 0,02
= = = Fig 12 energy code fragment

setting time = 1,5s %overshoot = 5% Lifting time=1,5s


Rt=speedJimit;
Et=rt-y; Ilerror calculation
It=ki*et;llcintegral error calculation
VIII. CONTROLLER CODlF1CATlON Dt=kd*(et-etO);llderivative error calculation
Ut=it+kp*et+dt; liPID output
The necessary code for the TM4C1294NCPDT
microcontroller code form the Tiva C series was written on the Source: the authors.
energy IDE, wherein the first part is responsible for the
connection to the graphical interface of Ubidots.

MOTOR.IJC CON ENCOCER

Fig. 10. Graphic interface UBIDOTS

The interface consists of 2 ubidots buttons to control the speed


and an indicator of the RPM speed, the ubidots service Fig. 13. Electronic Circuit.
delivers the "Variable ID" of each of the elements and the
token is required for authentication of the user that is X. RESULTS
accessing the interface, so that the data is not hacked. With the goal of testing the response of the controller, tests
consisting of several steps were conducted to observe the
stabilization time for the system.
String idvariablel ="55aOeda976254214dl d36c9c";
String token = SIMULAC!6N ------.
120 r---r-------,_--
"hy9BkZBBaPXPYtTSUaP7DyM4p3SSBetyKsKVuOzM08yXbiGTtv
xrPJUatgr"; . .

r :v i\}"-----T-----T-----
. .
100
. .
------------ ------ -
";;1.. -""'"'-....-,.. . . .

: tilri-r-LT1 II
Fig 10 code energy
Source: The Authors
The code in energy consists of two main parts:
: : : : : : : 1--
..

ent.rada
Ethernet communication with the page 40 ... --. --..-- : .--.-- : ..--.. : --..--:.--.--..--..--. .--. :---..--:..--..


, .
.
,
.
, .
.
, .
.
.
www.ubidots.com. where the authentication is performed by , .
.
"
, .
.
.
,..
. .
,. . . ,.
- .. - - - r - ----- ; . --.. -r -.---- ; - - - - - - ' - -.. - r' ---. ,--. --- - -.. -T'
. . .
the token and by identifying the transmission and reception of 20 , , . , , , . , ----
i
data [9]. , ,
, .
,, , .
T.
,,.

.
. ,' .
.
.
.

Monitoring and control of the DC motor speed, this


part makes the measurement of the motor speed depending on
the quadrature encoder output and the set point sent from Fig. 14. Response to different in steps
ubidots interface that has a button (speed up), which increases After designing and implementing the system for controlling
by lO% the speed of the motor, and a second button (speed the DC motor speed, favorable results were obtained, since the
down), which reduces by lO% the speed. Depending on the set
implementation of the driver found in MATLAB met the [3] K. Ogata, Modern Control Engineering. Englewood
requirements specified. Cliffs: Prentice-Hall, 1996.
The ident MATLAB tool allowed us to obtain a mathematical [4] Castano .A & Ramirez, D. (2014). SISTEMA
approximation of the plant. The connection interface ubidots ELECTRONICO PARA ESTUDIO DE ESPASTICIDAD
was stable, and allows sending and receiving data every 20ms. Y PERDIDA DE MASA MUSCULAR POR MEDIO DE
ELECTRO - ESTIMULACION. Universidad San
Buenaventura, Cali-Colombia, pp. 60.
XI. CONCLUSIONS [5] R. Ortega and R. Kelly, "PID self-tuners: Some
It is important to characterize the plant with different input theoretical and practical Aspects," IEEE Trans. Ind.
Electron., vol. IE-31, pp. 332-338, Nov. 1984.
values for various system responses, so a wider range of data
can be available for the IDENT software to better analyze the
behavior of the plant, and obtain a transfer function that
models the system correctly.

When using PWM to vary the motor speed, it must be taken


into account which is the minimum value of pulse width that
activates the motor correctly.

The selection of the sampling frequency is important for the


driver to function in a proper way, because any deviation
could cause problems in the response, so it is important to
consider the characteristics of the microcontroller to see if it
can meet the demands of the calculations in the required time.
This condition was met by the microcontroller that we used

The TM4C1294 LaunchPad was helpful because it has


Ethernet interface card and also a PWM pin that allowed for
the control of the motor speed.

The use of the PID controller in SISOTOOL provides the


implementation of the design with response to different user
defmed steps, this allows for the control the system's response
to different inputs, which is critical for the design of digital
controllers. SISOTOOL is a tool that uses the root locus of the
system and lets us add poles and zeros, which allows for
stability with the characteristic of the driver.

The developing of the instrumentation and control of a DC


motor through ubidots allows the user to have the control of
the device and check its speed at any moment.

XII. ACKNOWLEDGMENTS

This work was supported by the University of the Llanos


(UNILLANOS) and the Instituto de Investigaciones de la
Orinoquia Colombiana (IIOC) and developed by the Research
Group on Open Technologies (GITECX).

XIII. REFERENCES

[1] Junestrand, Passaret. (2005). Domotica y Hogar Digital.


International Thomson ediciones spain, pp. 3.
[2] Dominguez. saes (2006). Domotica: un enfoque
sociotecnico.Centros de Domotica Integral CEDINT,
Junio 2006, pp. 51-55.

You might also like