Dissertation
Dissertation
DISSERTATION
DOCTOR OF PHILOSOPHY
(Mechanical Engineering)
Sang-Hoon Lee
January 2009
Microcontroller-based Data Acquisition and Control
with Applications
DISSERTATION
Degree of
at the
by
Sang-Hoon Lee
January 2009
Approved:
Department Head
Date
Copy No.
Approved by the Guidance Committee:
Date
Date
Date
Date
ii
Microfilm or other copies of this dissertation are obtainable from:
iii
To God, my wife, my daughter, and my parents
Acknowledgment
There is a famous Korean proverb, “Whom one meets during his life could change him
into who he will be.” It was one of the turning points of my life that I met Professor Vikram
Kapila. It has been a great honor to have him as my academic advisor throughout my Ph.D.
program as well as my Master of Science program. He has opened my eyes in the fields of
controls and mechatronics. I still remember the day when Professor Kapila provided me my
first microcontroller kits to work on. That day was another turning point in my career. With
the knowledge of control and mechatronics that I have been taught by him, I was able to
not only accomplish many of my research goals, but also to elevate my career to a higher
level. I would be remiss not to mention how much dedication, trust, and patience he has
shown towards me. I couldn’t be who I am now without his support. In addition to being
the academic influence, he has been a counselor of my life like an uncle, brother, or rabbi.
I am also grateful that he has continuously provided me with financial assistance during my
academic years at Polytechnic Institute of New York University (NYU-POLY). I also thank
Professor Kapila for helping me secure a visiting faculty position at NYU-POLY. I sincerely
My graduate studies would not be possible without the financial assistance from various
sources. First, I thank the National Science Foundation’s Research Experience for Teachers
Program under grant 0227479 for financially supporting much of my doctoral degree program.
This grant provided me a research assistantship to assist Professor Kapila in developing and
conducting the Science and Mechatronics Aided Research for Teachers (SMART) program.
Second, I thank the New York State Department of Education’s Engineers of the Future Pro-
gram under grant C400682 for partially supporting me. This grant supported my research in
part and allowed me to collaborate with Professor Kapila in developing and conducting a Sum-
mer Mechatronics Institute for Teachers (SUMMIT) program. I thank all 67 New York/New
Jersey secondary school teachers who participated in the four-week summer research experi-
ence under the SMART (20032005) and SUMMIT (2007) projects, developing mechatronics
v
projects with me and my colleagues. I learned a lot by interacting with them. Finally, I
thank the Mechanical Engineering (ME) department of NYU-POLY for partially supporting
my graduate studies, in the form of teaching assistantships, at various times during my doctoral
degree.
Most of all, I sincerely thank my loving wife, JiYoung Kim, whose enduring patience is
boundless and support endless. She has given me encouragement and comfort during my
entire doctoral program. She has also been praying for me numerous days and nights. It will
never be possible to express, in words, my deep gratefulness for her support. “I love you,
JiYoung.” I also thank God for giving me a precious daughter, Claire Haerin Lee, who has
given me priceless moments and a joyful life just by her existence itself. My family has been
an essential anchor during my graduate studies. They have provided me nourishment in the
form of moral and ethical guidance and supported me with endless prayers. They have shown
Next, I thank Professors Magued Iskander and Nikhil Gupta for being members of my
committee, Professor Maurizio Porfiri, for introducing me to a new topic of chaos synchro-
nization which has led to a fruitful collaboration. I gratefully thank ME department chair,
Professor George Vradis, for many kind words of encouragement throughout my studies and
providing me with a great opportunity for a full-time teaching position at NYU-POLY. I also
thank ME department administrator, Ms. Lorraine Bildzukewicz, for her countless support
and care.
On a personal note, I thank Dr. Noel Kriftcher for his warm care like an uncle. Next,
Yan-Fang (Yvonne) Li, Antonio Mannino, Anshuman Panda, Valentin Siderskiy, Christopher
Wilkins, and Hong Wong for their wholehearted support towards many of my personal and
vi
AN ABSTRACT
APPLICATIONS
by
Sang-Hoon Lee
January 2009
In the first part of this dissertation, we consider the development of PC-based data ac-
quisition and control (DAC) tools that use inexpensive microcontrollers (e.g., PIC and BASIC
Stamp 2) and widely used technical computing software MATLAB/Simulink, which provides
a wealth of graphical design tools. Our MATLAB and Simulink-based toolboxes yield inex-
pensive DAC solutions by exploiting the serial communication capability of both MATLAB
and microcontrollers. Our framework is well suited for DAC tasks that require graphical user
interface and/or advanced computational capabilities but do not require stringent hardware
performance. We illustrate the efficacy of our DAC toolboxes by performing position control
In the second part of this dissertation, we consider two problems pertaining to synchro-
chaotic system in the sampled-data setting. Second, we address the problem of synchroniz-
ing a sporadically coupled master-slave chaotic system in the sampled-data setting. For both
for the first problem we use a time-invariant full-state feedback control law, for the second
vii
use the discrete-time Lyapunov stability theory and the linear matrix inequality framework
DAC techniques developed in the first part of this dissertation, we provide experimental val-
circuit.
viii
Contents
Acknowledgment v
Abstract vii
1 Introduction 1
2.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3.3. Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
ix
2.4.2. Serial Communication from PIC to PC: Data Acquisition, Processing,
and Plotting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.5. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.3.1. Template.mdl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.3.2. PICLibrary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.6. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
4.2.2. MATLAB/Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.3.1. Template.mdl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.3.2. BS2Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
x
4.4. Simulink Diagram Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.4.1. TotalCompile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.6. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.3.1. Experiment 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.3.2. Experiment 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.3.3. Experiment 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
5.6. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
6.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
xi
6.2. Euler Approximated Sampled-Data Chaotic System Model . . . . . . . . . . . . 71
6.7. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
7.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
7.6. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Appendix 94
Bibliography 107
xii
List of Tables
5.1 Settling time and percent overshoot requirements and PI controller gains . . . 68
6.1 Largest Lyapunov exponent with respect to different initial conditions and num-
ber of iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.2 Largest Lyapunov exponent with respect to different error magnitudes and num-
ber of iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.3 Largest Lyapunov exponent with respect to different error directions and number
of iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
7.1 Largest Lyapunov exponent with respect to different initial conditions and num-
ber of iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.2 Largest Lyapunov exponent with respect to different error magnitudes and num-
ber of iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.3 Largest Lyapunov exponent with respect to different error directions and number
of iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
xiii
List of Figures
2.3 (a) PC and PIC development board (b) Larger view of the PIC development
board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.5 (a) Light refraction experiment test bed (b) Light source mounted on the ser-
vomotor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.6 Detailed view of the light sensor traveling along the linear potentiometer . . . . 14
2.9 (a) Unfiltered plot of A2D and (b) Filtered plot of A2D . . . . . . . . . . . . . 22
2.10 Simulink block diagram for bi-directional serial communication between PIC
and PC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.11 Simulink block diagram for calculating the index of light refraction . . . . . . . 24
2.12 Angle of refraction vs. light sensor output for incidence angle (a) 40◦ and (b) 20◦ 25
3.2 (a) PIC-PG2C programmer and a PIC (b) PIC-PG2C programmer with a PIC
mounted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
xiv
3.5 PinStateIn block and parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.5 (a) Experiment 2–L1(t) response and (b) Experiment 3–L2(t) response . . . . . 67
5.6 Response of (a) L1 (t) and (b) L2(t) using the PI controller gains of case 1 . . . 68
5.7 Response of (a) L1 (t) and (b) L2(t) using the PI controller gains of case 2 . . . 69
5.8 Response of (a) L1 (t) and (b) L2(t) using the PI controller gains of case 3 . . . 69
6.1 Propeller demo boards and 912 MHz radio frequency transceivers for the sampled-
data master-slave Chua’s circuits . . . . . . . . . . . . . . . . . . . . . . . . . . 79
xv
6.2 Plots of the double scroll attractors of the sampled-data master Chua’s circuit:
(a) x1 vs. x2, (b) x1 vs. x3 , and (c) x2 vs. x3 . . . . . . . . . . . . . . . . . . . 79
6.3 Plots of the errors of the sampled-data master-slave Chua’s circuits: (a) e1 4
= x1 −
x̃1, (b) e2 4 4
= x2 − x̃2 , and (c) e3 = x3 − x̃3 . . . . . . . . . . . . . . . . . . . . . . 80
6.4 Plots of the states of the sampled-data master Chua’s circuit vs. the states of the
sampled-data slave Chua’s circuit showing synchronization of the master-slave
Chua’s circuits: (a) x1 vs. x̃1 , (b) x2 vs. x̃2 , and (c) x3 vs. x̃3 . . . . . . . . . . 80
7.2 Plots of the states of the sampled-data master Chua’s circuit vs. the states of the
sampled-data slave Chua’s circuit (xi vs. x̃i , i = 1, 2, 3) showing synchronization
of the master-slave Chua’s circuits: (a), (b), (c) with p = 1, q = 22 and (d), (e),
(f) with p = 3, q = 50 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.3 Plots of the states of the sampled-data master Chua’s circuit vs. the states of
the sampled-data slave Chua’s circuit (xi vs. x̃i , i = 1, 2, 3) showing lack of
synchronization of the master-slave Chua’s circuits: (a), (b), (c) with p = 1, q =
1500 and (d), (e), (f) with p = 3, q = 2000 . . . . . . . . . . . . . . . . . . . . . 91
xvi
Chapter 1
Introduction
Since ancient times, the innate human desire to understand, analyze, and imitate natural
phenomena has inspired numerous ingenious developments and inventions. In the last quarter-
century, the emergence of personal computers (PCs) has changed our lives drastically. For
example, in an earlier era, visual readouts of temperature were produced using thermometers,
which use the concept of the expansion and contraction of a liquid, such as mercury, in response
to the rise and fall of the temperature. A simple form of temperature data acquisition (DAQ)
may entail logging the temperature of the environment on a paper. However, the process of data
logging can also be computerized by using appropriate sensors that convert physical parameters
of interest into electrical signals which in-turn can be acquired by using computerized DAQ
hardware. Hence, DAQ technology creates a bridge between the data-measuring sensors and
data-storing memory devices. Advanced DAQ hardware can also provide a means for driving
external actuators from a computer, by producing command signals for actuators, which is
often termed data acquisition and control (DAC). DAC systems include both hardware and
software.
The role of DAC hardware is: i) to collect incoming analog input signals and convert the
same to digital signals, which is called analog to digital conversion (A2D), for further processing
and storage and ii) to convert outgoing digital signals to analog output, which is called digital
to analog conversion (D2A), for driving an actuator. Pertinent DAC terminology includes:
channels, and sampling rate. Specifications of commercially available DAC hardware are two
sampling rate. DAC systems are also categorized by their interfaces with PCs such as plug-in,
serial communication, USB, and parallel port. Each interface technique has its own benefits,
e.g., USB DAC systems have advantage of higher bandwidth and power supply, and plug-in
1
2
DAC systems yield high acquisition rates since they use the PC bus directly. For example,
Quanser’s [1] Q4 [2] plug-in DAC board is equipped with four A2Ds, four D2As, sixteen digital
I/Os, fourteen-bit input resolution, and twelve-bit output resolution. Yet another plug-in DAC
board from National Instrument [3] is NI PCI-7831R [4], which is configured with eight analog
DAC hardware without software is of little use. DAC systems require low-level hardware
function calls performed by driver software to interface application software with DAC hard-
ware for proper controls. With appropriate software, DAC systems can acquire data at a
specified sampling rate. The driver and application software are usually supplied by DAC
hardware vendors, and measurement and control software can be developed by using a variety
such measurement and control software, acquired data from DAC boards can be displayed,
analyzed, and stored on a computer. For example, LabVIEW [5] identifies, configures, and
controls DAC board hardware by a device number, and interfaces inputs from various sources
such as serial and parallel ports. In addition, it provides a user-friendly graphical user inter-
face (GUI) for developing complete instrumentation, data acquisition, analysis, and control
functions. Similarly, MATLAB/Simulink [6] enables processing of the acquired data without
necessitating the use of text-based programming languages, since it provides built-in graphical
The DAC technology is continuously being advanced toward being more accurate, reliable,
effective, efficient, and low-cost. It is envisioned that in future low-cost, small form factor DAC
hardware will become available, allowing DAQ technology to become portable and pervasive
by being embedded in hand-held computers, PDAs, and mobile phones. However, current
DAC systems tend to be quite expensive (and not very portable.) In a recent price comparison
of several MATLAB and Simulink supported PC-based DAC boards of different form factors
(e.g., PCI, ISA, and PCMCIA), we determined that these DAC boards cost from five hundred
to several thousand dollars. Furthermore, academic labs generally do not require the intrinsic
high performance features of these DAC systems (e.g., high sampling rates, high resolution
A2Ds, etc.) to educate students. The expensive DAC systems that have high sampling rates
3
and high resolution are sometimes not necessary for simple tasks. Therefore inexpensive DAC
In contrast to the PC-based DAC boards, microcontrollers are inexpensive devices (cost-
ing only a few tens of dollars), which are widely used for embedded computing. However, a
one or another high-level programming languages (e.g., BASIC, C, Java, etc.). In addition,
many low-cost microcontrollers do not allow floating-point numerical computations that may
expensive microcontrollers and user-friendly software such as LabVIEW and MATLAB will
The first part of this dissertation addresses design and development of a MATLAB and
Simulink-based software platform that enables the use of inexpensive microcontrollers for DAC
tasks. Motivated by the current trend toward user-friendly environment, we exploit Simulink’s
Simulink to communicate with various sensors and actuators connected to the microcontroller.
We then introduce position control of a DC motor system and liquid level control of a coupled,
The second part of this dissertation addresses problems of synchronization and pulse syn-
initial conditions [7]. Therefore, two identical chaotic systems never show the same trajec-
tories because even minute differences in their initial conditions cause the difference between
their trajectories to grow quickly. Such behavior drives chaos to be pervasive in the study of
oscillators is widely used in such application as cryptographic and secure communication sys-
4
tems [8–13]. For example, Pecora and Carroll of the U.S. Naval Research Laboratory realized
that synchronization of chaotic signals might be useful for encrypting private electronic commu-
nications [14]. The basic principle behind these systems is to use chaos to mask a transmitted
signal, and chaos synchronization to securely recover it in reception, which is often known as
chaotic masking. The other ways of encrypting signals by using chaos are chaos shift keying
and chaos modulation [15, 16]. The basic idea behind the use of chaos-based encryption is
to provide protection of data from unauthorized usage since an encrypted message cannot be
radios, and Internet communication are exposed to unwanted noise. Moreover, in secure com-
munications applications, noise corruption in analog signal transmission can lead to severe
drawbacks of synchronization schemes [27, 28]. Therefore, sampled-data systems have been
studied in [10, 29, 30] to improve the robustness of secure communications based on chaotic
synchronization. This sampled-data setting also leads to a reduction in the amount of infor-
mation exchange between a coupled master-slave chaotic system and results in the efficiency
of bandwidth usage.
may not be realistic because of excessive power load and additional time delay, etc. In a
that are only sporadically coupled seems particularly more realistic for communication systems
[31–34]. This synchronization scheme is referred to as pulse synchronization [19, 22], wherein
In the second part of this dissertation, we consider two problems pertaining to synchro-
chaotic system in the sampled-data setting. Second, we address the problem of synchroniz-
ing a sporadically coupled master-slave chaotic system in the sampled-data setting. For both
for the first problem we use a time-invariant full-state feedback control law, for the second
use the discrete-time Lyapunov stability theory and the linear matrix inequality framework to
construct the two control laws. Finally, by utilizing the MATLAB/microcontroller-based DAC
techniques developed in the first part of this dissertation, we provide experimental validation
Specially, using serial communication capabilities of the microcontroller and MATLAB, the
trollers (PICs) that are inexpensive microcontroller units with built-in serial communication
functionality. Similarly, MATLAB, a widely used technical computing software, allows serial
communication with external devices. In addition, MATLAB provides graphical design tools
such as Simulink and Dials and Gauges Blockset. In Chapter 2, we exploit the serial commu-
nication capability of PIC microcontrollers and the MATLAB software along with graphical
design tools of MATLAB to create a MATLAB-based GUI environment for PIC microcon-
troller projects. Three examples are included to illustrate that the integration of low-cost
PIC microcontrollers with the MATLAB-based GUI environment allows data acquisition, data
Chapter 3 addresses development of a PC-based DAC tool that uses a PIC microcontroller,
MATLAB, and Simulink. Specifically, a library of PIC microcontroller functions for Simulink
is created. Moreover, the PIC microcontroller and MATLAB are merged, by exploiting their
serial communication capability, to produce an inexpensive DAC platform. Finally, the efficacy
that enables the use of an inexpensive BS2 microcontroller for DAC tasks. The framework is
well suited for DAC tasks that require GUI and/or advanced computational capabilities but do
not require stringent hardware performance. We illustrate the efficacy of our DAC technique
6
by performing position control of a DC motor using a BS2 microcontroller and our MATLAB
DAC toolbox.
Chapter 5 addresses a liquid level control design problem of a coupled, two-tank system by
using the MATLAB-based DAC platform developed in Chapter 4. The classical proportional-
plus-integral (PI) controller is employed for the liquid level control of the coupled, two-tank
system. To effectively utilize this control methodology, the system parameters, e.g., tank
dimensions and pump characteristics, must be known exactly. However, this may not be feasible
since system parameters may change due to the effects of scaling in tanks and orifices, aging
of pump, and wear. Thus, to determine the system parameters, we conduct an experimental
system identification study which uses the inherent nonlinear dynamics of the two tank system.
to zero for arbitrary initial conditions. Moreover, using the discrete-time Lyapunov stability
theory and the linear matrix inequality (LMI) framework, we construct a state feedback control
law which yields global asymptotic synchronization of the sampled-data master-slave chaotic
for chaos synchronization. Similar to Chapter 6, the discrete-time Lyapunov stability theory
and the LMI framework are used to construct a state feedback periodic pulse control law for
circuit.
7
Finally, Chapter 8 provides some concluding remarks and recommendations for future
research.
Chapter 2
2.1. Introduction
ogy, Inc. [35], are inexpensive microcontroller units that include a central processing unit and
peripherals such as memory, timers, and input/output (I/O) functions on an integrated cir-
cuit (IC). There are more than 100 varieties of PIC microcontrollers available, each providing
functionality for different types of applications [36], making PICs one of the most popular
microcontrollers for educational, hobby, and industrial applications. Similar to other micro-
controllers, PICs are usually not designed to interface with human beings; instead they are
directly embedded into automated products/processes. Thus, graphical user interface (GUI)
capabilities, which have become a mainstay of many personal computer (PC) applications, are
Endowing PIC-based projects with GUI tools can speed the development process in data
driven applications such as feedback control, smart sensors, etc. Microchip Technology’s emu-
lator and debugger products (e.g., MPLAB IDE, MPLAB-ICE) are very helpful in debugging
PIC source code and emulating user-written programs. However, these tools do not provide
data communication with external devices such as analog to digital converters (A2Ds), 1-wire
ming software, also provides serial data communication functionality on PCs. In addition,
ulate and analyze dynamic system models. Finally, the Dials and Gauges Blockset of Simulink
8
9
allows users to embed control objects (e.g., sliders, knobs) and display objects (e.g., graphs,
with PIC microcontrollers to transmit control commands and receive sensory data. In addi-
tion, we utilize MATLAB, Simulink, and Dials and Gauges Blockset to develop an interactive
GUI environment for PIC projects, allowing enhanced data processing and visualization.
The rest of the Chapter is organized as follows. In Section 2.2, we describe the hardware
environment including the PIC microcontroller and a light refraction test bed. In Section 2.3,
we describe the software environment used in this Chapter. In Section 2.4, we illustrate the
using three examples: i) export user commands from a Simulink GUI to an actuator interfaced
to the PIC; ii) import signals from a sensor interfaced to the PIC into a Simulink GUI; and iii)
use Simulink GUI to export user commands to the PIC and import sensory data from the PIC
to control a device and monitor its status. Finally, Section 2.5, we provide some concluding
remarks.
The hardware environment for this Chapter consists of a PIC microcontroller, a PC, a
RS232 driver/receiver, and a DB-9 serial cable. The PIC microcontroller is interfaced with
external devices such as sensors (e.g., photoresistors) and actuators (e.g., servomotors). In
addition, the PIC microcontroller performs embedded computing. The PC is used to write
the PC hosts an interactive GUI for the user to manipulate control variables and visualize
sensory data. The PIC microcontroller and the PC communicate using a serial interface. A
PIC development board (see section 2.2.4) and a light refraction experiment test bed (see
section 2.2.5) are used to illustrate our PIC-based data acquisition and control approach.
10
PIC microcontrollers are small, low-cost controllers that include a processor and a variety
example, users can assign desired functionality (e.g., A2D, universal synchronous/asynchronous
receiver and transmitter (USART)) to I/O pins of PICs. PICs can be operated at various clock
speeds (32 kHz to 20 MHz). PIC’s memory architecture separates its data memory from its
program memory with the program memory available as One-Time Programmable (OTP),
the PIC assembly language using a 35 single-word instruction set. See [37, 38] for more details
The user specified embedded PIC program is written on the PC and downloaded from the
PC to the PIC microcontroller using the DB-9 serial cable connection between the PC and
available PIC Development Programmers include PICSTART Plus [39] from Microchip, Inc.,
and PIC-PG2B, a handy, low-cost programmer [40] from Olimex Ltd., among others. In this
Chapter, we use the PICSTART Plus programmer that requires MPLAB Integrated Devel-
opment Environment, a free software available on the Microchip website, for programming
PICs.
word length) microcontroller (see Figure 2.1). PIC16F74 has 4K (14-bit words) of FLASH
program memory and 192 bytes of data memory. Furthermore, it has 33 digital I/O pins
organized in 5 groups of I/O ports that can be assigned as 8-bit A2D, Capture/Compare/PWM
(CCP), the 3-wire Serial Peripheral Interface (SPI), the 2-wire Inter-Integrated Circuit (I2C)
bus, USART ports, etc. We use an external 20 MHz high-speed crystal oscillator to supply
operating clock cycles. The PIC16F74 can be powered using a wide range of voltage sources,
e.g., 2 volt direct current (VDC) to 5.5VDC, and each of its I/O pin can sink or source up to
25mA of current. It is ideal not only for laboratory data acquisition (the application considered
in this Chapter), but also for automotive, industrial, and consumer applications.
11
(a) (b)
operating system is used. As previously mentioned, the PC is used to write, debug, and
download embedded PIC programs. One of the serial ports on the PC is reserved for serial
communication with the PIC microcontroller. MPLAB, MATLAB (version 6.1), Simulink,
and Dials and Gauges Blockset are installed on the PC. Control variables are manipulated via
the PC by interacting with control panels embedded in the Simulink program. In addition,
all experimental data is collected and displayed on the PC in display panels embedded in the
Simulink program.
MAX232 (see Figure 2.2) is a 2-channel, RS232 driver and receiver manufactured by Maxim
Integrated Products, Inc. It requires a 5VDC power supply and converts voltage levels between
PC-based logic and PIC microcontroller-based logic. Specifically, whereas the voltage levels
of logic high and logic low for the PC correspond to -12VDC and 12VDC, respectively, like
many other microcontrollers the logic high and low for the PICs correspond to 5VDC and
0VDC, respectively. The MAX232 is used with five 1µF capacitors to adjust the voltage level
differences between the PC-based logic and the PIC-based logic. See [41] for more details of
(a) (b)
The PIC development board (see Figure 2.3) consists of a sensor (photoresistor), a 3-
pin header for a servomotor connection, a 20MHz crystal oscillator, a MAX232 with five
1µF capacitors, a PIC16F74 microcontroller, a breadboard, and two DB-9 connectors. The
photoresistor sensor provides light intensity measurement and is interfaced to a pin allocated
as an 8-bit A2D in port A of the PIC16F74 microcontroller. The circuit diagram of Figure 2.4
illustrates how various sensors and actuators of the light refraction experiment test bed (see
section 2.2.5) are interfaced to the PIC microcontroller. The PIC transmits/receives sensory
data to/from the PC via the MAX232. A reset button is connected to the Master Clear
Figure 2.3: (a) PC and PIC development board (b) Larger view of the PIC development
board
13
5V 5V
10 kΩ
1 40 H-Bridge
Reset button
10 kΩ H-Bridge
1kΩ 39
5V
2 Laser
Linear 38
potentiometer 3 34 Servomotor 1μF 1μF
Photoresistor
Limit switches 4 5V
1 16 2
5V 32 1μF
0.1μF 3 6
1μF
11 31 4
0.1μF 1μF
12 5
15pF 26 12 13 RS232 output
RX
13 14 RS232 input
25 11
TX
14 15
15pF 20MHz
MAX232
PIC16F74
The light refraction test bed (see Figure 2.5) is a mechatronics-aided physics experiment
developed under a National Science Foundation (NSF) sponsored Science and Mechatronics
Aided Research for Teachers (SMART) program [42] at Polytechnic Institute of New York
University. This experiment is designed to demonstrate the law of light refraction. It consists
of a light source, a light sensor, a linear potentiometer, two limit switches, a servomotor, a
DC motor, a liquid reservoir, and necessary circuitry. A liquid reservoir on the top of the
test bed can store various liquid media whose index of refraction needs to be determined. For
simplicity, in this Chapter, we use water from a water fountain as the test liquid.
Light sensor
Linear
DC motor Limit switches potentiometer
(a) (b)
Figure 2.5: (a) Light refraction experiment test bed (b) Light source mounted on the servo-
motor
14
On one side of the tank, as shown in Figure 2.5 (b), a laser pointer, used as the light
source, is mounted on the arm of the servomotor that sets the angular position of the light
source to the incidence angle specified by the user. On the other side of the tank, a general
Cadmium Sulfide (CdS) photoresistor, used as the light sensor, is mounted on the wiper of the
linear potentiometer. It monitors the refracted light coming out from the liquid reservoir (see
Figure 2.6). A DC motor drives the light sensor along the linear potentiometer by turning
a motor shaft connected to a brass screw rod thereby transforming rotary motion into linear
motion. Limit switches at each end of the linear potentiometer indicate sensor travel limit.
The photoresistor and the linear potentiometer output analog voltage signals between 0VDC
and 5VDC.
Figure 2.6: Detailed view of the light sensor traveling along the linear potentiometer
Software environment for this Chapter consists of the PIC assembly language, MATLAB,
Simulink, and Dials and Gauges Blockset. The PIC assembly language is a primitive pro-
gramming environment that is widely used to simulate and analyze dynamic system models
using icon-based tools. Finally, the Dials and Gauges Blockset of Simulink provides an ability
ter, these software tools are judiciously synthesized to produce an effective, interactive GUI
environment. In the sequel, we summarize key instructions of the PIC assembly language and
15
MATLAB that enable serial communication between PIC microcontroller and MATLAB GUI
As indicated above, the PIC assembly language consists of a 35 single-word instruction set
(see datasheets [43] for details). The PIC data memory is partitioned into several banks (e.g.,
5 banks for PIC16F74) that contain the general-purpose registers and the special-function reg-
isters. The special-function registers are used to set up special operations (e.g., A2D, USART,
and PWM) and to watch the status of the special operations (e.g., the availability of transmis-
sion or reception of the USART). Below, we review key PIC instructions and special function
BCF literally means that the bth bit in the register ‘f’ is cleared. BCF sets the bth bit in the
BSF instruction does the opposite of BCF, i.e., it sets the bth bit in the register ‘f’ to one,
logic high.
The literal ‘k’ is loaded into the working register. The literal ‘k’ can be expressed in terms of
an 8-bit binary, decimal, or hexadecimal number. For example, b’00101111’ in 8-bit binary is
equivalent to 0x2F in hexadecimal. Note that the prefixes b, 0x, and d declare the data type
MOVWF: Move w to f
MOVWF transfers data from the working register to the specified register ‘f.’ Since the lit-
eral ‘k’ cannot be directly assigned into the specified register ‘f,’ the literal ‘k’ is first assigned
to the working register (e.g., MOVLW k) and then moved into the register ‘f’ (e.g., MOVWF f).
BTFSS checks the bth bit in the specified register ‘f,’ and executes the next instruction if this
bit is zero. Alternatively, if the bit is one, the next instruction is skipped, and the following
instruction is executed.
MOVLW d’value’
MOVWF SPBRG
The special function register ‘SPBRG’ contains the user-specified baud rate for serial com-
munication. In particular, the command MOVLW d’129’ places 129 in the working register.
Next, the command MOVWF SPBRG moves the content of the working register to the special
function register ‘SPBRG.’ The placement of ‘value’ 129 in the ‘SPBRG’ register sets the baud
rate to 9,600.
MOVLW b’clock source select bit, 9-bit transmit enable bit, transmit enable bit, USART mode
select bit, unimplemented, high baud rate select bit, transmit shift register status bit, 9th bit of
transmit data’
MOVWF TXSTA
The special function register ‘TXSTA’ contains information for the data-transmit status and
control in an 8-bit binary expression. In particular, the use of commands MOVLW b’00100100’
and MOVWF TXSTA, sets up the ‘TXSTA’ register to enable 8-bit, high speed asynchronous
MOVLW b’serial port enable bit, 9-bit receive enable bit, single receive enable bit, continuous
receive enable bit, unimplemented, framing error bit, overrun error bit, 9th bit of received data’
MOVWF RCSTA
The special function register ‘RCSTA’ contains information for the data-receive status and
17
control in an 8-bit binary expression. In particular, the use of commands MOVLW b’10010000’
and MOVWF RCSTA, sets up the ‘RCSTA’ register to enable 8-bit, continuous asynchronous
ware. MATLAB’s versions 6.1 and higher provide serial communication functionality. To
serially communicate with an external device from MATLAB, the following steps need to be
performed. First, create a serial port object to identify the specific serial port of the PC
connected to the external device. In addition, specify how this serial port is to be configured
(i.e., baud rate, number of data bits, etc.). Second, connect the serial port object created
above to the external device. Third, send command signals to the external device and re-
ceive data from the external device. Fourth, disconnect serial communication connection from
the external device and close the serial port object. Finally, release control of the serial port.
We list the key MATLAB instructions used for serial communication. See [6] for further details.
serial (the PC serial port, the baud rate, the number of data bits)
This command is used to create a new serial port object. In addition, it configures the serial
port properties. In this Chapter, we used the COM2 serial port of the PC with 9,600 baud rate.
fopen (object)
This command opens the serial port object just created and connects the PC to the external
The fread command enables the PC to read binary data from the external device. Alternatively,
the fwrite command enables the PC to send control data in binary format to the external device.
fclose (object)
This command closes the serial port object, thereby disconnecting serial communication be-
freeserial (port)
Once MATLAB establishes a data link with the serial port, it assumes complete control of
the serial port. The freeserial command is used, after closing the port object using the fclose
command, to force MATLAB to relinquish control of the serial port. The command takes on
one argument, the port that was used for data communication. This command is executed
2.3.3. Simulink
users to build block diagrams to simulate and analyze dynamic system models. Designers can
effortlessly transfer paper designs of dynamic systems into Simulink block diagrams. Simulink
block diagrams can be modified as easily as paper models of dynamic systems. In addition,
Simulink allows for detailed monitoring of dynamic system outputs at any point in the block
diagram using various tools (e.g., Scope, Display, etc.). Finally, data processing tasks such as
The Dials and Gauges Blockset [45] provides enriched views of graphical, 3-D instruments
called virtual instruments. It has various templates that can be customized to create realistic
virtual instruments for electrical, aerospace, automotive, medical, and process control systems.
The virtual instruments created using the Dials and Gauges Blockset dynamically interact with
MATLAB and Simulink, thus providing an interactive interface for users to enter command
This example illustrates one-directional serial communication from the PC to the PIC
microcontroller. In particular, it demonstrates that the user commands from a Simulink block
diagram can be exported to an actuator interfaced to the PIC microcontroller. The example
19
The Simulink block diagram for this example is shown in Figure 2.7. It consists of a dial,
from the Dials and Gauges Blockset, denoted as the servo angle knob. The user interacts with
the dial to enter servomotor position control command. The dial has a range from 0 to 90
degrees with one-degree resolution. The value of the angle commanded by the user is shown
The MATLAB m-function block next to the knob contains a MATLAB m-file (see Table
2.1) to perform serial communication from the PC to the PIC. The user specified servomotor
position control command is transmitted to the PIC via a serial cable connection between the
PC and the PIC. When the PIC receives the command angle, it assigns the angle to a variable
in the PIC code. Next, the PIC utilizes the command angle to compute, generate, and apply
In this example, we used a 6VDC standard servomotor that is interfaced to the 3-pin
servomotor connection header on the PIC development board (see Figure 2.3). The PIC
2.4.2. Serial Communication from PIC to PC: Data Acquisition, Processing, and
Plotting
This example illustrates one-directional serial communication from the PIC microcontroller
to the PC. In particular, it demonstrates that a Simulink block diagram can be designed to
acquire measurement from a sensor that is interfaced to the PIC. The example focuses on
photoresistor in a voltage divider circuit. The output of the light sensor varies depending on
the light intensity incident upon the photoresistor; here the light sensor output refers to the
voltage at the junction of the 10KΩ resistor and the photoresistor. This output is connected
to I/O pin 2 of the PIC16F74. The I/O pin 2 is configured as an A2D in the PIC assembly
code. Each time, the PIC assembly code tasks the PIC to measure the light sensor output, the
PIC16F74 converts the analog voltage signal at the voltage divider output into a corresponding
8-bit digital value. Thus, when the photoresistor is placed in dark condition, the 8-bit A2D
returns a value close to 255. Alternatively, when the photoresistor is exposed to bright light,
The Simulink block diagram for this example is shown in Figure 2.8, where a MATLAB
m- function (see Table 2.2) is used to acquire the digitized output of the sensor using serial
communication. The Simulink block diagram of Figure 2.8 also processes and plots the sensory
data. In particular, the top scope in Figure 2.8 plots the light intensity measurement (in terms
21
of digitized output of the voltage divider circuit) versus time, where the measurements are
filtered using a low-pass filter. The middle scope plots the unfiltered light intensity measure-
ment. Finally, the bottom scope plots the light intensity measurement in terms of voltages by
processing the 8-bit digital value of the voltage divider circuit through a gain factor.
Scopes
An experiment was conducted in which the light intensity was abruptly altered at several
time instances. The response plots acquired and processed using the Simulink block diagram
of Figure 2.8 are shown in Figure 2.9. The filtered output response in Figure 2.9(b) is much
smoother than the unfiltered response in Figure 2.9(a). Thus, Figure 2.9 demonstrates the
efficacy of signal co-processing using MATLAB and Simulink for PIC-based projects. The PIC
22
(a) (b)
Figure 2.9: (a) Unfiltered plot of A2D and (b) Filtered plot of A2D
In this example, the light refraction test bed is used to demonstrate the advantage of ex-
ploiting bi-directional serial communication between PIC and MATLAB-based GUI executing
on the PC. A Simulink-based interactive GUI for the light refraction test bed is shown in
Figure 2.10. The user interacts with the dial object to command the angle of incidence of
light source. The MATLAB m-function block next to the knob contains a MATLAB m-file
(see Table 2.3) that transmits the user command input to the PIC serially. The PIC stores
the user input in a variable and uses it to compute, generate, and apply pulse trains to control
servomotor position. This positions the light source, mounted on the servomotor arm, at the
commanded angle of incidence. Next, the PIC turns on the light source and performs the fol-
lowing tasks: drive the light sensor along the linear potentiometer by turning the DC motor,
measure the position of the light sensor along the linear potentiometer and the corresponding
output of the light sensor, and transmit the position and light sensor measurements to the
PC. The MATLAB m-function block shown in Figure 2.10 enables receipt of the position and
light sensor measurements from the PIC serially. Simulink blocks following the m-file function
block are used for various data processing tasks, e.g., conversion of position measurement to
the refraction angle and computation of index of light refraction. Finally, a generic numeric
23
LED display, from the Dials and Gauges Blockset, is used to indicate the calculated value of
Figure 2.10: Simulink block diagram for bi-directional serial communication between PIC
and PC
Table 2.3: M-function for bi-directional serial communication between PIC and PC
%MATLAB function serial inout.m for bi-directional serial communication bet. PIC & PC
function V=serial inout(angle) %serial inout function defined
ser obj=serial(‘COM2’,‘baudrate’,9600);%create and configure a serial port object
ser obj.ReadAsyncMode = ‘manual’; %specify an asynchronous read operation
fopen(ser obj); %connect the serial port object to the device
ServoCommand =round(angle+107.3); %input for the servomotor with offset of 107.3
fwrite(ser obj,[ServoCommand],‘async’); %send user command, i.e., dial input, to the PIC
LightSensOut =fread(ser obj,1,‘uint8’); %read the light sensor output from the PIC
Position=fread(ser obj,1,‘uint8’)+9; %read the linear pot. output from the PIC
fclose(ser obj); %disconnect the serial port object from the device
V=[LightSensOut;Position]; %output in matrix form
Figure 2.11 shows the block diagram of index of light refraction subsystem of Figure 2.10.
The block diagram of Figure 2.11 is used to generate a plot of angle of refraction versus the
light sensor output. Figure 2.12 shows the plots of angle of refraction versus the light sensor
output for two commanded values of incidence angle, namely, 40◦ and 20◦. Note that for each
incidence angle, the index of refraction is computed from the angle of refraction corresponding
24
to the smallest output returned by the light sensor. Thus, the block diagram of Figure 2.11
is also used to calculate the index of light refraction. The MATLAB m-function (see Table
2.4) in this subsystem monitors and captures the angle data corresponding to the smallest
measurement returned by the light sensor. Note that the light sensor output is smallest when
the intensity of refracted light focused on the light sensor is highest. Next, the angle data is
used to compute the index of light refraction. The PIC assembly code corresponding to this
XY Graph block
Figure 2.11: Simulink block diagram for calculating the index of light refraction
%MATLAB function PickMin.m for capturing the angle of refraction when max.
%Light is on the light sensor.
function y=PickMin(minangle,minLSO,LSO,angle) %PickMin function defined
if LSO <= minLSO %loop for updating the minangle
minangle=angle; %update minangle wrt minLSO
end
y=minangle; %angle at the most light intensity
2.5. Conclusion
In this Chapter, we developed and presented MATLAB-based GUIs for PIC microcon-
troller projects by exploiting Simulink, Dials and Gauges Blockset, and serial communication
capabilities of MATLAB and PIC. Three examples were presented to illustrate the produc-
25
(a) (b)
Figure 2.12: Angle of refraction vs. light sensor output for incidence angle (a) 40◦ and (b)
20◦
tivity enhancement potential of the MATLAB-based GUI environment when developing PIC
microcontroller projects. The GUIs designed using framework of this Chapter allow the user
to: i) vary control commands; ii) acquire sensory data; iii) perform on-line data processing;
and iv) visualize data using realistic looking virtual instruments. Note that the framework
of this Chapter allows the use of microcontroller as a low-cost, stand-alone data acquisition
and control board (DACB). Whereas PC-based DACBs typically cost several hundred to over
thousand dollars, a PIC microcontroller costs only a few dollars. Thus, the use of PIC micro-
controllers with the proposed MATLAB-based GUI environment provides a low-cost DACB
3.1. Introduction
Data acquisition and control boards (DACBs) are essential for interfacing sensors/actuators
with decision making devices such as a personal computer (PC). Thus, DACBs are used in
in automatic control applications. Even though a variety of DACBs have become widely
available in the last 15 years, the systems that target the educational sector and provide support
for icon-based programming environments, such as LabVIEW [5] and Simulink [44], tend to
be quite expensive. Moreover, instructional labs generally may not require the intrinsic high-
performance features of many of the commercially available DACBs (e.g., high sampling rates,
high resolution analog to digital converters (A2Ds), etc.) for the typical electro-mechanical
control (DAC) system that is particularly suitable for educators interested in developing lab
experiments that do not require high-cost, high-performance data acquisition hardware and
Several recent papers [46–48] have focused on interfacing low-cost microcontrollers (such
as BASIC Stamp 2 (BS2) and Peripheral Interface Controller (PIC)) with icon-based pro-
concentrated primarily on endowing a PIC microcontroller with graphical user interface (GUI)
Chapter 2 requires manually programming the microcontroller for all sensing, control compu-
tation, and actuation tasks and for serial communication with the GUI running on the PC. To
program a PIC microcontroller using PIC assembly programming language requires knowledge
and experience with the syntax of the PIC programming languages and is often tedious.
26
27
This Chapter proposes a PIC microcontroller-based low-cost DAC system that exploits
MATLAB and Simulink as the key software components for implementing DAC algorithms
using a block-diagram format. Specifically, this Chapter exploits a newly developed library of
PIC functions for Simulink and the serial communication capability of both the PIC micro-
controller and MATLAB to produce a seamless integration between them. The framework of
this Chapter completely obviates the need to manually program the PIC microcontroller by
creating a library of PIC microcontroller functions for Simulink. Specifically, the DAC tool-
box of this Chapter facilitates: i) automatic generation of proper PIC assembly codes for a
variety of sensors and actuators; ii) automatic programming of the PIC microcontroller; and
iii) data communication between the PIC microcontroller and MATLAB. In an instructional
laboratory, this approach allows instructors and students to focus on hardware-in-the-loop im-
this Chapter is in the spirit of Chapter 4, which provides a MATLAB DAC toolbox for the BS2
microcontrollers. However, whereas the BS2 microcontroller costs over $45 and includes only
digital input/output (I/O) functionality, thus requiring external A2Ds to interface with ana-
log sensors, the PIC16F74 microcontroller, used in this Chapter, costs under $5 and includes
The rest of the Chapter is organized as follows. In Section 3.2, we describe the PIC mi-
crocontroller and the related development hardware. In Section 3.3, we describe the software
environment used in this Chapter. In Section 3.4, we give details concerning the software
integration of Simulink with the PIC microcontroller. In Section 3.5, we illustrate the func-
tionality and capability of the DAC hardware and software of this Chapter by performing
position control of a DC motor. Finally, In Section 3.6, we provide some concluding remarks.
The main components of the DAC hardware of this Chapter are a PIC microcontroller,
a PIC-PG2C programmer, and a PIC development board. A DB-9 serial cable is used to
interface the programmer/development board to a PC which hosts the MATLAB DAC toolbox.
Specifically, the DB-9 cable allows i) programming the PIC microcontroller from the PC and
28
ii) data communication between the PIC and the PC. In this Chapter, an IBM-compatible
Pentium 4 PC running Microsoft Windows XP operating system is used. See Figure 3.1 for a
PC
PIC microcontroller
PIC-PG2C programmer
The DAC platform of this Chapter uses a PIC16F74 [43] microcontroller. In this Chapter,
five of the six I/O pins of port A and three I/O pins of port E are reserved for eight 8-bit
A2Ds, eight I/O pins of port B are reserved for eight digital inputs, two of the eight I/O pins of
port C are reserved for two PWM outputs, and eight I/O pins of port D are reserved for eight
digital outputs. Finally, an external 20 MHz high-speed crystal oscillator is used to supply
operating clock cycles to the PIC. See Ref. [37, 38] for more details on hardware and software
The user specified PIC program, which is created on a PC, is downloaded from the PC to
the PIC microcontroller is enabled by using a DB-9 serial connection between the PC and
a PIC development programmer that hosts the PIC microcontroller. Two widely used PIC
development programmers are Microchip’s PICSTART Plus and Olimex’s PIC-PG2C [49]. In
this Chapter, the handy and low-cost PIC-PG2C programmer (see Figure 3.2) is used. In
contrast to other PIC programmers, the PIC-PG2C programmer receives power from the PC’s
serial port thus obviating the need for any additional power supply. Finally, the PIC-PG2C
29
programmer requires IC-Prog [50], a freely available software, to download PIC HEX code to
the PIC microcontroller. Note that the PIC HEX code is obtained from the PIC assembly
code by using the MPASM assembler [51], also available for free.
(a) (b)
Figure 3.2: (a) PIC-PG2C programmer and a PIC (b) PIC-PG2C programmer with a PIC
mounted
The PIC development board of this Chapter is a modified version from the board discussed
to supply operating clock cycles to the PIC microcontroller; iii) the RS232 driver/receiver
circuitry for serial data communication with the PC; iv) a DB-9 connector; and v) a bread-
board area for custom circuits and easy connectivity between the PIC microcontroller and
sensors/actuators. As discussed in Chapter 2, the Maxim’s MAX232 IC [41] with five 1µF ca-
pacitors serves as the RS232 driver/receiver for voltage-level transformation between PC-based
The software environment for this Chapter consists of MATLAB version 6.5, Simulink
version 5.0, the PIC assembly language, a newly developed Simulink library for the PIC micro-
controller, MPASM, and IC-Prog. The MATLAB toolbox for the PIC microcontroller consists
of a Simulink library of PIC microcontroller functions such that based on the user selected con-
figuration of individual I/O pins of the PIC microcontroller, Simulink automatically produces
and downloads the proper PIC assembly code to the microcontroller. Moreover, the MATLAB
30
toolbox also allows data communication between the PIC microcontroller and MATLAB. Thus,
the MATLAB toolbox for the PIC microcontroller completely obviates the need to manually
program the PIC microcontroller. Note that the MATLAB toolbox automatically executes
the assembler program MPASM and the download program IC-Prog, both of which usually
require command line execution. See Refs. [51, 52] for details on programming the PIC mi-
crocontroller in command line via serial communication. The MATLAB toolbox for the PIC
microcontrollers has two main components: i) a Simulink model file named Template.mdl and
3.3.1. Template.mdl
The Template.mdl model file (see Figure 3.3) is a predesigned Simulink model file which
must be used to design Simulink block diagrams for interaction with the PIC microcontroller.
A function named TotalCompile has been embedded within the callback parameters of the
Template.mdl so that the TotalCompile function executes at the beginning of each Simulink
block diagram cycle, before the block diagram actually runs. Details of various tasks performed
by the TotalCompile function are provided in a later subsection. Finally, note that renaming
the Template.mdl file still preserves the callback property embedded in the file, whereas opening
3.3.2. PICLibrary
The PICLibrary is a custom library of Simulink blocks (in the form of s-functions) that in-
terface with sensors and actuators connected to the PIC microcontroller. The following blocks
are currently included in the PICLibrary: A2D, PinStateIn, PWM, and PinStateOut. More-
over, the library includes a block labeled IOBlock that is required in all user-designed Simulink
diagrams to enable serial communication between the PIC microcontroller and MATLAB.
Hardware settings and parameter requirements of each block are detailed below.
1) A2D block (see Figure 3.4) configures the analog to digital conversion module of the PIC
microcontroller. Note that five of the six I/O pins of port A and three I/O pins of port E of
the PIC16F74 microcontroller can be configured as eight 8-bit A2Ds. Thus, analog sensors can
be directly interfaced to any of the eight A2D pins and the corresponding pin number can be
2) PinStateIn block (see Figure 3.5) configures the I/O pins of port B of the PIC16F74 mi-
crocontroller to serve as digital inputs. Specifically, each of the eight pins of port B can serve
as a digital input by passing the corresponding pin number as a parameter to the PinStateIn
block.
3) PWM block (see Figure 3.6) configures PWM modules of the PIC microcontroller. Specifi-
cally, two of the eight I/O pins of port C of the PIC16F74 microcontroller can be configured
as PWM outputs. Since the PIC16F74 microcontroller does not include a digital to analog
converter, in this Chapter, we use the PWM outputs to produce the required analog voltage
32
output by varying the duty cycle of the PWM signal. Thus, two analog actuators can be
interfaced to the two I/O pins of port C that produce PWM outputs and the corresponding
pin numbers are passed as the parameter required by the PWM block.
4) PinStateOut block (see Figure 3.7) configures the I/O pins of port D of the PIC16F74
microcontroller to serve as digital outputs. Specifically, each of the eight pins of port D can
serve as a digital output by passing the corresponding pin number as a parameter to the
PinStateOut block.
5) IOBlock is necessary for every Simulink block diagram that requires interaction with the
PIC microcontroller. It performs the following tasks: i) initiate serial communication be-
tween MATLAB and the PIC microcontroller when the Simulink block diagram is initially
executed; ii) transmit and receive data between MATLAB and the PIC microcontroller while
the Simulink block diagram is running; and iii) terminate serial communication between MAT-
33
LAB and the PIC microcontroller when the Simulink block diagram is stopped. The callback
function properties of the IOBlock include start serial and stop serial functions that initiate
and terminate serial communication, respectively. In the Simulink block diagram, the IOBlock
is programmed to have the first priority for execution. This ensures that all sensor and ac-
tuator data in MATLAB are first received and sent, respectively, which then is used by the
Several Simulink blocks, such as an integrator block, require the knowledge of sampling
period for their proper use in a given Simulink block diagram. In this Chapter, the IOBlock is
used to determine, experimentally, the sampling period of the Simulink block diagram. Here,
sampling period is defined as the time required to execute one entire cycle of the Simulink
block. The IOBlock determines the sampling period by averaging the time taken to run a
user-specified number of cycles of the Simulink block diagram. An averaged sampling period
34
is not expected to provide the exact sampling period for each Simulink block cycle and its use
When blocks from the PICLibrary are used in the Template.mdl model file, a sequence
of operations specified by the TotalCompile function are performed before the Simulink block
diagram begins to run. The main role of the TotalCompile function is to program the PIC
microcontroller and to facilitate serial communication between MATLAB and the PIC mi-
crocontroller. As seen in Figure 3.3, the TotalCompile function is set as a “Simulation start
The TotalCompile function performs the following sequence of tasks. First, global variables
are declared and used to share data with Simulink blocks of PICLibrary. Second, sensor and
actuator blocks used in the Simulink diagram are matched with the corresponding Simulink
blocks in the PICLibrary. Furthermore, each block is categorized as a sensor or an actuator and
its name is stored in an array of sensor/actuator structures with the specified block properties.
The sensor/actuator array information is also used when data is serially communicated. Third,
using the sensor/actuator block information gathered in the previous step, a PIC assembly
code is generated. This step is facilitated by the fact that for each sensor/actuator block in the
PICLibrary the corresponding PIC assembly code has already been created and saved as an m-
file. Fourth, a portion of the IOBlock MATLAB code is generated to allow serial communication
between MATLAB and the PIC microcontroller. This MATLAB code sends and receives the
same amount of data that the PIC microcontroller receives and sends, respectively. Fifth, the
PIC microcontroller is programmed in two steps: i) using the MPASM assembler the PIC
assembly code, generated in step 3 above, is converted to the corresponding PIC HEX code
and ii) using the IC-Prog the PIC HEX code is downloaded to a PIC microcontroller installed
on a PIC-PG2C programmer. Figure 3.9 shows a flow diagram of the three steps involved in
After the TotalCompile function completes its sequence of tasks, the Simulink block diagram
begins to execute when the user confirms that the PIC microcontroller has been removed from
35
PIC assembly code is PIC assembly code is converted PIC HEX code is downloaded
generated by TotalCompile to PIC HEX code by MPASM by IC-Prog via the serial port
the PIC-PG2C programmer and properly installed onto the PIC development board. At this
stage, serial communication between the PIC microcontroller and MATLAB also begins. If
Simulink is stopped and needs to be run again, without any changes to the configuration of
the PIC microcontroller I/O pins, then the PIC microcontroller need not be reprogrammed.
Once the Simulink block diagram begins to execute, the PIC and PC exchange sensory
feedback and actuator commands via serial data communication. Specifically, special function
8-bit PIC registers are used for the serial communication of sensor/actuator data [43, 47]. The
IOBlock receives/transmits data from/to the PIC and stores the data in sensor/actuator global
variables.
To illustrate the functionality and capability of the DAC hardware and software of this
interfaced with a PIC-based DAC board and a control algorithm is implemented using Simulink
and the MATLAB toolbox for the PIC microcontroller. The DC motor test-bed, shown in
The potentiometer output is used to obtain the necessary feedback signals and to provide
a real-time display of the angular position of the motor. To control the angular position of the
DC motor, the PIC microcontroller applies a controlled voltage signal produced by a control
DC motor and power module PIC development board Simulink block diagram
angular position control of the DC motor. The functionality of various Simulink blocks used in
Figure 3.10 (see Figure 3.11 for an exploded view) is as follows. The A2D Pot block serves as
an A2D block to convert the analog output of the potentiometer into an 8-bit digital data. The
PID Controller block encapsulates the standard PID control algorithm. The inputs to the PID
Controller block are: i) the desired angular position of the DC motor and ii) the potentiometer
signal (the digitized output of A2D Pot block). The output of the PID Controller block is a
controlled voltage signal to be applied to the motor. In Figure 3.11, the PID Controller block
output is processed by the PWM Motor block which serves as a PWM block. Note that
the power amplifier module of the DC motor shown in Figure 3.10 requires a ±5 volt direct
current (VDC) to drive the DC motor. Accordingly, the PID control algorithm outputs a
±5VDC control signal. However, the PIC microcontroller can output only 0—5 VDC using
the PWM output. Thus, the ±5VDC output of the PID controller is appropriately transformed
to command the PWM Motor block with a 0—5 VDC command signal. Finally, by processing
the PWM output from the PIC microcontroller using a simple operational amplifier based
circuitry, the 0—5 VDC PWM output is converted into a ±5VDC signal for input to the
An analytical model of the DC motor under PID control, yielding a third-order closed-loop
transfer function [53], is used to determine numerical values of the PID controller gains. Specif-
poles with a damping ratio and natural frequency of 0.69 and 1.93, respectively, and ii) a third
real pole at -80, the PID control gains are computed to be KP=1.43, KI=1.97, and KD =0.5.
37
This analog PID controller is implemented using Simulink’s ODE4 (Runge-Kutta) algorithm
with a sampling period of 0.13 second. For the computed gains, the experimental response
exhibits an average 2 percent settling time of 5.9sec and a percentage overshoot of 18.25%. For
comparison, the theoretical values for the 2 percent settling time and the percentage overshoot
are 3sec and 14%, respectively. Figure 3.12 shows a sample experimental response of the DC
motor angular position under PID control implemented using the framework of this Chapter.
3.6. Conclusion
This Chapter provided an overview of a low-cost DAC toolbox that consists of the newly
the PIC microcontroller and MATLAB allowed programming of the PIC microcontroller from
MATLAB and exchange of sensory data and actuation signals between the PIC microcontroller
and MATLAB. The capabilities of this low-cost DAC system were illustrated through a DC
4.1. Introduction
Data acquisition and control boards, also known as DAC boards, are used in virtually
making devices, e.g., a personal computer (PC). In academia these boards are used from entry
level laboratory experiments for physics and chemistry to upper level laboratory experiments
A variety of PC-based DAC boards are available from vendors such as Quanser [1], Na-
tional Instruments [3], and Advantech [54]. Furthermore, DAC solutions from several of these
vendors support icon-based programming environments (e.g., LabVIEW [5] and Simulink [44])
for implementing measurement and control algorithms. The existing PC-based DAC boards
supported DAC board, the user needs MATLAB’s Real-Time Workshop (RTW) toolbox and
a C compiler. In addition, the user must provide a real-time environment (e.g., Real-Time
Windows Target for MATLAB-based DAC solutions, Real-Time Extension for Quanser-based
DAC solutions, etc.) for real-time execution of the designed algorithm. However, in some
cases, the user may not require real-time execution of the algorithm (e.g., environmental mon-
itoring). Thus, similar to PC-based DAC hardware solutions, the software requirements for
the use of an inexpensive PIC microcontroller for DAC tasks. In this Chapter, we develop
a low-cost PC-based DAC board using Parallax Inc.’s BASIC Stamp 2 (BS2) microcontroller
[55]. Furthermore, we provide a library of BS2 functions for Simulink. Next, we exploit
39
40
block diagram format. In addition, we build upon the foundation of [48] to exploit Simulink
and MATLAB’s built-in serial communication capabilities to communicate with various sensors
and actuators connected to a BS2 microcontroller. The BS2 microcontroller was selected to
illustrate our DAC toolbox since MATLAB/Simulink device library for BS2 can be easily
developed and implemented by exploiting BS2’s BASIC style instructions that are simpler
vis-à-vis instruction sets of other microcontrollers. Moreover, our BS2 device library requires
only minor modification for use of new types of sensors and actuators with our MATLAB DAC
toolbox.
The framework of this Chapter is significant for several reasons. First, by extending the
common to most microcontrollers, viz., the lack of advanced icon-based software interface for
efficient development of control algorithms and the lack of a graphical user interface (GUI) to
allow intuitive interaction. Second, our DAC platform is very economical since it requires the
use of only an off-the-shelf BS2 microcontroller (under $50) and obviates the need for overhead
software such as RTW required for most PC-based DAC systems, thus further lowering the
cost of acquiring such a system. This affords an opportunity to students to conduct industry-
style rapid control prototyping and hardware in the loop experiments. Third, the ability to
interface and program microcontrollers using the intuitive graphical programming environment
of Simulink provides the flexibility and versatility of equipping a wide array of undergraduate-
economical cost using our DAC platform. Fourth, our microcontroller-based DAC system is
inherently portable due to its small size and low power requirement, extending its benefits
to students who can acquire their personal DAC system for capstone design projects and for
experimental research.
The rest of the Chapter is organized as follows. In Section 4.2, we describe the components
for the MATLAB-based BS2 DAC system. In Section 4.3, we describe two main components
of the software interface for the DAC system. In Section 4.4, we describe the sequence of tasks
running on the DAC system. In Section 4.5, we illustrate the functionality and capability of
41
the DAC hardware and software of this Chapter by performing position control of a DC motor.
Our MATLAB-based BS2 DAC system is composed of two main components, hardware
and software. The hardware required for this DAC system is the BS2 microcontroller and user
selectable sensors and actuators. The software required for this system is MATLAB with serial
The BS2 is a popular microcontroller used both in hobby and industrial projects. The BS2
has 16 general-purpose digital input/output (I/O) pins. Throughout the rest of this Chapter,
we will refer to these digital I/O pins as pins. The high state on a BS2 pin refers to a 5
volt direct current (VDC) and a low state on a BS2 pin refers to a 0VDC (ground potential).
Additional hardware used in this Chapter is the Board of Education (BOE) development
board. The BOE provides: i) built-in circuitry for programming the BS2 microcontroller and
serial data communication; ii) an interface for a power supply; iii) user accessibility of the BS2
pins; and iv) a breadboard area for custom circuits. In this Chapter, the BOE is used as an
4.2.2. MATLAB/Simulink
MATLAB/Simulink is the primary software environment for our BS2 DAC toolbox. The
Simulink toolbox contains many libraries whose elements can be embedded in Simulink block
diagrams. Simulink also provides user-defined blocks, in the form of s-function blocks, which
can be modified to perform user-defined tasks. Furthermore, every Simulink block allows for a
set of “callback functions,” which execute upon specific events when running a Simulink block
Referring to Figure 4.1 the software interface of our DAC system consists of two main
components: i) a Simulink model file named Template.mdl and ii) a block library named
BS2Library. Template.mdl is the file where the user designs the Simulink block diagram for
interaction with the BS2. BS2Library is the library of additional blocks that communicate
Template.mdl
Empty block diagram with predefined model
parameters
Figure 4.1: MATLAB data acquisition and control toolbox software interface
43
4.3.1. Template.mdl
The Template.mdl model file is an empty Simulink block diagram, where the user designs
the Simulink block diagram for interaction with the BS2. The key property of Template.mdl
is the inclusion of a function within the callback parameters of this Simulink model file, where
this function is to be executed before the start of the block diagram. Furthermore, renaming
this file still preserves this property, whereas opening a new Simulink model file does not.
When starting the Simulink block diagram, the callback function called TotalCompile is
executed first. This function performs several important tasks and enables the communication
between MATLAB and the BS2 microcontroller. Details of this function are provided in a
subsequent section.
4.3.2. BS2Library
The BS2Library is a custom library for Simulink, which provides blocks (in the form of
s-functions) that interface with sensors and actuators connected to the BS2. See Table 4.1
for a complete listing of sensor and actuator blocks currently available. Furthermore, this
library contains a block labeled IOBlock that enables serial communication between the BS2
microcontroller and MATLAB and computes the sampling period of a block diagram. This
block is required in all user-designed Simulink block diagrams that will incorporate sensors and
actuators connected with the BS2 microcontroller. Figure 4.2 provides a graphical description
of the BS2Library.
1) Sensors and Actuators: Sensor and actuator blocks provided in the BS2Library are used to
communicate with sensors and actuators connected with the BS2 microcontroller. Each sensor
or actuator block contains block parameters that need to be set for appropriate hardware
configuration. The following describes hardware settings and parameter requirements of each
block.
i) RCtime block: This block measures the time taken by a specific pin on the BS2 to change
its state. It is used to obtain measurements from a variable resistance/capacitance sensor. The
Name Description
PinStateIn Sensor block giving the state of a BS2 pin,
which is either high (5VDC) = 1 or low (0VDC) = 0
RCtime Sensor block that measures the time it takes for a pin
to change its state from high (5VDC) to low (0VDC), or vice versa
AtoD LTC1296 Sensor block that provides voltage on a specified channel
from an LTC1296 analog to digital converter (A2D)
PinStateOut Actuator block which changes the state of a BS2 pin
to high (5VDC) = 1 or low (0VDC) = 0
ServoMotor Actuator block that turns a servo motor to a desired position
DtoA MAX537 Actuator block that outputs a specified voltage
to a MAX537 digital to analog converter (D2A)
circuit with a constant capacitor/resistor, i.e., if the sensor is a variable resistor, a constant
capacitor is required, and vice versa. See [57] for further details on how to construct an RC
circuit. The RCtime block requires two parameters. The first parameter is the BS2 pin on
which the BS2 monitors the state of the resistor-capacitor circuit. The second parameter is
ii) AtoD LTC1296 block: This block can receive voltage data from an LTC1296 A2D IC.
The LTC1296 A2D IC, manufactured by Linear Technology Inc., is a 12-bit A2D (11-bit plus
an additional sign bit) that has 8 single input channels, which can be used as 4 differential
inputs, and requires a ±5VDC power supply. Furthermore, this IC is controlled by the BS2 via
the serial peripheral interface (SPI). The AtoD LTC1296 block requires five parameters. The
first parameter is the BS2 pin on which sensor data (in the form of a voltage signal) from the
LTC1296 IC is sent to the BS2. The second parameter is a specific channel on the LTC1296
IC that contains the sensor data. The third parameter is the BS2 pin from which the BS2
sends the “clock” signal to the LTC1296 IC. The fourth parameter is the “chip select” pin
and corresponds to the BS2 pin that enables operation of the LTC1296 IC. Finally, the fifth
parameter is the BS2 pin from which the configuration information for the LTC1296 IC is sent.
iii) ServoMotor block: This block controls standard servo motors connected to a BS2 mi-
45
BS2Library
Serial Communication
Sensors
Actuators
IOBlock Properties
Terminates serial
communication
crocontroller, one of which is the Parallax servo motor manufactured by Futaba Corp. The
ServoMotor block requires one parameter, the BS2 pin which transmits a pulse-width mod-
ulated signal that controls the servo motor. See [59] for further details on how to operate a
iv) DtoA MAX537 block: This block sends voltage data supplied by the Simulink block
diagram to the MAX537 D2A IC. The MAX537 D2A IC, manufactured by Dallas Semiconduc-
tor Inc., is a 12-bit D2A (11-bit plus an additional sign bit) that has 4 single output channels,
which can be used as 2 differential outputs, and requires a ±5VDC power supply. The MAX537
IC requires four parameters. The first parameter is the BS2 pin from which actuator data (in
the form of voltage output) is to be sent to the MAX537 IC. The second parameter is a specific
output channel on the MAX537 IC. The third parameter is the BS2 pin from which the BS2
sends the “clock” signal to the MAX537 IC. Finally, the fourth parameter is the “chip select”
Finally, sensor and actuator blocks are responsible for writing to or reading from global
variables, which are to be sent or received from the BS2, respectively. Details of these opera-
2) IOBlock: The main purpose of this block is: to i) initiate serial communication between
the BS2 microcontroller and MATLAB; ii) send and receive data between BS2 and MATLAB;
OpenSerialPortScript and CloseSerialPortScript, which are executed at the Start and Stop
state of the Simulink block diagram, respectively. For a set of sensors and actuators to be
used in a Simulink block diagram, the IOBlock performs serial communication with the BS2
such that the order of data received from sensors and sent to actuators is determined by the
section.
The IOBlock is programmed to be the first block executed in the Simulink block diagram.
This ensures that all sensor and actuator data in MATLAB is first received and sent, respec-
47
tively, which then is used by the appropriate sensor and actuator blocks in the Simulink block
diagram.
This section describes in detail the sequence of tasks that are performed before running a
Simulink block diagram. In particular, we outline the set of tasks that the function, Total-
Compile, performs. Finally, in this section we describe the serial data communication between
4.4.1. TotalCompile
1) Using Global Variables: Global variables are used in order to share data with any sensor or
2) Storing Sensors and Actuators Blocks: After defining global variables the TotalCompile
function reads the Simulink model file as a text file. In this process the function looks for
all the blocks (by name) that are present in the Simulink block diagram that match with the
ones stored in the BS2Library. It should be noted that for this task to be performed correctly,
the Simulink model file must be saved before starting the Simulink block diagram. Unsaved
Simulink model files may not include the most recent changes to the sensor or actuator block
parameters. Furthermore, if a user adds or removes sensor or actuator blocks to or from the
block diagram, this unsaved Simulink model file may not reflect these recent changes.
When a matching block is found, it is then categorized as a sensor or an actuator. The type
of block is then used in conjunction with the specified block parameters to be stored in a data
structure depending on its category, e.g., a sensor or an actuator structure. Thus, for multiple
sensor blocks in a Simulink block diagram, an array of sensor structures is allocated. Similarly,
an array of actuator structures is allocated. The sensor array stores all sensor blocks present
in the Simulink block diagram, and an actuator array stores all actuator blocks present in this
diagram. If there are no sensor or actuator blocks present in the diagram a “null” object is
48
The order in which sensor blocks are stored in the array is the same as the order in which
the sensor blocks are listed in the text file of the Simulink model file. The actuator array is
Since in a Simulink block diagram it is possible to have multiple blocks with the same
name, two parameters are used to determine each block uniquely. The first parameter is a pin
of the sensor/actuator connected to the BS2. However, certain sensors or actuators devices
may have multiple channels, in which case, a second parameter is used to store the channel
information. The sensor or actuator array information is later used to organize data sent via
serial communication.
3) Generating MATLAB and PBASIC Code: The sensor and actuator arrays are used to gen-
erate MATLAB and PBASIC code. The PBASIC code, which is used to program the BS2, is
generated first. We note that within the BS2Library block, every sensor or actuator block has
an associated PBASIC code. Thus, for a given sensor or actuator structure, a corresponding
PBASIC code can be provided. Finally, the PBASIC code is organized as follows: i) BS2
waits for MATLAB to send the actuator data; ii) this actuator data drives the actuators; iii)
data is gathered from the sensors; and iv) sensor data is sent to the Simulink block diagram.
Next, a section of the IOBlock’s MATLAB code is generated to facilitate serial communication
between MATLAB and BS2. In particular, this MATLAB code sends and receives the same
4) Programming the BS2: Referring to Figure 4.3, programming the BS2 involves: i) the tok-
enization of the PBASIC code and ii) the sending of this tokenized code to the BS2 via serial
communication. The tokenization process involves sending the PBASIC code to a C++ exe-
cutable program. This program performs tokenization of the PBASIC code using a tokenizer
library provided by Parallax Inc. and stores the result in a text file. The tokenized code is
organized as a set of data packets to be sent to the BS2. See [61] for details on how to tokenize
PBASIC code. Next, a Java program transmits the tokenized PBASIC code packet by packet
to the BS2 using serial communication. See [61] for details on how to program the BS2 via
49
serial communication. After attempting to program the BS2, a Boolean is set to true or false
5) Starting a Simulink Block Diagram: If the BS2 was successfully programmed, then the
Simulink block diagram will start, otherwise the block diagram will stop and produce an error
Referring to Figure 4.4, BS2 and MATLAB communicate with each other using the serial
communication port. Both BS2 and MATLAB have built-in functions that provide serial
communication capabilities. It is important to note that all sensor data is sent from MATLAB
as one packet and all actuator data is received by MATLAB as one packet through serial
communication. Sensor data in the sensor packet can be retrieved by the corresponding sensor
blocks in the Simulink block diagram, whereas data from the actuator blocks are packaged into
The use of packets for data communication between MATLAB and BS2 is efficient compared
with the transmission of individual, disjoint sensor or actuator data. In transmitting packets
for data communication, the amount of information needed to be sent via serial communication
is reduced, i.e., in one sensor or actuator packet, the necessary data for serial communication is
one start and stop bit, whereas for individual, disjoint sensor or actuator data, multiple start
The IOBlock receives the sensor packet and stores the data in a sensor global variable. The
sensor packet received from the BS2 is first converted to the appropriate sensor data, i.e., a
numerical value dependent on the sensor type, and is then stored in the sensor global variable.
The IOBlock transmits data from the actuator global variable to the BS2 for execution. In
constructing the actuator global variable, each actuator block converts the numerical value
of their actuator data into a set of bytes. Next, the sets of bytes for all actuator blocks
are packaged into a packet and saved into the actuator global variable. See Figure 4.4 for a
graphical description of this packet. Lastly, data communication between BS2 and MATLAB
Tokenization of PBASIC
MATLAB
Gets data from actuator blocks and sends to Bs2
Receives sensor data from BS2
Serial Port
Bidirectional data communication is established
DB-9 serial cable
1 byte
Start
Tach1 Start PC
2 Bytes of
Tachometer Data Tach2 M1 2 Bytes of
DC Motor
Pot1 M2 Data
2 Bytes of
Potentiometer Data Stop
Pot2
Stop
BS2 installed on BOE
BS2
Outputs actuator data to the actuator
Collects data from sensors and transmits information to MATLAB
DAC ADC
Laptop
BS2 installed on
Figure 4.4: Graphical description of serial communication between BS2 and MATLAB
52
Both sensor and actuator data transmitted through serial communication is organized in a
specific order. As seen in Figure 4.5, the order in which data is stored for a sensor packet is the
same as how the sensor structures are ordered in the sensor array. Furthermore, the actuator
Each BS2Library block has access to both sensor and actuator arrays and sensor and
actuator global variables. Each sensor or actuator used in the Simulink block diagram is
uniquely determined based on a pin number that the sensor or actuator uses for connection
with the BS2 and the device channel (if device controls multiple channels). Depending on the
pin number and device channel, each sensor or actuator block can search for its position in its
corresponding sensor or actuator array. See Figure 4.5 for an example of a sensor block with its
corresponding position in the sensor array. Once the position of a sensor block is determined,
the appropriate sensor data can be retrieved from the sensor global variable. Also, an actuator
block can store actuator data to the actuator global variable in a similar manner.
For illustrative purposes, in this example, we explore the DC motor control experiment
discussed in Chapter 3 using the BS2 microcontroller and our MATLAB DAC toolbox shown
in Figure 4.4. The potentiometer outputs a ±5VDC signal corresponding to the absolute
angular position of the motor. The tachometer outputs a ±5VDC signal corresponding to
the angular velocity of the motor. The BS2 supplies a controlled voltage signal to control
the DC motor angular position. The DC motor sends and receives analog signals from the
microcontroller using an LTC1296 A2D and a MAX537 D2A, respectively. A MAX764 DC-DC
inverter, manufactured by Dallas Semiconductor Inc. [62] and powered by the BOE’s +5VDC
power supply, is used to obtain a ±5VDC power supply for the LTC1296 and MAX537.
In this experiment, we used MATLAB version 6.5, which has a built-in serial communication
library, in addition to Simulink version 5.0. This experiment utilizes the classical proportional-
integral-derivative (PID) controller to control the position of the DC motor. Referring to Figure
53
4.4, two A2D blocks are used to import sensor data to the PID controller, i.e., the block labeled
AtoD LTC Pot sends DC motor potentiometer data and the block labeled AtoD LTC Tach
sends DC motor tachometer data to the PID controller. The output from these sensor blocks
is then connected to appropriate calibration gain blocks. Furthermore, a D2A block labeled as
DtoA MAX Motor is used to transmit the PID controller output to the DC motor.
A classical PID controller is implemented in Simulink to control a DC motor using the BS2
library. Specifically, an analog PID controller is designed and implemented using Simulink’s
Euler approximation integration algorithm [56] (with a sampling period of 0.13sec). For il-
lustrative purposes, two sets of performance specifications are used to design corresponding
PID control gains that are used to obtain experimental response of the motor for 0◦ and 90◦
The PID control gains used in this experiment are computed using the analytical model
of the DC motor under the PID feedback control. It can be shown that a third-order transfer
function with one real pole, a pair of complex-conjugate poles, and a finite zero captures
the closed-loop transfer function of the DC motor with the PID controller (see, Section 5.4
of [53] for a similar transfer function). Next, by specifying the desired damping ratio and
natural frequency of complex-conjugate closed-loop poles and the location of the real pole as
0.69, 1.16, and -47.8479, respectively, the PID control gains are computed to be KP = 1.28,
KI = 1.06, and KD = 0.21. Following [53], for these control gains it can be shown that
the closed-loop response theoretically exhibits a 2 percent settling time of 5sec and a percent
overshoot of 25%. Referring to Figure 4.6, which shows experimental time history of the DC
motor arm angular position, these control gains were used from 0 to 58sec. As evidenced from
Figure 4.6, the experimental response exhibits an average experimental 2 percent settling time
of 9.89sec and a percent overshoot of 29.36%. Next, by specifying the desired damping ratio
and natural frequency of complex-conjugate closed-loop poles and the location of real pole
as 0.69, 0.58, and -24, respectively, the PID control gains are computed to be KP = 0.32,
KI = 0.13, and KD = −0.19. For these control gains it can be shown that the closed-loop
response theoretically exhibits a 2 percent settling time of 10sec and a percent overshoot of
25%. Referring to Figure 4.6, these control gains were used from 58 to 105sec. As evidenced
from Figure 4.6, the experimental response exhibits an average experimental 2 percent settling
4.6. Conclusion
In this Chapter, we developed an inexpensive DAC system by exploiting the serial commu-
nication capabilities of MATLAB and the BS2 microcontroller. Using the advanced features
of Simulink, our software environment allows for the generation of PBASIC code for a variety
of sensors and actuators, programming of the BS2 microcontroller, and data communication
between BS2 and MATLAB. Furthermore, a DC motor control experiment was conducted to
show the salient features of our DAC toolbox. Specifically, a PID controller was implemented
105
90
DC Motor Position (degrees)
75
60
45
30
15
−15
PID Control gains are switched
−30
−45
0 10 20 30 40 50 60 70 80 90 100
Time (seconds)
5.1. Introduction
A variety of PC-based data acquisition and control (DAC) boards are currently available
in the market. These DAC boards can be broadly classified in two categories: i) high-end
DAC boards, which provide a wide range of advanced hardware capabilities along with a
sophisticated software environment; and ii) low-end DAC boards, which are primarily used for
With the emergence of MATLAB [6] as a widely used scientific computing tool in industry
and academia, many users seek a DAC platform that can interface with and exploit advanced
within the last decade, new developments in automated code generation programs have allowed
users to utilize interactive icon-based control system simulation tools such as Simulink [44] for
real-time control. In particular, using the Simulink block library and Real-Time Workshop
(RTW) along with Simulink block libraries for vendor-specific DAC boards, one can generate
C code from Simulink-based feedback control diagrams for real-time controller implementation
on PC-based DAC boards. The ability to rapidly and efficiently design and implement complex
enhance productivity.
In Chapter 4, we developed a low-cost DAC platform which allows Parallax Inc.’s BASIC
Chapter, we illustrate several important features of the DAC platform developed in Chapter
4 by performing liquid level control of a coupled, two-tank system. Liquid level control is
ubiquitous in industrial applications, e.g., food processing, effluent treatment, power gener-
56
57
ation plants, pharmaceutical industries, water purification systems, and industrial chemical
processing. Thus, the study of liquid level control encompasses many engineering disciplines,
In this Chapter, we employ the classical proportional-plus-integral (PI) controller for liquid
level control of a coupled, two-tank system [63]. To effectively utilize this control methodology,
the system parameters, e.g., tank dimensions and pump characteristics, must be known exactly.
However, this may not be feasible since system parameters may change due to the effects
of scaling in tanks and orifices, aging of pump, and wear. Thus, to determine the system
parameters, we conduct an experimental system identification study which uses the inherent
The rest of the Chapter is organized as follows. In Section 5.2, we describe the coupled,
two-tank system model and formulate system identification and control design objectives. In
Section 5.3, we outline a method to perform system identification. In Section 5.4, we design
Figure 5.1 shows a two degree-of-freedom, state-coupled, two-tank system. This system
consists of two tanks with orifices and liquid level sensors at the bottom of each tank, a pump,
and a liquid basin. The two tanks have the same diameters and can be fitted with differing
diameter outflow orifices. In this experimental setup, the pump provides the infeed to Tank 1
and the outflow of Tank 1 becomes the infeed to Tank 2. The outflow of Tank 2 is emptied
into the liquid basin. The following conditions, with regard to the system dynamic model, are
i) the liquid levels in Tanks 1 and 2, denoted as L1(t) and L2(t), respectively, are measured
ii) L1(t) is always greater than 0cm and less than 30cm;
iv) the desired liquid level in Tank 2 is greater than 0cm and less than 20cm for t > 0 ; and
58
v) the voltage applied at the input terminals of the pump, denoted by Vp(t), is between 0 and
The nonlinear mathematical model describing the liquid levels of Tanks 1 and 2 is given
by [63]
q
L̇1 (t) = −A L1 (t) + BVp (t), (5.1)
q q
L̇2 (t) = C L1 (t) − D L2(t), (5.2)
a1 √ Kp 4 a1
√ 4 a2
√
where A 4
= A1 2g, B 4
= A1 , C = A2 2g, and D = A2 2g, ai is the cross-sectional area of the
outflow orifice at the bottom of the Tank i, Ai is the cross-sectional area of the Tank i, Kp is
ai , Ai , Kp , and g, for i =1, 2, are not known exactly. As previously discussed, the uncertainty
about system parameters may arise due to corrosive buildup in the liquid level system or the
deterioration of the pump motor. Thus, a control design based on the idealized values of the
system parameters may lead to performance deterioration for the closed-loop system. In a
subsequent section, we outline a series of experiments, which exploit the nonlinear dynamics
Given a desired, constant, liquid level for Tank 2, denoted as L2d, design a control input
Vp(t) such that lim L2 (t) = L2d . This objective is to be achieved with the assumption that
t→∞
L1 (t) and L2 (t) can be measured. Furthermore, the control design is to utilize estimates of the
system parameters.
To quantify this control objective, we define the liquid level tracking error for Tanks 1 and
where L1d is some desired, constant liquid level for Tank 1, which using (5.2) is characterized
a2 2
as L1d 4
= ( a1 ) L2d .
begin by describing the linearized error system model (see reference [63] for details)
4
where u(t) = Vp(t) − Vpd and Vpd is the desired pump voltage, which using (5.1) is characterized
√
2gL1d
as Vpd 4
= a1 Kp . Furthermore, the parameters α1 , β1 , α2 , and β2 in (5.5) and (5.6) are defined
60
as, respectively,
A D C
α1 4
= − √ , β1 4 4
= B, α2 = − √ , and β2 4
=√ . (5.7)
4L1d 4L2d 4L1d
Next, we develop the transfer function models for the linearized error system of (5.5) and (5.6)
by taking the Laplace transform of (5.5) and (5.6) and rearranging terms to yield
l1(s) β1
= , (5.8)
u(s) s − α1
l2(s) β2
= , (5.9)
l1(s) s − α2
4 L[l (t)], l (s) 4 L[l (t)], and u(s) 4 L[u(t)] with L denoting the Laplace operator
where l1(s) = 1 2 = 2 =
[64].
coupled two-tank system given in (5.1) and (5.2). Specifically, motivated by the nonlinear
dynamics of (5.1) and (5.2), we outline a set of experiments that yield the system parameters
A C
A, B, C, and D. In experiment 1, we first obtain numerical values for the ratios B and D. In
experiment 2, we obtain the numerical value for the parameter A, which using the numerical
A
value of B obtained in experiment 1 yields B. In experiment 3, we obtain the numerical value
for the parameter D using the same procedure as in experiment 2, which using the numerical
C
value of D obtained in experiment 1 yields C.
5.3.1. Experiment 1
A C
In this experiment, we obtain expressions that relate the ratios B and D to steady state
conditions of the pump and the liquid levels of Tanks 1 and 2. Specifically, we begin by noting
that if a fixed voltage is applied to the pump, then the liquid levels of Tanks 1 and 2 will reach
steady state after a sufficient amount of time. This characteristic can be proven by directly
solving the differential equations (5.1) and (5.2) given that Vp(t) is constant. Next, the solution
of (5.1) and (5.2) under steady state conditions, i.e., with L̇1 (t) = 0 and L̇2 (t) = 0 yields
A Vpss
=√ , (5.10)
B L1ss
61
s
C L2ss
= , (5.11)
D L1ss
respectively, where L1ss, L2ss, Vpss are the steady state liquid levels of Tanks 1 and 2, and the
steady state pump voltage, respectively. From (5.10) and (5.11), by applying a fixed voltage
Vpss to the pump and directly measuring the liquid levels of Tanks 1 and 2 after a sufficient
A C
amount of time, i.e., L1ss and L2ss , we can determine numerical values of B and D.
5.3.2. Experiment 2
In this experiment, we fill Tank 1 with a fixed amount of liquid and record the time history
of the liquid level in Tank 1 as it is discharged. Using this time history, we can determine
a relationship between the system parameter and the liquid level in Tank 1 at a given time
instant. To do so, we solve the differential equation (5.1) with Vp(t) = 0 and obtain
q q 1
L1 (t) = L1(t0 ) − A(t − t0 ), (5.12)
2
where t0 is the initial time and L1 (t0) is the initial liquid level in Tank 1. Note that equation
(5.12) is only valid when the right hand side of (5.12) is nonnegative, i.e., prior to full discharge
of Tank 1 since once Tank 1 is fully discharged the right hand side of (5.12) becomes negative.
To determine when the liquid in Tank 1 is fully discharged, we set L1(t) = 0 in (5.12) and
where t∗ is the time of full discharge of Tank 1. Using (5.13), the analytic expression for the
in Tank 1 is still discharging, then (5.12) can be rewritten to yield the parameter A as follows
p p
L1 (t0 ) − L1(t̄)
A=2 . (5.15)
(t̄ − t0 )
62
Next, substituting (5.15) into (5.10), we can determine the parameter B as follows
p p √
L1(t0 ) − L1(t̄) L1ss
B= 2 . (5.16)
(t̄ − t0 ) Vpss
Note that the determination of the numerical value for B in (5.16) requires the use of the
experimental data obtained from experiments 1 and 2, i.e., the steady state values L1ss, Vpss
5.3.3. Experiment 3
In this experiment, we fill Tank 2 with a fixed amount of liquid and then obtain the time
history of the liquid level in Tank 2 as it is discharging. Using this time history, we can obtain
a relationship between the system parameter D and the liquid level in Tank 2 at a given time
instant. Similar to experiment 2, using the solution of (5.2), we obtain a relationship between
where t̂ is a time instant before Tank 2 is fully discharged. Now, substituting (5.17) into (5.11),
Note that the determination of the numerical value for C in (5.18) requires the use of the
experimental data obtained from experiments 1 and 3, i.e., the steady state values L1ss , L2ss
In this section, we outline a PI liquid level control design that is based on the linearized
model of (5.8) and (5.9). As described previously, the liquid level control problem consists
of controlling the liquid level of Tank 2 to a desired, constant liquid level L2d . From (5.9),
to control the liquid level in Tank 2, we must use the liquid level of Tank 1, i.e., l1 (t) as a
pseudo control input. This necessitates control of liquid level of Tank 1 to a desired liquid level
63
L1d, which serves as a command signal for the Tank 1 controller u(t), or equivalently Vp (t).
Referring to Figures 5.2 and 5.3, we design PI controllers for Tank i, i =1, 2, as follows
KIi
Ci (s) = KPi + , (5.19)
s
where KPi is the proportional gain and KIi is the integral gain. To aid in determining the
controller gains KPi and KIi, the desired closed-loop responses for Tank i are specified in
terms of a settling time Tsi and percent overshoot oi performance criterion. It then follows
from reference [64] that the settling time and percent overshoot criterion can be related with
the closed loop damping ratio ξi and natural frequency ωni for Tank i, as follows
bi
ξi = q , (5.20)
2
bi + π 2
4
ωni = , (5.21)
Tsiξi
oi
where bi = log( 100 ). Thus, using (5.20) and (5.21), the controller gains KPi and KIi that
achieve the desired closed-loop responses for Tank i are obtained as follows [63]
1
KPi = (2ξiωni + αi ), (5.22)
βi
2
ωni
KIi = , (5.23)
βi
where αi and βi given in (5.7) depend on the parameters A, B, C, and D, which are obtained
In this section, we explore the experimental system identification and liquid level control
of a two-tank system using the BS2 microcontroller and the BS2 DAC toolbox developed in
Chapter 4. The two-tank, liquid level system is a commercial laboratory equipment developed
and marketed by Quanser Consulting Inc. [65]. The PC-based BS2 DAC platform developed in
Chapter 4 allows MATLAB and Simulink to seamlessly interact with the BS2 microcontroller.
In particular, this DAC platform provides a library of Simulink functions, which allows for di-
rect interaction between user-defined Simulink block diagrams and sensors/actuators connected
The PC-based BS2 DAC platform is composed of two main components, hardware and
software. The hardware required for this platform is the BS2 microcontroller, and user se-
lectable sensors and actuators. The software required for this platform is the MATLAB-based
DAC toolbox.
The BS2 DAC toolbox supports several different types of input and output signals. How-
ever, in this Chapter, only analog input and output signals between ±5VDC are considered.
To convert an analog input signal to a digital format for use on a PC, we utilize the 12-bit
digital format, to an analog output signal, we utilize the 12-bit MAX537 D2A IC. Both ICs
are natively supported in the BS2 DAC toolbox. See Chapter 4 for more details of the BS2
The BS2 DAC toolbox allows users to implement control designs and to develop DAC
panels within Simulink block diagrams. This toolbox provides a Simulink custom library
(BS2Library), which contains blocks that interface with sensors and actuators connected to
the BS2. In this Chapter, we use only the IOBlock, AtoD LTC1296, and DtoA MAX537. The
As described earlier, the liquid levels of Tanks 1 and 2 are measured using pressure sensors,
where the output signal of the sensor is a voltage in the range of 0 to 5VDC corresponding
to the liquid levels in Tanks 1 and 2. A calibration gain for the pressure sensors is then
determined, i.e., the gain that converts the sensor output voltage to centimeters of liquid is
20
computed as 4.2 ( Vcm
olt ) . The pressure sensor analog signals are supplied to the LTC1296 A2D
and are utilized in the Simulink block diagram, as shown in Figures 5.2 and 5.4. Using the
MAX537 D2A, the BS2 supplies a controlled voltage signal to the pump, which controls the
the pump Vpss , which produced a steady state liquid level in Tanks 1 of L1ss = 10.75cm and
a steady state liquid level in Tank 2 of L2ss = 11.40cm. Next, we performed experiment 2
65
Figure 5.2: Simulink block diagram of the PI controller for Tanks 1 and 2
outlined earlier by filling Tank 1 with 16.46cm of water, i.e., L1(t0 ) = 16.46cm, and obtained
the liquid level of Tank 1 as it was discharged. Figure 5.5(a) shows the liquid level time
history of Tank 1. From Figure 5.5(a), the initial time of discharge t0 is 11.5sec and the time
of full discharge t∗ is 26sec. To compute the system parameter A, we chose t̄ = 16sec, which
corresponds to a liquid level in Tank 1 of L1 (t̄) = 10cm. Using (5.15) and (5.16), A and B are
Next, we performed experiment 3 outlined earlier, by filling Tank 2 with 15.80cm of water,
i.e., L2 (t0 ) = 15.80cm, and obtained the liquid level of Tank 2 as it was discharged. Figure
5.5(b) shows the liquid level time history of Tank 2. From Figure 5.5(b), the initial time
67
of discharge t0 is 59.5sec and the time of full discharge t∗ is 76sec. To compute the system
7.8cm. Using (5.17) and (5.18), C and D are computed numerically to be 0.4056 and 0.3938,
respectively.
Next, we used the liquid level time histories given in Figure 5.5 to obtain numerous time
instances t̄ and t̂, corresponding to many estimates of the system parameters A, B, C, and D.
We then averaged, individually, the estimates of A, B, C, and D and obtained the following:
of the Tanks 1 and 2 cross-sectional areas and orifices areas produce the nominal system
(a) (b)
Figure 5.5: (a) Experiment 2–L1(t) response and (b) Experiment 3–L2(t) response
Next, we implement the PI control architecture discussed earlier to control the liquid level
of Tank 2. Referring to Figure 5.2, two A2D blocks labeled Tank 1 Liquid Level and Tank 2
Liquid Level, are used to import the signals L1 (t) and L2 (t). These sensor signals are then
used for the PI controller of Tanks 1 and 2, wherein the control signal Vp(t) is sent to a D2A
In this experiment, we specify the desired liquid level of Tank 2 to be L2d = 12cm. Next,
68
we design the control gains KPi, KIi, i = 1, 2 using (5.22) and (5.23) given a set of settling
time and overshoot performance criterion. The resulting control gains are shown in Table 5.1.
Table 5.1: Settling time and percent overshoot requirements and PI controller gains
Figures 5.6–5.8 show the time history of L1 (t) and L2 (t) using the control gains given in
Cases 1–3 given in Table 5.1. Note that the controller design for the system is obtained by
linearizing the nonlinear model near the predetermined steady state level of Tank 2. Therefore,
(a) (b)
Figure 5.6: Response of (a) L1 (t) and (b) L2(t) using the PI controller gains of case 1
5.6. Conclusion
In this Chapter, we utilized the MATLAB and Simulink-based DAC platform developed in
tracking controller to control the liquid level of the two-tank system. In addition, we exper-
imentally validated the system identification method by using the BS2 DAC toolbox, which
69
(a) (b)
Figure 5.7: Response of (a) L1 (t) and (b) L2(t) using the PI controller gains of case 2
(a) (b)
Figure 5.8: Response of (a) L1 (t) and (b) L2(t) using the PI controller gains of case 3
the response of the set-point tracking controller, which showed good tracking performance
using several sets of performance criterion. This Chapter illustrates that the integration of a
low-cost BS2 microcontroller and the MATLAB and Simulink based DAC toolbox can be used
for data acquisition, experimental system identification, and advanced feedback control.
Chapter 6
6.1. Introduction
Synchronization of chaotic oscillators has incurred great interest in recent years, see for ex-
ample the excellent reviews [66–68]. Synchronization phenomena have been observed in many
biological systems, including animal groups [69], fireflies [70], animal gaits [71], heart stimula-
tion [72], and neural activity [73]. Synchronization techniques are applied in many engineering
and science fields, including secure communications [8–11], meteorology [74], chemistry [74],
Synchronization schemes for two identical chaotic oscillators can be classified into bidi-
rectional [77–79] and unidirectional [17, 21, 23, 24, 26] depending on the coupling between the
as master-slave synchronization. In this case, one system acts as a “master” by driving the
continuous-time systems, see for example [17, 21, 23, 24,26]. Nevertheless, in many engineering
applications noise corruption in analog signal transmission can lead to severe drawbacks of
synchronization schemes [27, 28]. Sampled-data systems have been studied in [10, 29, 30] to
tion of sampled-data systems can also be useful in designing robust and effective cooperative
data master-slave chaotic system. We consider the case of linear state feedback, and we
determine sufficient conditions on the feedback gain matrix for global synchronization. We
transform the global synchronization problem into a global asymptotic stability problem, by
describing the system dynamics in terms of an error sequence. We use the discrete-time
70
71
Lyapunov stability theory and the linear matrix inequality (LMI) framework to analyze global
illustrate the proposed approach, we specialize our results to the synchronization of Chua’s
The rest of the Chapter is organized as follows. In Section 6.2, we present a sampled-data
In Section 6.3, we transform the global synchronization problem into a global asymptotic
stability problem. In Section 6.4, we provide a sufficient condition for global synchronization.
In Section 6.5, we apply the LMI framework to construct a feedback gain matrix. In Section
In this section, we develop a sampled-data representation of a chaotic system using the Euler
sampled-data model of the chaotic system. To begin, consider the following continuous-time
chaotic system
where x(t) ∈ Rn is the continuous-time state vector, Ac ∈ Rn×n is a constant state matrix of the
proceeding, we assume that the nonlinear function, gc (·) satisfies the following condition [21]
˜ = Mc (ξ − ξ),
gc (ξ) − gc(ξ) ˜ (6.2)
where ξ, ξ̃ ∈ Rn and Mc ∈ Rn×n is a bounded matrix with its components dependent on ξ and
˜ Next, using the Euler approximation method [81], the continuous-time chaotic system (6.1)
ξ.
72
where Ad 4 4
= hAc + I, gd = hgc , h is the step size of the Euler approximation method, and I is
Now using the unidirectional coupling technique, we characterize a chaotic slave system for
(6.3) as follows
where K ∈ Rn×n is a feedback gain matrix that is to be designed to synchronize the slave
define the error between the states of the master and slave systems, (6.3) and (6.4), respectively,
as follows
4
e(k) = x(k) − x̃(k). (6.5)
The dynamics of the error state e(k) is readily obtained from the master system dynamics
where à 4
= Ad − K.
˜ = Md (ξ − ξ),
gd(ξ) − gd(ξ) ˜ (6.7)
where Md 4 ˜
= hMc is a bounded matrix with its components dependent on ξ and ξ.
Finally, the problem of synchronizing the dynamics of sampled-data slave system (6.4) to
the dynamics of sampled-data master system (6.3) necessitates that the states of the error
73
system dynamics given in (6.6) asymptotically converge to zero for any initial condition, i.e.,
In this section, using a quadratic Lyapunov function and Lyapunov stability analysis, we
provide a sufficient condition for the synchronization of the sampled-data master-slave chaotic
where γi is a bounded scalar with its components dependent on ξ and ξ˜ and M̂i is a constant
structure matrix that captures the structure of Md. Moreover, let δi , i = 1, . . . , q, be given
γi γj ≤ δi δj , i = 1, . . . , q, (6.10)
for ξ, ξ̃ ∈ Rn .
Theorem 6.1. Let K ∈ Rn×n be given and suppose there exists an n × n positive definite
is a Lyapunov function that guarantees that the error system dynamics (6.6) satisfy (6.8), thus
Proof. To show that the error state dynamics (6.6) are globally asymptotically convergent,
+eT (k)ÃT P [gd(x(k)) − gd (x̃(k))] + [gd(x(k)) − gd(x̃(k))]T P [gd (x(k)) − gd (x̃(k))]. (6.14)
74
Next, using (6.7), and collecting terms, ∆V (e(k)) can be compactly written as
Since V (e(k)) of (6.12) is a positive definite candidate Lyapunov function, global asymptotic
stability for the error system dynamics (6.6) is ensured by requiring that ∆V (e(k)) in (6.15)
We now provide a sufficient condition for (6.16) to hold. First, using (Ã − Md )T P (Ã − Md ) ≥ 0
to bound the second and third terms of the left hand side of (6.16), we obtain
Next, using (6.9) and (6.10), the right hand side of (6.17) can be further bounded as follows
q X
X q
2ÃT P Ã + 2MdT P Md − P ≤ 2ÃT P Ã + 2 δi δj M̂iT P M̂j − P. (6.18)
i=1 j=1
It now follows that (6.11) provides a sufficient condition for (6.16), which in turn provides a
sufficient condition for the global asymptotic stability for the error system dynamics (6.6).
In this section, we transform the sufficient condition (6.11) into an LMI condition which
yields the controller gain matrix K of (6.4) to facilitate the global asymptotic synchronization
Theorem 6.2. Suppose there exist a positive definite matrix P ∈ Rn×n and a matrix
G ∈ Rn×n satisfying
q
q X
X
1
− δi δj M̂iT P M̂j + 2P ATd P −G T
i=1 j=1 > 0. (6.19)
P Ad − G P
In addition, let K ∈ Rn×n be given by
K = P −1 G. (6.20)
75
Then P and K satisfy (6.11), yielding the global asymptotic stability for the error system
dynamics (6.6).
Finally, by an application of the Schur Complement [82], it follows that (6.22) is equivalent
to (6.19). Thus, it follows that the existence of a positive definite matrix P ∈ Rn×n and a
matrix G ∈ Rn×n satisfying (6.19) and of K ∈ Rn×n satisfying (6.20) is equivalent to the
existence of a positive definite matrix P ∈ Rn×n and K ∈ Rn×n satisfying (6.11). This proves
that the existence of a positive definite matrix P ∈ Rn×n and a matrix G ∈ Rn×n satisfying
(6.19) and of K ∈ Rn×n satisfying (6.20) yields the global asymptotic stability for the error
In this section, we illustrate the result of Section 6.5 by designing and implementing a
feedback control gain K for the chaotic slave system dynamics (6.4). We do so by considering
where α, β are given positive scalars, x1 denotes the first component of vector x, f (·) is a
1
f (x1) = bx1 + (a − b)(|x1 + 1| − |x1 − 1|), (6.25)
2
and a and b are given negative constants. Referring to [21], the nonlinear function f (·) can be
expressed as
b < 0.
Euler approximated sampled-data representations of the master and slave Chua’s circuits
Next, select the step size for the Euler discretization technique as h = 0.02. Then, the
sampled-data system (6.3) with Ad and gd(x) given by (6.27) and (6.28), respectively, can be
shown to be chaotic by showing that its largest Lyapunov exponent is positive [83]. Following
the procedure of [83], which eliminates the dependence of Lyapunov exponent computation
on initial condition (Table 6.1), error magnitude (Table 6.2), error direction (Table 6.3), and
Table 6.1: Largest Lyapunov exponent with respect to different initial conditions and number
of iteration
Table 6.2: Largest Lyapunov exponent with respect to different error magnitudes and number
of iteration
Table 6.3: Largest Lyapunov exponent with respect to different error directions and number
of iteration
The following numerical values for the various system parameters are adopted from [21]:
α = 9.78, β = 14.97, a = −1.31, and b = −0.75. Finally, to simplify the experimental demon-
and G in LMI (6.19) to be diagonal, which in turn yields a diagonal gain matrix K in (6.20).
Using this procedure, for the given problem data, the following gain matrix K can be obtained
For an experimental validation of the results of this Chapter, the following sequence of
First, the sampled-data representation of the master Chua’s system (i.e., (6.3) with Ad
Second, the sampled-data representation of the slave Chua’s system (i.e., (6.4) with Ad,
gd, and K given by (6.27), (6.28), and (6.30), respectively) is implemented on MC2. Note that
as stated above, MC2 receives, using an RF transceiver, the state x(k) of the master Chua’s
system and uses it as indicated in (6.4). Finally, for post-processing, at each sampling instant
k = 0, 1, . . ., MC2 communicates master and slave states x(k) and x̃(k), respectively, using
the serial communication capabilities of the Propeller microcontroller and MATLAB (see, e.g.,
Chapter 2—Chapter 5 for serial interfacing of various microcontrollers and MATLAB), x(k)
and x̃(k) are imported into MATLAB for a graphical representation of the synchronization of
In this Chapter, for MC1 and MC2, we used Parallax’s [84] Propeller demo boards [85] that
are based on a 32-bit processor. The Propeller demo board consists of a P8X32A-Q44 Propeller
microcontroller chip, an EEPROM, and eight digital I/O pins. The P8X32A-Q44 Propeller
chip has eight 32-bit processors, thus allowing multi-processing. The Propeller chip can be
language Spin, used in this Chapter. Finally, the Propeller chip is operated with a voltage level
of 3.3 volt direct current (VDC) and can communicate with a PC serially via a USB connec-
tion. For RF communication from MC1 to MC2, we used two 912MHz RF transceivers [86],
which have both transmitter and receiver functionalities on the module. The RF transceivers
communicate eight bits of data at 9600 baud rate. Note that at each sampling instant k, MC1
executing the sampled-data representation of the master Chua’s circuit needs to transmit the
79
corresponding three-D state vector x(k). Since, MC1 is based on a 32-bit processor, each
component of x(k) is encoded using 32 bits. Thus, for the purposes of RF transmission, MC1
divides each component of x(k) into four sets of eight-bit data. Analogously, as MC2 receives
four sets of eight-bit data, it combines them to produce the original 32-bit representation of
Figure 6.1 shows the pair of Propeller demoboards (MC1 and MC2), with RF transceivers
installed on-board, that are used to experimentally illustrate the synchronization of sampled-
data master-slave Chua’s system. Figure 6.2 shows the chaotic behavior produced by (6.3)
running on MC1 and plotting on MATLAB. Finally, Figures 6.3 and 6.4 show that the master-
Figure 6.1: Propeller demo boards and 912 MHz radio frequency transceivers for the sampled-
data master-slave Chua’s circuits
1.5 8 8
6 6
1
4 4
0.5
2 2
x2
x3
x3
0 0 0
−2 −2
−0.5
−4 −4
−1
−6 −6
−1.5 −8 −8
−5 −4 −3 −2 −1 0 1 2 3 4 5 −5 −4 −3 −2 −1 0 1 2 3 4 5 −1.5 −1 −0.5 0 0.5 1 1.5
x1 x1 x2
Figure 6.2: Plots of the double scroll attractors of the sampled-data master Chua’s circuit:
(a) x1 vs. x2 , (b) x1 vs. x3, and (c) x2 vs. x3
80
10 10 10
8 8 8
6 6 6
4 4 4
e1 2 2 2
e2
e3
0 0 0
−2 −2 −2
−4 −4 −4
−6 −6 −6
−8 −8 −8
Figure 6.3: Plots of the errors of the sampled-data master-slave Chua’s circuits: (a) e1 4
= x1 −
x̃1 , (b) e2 4 x
= 2 − x̃ 2 , and (c) e 4 x − x̃
3= 3 3
5 1.5 8
4
6
1
3
4
2
0.5
2
1
x˜1
x˜2
x˜3
0 0 0
−1
−2
−0.5
−2
−4
−3
−1
−6
−4
−5 −1.5 −8
−5 −4 −3 −2 −1 0 1 2 3 4 5 −1.5 −1 −0.5 0 0.5 1 1.5 −8 −6 −4 −2 0 2 4 6 8
x1 x2 x3
Figure 6.4: Plots of the states of the sampled-data master Chua’s circuit vs. the states of the
sampled-data slave Chua’s circuit showing synchronization of the master-slave Chua’s circuits:
(a) x1 vs. x̃1 , (b) x2 vs. x̃2, and (c) x3 vs. x̃3
6.7. Conclusion
In this Chapter, using the Euler approximation method, we obtained a sampled-data rep-
slave chaotic system. In addition, using the LMI framework, we constructed a state feedback
control law for the synchronization of the coupled chaotic system. By implementing a sampled-
7.1. Introduction
recently investigated, see for example [8–13]. The general idea behind these systems is to
use chaos to mask a transmitted signal, and chaos synchronization to securely recover it in
reception. In this case, the chaotic oscillator at the transmitter acts as a “master” by driving
are only sporadically coupled. This scenario seems particularly realistic for communication
systems. We consider the case of linear state feedback and we assume that the feedback
periodically changes over time. Following the work of [19] for analog systems, we refer to this
synchronization scheme as pulse synchronization [19, 22]. We establish sufficient conditions for
pulse synchronization using Lyapunov stability theory and the linear matrix inequality (LMI)
framework. Specifically, we show that chaotic synchronization is possible even if the oscillators
are only intermittently coupled, that is, even if most of the time they are uncoupled. The
Chua’s circuits experiment setup discussed in Chapter 6 is also used to specialize our results
of this Chapter.
The type of intermittent coupling considered in this Chapter has been analyzed in the
framework of consensus theory for continuous-time systems [31, 32], and peer-to-peer synchro-
nization of analog complex networks [33,34]. We note that, in consensus theory, the individual
systems’ dynamics is linear while in the present case the coupled systems are strongly nonlin-
ear. We further observe, that results in [33,34] are only for local synchronization since they are
based on linearized dynamics. In this Chapter, the inherent nonlinear nature of the coupled
81
82
The rest of the Chapter is organized as follows. In Section 7.2, we formulate a global
pulse synchronization problem. In Section 7.3, we provide sufficient conditions for global pulse
synchronization. In Section 7.4, we apply the LMI framework to construct periodic feedback
gain matrices that yield global pulse synchronization. In Section 7.5, we provide experimental
In order to characterize the pulse synchronization problem for the sampled-data master-
slave chaotic system, we use the sampled-data representation of the system developed in Chap-
where Ad 4 4
= hAc + I, gd = hgc , h is the step size of the Euler approximation method, and I is
the n × n identity matrix, K : Z → Rn×n , with Z denoting the set of nonnegative integers, is a
feedback gain matrix that is to be designed to synchronize the slave system (7.2) to the master
system (7.1).
Then the dynamics of the error state e(k) (see (6.5)) is readily obtained from the master
system dynamics (7.1) and the slave system dynamics (7.2) and is given by the following
For pulse synchronization of the sampled-data master-slave chaotic system, we consider the
where N 4
= p + q is the number of samples in a complete cycle, m ∈ Z, and p, q ∈ Z+ , with
Z+ denoting the set of positive integers. That is, over a period N , the periodic control gain
K(k) is non-zero for the first p samples and zero for the next q samples. In this case, the error
where
= A d + Md , k = mN + p, . . . , mN + p + q − 1, (7.8)
Finally, the problem of pulse synchronizing the dynamics of sampled-data slave system
(7.2) to the dynamics of sampled-date master system (7.1) necessitates that the states of the
error system dynamics given in (7.6) asymptotically converge to zero for any initial condition,
i.e.,
In this section, using quadratic Lyapunov functions and Lyapunov stability analysis, we
provide sufficient conditions for pulse synchronization of the sampled-data master-slave chaotic
X̀ X̀
2ATd Pk+1 Ad + 2 δi δj M̂iT Pk+1 M̂j − Pk < 0, k = p, . . ., p + q − 1, (7.11)
i=1 j=1
where Ãk 4
= Ad − Kk . In this case
4
V (e(k), k) = eT (k)Pk e(k), (7.12)
84
is a periodic quadratic Lyapunov function, with Pk+N = Pk , k ∈ Z, that guarantees that the
system dynamics (7.6) satisfy (7.9), thus yielding global asymptotic synchronization of the
Proof. To show that the error system dynamics (7.6) are globally asymptotically convergent,
Since V (e(k), k) of (7.12) is a positive definite candidate Lyapunov function, global asymptotic
stability for the error system dynamics (7.6) is ensured by requiring that ∆V (e(k), k) in (7.14)
We now provide sufficient conditions for (7.16) and (7.17) to hold. First, for k = 0, . . . , p − 1,
ÃTk Pk+1 Ãk + MdT Pk+1 Ãk + ÃTk Pk+1 Md + MdT Pk+1 Md − Pk
Next, using (6.9) and (6.10), the right hand sides of (7.17) and (7.18) can be further bounded
as follows
X̀ X̀
2ÃTk Pk+1 Ãk + 2MdT Pk+1 Md − Pk ≤ 2ÃTk Pk+1 Ãk + 2 δi δj M̂iT Pk+1 M̂j − Pk , (7.19)
i=1 j=1
X̀ X̀
2ATd Pk+1 Ad + 2MdT Pk+1 Md − Pk ≤ 2ATd Pk+1 Ad + 2 δi δj M̂iT Pk+1 M̂j − Pk . (7.20)
i=1 j=1
It now follows that (7.10) and (7.11) provide sufficient conditions for (7.16) and (7.17), respec-
tively, which in turn provide a sufficient condition for the global asymptotic stability for the
Remark 7.1. Note that by selecting a periodic Lyapunov function, we are able to guaran-
tee that the Lyapunov difference is decreasing even when the master-slave chaotic system is
decoupled.
In this section, we transform the sufficient condition (7.10) into an LMI condition which
when solved along with the LMI condition (7.11) yields the periodic controller gain matrices Kk
of (7.7) to facilitate the global asymptotic pulse synchronization of the sampled-data master-
Theorem 7.2. Suppose there exist N matrices Pk ∈ Pn and p matrices Gk ∈ Rn×n satisfying
X̀X̀
1
−
δi δj M̂iT Pk+1 M̂j + 2 Pk ATd Pk+1 − GTk
i=1 j=1 > 0,
Pk+1 Ad − Gk Pk+1
k = 0, . . . , p − 1, (7.21)
−1
Kk = Pk+1 Gk . (7.22)
Then Pk and Kk satisfy (7.10) and (7.11), yielding the global asymptotic stability for the error
X̀ X̀ 1
− δi δj M̂iT Pk+1 M̂j + Pk − (Ad − Kk )T Pk+1 Pk+1
−1
Pk+1 (Ad − Kk ) > 0. (7.23)
i=1 j=1
2
X̀ X̀ 1 −1
− δi δj M̂iT Pk+1 M̂j + Pk − (ATd Pk+1 − GTk )Pk+1 (Pk+1 Ad − Gk ) > 0. (7.24)
i=1 j=1
2
Finally, by an application of the Schur Complement [82], it follows that (7.24) is equivalent to
(7.21). Thus, it follows that the existence of N matrices Pk ∈ Pn and p matrices Gk ∈ Rn×n
satisfying (7.21) and (7.11) and of p matrices Kk : Z → Rn×n satisfying (7.22) is equivalent
(7.11). This proves that the existence of N matrices Pk ∈ Pn and p matrices Gk ∈ Rn×n
satisfying (7.21) and (7.11) and of p matrices Kk : Z → Rn×n satisfying (7.22) yields the global
Remark 7.2. Suppose for a given problem (7.21) and (7.11) are feasible with p = p∗ and
(7.22) render the error system dynamics (7.6) globally asymptotically stable for all q ≤ q ∗ .
In this section, we illustrate the result of Section 7.4 by designing and implementing a
periodic feedback control gain Kk for the chaotic slave system dynamics (7.2). We use the
Euler approximated sampled-data Chua’s system (6.27) and (6.28) discussed in Chapter 6.
In this Chapter, we select the step size for the Euler discretization technique as h = 0.005.
Then, the sampled-data system (7.1) with Ad and gd (x) given by (6.27) and (6.28), respectively,
can be shown to be chaotic by showing that its largest Lyapunov exponent is positive (≈ 0.4)
[83]. Table 7.1—Table 7.3 show the independence of Lyapunov exponent computation on initial
Table 7.1: Largest Lyapunov exponent with respect to different initial conditions and number
of iteration
Table 7.2: Largest Lyapunov exponent with respect to different error magnitudes and number
of iteration
Table 7.3: Largest Lyapunov exponent with respect to different error directions and number
of iteration
The following numerical values for the various system parameters are adopted from [21]:
α = 9.78, β = 14.97, a = −1.31, and b = −0.75. Finally, to simplify the experimental demon-
stration of pulse synchronization for the sampled-data master-slave chaotic system, we restrict
Pk and Gk in (7.21) and (7.11) to be diagonal, which in turn yields diagonal gain matrices
Kk in (7.22). Using this procedure, for the given problem data with p = 1, LMIs (7.21) and
(7.11) were determined to be feasible up to q = 22 and the following control gain matrix was
obtained
Similarly, for the given problem data with p = 3, LMIs (7.21) and (7.11) were determined to
For an experimental validation of the results of this Chaper, the same experimental setup
discussed in Chapter 6 is used. Figures 7.1(a), 7.1(b), and 7.2 show that control gains (7.25)
and (7.26) yield pulse synchronization of the master-slave system (i.e., (7.1) running on MC1
Figures 7.1(c), 7.1(d), and 7.3 show that the master-slave system lacks synchronization for
p = 1, q = 1500 and p = 3, q = 2000, with control gains (7.25) and (7.26), respectively.
7.6. Conclusion
data master-slave chaotic system using the discrete-time Lyapunov stability theory. In addi-
tion, using the LMI framework, we constructed a periodic state feedback control law for pulse
synchronization of the coupled chaotic system. We validated our results by performing pulse
0.5 0.5
e1
e1
0 0
−0.5 −0.5
0.2 0.2
e2
e2
0 0
−0.2 −0.2
0 50 100 150 200 0 50 100 150 200
1 1
e3
e3
0 0
−1 −1
0 50 100 150 200 0 50 100 150 200
k k
(a) (b)
0.5 0.5
0
e1
e1
0
−0.5 −0.5
0 1000 2000 3000 4000 5000 6000 7000 0 1000 2000 3000 4000 5000 6000 7000
0.2
0.2
e2
e2
0 0
−0.2
−0.2
0 1000 2000 3000 4000 5000 6000 7000 0 1000 2000 3000 4000 5000 6000 7000
1
1
e3
e3
0 0
−1
−1
0 1000 2000 3000 4000 5000 6000 7000 0 1000 2000 3000 4000 5000 6000 7000
k k
(c) (d)
5 8
1
4
x∼
x∼
x∼
3
1
0 0 0
−4
−1
−5 −8
−5 0 5 −1 0 1 −5 0 5
x1 x2 x3
1
4
x∼
x∼
x∼
3
1
0 0 0
−4
−1
−5 −8
−5 0 5 −1 0 1 −5 0 5
x1 x2 x3
Figure 7.2: Plots of the states of the sampled-data master Chua’s circuit vs. the states of
the sampled-data slave Chua’s circuit (xi vs. x̃i , i = 1, 2, 3) showing synchronization of the
master-slave Chua’s circuits: (a), (b), (c) with p = 1, q = 22 and (d), (e), (f) with p = 3, q = 50
91
5 8
1
4
x∼
x∼
x∼
3
1
0 0 0
−4
−1
−5 −8
−5 0 5 −1 0 1 −5 0 5
x x x
1 2 3
1
4
x∼
x∼
x∼
3
1
0 0 0
−4
−1
−5 −8
−5 0 5 −1 0 1 −5 0 5
x x x
1 2 3
Figure 7.3: Plots of the states of the sampled-data master Chua’s circuit vs. the states of
the sampled-data slave Chua’s circuit (xi vs. x̃i , i = 1, 2, 3) showing lack of synchronization
of the master-slave Chua’s circuits: (a), (b), (c) with p = 1, q = 1500 and (d), (e), (f) with
p = 3, q = 2000
Chapter 8
This dissertation has concentrated on two disparate topics: i) design and development of
a user-friendly icon-based data acquisition and control (DAC) software that enables the use
systems. Throughout this dissertation, the design and efficacy of our proposed methodologies
were verified via experimental validation studies. MATLAB-based DAC tools exploited Pe-
ripheral Interface Controller (PIC) and BASIC Stamp 2 (BS2) microcontrollers. On the other
In the first part of this dissertation (Chapters 2—5), we developed MATLAB-based DAC
tools that provide graphical user interfaces (GUIs) to interact with inexpensive microcontrollers
such as PIC and BS2. We exploited the serial communication functionality of MATLAB to
receive sensory data. Moreover, we utilized MATLAB, Simulink, and Dials and Gauges Block-
set to develop interactive GUI environments for the microcontrollers, allowing enhanced data
processing and visualization. Next, we developed a DAC toolbox wherein users can simply
was designed for allowing in particular: i) the generation of proper microcontroller codes for a
variety of sensors and actuators; ii) programming of the microcontroller; and iii) data commu-
nication between the microcontroller and MATLAB. The effectiveness of our MATLAB-based
GUI environment to interact with microcontrollers was illustrated by showing several impor-
tant features of the DAC platform by performing liquid level control of a coupled, two-tank
system and position control of a DC motor system. The classical PI and PID controllers were
92
93
The results of Chapters 2—5 can be extended in several ways. In regards to the communi-
cation method of the DAC toolbox, our current approach uses the RS232 serial communication
protocol. However, many newer computing platforms (desktops and laptops) do not provide the
serial ports. Instead, the RS232 protocol has been replaced by the USB communication proto-
col. Although the RS232 serial communication protocol still can be used by using serial/USB
adapters for the computing platforms which do not have serial ports, further exploration of
USB-based DAC tool design can provide additional speed for data acquisition.
In the second part of this dissertation (Chapters 6 and 7), synchronization of a master-slave
chaotic system in the sampled-data setting was studied by using the Euler approximation tech-
setting was investigated by developing a pulse-based intermittent control system for chaos
matrix inequality framework to construct a time-invariant full-state feedback control law for
periodic, full-state feedback control law for the sporadically coupled synchronization problem
The results of Chapters 6 and 7 can be extended in several ways. In regards to the discretiza-
tion technique, instead of using the Euler approximation technique, higher order discretization
technique such as the Runge-Kutta method can be used to discretize the continuous-time
chaotic systems. In regards to the applications of the results, the synchronization of the
sampled-data chaotic system can be expanded to various applications such as the cooperative
control algorithm for the teams of robots to achieve tasks assigned by synchronizing motions.
Appendix A.1
LIST p=16f74
INCLUDE “p16f74.inc”
CONFIG CP OFF & WDT OFF & HS OSC & PWRTE ON ;configure PIC16F74
BootStart
MOVLW b’00000000’
MOVLW b’10000000’
MOVLW b’00000001’
MOVLW b’10000100’
MOVWF INTCON ;enable all unmasked interrupts and TMR0 register overflow
BaudRateSettingsforUSART
MOVLW d’129’
MOVLW b’00100100’
MOVLW b’10010000’
MOVF RCREG, W
MOVF RCREG, W
MainProgram
GOTO Check
MOVLW 0x64
LoopHigh
MOVLW 0x05
InnerLoopHigh
MOVLW 0xfa
LoopLow
MOVLW 0x15
InnerLoopLow
;This code is used to collect the light sensor output ;1. Measure the voltage output from pho-
toresistor
LIST p=16f74
INCLUDE “p16f74.inc”
CONFIG CP OFF & WDT OFF & HS OSC & PWRTE ON ;configure PIC16F74
BootStart
MOVLW b’00000001’
MOVLW b’10000000’
ADCInitialization
MOVLW b’10000001’
MOVWF ADCON0 ;enable ADC and select CH0
MOVLW b’00000100’
TimerInitialization
MOVLW b’00000001’
MOVLW b’10000100’
MOVWF INTCON ;enable all unmasked interrupts and TMR0 register overflow
BaudRateSettingsforUSART
MOVLW d’129’
MOVLW b’00100100’
MOVLW b’10010000’
StartADCandUSART
;SUBROUTINE
ADCLight
GOTO Wait
RETURN
Send
GOTO Send
RETURN
;5. Convert sensor data into 8-bit A/D and send them to PC
LIST p=16f74
INCLUDE “p16f74.inc”
CONFIG CP OFF & WDT OFF & HS OSC & PWRTE ON ;configure PIC16F74
MOVLW b’00000111’
MOVLW b’00000000’
MOVLW b’10000000’
ADCInitialization
MOVLW b’10000001’
MOVLW b’00000100’
TimerInitialization
MOVLW b’00000001’
MOVLW b’10000100’
MOVWF INTCON ;enable all unmasked interrupts and TMR0 register overflow
BaudRateSettingsforUSART
BSF STATUS, RP0 ;select bank 1
MOVLW d’129’
MOVLW b’00100100’
MOVLW b’10010000’
MOVF RCREG, W
MOVF RCREG, W
MainProgram
MOVLW 0x64
BeginServo
LoopHigh
MOVLW 0x05
InnerLoopHigh
MOVLW 0xfa
LoopLow
MOVLW 0x15
InnerLoopLow
TurnLaser
TurnMotor
StartADCandUSART
ReverseDCMotor
BCF PORTB, 5
CheckInitialPosition
GOTO CheckInitialPosition
Finish
;SUBROUTINE
ReceiveAngle
GOTO ReceiveAngle
RETURN
Send
RETURN
ADCLight
MOVLW b’10000001’
ADCPosition
MOVLW b’10001001’
Wait
GOTO Wait
RETURN
MOVLW 08h
MOVWF iter
GOTO Loop1
RETURN
DelayUSART ;delay for USART
MOVLW 0x0a
MOVWF iter1
GOTO Delay
MOVLW 0x1a
MOVWF iter1
GOTO Delay
MOVLW 0x3f
MOVWF iter1
GOTO Delay
Delay
MOVWF iter2
MOVWF iter3
GOTO Loop4
DECFSZ iter2
GOTO Loop3
DECFSZ iter1
GOTO Loop2
RETURN
[7] S. H. Strogatz, Nonlinear Dynamics and Chaos, Westview Press, Cambridge, MA, 2000.
[9] M. Feki, “An Adaptive Chaos Synchronization Scheme Applied to Secure Communica-
tion,” Chaos, Solitons and Fractals, vol. 18, pp. 141–148, 2003.
[10] M. Feki, B. Robert, G. Gelle, and M. Colas, “Secure Digital Communication using
Discrete-Time Chaos Synchronization,” Chaos, Solitons and Fractals, vol. 18, pp. 881–
890, 2003.
[11] S. Hayes, C. Grebogi, and E. Ott, “Communicating with Chaos,” Physical Review Letters,
[15] H. Dedieu, M. P. Kennedy, and M. Hasler, “Chaos Shift Keying: Modulation and De-
actions on Circuits and Systems II, vol. 40, no. 4, pp. 634–642, 1993.
[16] S. Tang, H. F. Chen, S. K. Hwang, and J. M. Liu, “Message Encoding and Decoding
[18] H.-H. Chen, “Global Synchronization of Chaotic Systems via Linear Balanced Feedback
Control,” Chaos, Solitons and Fractals, vol. 186, pp. 923–931, 2007.
Chaotic Circuits,” Chaos, Solitons and Fractals, vol. 17, pp. 335–361, 2003.
[20] G. Grassi and S. Mascolo, “Nonlinear Observer Design to Synchronize Hyperchaotic Sys-
tems via a Scalar Signal,” IEEE Transactions on Circuits and Systems - I: Fundamental
for Coupled Chaotic System,” Chaos, Solitons and Fractals, vol. 15, pp. 925–935, 2003.
Chua’s Circuits,” Nonlinear Analysis: Real World Applications, vol. 7, pp. 1298–1303,
2006.
Synchronized Chaotic Systems,” Chaos, Solitons and Fractals, vol. 22, pp. 599–604,
2004.
[24] J. H. Park, “Chaos Synchronization of a Chaotic System via Nonlinear Control,” Chaos,
[26] J. Sun and Y. Zhang, “Some Simple Global Synchronization Criterions for Coupled
Time-Varying Chaotic Systems,” Chaos, Solitons and Fractals, vol. 19, pp. 93-98, 2004.
[27] U. Kocarev and L. Parlitz, “General Approach for Chaotic Synchronization with Ap-
plications to Communication,” Physical Review Letters, vol. 74, no. 25, pp. 5028-5031,
1995.
Carrier,” Mathematics and Computers in Simulation, vol. 58, pp. 285–293, 2002.
[29] T.-L. Liao and N.-S. Huang, “Dead-Beat Chaos Synchronization and its Applications to
1669-1673, 1999.
[30] U. Parlitz and S. Ergezinger, “Robust Communication Based on Chaotic Spreading Se-
[32] M. Porfiri and D. J. Stilwell, “Consensus Seeking over Random Weighted Directed
Graphs,” IEEE Transactions on Automatic Control, vol. 52, no. 9, pp. 1767–1773, 2007.
[33] M. Porfiri, D. J. Stilwell, E. M. Bollt, and J. D. Skufca, “Random Talk: Random Walk
102–113, 2006.
[34] D. J. Stilwell, E. M. Bollt, and D. G. Roberson, “Sufficient Conditions for Fast Switch-
Inc.
crochip Technology, Inc., (access link for application notes, code examples, and tem-
plates).
.htm, website of Microchip Technology, Inc., (access link for PICSTART Plus Develop-
ment Programmer).
[40] Online: http://www.olimex.com/dev/, website of Olimex Ltd., (access link for PIC-
b.pdf, website of Microchip Technology, Inc., (access link for PIC16F74 device datasheet).
Works, Inc., developer and distributor of Dials and Gauges Blockset (access link for
sw/labviewbs2.pdf.
[47] S.-H. Lee, Y.-F. Li, and V. Kapila, “Development of a Matlab-Based Graphical User
Interface for PIC Microcontroller Projects,” Proceedings of the American Society of En-
gineering Education Conference, Salt Lake City, UT, Session 2220, 2004.
[48] Y.-F. Li, S. Harari, H. Wong, and V. Kapila, “Matlab-based Graphical User Interface
(access link for the MPASM assembler user’s guide for PIC microcontrollers).
CA, 2005.
veloper and distributor of the BASIC Stamp 2 (BS2-IC) microcontroller (access link for
pdf, website of MathWorks Inc., developer and distributor of Simulink (access link for
lax Inc., developer and distributor of the BASIC Stamp 2 microcontroller (access link
for documentation on the RCtime instruction for the BASIC Stamp 2 microcontroller).
lax Inc., of the BASIC Stamp 2 microcontroller (access link for servo motor product
information).
Semiconductor Inc., developer and distributor of the MAX537 D2A (access link for prod-
uct information).
site of Parallax Inc., developer and distributor of the PBASIC tokenizer library (access
link for the Parallax tokenizer library and the tokenizer documentation).
[62] Online: http://pdfserv.maxim-ic.com/en/ds/MAX764-MAX766.pdf, website of Dallas
Semiconductor Inc., developer and distributor of the MAX764 DC-DC inverter (access
linear Backstepping Liquid Level Controller for a State Coupled Two Tank System,”
ks PIS 031708.pdf, website of Quanser Consulting Inc., developer and distributor of the
nization of Chaotic Systems,” Physics Reports, vol. 366, pp. 1–101, 2002.
[67] G. Chen and X. Yu (Eds.), Chaos Control Theory and Applications, Lecture Notes in
London, 2004.
[70] J. Buck and E. Buck, “Synchronous Fireflies,” Scientific American, vol. 234, p. 74, 1976.
[71] J. J. Collins and I. Stewart, “Coupled Nonlinear Oscillators and the Symmetries of
[74] Y. Kuramoto, Chemical Oscillations, Waves and Turbulence, Springer, Berlin, 1984.
[75] J. Ohtsubop, “Feedback Induced Instability and Chaos in Semiconductor Lasers and
[76] J. A. Fax and R. M. Murray, “Information Flow and Cooperative Control of Vehicle
Formations,” IEEE Transactions on Automatic Control, vol. 49, no. 9, pp. 1465–1476,
September 2004.
[77] Z. Ge and Y. Chen, “Synchronization of Mutual Coupled Chaotic Systems via Partial
[78] S. Tsay, C. Huang, D. Qiu, and W. Chen, “Implementation of Bidirectional Chaotic Com-
munication Systems Based on Lorenz Circuits,” Chaos, Solitons and Fractals, vol. 20,
of Identical Chaotic Systems,” Chaos, Solitons and Fractals, vol. 29, pp. 1002–1022, 2006.
[81] M. Arcak and D. Nesic, “A Framework for Nonlinear Sampled-Data Observer Design via
Approximate Discrete-Time Models and Emulation,” Automatica, vol. 40, no. 11, pp.
1931–1938, 2004.
[83] H. Peitgen, H. Jurgens, and D. Saupe, Chaos and Fractals, Springer-Verlag, New York,
NY, 1992.
[84] Online: http://www.parallax.com/, website of Parallax, Inc.