Application Notes DSP
Application Notes DSP
This is the author’s final version of the work, as accepted for publication
following peer review but without the publisher’s layout or pagination.
The definitive version is available at :
http://dx.doi.org/10.1109/AUPEC.2014.6966533
http://researchrepository.murdoch.edu.a/32585/
Trolling VSCs, they will not result in very fast dynamic per-
formances. FPGAs are slightly cheaper and can process data
faster than DSPs. However, they need a much lower pro-
gramming level compared to them. A comparison between
DSP and FPGA for VSCs is presented in [5] and concludes
that the FPGAs cost more than DSPs in terms of development
time while resulting in almost similar dynamic results by the
VSCs.
Nowadays, there are plenty of DSPs available in the mar-
ket from different manufacturers with various specifications.
Hence, the possible options should be carefully analyzed be-
fore choosing a DSP. Among various DSP manufacturers, in Fig. 3. (a) Packaged DSP, (b) TI DSP Experimenter’s Kit, (c) eZdspTM board,
(d) Schematic of the DSP docking station.
2006 it was reported that Texas Instruments® (TI) dominates
the market by 59% [4]. Table 1 summarizes some of the TI II. DSP KITS AND DEVELOPMENT SOFTWARE
processors in C2000 family, which are used for real-time ap-
TMS320F28335 DSP comes either in a packaged chip or
plications [6-7].It is to be noted that their ARM, C5000 and
on a control card. In either of the above cases, the DSP needs
C6000 series are also applicable for real-time applications but
to be mounted on a board. TI provides cheaper boards, re-
are more commonly used for control applications requiring
ferred to as Experimenter’s Kit [9] where the control cards
higher computations and data processing like multimedia or
can be mounted on. More professional and expensive boards
communication applications [4].
are also available for the packaged chips such as the Spec-
Depending on the application of the VSCs to be controlled,
trum Digital® eZdspTM board [10], which is one the most
the DSP should have a specific number of Analogue-to-
popular boards used for power electronic applications. Fig. 3
Digital Converters (ADC) and Digital-to-Analogue Conver-
shows the TMS320F28335 DSP package chip along with its
ters (DAC). In addition, depending on the number of calcula-
Experimenter’s Kit and eZdspTM board.
tions to be carried out by the controller, the DSP should have
In general, a DSP docking station can be represented with
a reasonable clock speed. It is to be noted that some DSPs
the main modules shown in Fig. 3(d). The signals applied to
have floating point support to provide high precision calcula-
the docking station are transmitted to and processed by the
tions, whereas fixed point DSPs have a lower precision [4].
DSP processor and then retrieved from it. Input signals are
Among the C2000 series of TI, TMS320F28335 DSC/DSP
applied on pins present on the docking station. These pins are
is a better trade-off between price, performance and features
internally connected to the General Purpose Input/Outputs
[6, 7]. Hence, this specific DSP is one of the most popular
(GPIO) of the DSP [6]. GPIOs can be set up by the user ei-
DSPs used to control the VSCs. Unlike FPGAs and like other
ther as inputs or outputs. TMS320F28335 has 88 GPIOs that
DSCs/DSPs, TMS320F28335 is a software based processor,
are connected to multiplexers. These multiplexers transmit
built on a modified Harvard architecture. In addition, it can
multiplexed signals to sample-and-hold registers where the
be programmed for real-time applications using C/C++ lan-
signals are held until the next conversion of the integrated
guage. It is to be noted that this DSP lacks DACs; however,
ADC. The ADC outputs are then transferred to the processor
this is not normally required in VSC applications. In case a
of the DSP through the result registers of the ADC. In order
digital signal inside the DSP needs to be exported out in ana-
to process the data, the code with which the DSP runs, can be
logue format, some auxiliary DAC chips are available to be
loaded from the Flash memory or from the Static Random
interconnected with the DSP. Alternatively, to export internal
Access Memory (SRAM). The flash memory is utilized in
data in digital format to an external display, the data can be
stand-alone applications of the DSP while SRAM is utilized
retrieved through a serial peripheral interface [8].
when the DSP is connected to its dedicated software on a
As a matter of comparison, the TMS320F2812 is also a
computer. The outputs of the program are then exported via
popular DSC/DSP of the TI C2000 series. However, as an
output GPIOs.
older fixed point unit model, its capability for numerical cal-
There are two possibilities to program the DSP. It can be
culations of floating point data is more limited than that of the
programmed in C/C++language using Code Composer Studio
floating point DSC/DSPs [4, 6-7]. Additionally, for the same
(CCS) which is a dedicated software, developed by the manu-
price of TMS320F28335, the TMS320F2812 offers slightly
facturer [11]. This process requires a good level of C lan-
less interesting hardware resources, as listed in Table 1.
Australasian Universities Power Engineering Conference, AUPEC 2014, Curtin University, Perth, Australia, 28 September – 1 October 2014 3
execution of the ISR (i.e. TIME = Ts), the input is saved as Table 2. Comparison of execution times [clock cycles].
the second element of the buffer. From the third execution of Input Signal FFT DFT Sine Analyzer + PLL
the ISR onwards (e.g. TIME = 2Ts, 3Ts, …), the first element 1-freq. Signal 17622 2063 375
of the buffer is overwritten by the second element while a 2-freq. Signal 17622 2062 376
3-freq. Signal 17622 2056 376
new input is saved as its second element. This is shown
schematically in Fig. 6.
A similar methodology can be applied when implementing v1 v2 v3 v4
a low pass filter. v2 v3
C. Sine Wave Analyzer v1 v1 v 2 v2 v2 v 2 v3 v3 v3 v 3 v4
x0 x 1 x0 x 1 x0 x 1 x0 x 1 x0 x 1 x0 x 1
Different methods can be utilized to define the magnitude Fig. 6. Schematic operation of a 2-element circular buffer.
and phase angle of a given signal, as discussed below:
1- Using the Fast Fourier Transform (FFT) the magnitude and bigger, the process differs slightly though, as discussed be-
phase angle for different frequency components can be low:
calculated. However, due to high number of calculations it 1-During the N first executions of the ISR, the buffers A and
is not really suitable for real-time control of VSCs. B are filled in with the calculated values.
2- If only the magnitude and phase angle of one specific fre- 2- At the end of the Nth execution of the ISR, the buffers are
quency (e.g. 50 Hz) is required to be utilized in ISR, then full and the input RMS and angle are calculated.
the Sine Analyzer and Digital Phase Locked Loop (PLL) 3- At the beginning of the (N+1)th execution of the ISR and
built-in functions of TI Control Suite are more time- onwards, the values of the oldest real element within the
efficient. current input signal period is subtracted from A and the
3- If the input signals have frequencies other than constant 50 oldest imaginary element within the current input signal
Hz (which is more probable in off-grid applications of period is subtracted from B
VSCs), then a Discrete Fourier Transform (DFT) can be 4- Within the same execution cycle of the ISR, a new real
developed by the user and operate fast enough to be uti- element and a new imaginary element of the input signal
lized for real-time purposes. The DFT first detects the are calculated and respectively added to A and B.
fundamental frequency of the input signal and then calcu- 5- Within the same execution cycle of the ISR, the RMS am-
lates its magnitude and phase angle. plitude and phase angle are calculated and updated.
The developed DFT calculates the root mean square Comparing the above three methods, FFT has the longest
(RMS) and phase angle of the fundamental frequency of its computational delay while the Sine Analyzer and PLL com-
input signal, regardless of the signal frequency from bination has the least computational delay. As an example,
2 Table 2 lists a comparison of the execution times, expressed
RMS = A2 + B2 in number of clock cycles, to process several different input
N (5) signals.
Angle= tan−1(B / A)
D. Deadband and Hysteresis Function
where N is the number of samples within a period of the sig-
nal (e.g. N=250 for a 50 Hz input signal), A is the sum of the To provide an acceptable level of tracking for the VSC cur-
real components of the input signal over one period, calcu- rent and voltage, the difference between the desired output
lated as and the actual output should be calculated. This is referred to
N N
as the VSC output tracking error, which should be kept close
⎛ 2π i ⎞
A= ∑Re(xi ) = ∑x[i].cos ⎜⎝ N ⎠
⎟ (6) to zero. Hence, a hysteresis controller can be developed and
utilized to properly turn on and turn off the switches in the
i =0 i =0
VSC to keep the tracking error within a very small bandwidth
and B is the sum of the imaginary components of the input
around zero. This can be achieved by developing ‘if state-
signal over one period
ments’ in the ISR. ‘If statements’ are very fast to execute and
N N
⎛ 2π i ⎞ only creates a negligible delay. Depending on the output of
B= ∑Im(xi ) = ∑x[i].sin ⎜⎝ N ⎟⎠ (6)
the ‘if statements’ a couple of predefined output GPIOs are
i=0 i=0
set to logic High or Low. The GPIOs being set as High or
It is to be noted that the angle needs to be in the range of [0-
Low activates or deactivates the driver circuits of a switch to
2π]. Hence, mathematical function of atan2 should be utilized which the GPIO is connected.
when developing (5) in ISR. The number of samples N is As discussed earlier, the switches in each leg of the VSC
calculated by measuring the period of the input signal. To do should operate in a complimentary fashion to prevent short-
so, the DC component of the input signal is filtered out and at circuiting the DC bus. Hence, it is necessary to implement a
least two periods of the filtered signal need to be stored in a dead-band between the assignments of the complementary
large array. N is given by the number of elements in the large output GPIOs to guarantee the prevention of any probable
array between two zero-crossings of the signal. short-circuits. The dead-band is created by using a ‘while
Circular buffers containing N elements are used to calcu- loop’ and by incrementing a counter until a certain value cor-
late A and B. The principle of this method is similar to the responding to the desired delay. The desired delay should be
procedure explained in the HPF section. Since the buffers are defined based on the recommended deadband of the switches.
Australasian Universities Power Engineering Conference, AUPEC 2014, Curtin University, Perth, Australia, 28 September – 1 October 2014 6
calculated RMS and angles which is compared with vcf. The vcf ,ref
K1
result of this comparison is then multiplied by of constant
positive gain K1 and considered as the second error in VSC
control. These two errors are added together and their sum is Fig. 8: Algorithm of the real-time application happening in Timer0 ISR.
compared with a reference by the developed hysteresis func- reached, the program cannot be compiled. Another memory
tion. The hysteresis and deadband controller function gene- slot of 8kB (L7) is used for constant values whereas the 2
rates an output out and its complementary തതതതത
ݐݑby the desired other remaining slots of 8kB (L5 and L6) are not used.
deadband limit. These two output commands are then fed to Hence, modifications were needed in the default Linker
the driver circuits of the IGBT switches in the VSC, through Command file to merge the slots L4, L5 and L6 to dedicate
opto-couplers. the new big memory block for global variables.
VI. DSP HARDWARE AND SOFTWARE LIMITATIONS The execution time is another important limitation; TI pro-
vides a good collection of library files for various operations,
A major limitation of embedded systems is the size of their such as digital filtering, waveform analyzing, etc. Although
memory. The TMS320F28355 DSP only contains a 68kB highly optimized, many of these functions take too many
SRAM and a 512kB flash memory. Code, variables and con- clock cycles to execute and may contain features that are not
stant values are managed in the memory through the com- required for the desired VSC application. Hence, developing
mand .cmd file. user defined functions to perform the exact required operation
Although the size of the flash memory is reasonable, using is often more time-efficient.
the flash memory can be delicate and problems may occur Some common issues may occur when programming and
frequently for example when intending to run the ADC with a compiling the program for TMS320F28355 DSP. For exam-
flash-based memory mapping. It is therefore advised to de- ple, in the case of an input signal with a varying frequency, it
velop the program by using SRAM only for simplification. is advised to use only the right amount of memory with dy-
Even though the SRAM is relatively fast but it is small and namic allocation, with respect to the signal frequency. How-
mostly protected, preventing the user from using it to store ever, compilation problems may be encountered when using
data. Maximum of 32kB can be used by the user to store the the most common way to create dynamically sized arrays, i.e.
global variable (referred to as .ebss) [4-6]. By default, this using the malloc and calloc commands. Using only fixed
total available memory of 32kB space is divided into 4 small- sized arrays for the program helps to tackle this issue, even
er spaces of 8kB. Only one small space of 8kB (the memory though it does not optimize the memory usage.
space L4) is used for global variables and once that limit is
Australasian Universities Power Engineering Conference, AUPEC 2014, Curtin University, Perth, Australia, 28 September – 1 October 2014 7