You are on page 1of 6

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/224302996

Rapid prototyping of control systems using embedded target for TI C2000 DSP

Conference Paper · July 2007


DOI: 10.1109/MED.2007.4433860 · Source: IEEE Xplore

CITATIONS READS

27 1,036

4 authors, including:

Petru Dobra
Universitatea Tehnica Cluj-Napoca
102 PUBLICATIONS   233 CITATIONS   

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Modelling a single track vehicle View project

Nonlinear model and control of a quadcopter View project

All content following this page was uploaded by Petru Dobra on 30 May 2014.

The user has requested enhancement of the downloaded file.


3URFHHGLQJVRIWKHWK0HGLWHUUDQHDQ&RQIHUHQFHRQ 7
&RQWURO $XWRPDWLRQ-XO\$WKHQV*UHHFH

Rapid Prototyping of Control Systems using


Embedded Target for TI C2000 DSP
R. Duma, P. Dobra, M. Abrudean, M. Dobra
Technical University of Cluj
St. C. Daicoviciu 15, 400020
Cluj-Napoca
Romania

Abstract— The paper presents a digital control is easier: powerful C and C++ compilers are available,
application, in which a tuning method is proposed for DC which remove the need to code in assembly, speeding the
motors, using DSP from Texas Instruments (TI). development process [3].
Experimental application for the DC motor illustrates the CACSD (Computer Aided Control System Design)
effectiveness and the simplicity of the proposed method for tools are extensively used to generate real time code
controller design. The control algorithm for the drive automatically. The graphical programming approach
application runs on a TMS320F2812 DSP. Once the desired removes the need to write software by hand and allows the
functionality has been captured and simulated, using engineer to focus instead on improving functionality and
MATLAB/Simulink/Embedded Target for TI C2000 DSP performance. Complete system design is carried out
environment can be generated code for the DSP. All task within the simulation environment.
assignments to processor are automatically made by the
software. The DC Motor is driven by pulse width modulated With the great diversity of applications, a development
(PWM) signals generated by the DSP. environment must be flexible and provide exactly the
Keywords- PID control, limit cycle, PWM, DSP, functionality necessary for efficient problem solving.
embedded target, Simulink, Code Composer Studio. Mathworks' Simulink software is such a graphical
modelling tool.
I. INTRODUCTION Simulink is a platform for multidomain simulation and
Developing controllers for applications (electrical drive model-based design of dynamic systems. It provides an
systems) means large expenditure, when performed with interactive graphical environment and a customizable set
usual development methods. The workload comprises of block libraries. The engineer can accurately design,
development of a mathematical model as well as simulate, implement, and test control, signal processing,
algorithm design and implementation, off-line simulation, communications, and other time-varying systems.
and optimization. The whole process has to be restarted on A recent toolbox of Simulink is the 'Embedded Target'
occurring errors or divergences, which makes the for Texas Instruments' C2000 DSP platform.
development process time consuming and costly [1].
Rapid Control Prototyping is a way out of this situation, II. C2000 EMBBEDED TARGET
especially if the control algorithm is complex and a lot of Simulink, Real-Time Workshop, the Embedded Target
iteration steps are necessary. for TI C2000 DSP, and Link for Code Composer Studio
Digital signal processors (DSP) are a key technology (CCS; TI’s Integrated Development Environment) provide
enabling electric drives to be smoother, more efficient, an integrated platform for design, simulation,
more reliable and most importantly, cheaper. This is being implementation, and verification of embedded control
exploited in a whole spectrum of applications such as systems on standard and custom C2000 DSP targets (Fig.
washing machines, heating and air conditioning and 1) [4].
electric power assisted steering in cars. The processing Simulink models are constructed from standard
power of DSP controllers is allowing the accurate control libraries. Embedded Target provides blocks specific to the
motors with fewer sensors. C2000 DSP family: I/O, CAN, PWM, QEP, Read From
Apart from the basic requirement to control the motor's
speed and direction, modern motor controllers might also
be expected to regulate energy consumption and to
implement other functions, ranging from power factor
correction to Ethernet drivers and TCP/IP protocol stacks.
Depending on application requirements, system
complexity ranges from the minimal DC brush motor
controller to high end vector drives [2].
DSP application development has changed markedly in
the last decade. The lack of efficient C compilers for DSP
obliged developers to write algorithms by hand using a Figure 1. The steps from the model to the implementation
low level assembly language - a laborious process. Today
3URFHHGLQJVRIWKHWK0HGLWHUUDQHDQ&RQIHUHQFHRQ 7
&RQWURO $XWRPDWLRQ-XO\$WKHQV*UHHFH

Memory, and Write To Memory. Engineers can


automatically generate prototype code for any of the
supported boards, combining these blocks with standard
blocks from Simulink, Simulink Fixed Point, and the
Signal Processing Blockset. User defined blocks, S-
functions, can be added to the Simulink model. Thus
portions of proven code can be integrated in the model.
A Target Preference block has to be added to the
model. It does not connect to any other blocks, but stands
alone to set the target preferences for the model (build
options for the compiler, assembler and linker which will
be invoked to generate the executable image file for
download to the DSP).
Each DSP peripheral is represented by a Simulink
block, and can be configured using a graphical interface, Figure 2. DC motor control setup with F2812
allowing the user to define the settings of the internal
registers associated with the peripheral. is supplied at 12 V and its speed is controlled using a
Once the desired functionality has been captured and PWM signal.
simulated, can be generated code for the DSP. The speed is measured using an optical encoder sensor
Simulink/Real-Time Workshop generates a C language and a shaft sprocket with 32 teeth. The signal from the
real time implementation of the model, creates and sensor is conditioned using a 74HCT14 Trigger Smidth
populates a CCS project with the code. CCS is opened, the circuit and is applied at the input pin of a capture and log
project compiled and linked, and the image file transition unit of the eZdsp F2812 target.
downloaded to the target DSP. Fig. 4 presents the hardware setup at work.
The code may be instrumented with Real Time Data
eXchange modules to stream data to and from the target. IV. CONTROLLER IMPLEMENTATION
These are additional I/O blocks from the Embedded
Target library. Using MATLAB and Simulink for modeling, analysis,
design and offline simulation has become a de facto
A key feature of Embedded Target is its ability to standard for control system development.
generate efficient DSP code [3].
The Simulink model is constructed from blocks of the
C2000 Embedded Target Library which are used to
III. HARDWARE ARCHITECTURE represent algorithms and peripherals specific to the C2800
DSP family.
A. Processor The block diagram of the closed loop control structure
The control algorithm runs on eZdsp F2812 target is shown in Fig.5 and the Simulink model of the control
equipped with a TI TMS320F2812 DSP, for fast fixed- algorithm in Fig. 6.
point calculation at 150 MHz (6.67 ns cycle time). A Target Preference block has to be added to the
The TMS320F2812 device, member of the model, in this case the F2812 eZdsp block. It does not
TMS320C28x DSP generation, is highly integrated, high- connect to any other blocks, but stands alone to set the
performance solutions for demanding control applications. target preferences for the model. This allows the user to
The board can be adapted to a wide range of closed- control build options for the compiler, assembler and
loop applications due to its motor control peripherals( two linker who will be invoked to generate the executable
event managers (EVA, EVB)), 16 12-Bit ADC channels image file for download to the DSP. The speed feedback
with fast conversion rate: 80 ns/12.5 MSPS, up to 56 subsystem is presented in Fig. 7 and the target speed
general purpose I/O (GPIO) pins, high-performance 32-bit subsystem in Fig. 8. The system works at a sampling rate
CPU, three 32-Bit CPU-timers. of 1 ms. For the DC Motor speed measurement an Capture
The multiple bus architecture, commonly termed Unit (CU) of the Event Manager is used. The capture unit
“Harvard Bus”, enables the F2812 to fetch an instruction, log transitions detected on the capture unit pin by
read a data value and write a data value in a single cycle. recording the times of these transitions into a two-level-
All peripherals and memories attached to the memory bus deep FIFO stack.
will prioritize memory accesses. At multiples of the sample time the values from the
two-level-deep FIFO stack are subtracted. For a good
B. DC Motor resolution the 75 MHz input clock, associated with the
The DC Motor comprises the motor, a shaft sprocket capture unit, is divided by a factor of 1/128. By this factor
with 32 teeth, an optical gear tooth sensor for speed the general purpose (GP) timer is prescaled to produce the
measurement, and a DC/DC electronic converter. The counting rate of 1.70752.
DC/DC electronic converter is driven by pulse width The counter associated with the capture unit is on 16
modulated (PWM) signals from the F2812 target. The bits. If it reaches the upper limit of 216-1 it will reset to 0.
whole setup is shown in Fig. 2. For a motor speed between 0-4000 RPM the measured
signal is in the range 80 – 360 Hz.
C. Motor Driver In order to reduce signal jitter or period fluctuation a
The interface between the F2812 target and the motor is first order delay filter is used. The time constant of this
implemented by the circuit presented in Fig. 3. The motor filter is 0.3 seconds. The output of the filter is applied at
3URFHHGLQJVRIWKHWK0HGLWHUUDQHDQ&RQIHUHQFHRQ 7
&RQWURO $XWRPDWLRQ-XO\$WKHQV*UHHFH

the feedback input port of the PID Controller block, from


Digital Motor Control Library (DMC).
At the reference input port of the controller is applied
the target speed using a RTDX block. The drive can be
controlled using a graphical user interface (GUI), created
using GUIDE, the MATLAB Graphical User Interface
development environment. Figure 5. Block diagram of the closed loop control structure
The controller computes the duty ratio of the PWM
control signal generated using a Simulink/Embedded
Target block. The frequency of the PWM signal is fixed at
5 KHz.

Figure 6. Simulink block diagram of control system of DC Motor

Figure 7. Simulink block diagram for motor speed measurement

Figure 8. Simulink block diagram for setting the reference speed

V. CONTROLLER TUNING
Figure 3. The motor driver A key method for auto-tuning is the use relay feedback
method [7]. Processes with the dynamics typically
encountered in process control will exhibit limit cycle
oscillations. The relay feedback causes the process to
oscillate with controlled amplitude. The frequency of the
limit cycle is approximately the ultimate frequency where
the process has a phase lag of 180o. The ratio of the
amplitude of limit cycle and the relay amplitude is
approximately the process gain at that frequency. Thus a
point on the Nyquist curve of the open loop dynamics
close to the ultimate point is determined.
The parameters of the controller can be computed using
Ziegler-Nichols tuning methods or tuning with specify
phase and amplitude margin. Better results were obtained
by specifying the phase and amplitude margin. The
implementation of the last tuning method is presented
below. Consider a situation where one point on the
Nyquist curve for the open loop system is known. With
PID control it is possible to move the given point on the
Nyquist curve to an arbitrary position in the complex
plane.
Figure 4. Computer, eZdsp F2812 target, oscilloscope, DC motor,
motor driver and power supply A limit cycle is obtained by introducing in the control
loop a relay type nonlinearity (Fig. 9). The Simulink block
diagram for obtaining the limit cycle is shown in Fig. 10.
3URFHHGLQJVRIWKHWK0HGLWHUUDQHDQ&RQIHUHQFHRQ 7
&RQWURO $XWRPDWLRQ-XO\$WKHQV*UHHFH

If the error is smaller than zero the PWM duty ratio will Solving equation (3), for Ti = αTd with α ∈ ( 2 ÷ 6) ,
be 95% and if it is greater than zero the duty ratio will be
of 80%, thus obtaining a limit cycle. RTDX blocks are is obtained the derivative time constant:
used to fetch and retrieve data from the target. For this in
the Simulink model From RTDX and To RTDX blocks 1
have been added. Td = (tan γ m + 4 α + tan 2 γ m ) . (4)
The obtained limit cycle is shown in Fig. 11. 2ω0
From Fig. 10 the critical period Tu is determined. The
ultimate gain Ku is computed using relation: If the magnitude of the open loop transfer function is
specified to k m simple trigonometric calculations give
4d k p = k m K u cos γ m . (5)
Ku = . (1)
πa
The step response, using the computed PID controller,
The open loop transfer function with PID control is: is shown in Fig. 12.
In order to obtain the step reference input signal is used
1 the Simulink diagram shown in Fig. 13.
k p (1 − + jωTd ) H DCM . (2)
jωTi VI. INSTRUMENTATION, DATA AQUISISION AND
RESULTS
Consider the phase of the PID controller at
Until recently, developers were forced to stop their
ω0 = 2π Tu to be γ m : application with a breakpoint to exchange data
"snapshots" with the host computer in a technique that is
called "stop-mode debugging". This intrusive approach
1 can be misleading, because the isolated snapshot of a
arctg (ωTd − ) =γm . (3)
ωTi halted high-speed application cannot show the real-world
operation of the system [8].
To solve this problem, TI developed RTDX, or Real
Time Data Exchange, which gives designers continuous,
real- time visibility into their applications.
RTDX enables real-time, asynchronous exchange of
data between the target and the host, without stopping the
Figure 9. Relay feedback diagram
target.
In essence, the RTDX data link provides a "data pipe"
between DSP application and the host. The bidirectional
capability allows developers to access data from the
application for real-time visibility, or to simulate data
input to the DSP, perhaps before real-time sensor
hardware is available. This shortens development time by
giving developers a realistic view of the way their
systems operate.
The drive can be controlled using a graphical user
interface (GUI), created using GUIDE, the MATLAB
Graphical User Interface development environment,
which provides a set of tools for creating graphical user
interfaces (GUIs).
The instrumentation control panel is shown if Fig. 14.
The target speed, which is set by turning the needle of an
Angular Gauge Control, the speed, the command and
Figure 10. Simulink block diagram of Ziegler – Nichols ultimate period the PWM signal can be analyzed and displayed. In the
method upper graphic of the panel the DC motor step response is
shown.

Figure 11. Limit cycle Figure 12. DC motor step response


3URFHHGLQJVRIWKHWK0HGLWHUUDQHDQ&RQIHUHQFHRQ 7
&RQWURO $XWRPDWLRQ-XO\$WKHQV*UHHFH

[6] W. Leonard, Control of electric drives. Spinger Verlag, London,


1985.
[7] J. Ziegler and N. Nichols, “Optimum settings for automatic
controllers,” Trans. ASME, pp. 759–768, 1942.
[8] *****, www.ti.com.
[9] D. Hercog, M. Curkovic and K. Jezernik, “DSP based rapid
prototyping systems for engineering education and research,” in
Proc. IEEE Conference on Conference of Computer Aided Control
System Design, Munich, 2006.
[10] A. Leva and F. Schivo, “Robust autotunning of industrial
regulators based on complex process models: the DIMC
approach,” in Proc. IEEE Conference on Conference of Computer
Aided Control System Design, Munich, 2006.
Figure 13. Simulink block diagram for obtaining the step input signal
[11] K. Astrom and T. Hägglund, PID Controllers: Theory, Design,
and Tuning. ISA Research Triangle Park, 1995.

Figure 14. Instrumentation control panel

VII. CONCLUSIONS
The paper presented a digital control application in
which a PID tuning method for a DC motor is
implemented and tested. The control algorithm runs on
the eZdsp F2812 target equipped with a DSP
(TMS320F2812).
Using this design approach, there is no need to
determine an algorithm or to compute a mathematical
model of the motor. The parameters of the controller are
determined using experimental methods. The overshot
obtained is under 10%, an acceptable result.
The real-time code for the complete system is
automatically generated using Embedded Target and Real
Time Work Shop. No hand-coding is required. Time for
implementation and testing is minimized.
In the feature we plan a similar approach for a
Brushless DC Motor.

REFERENCES
[1] H. Hanselmann, “Control: the total development environment,”
International Conference on Signal Processing Applications,
Boston, MA, 1995.
[2] K. Godbole, O. Monnier, and J. Skinner Gray , “Modern motor
controllers must do more than just spin the motor”,
http://www.neon.co.uk/campus/articles/texas/ti_articles_spring04.
cfm
[3] R. Poley,“Blocks bring benefits”, http://www.neon.co.uk/ campus/
articles/texas/ ti_articles_autumn05.cfm.
[4] *****, www.mathworks.com.
[5] B. Anderson, and J. Moore, Linear optimal control. Prentice-Hall,
Englenwood Cliffs, New Jersy, 1971.

View publication stats

You might also like