Prototyping Advanced Control Systems On FPGA
Prototyping Advanced Control Systems On FPGA
net/publication/220205578
CITATIONS READS
14 1,090
3 authors, including:
All content following this page was uploaded by Jean-Gabriel Mailloux on 15 May 2014.
Research Article
Prototyping Advanced Control Systems on FPGA
In advanced digital control and mechatronics, FPGA-based systems on a chip (SoCs) promise to supplant older technologies, such
as microcontrollers and DSPs. However, the tackling of FPGA technology by control specialists is complicated by the need for
skilled hardware/software partitioning and design in order to match the performance requirements of more and more complex
algorithms while minimizing cost. Currently, without adequate software support to provide a straightforward design flow, the
amount of time and efforts required is prohibitive. In this paper, we discuss our choice, adaptation, and use of a rapid prototyping
platform and design flow suitable for the design of on-chip motion controllers and other SoCs with a need for analog interfacing.
The platform consists of a customized FPGA design for the Amirix AP1000 PCI FPGA board coupled with a multichannel analog
I/O daughter card. The design flow uses Xilinx System Generator in Matlab/Simulink for system design and test, and Xilinx
Platform Studio for SoC integration. This approach has been applied to the analysis, design, and hardware implementation of
a vector controller for 3-phase AC induction motors. It also has contributed to the development of CMC’s MEMS prototyping
platform, now used by several Canadian laboratories.
Copyright © 2009 Stéphane Simard et al. This is an open access article distributed under the Creative Commons Attribution
License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly
cited.
Hardware Software
Matlab/Simulink libraries
library
modeling and drivers
component
FPGA prototype
to support analog interfacing, user logic on the Processor read multiplexer. This allows to decide which data is provided
Local Bus (PLB), and communication with application when a read request is sent to the user logic peripheral by
software under embedded Linux. XPS generates the corre- another peripheral in the system. While a greater number
sponding .bin file, which is then transferred to the Flash may be used, our pilot application, the vector control, only
configuration memory on the AP1000. The contents of this use four slave registers. The user logic peripheral has a
memory is used to reconfigure the FPGA. We have found specific base address (C BASEADDR), and the four 32-
an undocumented fact that, on the AP1000, this approach bit registers are accessed through C BASEADDR + register
is the only practicable way to program the FPGA. JTAG offset. In this example, C BASEADDR + 0x0 corresponds
programming is proved inconvenient, because it suppresses to the control and status register, which is composed of the
the embedded Linux, which is essential to us for PCI following bits:
initialization. Once programmed, user logic awaits a start
signal from our application software following analog I/O 0–7 : the DIP switches on the AP1000 for
card initialization. debugging purposes,
To accelerate the logic synthesis process, the mapper and 8 : used by user software to reset, start, or
place and route options are set to STD (standard) in the stop the controller,
implementation options file (etc/fast runtime.opt), found in 9–31 : reserved.
the Project Files menu. If the user wants a more aggressive
effort, these options should be changed to HIGH, which As for the other 3 registers, they correspond to
requires much more time. Our experiments have shown that
it typically amounts to several hours. C BASEADDR + 0x4: Output to analog
channel 1
4.1. Bus Interfacing. The busses implemented in FPGA logic C BASEADDR + 0x8: Output to analog
follow the IBM CoreConnect standard. It provides master channel 2
and slave operation modes for any instanciated hardware C BASEADDR + 0xC: Reserved (often used for
module. The most important system busses are the Processor debugging purposes)
Local Bus (PLB), and the On-chip Peripheral Bus (OPB).
The implementation of the vector control scheme 4.1.2. Master Model Control. The master model control
requires much less of generality, and deletes some commu- state machine is used to control the requests and responses
nication stages that might be used in other applications. It is between the user logic peripheral and the analog I/O card.
easier to start from such a generic design, dropping unneeded The latter is used to read the input currents and voltages
features, than to start from scratch. This way, one can quickly for vector control operation. The start signal previously
progress from SoC architecture in XPS down to a working mentioned in slave register 0 is what gets the state machine
controller on the AP1000. out of IDLE mode, and thus starts the data acquisition
process. In this specific example, the I/O card is previously
4.1.1. Slave Model Register Read Mux. The baseline XPS initialized by the embedded application software, relieving
design provides the developer with a slave model register the state machine of any initialization code. Analog I/O
EURASIP Journal on Embedded Systems 5
4.2. Creating or Importing User Cores. User-designed logic Table 1: The Two Intel StrataFlash Flash memory devices.
and other IPs can be created or imported into the XPS design
Bank Address Size Mode Description
following this procedure.
1 0x20000000 0x1000000 (16 MB) 16 Program Flash
(1) Select Create or Import Peripheral from the Hard- 2 0x24000000 0x1000000 (16 MB) 8 Config. Flash
ware menu, and follow the wizard (unless otherwise
stated below, the default options should be accepted).
Table 2: AP1000 flash configurations.
(2) Choose the preferred bus. In the case of our vector
controller, it is connected to the PLB. Region Bank Sectors Description
(3) For PLB interfacing, select the following IPIF ser- 0 2 0–39 Configuration 0
vices: 1 2 40–79 Configuration 1
2 2 80–127 Configuration 2 (Default Config.)
(a) burst and cacheline transaction support,
(b) master support,
(c) S/W register support. 4.4. BIN File Generation and FPGA Configuration. To config-
ure the FPGA, a BIN file must be generated from the XSG
(4) The User S/W Regitser data width should be 32. project. Since JTAG programming disables the embedded
Linux, the BIN file must be downloaded directly to onboard
(5) Accept the other wizard options as default, then click
Flash memory. There are two Intel Strataflash Flash memory
Finish.
devices on the AP1000, one for the configuration, and one
(6) You should find your newly created/imported core in for the U-boot bootstrap code (which should not be crushed)
the Project Repository of the IP Catalog; right click (Table 1).
on it, and select Add IP. The configuration memory (Table 2) is divided into three
(7) Finally go to the Assembly tab in the main System sections. Section 2 is the default Amirix configuration, and
Assembly View, and set the base address (e.g., should not be crushed. Downloading the BIN file to memory
0x2a001000), the memory size (e.g., 512), and the bus is done through a network cable using the TFTP protocol.
connection (e.g., plb bus). For this purpose, a TFTP server must be set up on the
host PC. The remote side of the protocol is managed by
U-boot on the AP1000. Commands to U-boot to initiate
4.3. Instantiating a Netlist Core. Using HDL generated by the transfer and to trigger FPGA reconfiguration from a
System Generator may be inconvenient for large control designated region are entered by the user through a serial link
systems described with the XSG blockset, as it can require terminal program. Here is the complete U-boot command
a couple of days of synthesis time. System Generator sequence:
can be asked to produce a corresponding NGC binary
netlist file instead, which is then treated as a black box setenv serverip 132.212.202.166
to be imported and integrated into an XPS project. This setenv ipaddr 132.212.201.223
considerably reduces the synthesis time needed. The process erase 2 : 0–39
of instantiating a Netlist Core in a custom peripheral (e.g., Send tftp 00100000 download.bin
user logic.vhd), performed following the steps documented Send cp.b 00100000 24000000 00500000
in XPS user guide. Send swrecon
6 EURASIP Journal on Embedded Systems
DEFINES = −D— KERNEL— −DMODULE\\ This is described by equations in the synchronously rotating
−DEXPORT SYMTAB reference frame (d, q) as
INCLUDES= −I$(KERNELDIR)/include\\
−I$(KERNELDIR)/include/Linux\\ d M d
−I$(KERNELDIR)/include/asm usd = Rs isd + σLs isd −σLs ωisq + Ψr ,
dt Lr dt
FLAGS =−fno-strict-aliasing \\
Dd
−fno-common\\
−fomit-frame-pointer\\ d M
−fsigned-char
usq = Rs isq + σLs isq +σLs ωisd + ωΨr ,
dt Lr
CFLAGS = $(DEFINES) $(WARNINGS)\\ Dq
$(INCLUDES) $(SWITCHES)\\ (1)
$(FLAGS) d R
all: $(TARGET).o Makefile Ψr = r (Misd − Ψr ),
dt Lr
VDC
sp ah
ωr∗ + Speed PI i∗
sq + Q-current vsq sp al
+ + usq ∗ 3-φ
− controller −
PI controller Inverse usα SVPWM sp bh
voltage
Decoupling usd transform u∗ module sp bl
Ψ∗
r + Rotor flux i∗sd + D-current vsd park
sβ
gating sp ch
PWM
+ + inverter
− PI controller − PI controller sp cl
i sd isα i sa
Park Clarke
i sq transform isβ transform i sb
cos θ Rotor
sin θ usα Clarke usa
flux
Ψr estimator usβ transform usb
ω
ω estimator IM
ωr
Speed measure
Gating
fu ua
fv ub
In
prediction_uab vqs_in1
In
vds_in1
y
spd_ref In Wref
vqs_in
x Speed_Ref
uA flux_ref In
vds_in
isa phiref
Rotor_Flux_Ref
uB
usa
usb Discrete,
Ts = 2.5e- 006 s
Figure 8: Indcution motor RFOC drive, as modelled with XSG and SPS blocksets.
Table 3: Simulation times and methods being fully designed, analysed (timing wise), and debugged
Type of simulation Simulation time
through the aforementioned FPGA-in-the-loop simulation
platform, the corresponding NGC binary netlist file or
Free-running cosimulation 1734 s
VHDL/Verilog code are automatically generated. These
Single-step cosimulation 174610 s (48 hours) could then be integrated within the SoC architecture using
Xilinx Platform Studio (XPS) and targetting the AP1000
platform. Next section describes the related steps.
run at 100 MHz (10 nanoseconds step time). As long as the
design is running inside Simulink, there are never any issues
with meeting timing requirements for the XSG model. Once 6.6. Experimental Setup. Figure 7 shows the experimental
completed, the design will be synthesized, and simulated on setup with power electronics, induction motor, and loads.
FPGA. If the user launches the cosimulation block generation The power supply is taken from a 220 V outlet. The high
process, the timing errors will be mentioned quite far into voltage power module, from Microchip, is connected to the
the operation. This means that, after waiting for a relatively analog I/O card through the rainbow flex cable, and to
long delay (sometimes 20–30 minutes depending on the the expansion digital I/Os of the AP1000 through another
complexity of a design and the speed of the host computer), parallel cable. Signals from a 1000-line optical speed encoder
the user notices the failure to meet timing requirements with are among the digital signals fed to the FPGA. As for the
no extra information to quickly identify the problem. This loads, there is both a manually-controlled resistive load box,
is why the timing analysis tool must always be run prior to and a dynamo coupled to the motor shaft.
cosimulation. While it might seem a bit time-consuming, From the three motor phases, three currents and three
this tool will not simply tell you that your design does not voltages (all prefiltered and prescaled) are fed to the analog
meet requirements, but it will give you the insight required I/O board to be sampled. Samples are stored in an internal
to fix the timing problems. The control algorithm once input buffer until fetched by the controller on FPGA. Data
EURASIP Journal on Embedded Systems 11
exchange between the FPGA and the I/O board proceeds suitable for the design of on-chip motion controllers and
through the PLB and the Dual Processor PCI Bus Bridge to other SoCs with a need for analog interfacing. It supports
and from the PMC site. embedded application software coupled with custom FPGA
The process of generating SVPWM signals continuously logic and analog interfacing, and is very well suited to FPGA-
runs in parallel with controller logic, but the speed at which in-the-loop control and SoC controller prototyping. Such
these signals are generated is greater than the speed required platform is suitable for academia and research communauty
for the vector control processing. As a consequence, these that cannot afford the expensive commercial solutions for
two processes are designed and tested separately before being FPGA-in-the-loop simulation [12, 13].
assembled and tested together. A convenient FPGA design, simulation, and test proce-
Power gating and motor speed decoding are continuous dure, suitable for advanced feedback controllers, has been
processes that have critical clocking constraints beyond the outlined. It uses the Xilinx System Generator blockset in
capabilities of bus operation to and from the I/O board. Matlab/Simulink and a simulated motor drive described with
Therefore, even though the PMC66-16AISS8A04 board also the SPS blockset. SoC integration of the resulting controller is
provides digital I/O, both the PWM gating signals and the done in Xilinx Platform Studio. Our custom SoC design has
input pulses from the optical speed encoder are directly been described, with highlights on the state machine for bus
passed through FPGA pins to be processed by dedicated interfacing, NGC file integration, BIN file generation, and
hardware logic. This is done by plugging a custom-made FPGA configuration.
adapter card with Samtec CON 0.8 mm connectors into the Application software and drivers development for
expansion site on the AP1000. While the vector control uses embedded Linux are often needed to provide for PCI and
data acquired from the AIO card through a state machine, analog I/O card initialization, interfacing, and monitoring.
the PWM signals are constantly fed to the power module We have provided here some pointers along with essential
(Figure 6). Those signals are sent directly through the general information not easily found elsewhere. The proposed design
purpose digital outputs on the AP1000 itself instead of going flow and prototyping platform have been applied to the
through the AIO card. This ensures complete control over analysis, design, and hardware implementation of a vector
the speed at which these signals are generated and sent controller for three-phase AC induction motors, with very
while targeting a specific operating frequency (16 kHz in good performance results. The resulting computation times,
our example). This way, the speed calculations required for of about 1.5 μs, can in fact be considered record-breaking for
the vector control algorithm are done using precise clocking such a controller.
without adding to the burden of the state machine which
dictates the communications between FPGA and the AIO
card. The number of transitions found on the signal lines Acknowledgments
between the FPGA and speed encoder are used to evaluate
the speed at which the motor is operating. This research is funded by a Grant from the National
Sciences and Engineering Research Council of Canada
6.7. Timing Issues. Completion of one loop cycle of our vec- (NSERC). CMC Microsystems provided development tools
tor control design, takes 122 steps leading to a computation and support through the System-on-Chip Research Network
time of less than 1.5 μs. To be noticed that for a sampling rate (SOCRN) program.
of 32 kHz, the SVPWM signal has 100 divisions (two zones
divided by 50), which has been chosen as a good compromise
between precision and simulation time. The simulation References
fixed-step size is then 625 nanoseconds, which is already [1] “Accelerating Canadian competitiveness through microsys-
small enough to hinder the performance of simulating the tems: strategic plan 2005–2010,” Tech. Rep., CMC Microsys-
SPS model. Since PWM signal generation is divided into tems, Kingston, Canada, 2004.
two zones, for every 50 steps of Simulink operations (PWM [2] J. J. Rodriguez-Andina, M. J. Moure, and M. D. Valdes,
signal generation and SPS model simulation), the 122 vector “Features, design tools, and application domains of FPGAs,”
control steps must complete. The period of the XSG— IEEE Transactions on Industrial Electronics, vol. 54, no. 4, pp.
Simulink system must be adjusted in order for the XSG 1810–1823, 2007.
model to run 2.44 times faster than the other Simulink [3] R. Dubey, P. Agarwal, and M. K. Vasantha, “Programmable
components. The simulation fixed-step size becomes 2.56 logic devices for motion control—a review,” IEEE Transactions
nanoseconds, thus prolonging simulation time. In other on Industrial Electronics, vol. 54, no. 1, pp. 559–566, 2007.
words, since the SPS model and PWM signals generation take [4] E. Monmasson and M. N. Cirstea, “FPGA design methodology
little time (in terms of steps) to complete whereas the vector for industrial control systems—a review,” IEEE Transactions on
control scheme requires numerous steps, the coupling of the Industrial Electronics, vol. 54, no. 4, pp. 1824–1842, 2007.
two forces the use of a very small simulation fixedstep size. [5] D. Zhang, A stochastic approach to digital control design and
implementation in power electronics, Ph.D. thesis, Florida State
University College of Engineering, Tallahassee, Fla, USA, 2006.
7. Conclusion [6] Y.-Y. Tzou and H.-J. Hsu, “FPGA realization of space-vector
PWM control IC for three-phase PWM inverters,” IEEE
In this paper, we have discussed our choice, adaptation, Transactions on Power Electronics, vol. 12, no. 6, pp. 953–963,
and use of a rapid prototyping platform and design flow 1997.
12 EURASIP Journal on Embedded Systems
Preliminaryȱcallȱforȱpapers OrganizingȱCommittee
HonoraryȱChair
The 2011 European Signal Processing Conference (EUSIPCOȬ2011) is the MiguelȱA.ȱLagunasȱ(CTTC)
nineteenth in a series of conferences promoted by the European Association for GeneralȱChair
Signal Processing (EURASIP, www.eurasip.org). This year edition will take place AnaȱI.ȱPérezȬNeiraȱ(UPC)
in Barcelona, capital city of Catalonia (Spain), and will be jointly organized by the GeneralȱViceȬChair
Centre Tecnològic de Telecomunicacions de Catalunya (CTTC) and the CarlesȱAntónȬHaroȱ(CTTC)
Universitat Politècnica de Catalunya (UPC). TechnicalȱProgramȱChair
XavierȱMestreȱ(CTTC)
EUSIPCOȬ2011 will focus on key aspects of signal processing theory and
TechnicalȱProgramȱCo
Technical Program CoȬChairs
Chairs
applications
li ti as listed
li t d below.
b l A
Acceptance
t off submissions
b i i will
ill be
b based
b d on quality,
lit JavierȱHernandoȱ(UPC)
relevance and originality. Accepted papers will be published in the EUSIPCO MontserratȱPardàsȱ(UPC)
proceedings and presented during the conference. Paper submissions, proposals PlenaryȱTalks
for tutorials and proposals for special sessions are invited in, but not limited to, FerranȱMarquésȱ(UPC)
the following areas of interest. YoninaȱEldarȱ(Technion)
SpecialȱSessions
IgnacioȱSantamaríaȱ(Unversidadȱ
Areas of Interest deȱCantabria)
MatsȱBengtssonȱ(KTH)
• Audio and electroȬacoustics.
• Design, implementation, and applications of signal processing systems. Finances
MontserratȱNájarȱ(UPC)
Montserrat Nájar (UPC)
• Multimedia
l d signall processing andd coding.
d
Tutorials
• Image and multidimensional signal processing. DanielȱP.ȱPalomarȱ
• Signal detection and estimation. (HongȱKongȱUST)
• Sensor array and multiȬchannel signal processing. BeatriceȱPesquetȬPopescuȱ(ENST)
• Sensor fusion in networked systems. Publicityȱ
• Signal processing for communications. StephanȱPfletschingerȱ(CTTC)
MònicaȱNavarroȱ(CTTC)
• Medical imaging and image analysis.
Publications
• NonȬstationary, nonȬlinear and nonȬGaussian signal processing. AntonioȱPascualȱ(UPC)
CarlesȱFernándezȱ(CTTC)
Submissions IIndustrialȱLiaisonȱ&ȱExhibits
d i l Li i & E hibi
AngelikiȱAlexiouȱȱ
Procedures to submit a paper and proposals for special sessions and tutorials will (UniversityȱofȱPiraeus)
be detailed at www.eusipco2011.org. Submitted papers must be cameraȬready, no AlbertȱSitjàȱ(CTTC)
more than 5 pages long, and conforming to the standard specified on the InternationalȱLiaison
EUSIPCO 2011 web site. First authors who are registered students can participate JuȱLiuȱ(ShandongȱUniversityȬChina)
in the best student paper competition. JinhongȱYuanȱ(UNSWȬAustralia)
TamasȱSziranyiȱ(SZTAKIȱȬHungary)
RichȱSternȱ(CMUȬUSA)
ImportantȱDeadlines: RicardoȱL.ȱdeȱQueirozȱȱ(UNBȬBrazil)
P
Proposalsȱforȱspecialȱsessionsȱ
l f i l i 15 D 2010
15ȱDecȱ2010
Proposalsȱforȱtutorials 18ȱFeb 2011
Electronicȱsubmissionȱofȱfullȱpapers 21ȱFeb 2011
Notificationȱofȱacceptance 23ȱMay 2011
SubmissionȱofȱcameraȬreadyȱpapers 6ȱJun 2011
Webpage:ȱwww.eusipco2011.org