**Meet the editor**

Dr S. C. Chakravarty did his Ph.D degree in space physics from the Physical Research Laboratory (PRL) , Ahmedabad, India and joined the Indian Space Research Organisation (ISRO) at Bangalore during 1973. He assumed various responsibilities to plan, organise and implement the coordinated atmospheric and space science research programmes sponsored by ISRO. As the Programme Di-

rector of Space Science research activities, Dr Chakravarty was involved in the planning and coordination of work related to India's first moon mission, Chandrayaan-1. He also coordinated large number of scientific research programmes involving scientific balloon and sounding rocket experiments, space science satellite missions including Astrosat, SROSS-C, and Megha-Tropiques. Dr Chakravarty also helped to enable Indian participation in internationally coordinated programmes like MAP, INDOEX, CAWSES etc. Presently his research activities include development of physics based and real time models on monsoon dynamics, the total electron content (TEC) of the ionosphere and aspects of mesospheric phenomena.

Contents

**Preface IX** 

Chapter 1 **Analysis of Power Electronic** 

Chapter 2 **Study of Inductive-Capacitive** 

Chapter 3 **Fixed Transmission Media 41**  Rastislav Róka

Chapter 4 **Co-Simulation Procedure for** 

Chapter 5 **S-Function Library for** 

B. Umesh Rai

Chapter 6 **From Control Design to** 

Marcus Müller,

Titu Niculescu

Juan Segundo-Ramirez and A. Medina

**PID and Fuzzy Logic Active Controls** 

**Bond Graph Modeling 97** 

**FPGA Implementation 129** 

Chapter 7 **Describing Function Recording with Simulink and MATLAB 149** 

Chapter 8 **Performance Evaluation of a Temperature** 

**Controllers in Electric Power Systems Using Simulink 1** 

**Series Circuits Using the Simulink Software Package 19** 

**Strategies Applied to a Sprayers Boom Suspension 69**  Cristiano Okada Pontelli and Mario Francisco Mucheroni

Hans-Christian Schwannecke and Wolfgang Fengler

Krunoslav Horvat, Ognjen Kuljaca and Tomislav Sijak

**Sensor 3D Electro-Thermal Model Through Simulink® 167** 

**Control Stage Used on a Semiconductor Gas** 

E.N. Vázquez-Acosta, S. Mendoza-Acevedo, M.A. Reyes-Barranca, L.M. Flores-Nava, J.A. Moreno-Cadenas and J.L. González-Vidal

## Contents

## **Preface XI**


M.A. Reyes-Barranca, L.M. Flores-Nava,

J.A. Moreno-Cadenas and J.L. González-Vidal

X Contents



## Preface

Building on MATLAB (the language of technical computing), Simulink provides a platform for engineers to plan, model, design, simulate, test and implement complex electromechanical, dynamic control, signal processing and communication systems. Simulink-Matlab combination is very useful for developing algorithms, GUI assisted creation of block diagrams and realisation of interactive simulation based designs. The eleven chapters of the book demonstrate the power and capabilities of Simulink to solve engineering problems with varied degree of complexity in the virtual environment. The first four chapters provide details of design, analysis, simulation and implementation of flexible AC transmission system devices to control the power variables, multi-component electric circuits, signal transmission through power distribution lines of different kinds and PID/fuzzy logic control of a boom suspension. Details of enhanced capabilities in simulation effects constitute the subject matter of the next three chapters on S-functions for custom made subroutines and bond graph models, development of model and HDL code on FPGA system and harmonic linearization method of non-linear characteristics of modulation techniques. The last four chapters deal with examples of electromagnetic and dynamic systems of thermoelectrical micro hot plate with temperature control circuit, braked railed vehicle wheel slide protection, replacement in a car battery by a hybrid supply of battery and super capacitors and a novel speed control logic for electric vehicle. I hope that both newcomers and professionals in the field would benefit by going through the details given in the above chapters of the book.

**S.C. Chakravarty** 

Scientist (retired), Indian Space Research Organisation (ISRO), Bangalore or Hon Senior Professor, Indian Centre for Space Physics (ICSP), Kolkata, India

**1** 

*México* 

**Analysis of Power Electronic Controllers in** 

Flexible ac Transmission Systems (FACTS) devices have emerged in power system because of the development of power electronics components for high voltage and power. The FACTS devices provide higher controllability in power systems by means of power electronic devices. Several FACTS equipments have been already introduced for various applications worldwide, and new types of FACTS are in the stage of being introduced in practice. FACTS technology provides a better ability to varying operational conditions and

It can be seen that with growing line length and with higher power demand the opportunity for FACTS devices gets more important. The devices work electrically as fast current, voltage or impedance controllers. The power electronic allows very short reaction times down to far below one second (~ms). Detailed introductions in FACTS devices can also be found in the literature (Hingorani & Gyudyi, 2000) (Acha, et al. 2004) (Mathur & Varma, 2002)(Padiyar, 2007) (Zhang, Rehtanz, & Pal, 2006) with the main focus on new topologies,

Basically, there are two groups of FACTS, one is based on thyristor valve operation (Hingorani & Gyudyi, 2000), and the other is based on Voltage Source Converters (VSCs) (Segundo-Ramírez & Medina, 2008) (Segundo-Ramírez & Medina, 2009). A list of some FACTS devices are shown in Table 1. The FACTS devices based on VSCs provide a controllable voltage magnitude and phase angle due to a Pulse Width Modulation (PWM) technique (Mohan, Underland, & Robins, 1995). The Static Compensator (STATCOM) (Hingorani & Gyudyi, 2000) is a shunt connected device that is able to provide reactive power support at a network location far away from the generators. Through this reactive power injection, the STATCOM can regulate the voltage at the connection node. The Static Synchronous Series compensator (SSSC) (Hingorani & Gyudyi, 2000) is a series device which injects a voltage in series with the transmission line. The Unified Power Flow Controller (UPFC) (Hingorani & Gyudyi, 2000) is the most versatile device of the family of FACTS devices, since it is able to control the active and the reactive power, respectively, as

**1. Introduction** 

modeling and control.

improves the usage of existing installations.

**2. Power electronic application in transmission systems** 

**Electric Power Systems Using Simulink** 

Juan Segundo-Ramirez1 and A. Medina2 *1Universidad Autónoma de San Luis Potosí* 

*2Universidad Michoacana de San Nicolás de Hidalgo* 

## **Analysis of Power Electronic Controllers in Electric Power Systems Using Simulink**

Juan Segundo-Ramirez1 and A. Medina2

*1Universidad Autónoma de San Luis Potosí 2Universidad Michoacana de San Nicolás de Hidalgo México* 

## **1. Introduction**

Flexible ac Transmission Systems (FACTS) devices have emerged in power system because of the development of power electronics components for high voltage and power. The FACTS devices provide higher controllability in power systems by means of power electronic devices. Several FACTS equipments have been already introduced for various applications worldwide, and new types of FACTS are in the stage of being introduced in practice. FACTS technology provides a better ability to varying operational conditions and improves the usage of existing installations.

## **2. Power electronic application in transmission systems**

It can be seen that with growing line length and with higher power demand the opportunity for FACTS devices gets more important. The devices work electrically as fast current, voltage or impedance controllers. The power electronic allows very short reaction times down to far below one second (~ms). Detailed introductions in FACTS devices can also be found in the literature (Hingorani & Gyudyi, 2000) (Acha, et al. 2004) (Mathur & Varma, 2002)(Padiyar, 2007) (Zhang, Rehtanz, & Pal, 2006) with the main focus on new topologies, modeling and control.

Basically, there are two groups of FACTS, one is based on thyristor valve operation (Hingorani & Gyudyi, 2000), and the other is based on Voltage Source Converters (VSCs) (Segundo-Ramírez & Medina, 2008) (Segundo-Ramírez & Medina, 2009). A list of some FACTS devices are shown in Table 1. The FACTS devices based on VSCs provide a controllable voltage magnitude and phase angle due to a Pulse Width Modulation (PWM) technique (Mohan, Underland, & Robins, 1995). The Static Compensator (STATCOM) (Hingorani & Gyudyi, 2000) is a shunt connected device that is able to provide reactive power support at a network location far away from the generators. Through this reactive power injection, the STATCOM can regulate the voltage at the connection node. The Static Synchronous Series compensator (SSSC) (Hingorani & Gyudyi, 2000) is a series device which injects a voltage in series with the transmission line. The Unified Power Flow Controller (UPFC) (Hingorani & Gyudyi, 2000) is the most versatile device of the family of FACTS devices, since it is able to control the active and the reactive power, respectively, as

Analysis of Power Electronic Controllers in Electric Power Systems Using Simulink 3

The SSSC is a series device in which a synchronous voltage source injects a fundamental frequency voltage in series with the transmission line through a coupling transformer. The synchronous voltage source is supplied by a VSC. A schematic representation of the SSSC is

Ideally, the injected voltage is in quadrature with the line current. In this mode the VSC does not absorb or inject any real power. However, in practice, the VSC losses must be replenished by the ac system, in consequence a small phase lag is introduced for this purpose. The operating characteristics make this device very attractive for power transmission application. The main limitation of application is due to the losses and cost of the converter. The SSSC is a device which has so far not been built at transmission level because Series Compensator (fixed capacitor) and thyristor controlled series capacitor (TCSC) (Hingorani & Gyudyi, 2000) are fulfilling all the today's operational requirements at

This device contains two VSCs connected together through a dc link storage capacitor. One of the VSCs is connected in series with the transmission line, while the other VSC is connected in shunt with the transmission line. The UPFC can control the active and reactive power flow in the transmission line, and at the same time can regulate the voltage magnitude at the connection node. To control the real and reactive power flow in the series side, the UPFC allows interchange of real power between the shunt and the series converters. The main disadvantage of this device is the high cost level due to the complex systems setup (Zhang, Rehtanz, & Pal, 2006). A schematic representation of the UPFC is

Power System Blockset (PSB) for use with Matlab/Simulink employs state-variable analysis. In PSB complex control algorithms can be implemented into the models in an easy and fast way. Besides, PSB can use several Matlab toolboxes. In particular, it has the PWM generator and the VSC blocks. The main advantage of the PSB is that it is developed in Matlab/Simulink environment, this fact makes possible to use it together with several other control design tools. It is possible to use the Simulink Accelerator and the Real-Time Workshop to improve the PSB performance; a C code is generated. Additionally, the PSB can use several integration methods, which make it a powerful

This section is divided into three parts. Simulations relating to the STATCOM are presented first. This is followed by simulations carried out for the SSSC and then for the UPFC. The study case related to the STATCOM is described in detail using PSB/Simulink. For the cases

**2.2 Static synchronous series compensator (SSSC)** 

**2.3 Unified power flow controller (UPFC)** 

**3.1 Modeling and analysis of FACTS by PSB/SIMULINK** 

of the SSSC and the UPFC, only the general implementation is described.

shown in Figure 1(b).

a low cost.

shown in Figure 1(c).

**3. PSB/SIMULINK** 

simulation tool.

well as the voltage at the connection node. In Figure 1 a schematic representation of the STATCOM, the SSSC, and the UPFC are presented. The compensating FACTS devices under analysis in this chapter are briefly described below.


Table 1. Overview of the principal FACTS-Devices.

Fig. 1. FACTS devices based on VSCs. (a) STATCOM, (b) SSSC, and (c) UPFC.

## **2.1 Static compensator (STATCOM)**

It is a shunt device that does not require passive elements for reactive compensation. The STATCOM operation is based on a VSC, which is supplied by a dc storage capacitor. The VSC terminals are connected to the dc system through a coupling transformer. The VSC produces a quasi-sine wave voltage at the fundamental frequency (50 or 60 Hz). The STATCOM can generate or absorb reactive power. A schematic representation of the STATCOM is shown in Figure 1(a).

Assuming that the losses in the VSC and the coupling transformer are negligible, *vstatcom* is in phase with the voltage at the terminal bus *vk*. In this situation, the current *istatcom* is completely reactive. If the magnitude of the voltage *vk* is higher than the magnitude of *vstatcom*, the reactive current flows from the bus to the VSC, which means that the STATCOM absorbs reactive power. On the other hand, if the magnitude of *vstatcom* is higher than the magnitude of *vk*, the reactive current flows from the VSC to the ac system. Then, the STATCOM injects reactive power to the system. In practice, the power losses of the STATCOM are not negligible and must be drawn from the ac system to maintain constant the dc capacitor voltage.

## **2.2 Static synchronous series compensator (SSSC)**

The SSSC is a series device in which a synchronous voltage source injects a fundamental frequency voltage in series with the transmission line through a coupling transformer. The synchronous voltage source is supplied by a VSC. A schematic representation of the SSSC is shown in Figure 1(b).

Ideally, the injected voltage is in quadrature with the line current. In this mode the VSC does not absorb or inject any real power. However, in practice, the VSC losses must be replenished by the ac system, in consequence a small phase lag is introduced for this purpose. The operating characteristics make this device very attractive for power transmission application. The main limitation of application is due to the losses and cost of the converter. The SSSC is a device which has so far not been built at transmission level because Series Compensator (fixed capacitor) and thyristor controlled series capacitor (TCSC) (Hingorani & Gyudyi, 2000) are fulfilling all the today's operational requirements at a low cost.

## **2.3 Unified power flow controller (UPFC)**

This device contains two VSCs connected together through a dc link storage capacitor. One of the VSCs is connected in series with the transmission line, while the other VSC is connected in shunt with the transmission line. The UPFC can control the active and reactive power flow in the transmission line, and at the same time can regulate the voltage magnitude at the connection node. To control the real and reactive power flow in the series side, the UPFC allows interchange of real power between the shunt and the series converters. The main disadvantage of this device is the high cost level due to the complex systems setup (Zhang, Rehtanz, & Pal, 2006). A schematic representation of the UPFC is shown in Figure 1(c).

## **3. PSB/SIMULINK**

2 Technology and Engineering Applications of Simulink

well as the voltage at the connection node. In Figure 1 a schematic representation of the STATCOM, the SSSC, and the UPFC are presented. The compensating FACTS devices under

Shunt Connected Static Var Compensator (SVC) Static Compensator (STATCOM)

Compensator (TCSC)

FACTS Devices Thyristor-Based FACTS VSC-Based FACTS

> Static Series Synchronous Compensator (SSSC)

Unified Power Flow Controller (UPFC) HVDC VSC

analysis in this chapter are briefly described below.

Series Connected Thyristor Controlled Series

Connection Type

Table 1. Overview of the principal FACTS-Devices.

Back-to-Back Connected HVDC

**2.1 Static compensator (STATCOM)** 

STATCOM is shown in Figure 1(a).

Fig. 1. FACTS devices based on VSCs. (a) STATCOM, (b) SSSC, and (c) UPFC.

must be drawn from the ac system to maintain constant the dc capacitor voltage.

It is a shunt device that does not require passive elements for reactive compensation. The STATCOM operation is based on a VSC, which is supplied by a dc storage capacitor. The VSC terminals are connected to the dc system through a coupling transformer. The VSC produces a quasi-sine wave voltage at the fundamental frequency (50 or 60 Hz). The STATCOM can generate or absorb reactive power. A schematic representation of the

Assuming that the losses in the VSC and the coupling transformer are negligible, *vstatcom* is in phase with the voltage at the terminal bus *vk*. In this situation, the current *istatcom* is completely reactive. If the magnitude of the voltage *vk* is higher than the magnitude of *vstatcom*, the reactive current flows from the bus to the VSC, which means that the STATCOM absorbs reactive power. On the other hand, if the magnitude of *vstatcom* is higher than the magnitude of *vk*, the reactive current flows from the VSC to the ac system. Then, the STATCOM injects reactive power to the system. In practice, the power losses of the STATCOM are not negligible and Power System Blockset (PSB) for use with Matlab/Simulink employs state-variable analysis. In PSB complex control algorithms can be implemented into the models in an easy and fast way. Besides, PSB can use several Matlab toolboxes. In particular, it has the PWM generator and the VSC blocks. The main advantage of the PSB is that it is developed in Matlab/Simulink environment, this fact makes possible to use it together with several other control design tools. It is possible to use the Simulink Accelerator and the Real-Time Workshop to improve the PSB performance; a C code is generated. Additionally, the PSB can use several integration methods, which make it a powerful simulation tool.

## **3.1 Modeling and analysis of FACTS by PSB/SIMULINK**

This section is divided into three parts. Simulations relating to the STATCOM are presented first. This is followed by simulations carried out for the SSSC and then for the UPFC. The study case related to the STATCOM is described in detail using PSB/Simulink. For the cases of the SSSC and the UPFC, only the general implementation is described.

Analysis of Power Electronic Controllers in Electric Power Systems Using Simulink 5

peak line-to-neutral voltage at the bus 1 is shown in Figure 5(d). Figure 6 shows the steady state waveform of the voltage at the bus 1 at the top of the figure, and its harmonic spectrum at the bottom of the figure. The Figure 6 was obtained using the FFT Analysis button in the

In the Figure 7, some selected transient waveforms of the STATCOM with the passive filter are shown: Figure 7(a) presents the output of the phase controller; Figure 7(b) presents the output of the magnitude control; Figure 7(c) shows the voltage across the dc capacitor, and finally, the peak line-to-neutral voltage at the bus 1 is shown in Figure 7(d). Figure 8 shows the steady state waveform of the voltage at the bus 1 at the top of the figure, and its

(a) Control System (b) Bandpass Filter

(c) Vabc to Peak Value

Fig. 3. STATCOM PI control system. (a) Main control system. (b) Bandpass filter. (c)

Extraction of the peak value of a three-phase voltage in abc-reference.

powergui block.

harmonic spectrum at the bottom of the figure.

### **3.2 Static compensator (STATCOM)**

The test case is shown in Figure 2, where the STATCOM includes the control system described in (Mahyavanshi & Radman, 2006). The initial conditions are zero, the reference line to line voltage is 179.6292 volts at node 1, the reference voltage for the dc capacitor is 500 volts, and the modulation index is *mf =*15 (900 Hz). The shunt transformer, the line 1 and the line 2 are represented by *RL* branches, whose impedances areͲǤͲͷ ݆߱ ൈ ͲǤͲͲͷȳ, ͲǤʹ ݆߱ ൈ ͲǤͲͳͷȳ, and ͲǤͳͷ ݆߱ ൈ ͲǤͲͳȳ, respectively. The Figure 3 shows the PI control used in this analysis. On the other hand, Figure 4 shows some important blocks parameters of the system. Figure 4 shows some important block of parameters for some components shown in Figure 2 and Figure 3. Please notice that a passive filter has been connected at bus 1, in order to drain the harmonic currents.

Fig. 2. Test system including the STATCOM.

The test case is initially in periodic steady state, at ݐ ൌ ͲǤͲͷݏ, the voltage magnitude of the three-phase programmable voltage source is increased 15%, and finally at ݐ ൌ ͲǤ͵ͷݏ, the initial operating point is reestablished. The study for the STATCOM is divided in two parts, firstly the three-phase breaker is open, and consequently the passive filter is disconnected. In the second part, the three-phase breaker is closed allowing the filtering function. The passive filter is represented as a RC branch with ܥ ൌ ͺͲܨߤ and ܴ ൌ ͲǤͷȳ.

In the Figure 5, some selected transient waveforms of the STATCOM without the passive filter are shown: Figure 5(a) presents the output of the phase controller, alfaE, which is actually the phase angle of the voltage at the ac terminals of the VSC; Figure 5(b) presents the output of the magnitude control, which is the half part of the voltage magnitude at the ac terminal of the VSC; Figure 5(c) shows the voltage across the dc capacitor, and finally, the

The test case is shown in Figure 2, where the STATCOM includes the control system described in (Mahyavanshi & Radman, 2006). The initial conditions are zero, the reference line to line voltage is 179.6292 volts at node 1, the reference voltage for the dc capacitor is 500 volts, and the modulation index is *mf =*15 (900 Hz). The shunt transformer, the line 1 and the line 2 are represented by *RL* branches, whose impedances areͲǤͲͷ ݆߱ ൈ ͲǤͲͲͷȳ, ͲǤʹ ݆߱ ൈ ͲǤͲͳͷȳ, and ͲǤͳͷ ݆߱ ൈ ͲǤͲͳȳ, respectively. The Figure 3 shows the PI control used in this analysis. On the other hand, Figure 4 shows some important blocks parameters of the system. Figure 4 shows some important block of parameters for some components shown in Figure 2 and Figure 3. Please notice that a passive filter has been connected at bus

The test case is initially in periodic steady state, at ݐ ൌ ͲǤͲͷݏ, the voltage magnitude of the three-phase programmable voltage source is increased 15%, and finally at ݐ ൌ ͲǤ͵ͷݏ, the initial operating point is reestablished. The study for the STATCOM is divided in two parts, firstly the three-phase breaker is open, and consequently the passive filter is disconnected. In the second part, the three-phase breaker is closed allowing the filtering function. The

In the Figure 5, some selected transient waveforms of the STATCOM without the passive filter are shown: Figure 5(a) presents the output of the phase controller, alfaE, which is actually the phase angle of the voltage at the ac terminals of the VSC; Figure 5(b) presents the output of the magnitude control, which is the half part of the voltage magnitude at the ac terminal of the VSC; Figure 5(c) shows the voltage across the dc capacitor, and finally, the

passive filter is represented as a RC branch with ܥ ൌ ͺͲܨߤ and ܴ ൌ ͲǤͷȳ.

**3.2 Static compensator (STATCOM)** 

1, in order to drain the harmonic currents.

Fig. 2. Test system including the STATCOM.

peak line-to-neutral voltage at the bus 1 is shown in Figure 5(d). Figure 6 shows the steady state waveform of the voltage at the bus 1 at the top of the figure, and its harmonic spectrum at the bottom of the figure. The Figure 6 was obtained using the FFT Analysis button in the powergui block.

In the Figure 7, some selected transient waveforms of the STATCOM with the passive filter are shown: Figure 7(a) presents the output of the phase controller; Figure 7(b) presents the output of the magnitude control; Figure 7(c) shows the voltage across the dc capacitor, and finally, the peak line-to-neutral voltage at the bus 1 is shown in Figure 7(d). Figure 8 shows the steady state waveform of the voltage at the bus 1 at the top of the figure, and its harmonic spectrum at the bottom of the figure.

Fig. 3. STATCOM PI control system. (a) Main control system. (b) Bandpass filter. (c) Extraction of the peak value of a three-phase voltage in abc-reference.

Analysis of Power Electronic Controllers in Electric Power Systems Using Simulink 7

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7

Time (s)

Fig. 5. Selected transient waveforms of the STATCOM without passive filter. (a) Phase angle of the voltage at the ac terminals of the VSC. (b) Amplitude modulation ratio. (c) Voltage

From Figure 5 and Figure 7 it is easy to notice that the passive filter has a positive impact on the reduction of the harmonic distortion in the power network without affecting the performance of the controller. In Figure 6, the waveform of the voltage at bus 1 is severely distorted with a total harmonic distortion (THD) of 39.88%. In this case, some harmonic components have a magnitude of almost 20% of the fundamental component, which is an undesirable operating condition in practical applications. On the other hand, the obtained voltage at bus 1 when the passive filter is on has a THD of 4.23% and the highest magnitude of the harmonic components is around 3.5% of the fundamental component, as shown in

In this simulation analysis, a discrete representation of the system given in Figure 2 was

used in order to carry-out the simulations, an integration step of ͳݏߤ was selected.

across the dc capacitor. (d) Peak line-to-neutral voltage at the bus 1.

Figure 8.


> 0.6 0.7 0.8

480 500 520

170

180

190

(a) alfaE

(b) mE

(c) Vdc (Volts)

(d) V1 (Volts)

peak L-n


Fig. 4. Blocks parameters of important components.

Fig. 4. Blocks parameters of important components.

Fig. 5. Selected transient waveforms of the STATCOM without passive filter. (a) Phase angle of the voltage at the ac terminals of the VSC. (b) Amplitude modulation ratio. (c) Voltage across the dc capacitor. (d) Peak line-to-neutral voltage at the bus 1.

From Figure 5 and Figure 7 it is easy to notice that the passive filter has a positive impact on the reduction of the harmonic distortion in the power network without affecting the performance of the controller. In Figure 6, the waveform of the voltage at bus 1 is severely distorted with a total harmonic distortion (THD) of 39.88%. In this case, some harmonic components have a magnitude of almost 20% of the fundamental component, which is an undesirable operating condition in practical applications. On the other hand, the obtained voltage at bus 1 when the passive filter is on has a THD of 4.23% and the highest magnitude of the harmonic components is around 3.5% of the fundamental component, as shown in Figure 8.

In this simulation analysis, a discrete representation of the system given in Figure 2 was used in order to carry-out the simulations, an integration step of ͳݏߤ was selected.

Analysis of Power Electronic Controllers in Electric Power Systems Using Simulink 9

Fig. 8. Steady state waveform of the voltage at the bus 1 with passive filter (top), and its

The test system for the analysis of the SSSC is shown in Figure 9. The network parameters are the same of those of Figure 2. The series transformers are represented b an ideal model. The series active power reference Pref in the line 2 is equal to 5500 W; the dc voltage capacitor reference is equal to 500 V; the gains of the power control are Kp=0.000015 and Ki=0.004, and its limits are 0 and 1; the gains of the dc voltage control are Kp=0.03 and Ki=1,

The SSSC includes the control system shown in Figure 10. This control has two control objectives: to control the active power (P) that flows in the transmission line connected in series with the SSSC, and to maintain the dc voltage capacitor at its reference value. Remember that the SSSC does not interchange active power in steady-state, only the power loss; otherwise the dc capacitor is discharged. In transient state the SSSC has transient interchanges of active power with the network, which is reflected in variation of the dc voltage. Under this situation, the control regulates the interchange of active power in order to maintain the dc voltage capacitor at its steady-state. The initial

harmonic spectrum (bottom).


0 0.5 1 1.5 2 2.5 3 3.5

Mag (% of Fundamental)


0

100

200

and its limits are Ȃ ߨ and ߨ

**3.2.1 Static synchronous series compensator (SSSC)** 

0 10 20 30 40 50 60 70 80

Harmonic order

1.184 1.186 1.188 1.19 1.192 1.194 1.196 1.198

Time (s)

Fundamental (60Hz) = 179.6 , THD= 4.23%

FFT window: 1 of 72 cycles of selected signal

Fig. 6. Steady state waveform of the voltage at the bus 1 without passive filter (top), and its harmonic spectrum (bottom).

Fig. 7. Selected transient waveforms of the STATCOM with passive filter. (a) Phase angle of the voltage at the ac terminals of the VSC. (b) Amplitude modulation ratio. (c) Voltage across the dc capacitor. (d) Peak line-to-neutral voltage at the bus 1.

1.184 1.186 1.188 1.19 1.192 1.194 1.196 1.198

Time (s)

Fundamental (60Hz) = 179.6 , THD= 39.88%

0 10 20 30 40 50 60 70 80

Harmonic order

FFT window: 1 of 72 cycles of selected signal

Fig. 6. Steady state waveform of the voltage at the bus 1 without passive filter (top), and its

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8

Time (s)

Fig. 7. Selected transient waveforms of the STATCOM with passive filter. (a) Phase angle of the voltage at the ac terminals of the VSC. (b) Amplitude modulation ratio. (c) Voltage

across the dc capacitor. (d) Peak line-to-neutral voltage at the bus 1.

harmonic spectrum (bottom).

(a) alfaE


0.6

480

500

520

(b) mE

(c) Vdc (Volts)

(d) V1 (Volts)

peak L-n

0.8

0

5

10

Mag (% of Fundamental)

15

20


Fig. 8. Steady state waveform of the voltage at the bus 1 with passive filter (top), and its harmonic spectrum (bottom).

#### **3.2.1 Static synchronous series compensator (SSSC)**

The test system for the analysis of the SSSC is shown in Figure 9. The network parameters are the same of those of Figure 2. The series transformers are represented b an ideal model. The series active power reference Pref in the line 2 is equal to 5500 W; the dc voltage capacitor reference is equal to 500 V; the gains of the power control are Kp=0.000015 and Ki=0.004, and its limits are 0 and 1; the gains of the dc voltage control are Kp=0.03 and Ki=1, and its limits are Ȃ ߨ and ߨ

The SSSC includes the control system shown in Figure 10. This control has two control objectives: to control the active power (P) that flows in the transmission line connected in series with the SSSC, and to maintain the dc voltage capacitor at its reference value. Remember that the SSSC does not interchange active power in steady-state, only the power loss; otherwise the dc capacitor is discharged. In transient state the SSSC has transient interchanges of active power with the network, which is reflected in variation of the dc voltage. Under this situation, the control regulates the interchange of active power in order to maintain the dc voltage capacitor at its steady-state. The initial

Analysis of Power Electronic Controllers in Electric Power Systems Using Simulink 11

Fig. 11. Selected transient waveforms of the SSSC without passive filter. (Top left) Series active power. (Top right) Amplitude modulation ratio. (Bottom left) Voltage across the dc

capacitor. (Bottom right) Phase angle of the voltage at the ac terminals.

Fig. 10. SSSC control.

conditions are zero; the active power reference Pref is 5500 W, and the index modulation is 41 (2.46 kHz). Pref is the active power reference in the transmission line in series with the SSSC.

The test case has zero initial conditions for all the state variables, except for the voltage across the dc capacitor; its initial condition is 500 V. At ݐ ൌ ͲǤͶݏ the voltage magnitude of the three-phase programmable voltage source is increased 15%, and finally at ݐ ൌ ͲǤݏ, the initial operating point is reestablished. In this simulation analysis, a discrete representation of the system given in Figure 2 was used in order to carry-out the simulations, and an integration step of ʹݏߤ was selected. This analysis is also carried-out with and without the passive filter.

Figure 11 shows some selected transient waveforms of the SSSC without passive filter. In this figure it is possible to notice that the series active power decreases about 25% when the voltage magnitude of the three-phase programmable voltage source increases 15%, and the series active power increases about 25% when the same voltage goes back to the original value. The control objectives of the SSSC controller are achieved in six full cycles, as shown in this figure.

Fig. 9. Test system including the SSSC.

Fig. 10. SSSC control.

conditions are zero; the active power reference Pref is 5500 W, and the index modulation is 41 (2.46 kHz). Pref is the active power reference in the transmission line in series with

The test case has zero initial conditions for all the state variables, except for the voltage across the dc capacitor; its initial condition is 500 V. At ݐ ൌ ͲǤͶݏ the voltage magnitude of the three-phase programmable voltage source is increased 15%, and finally at ݐ ൌ ͲǤݏ, the initial operating point is reestablished. In this simulation analysis, a discrete representation of the system given in Figure 2 was used in order to carry-out the simulations, and an integration step of ʹݏߤ was selected. This analysis is also carried-out with and without the

Figure 11 shows some selected transient waveforms of the SSSC without passive filter. In this figure it is possible to notice that the series active power decreases about 25% when the voltage magnitude of the three-phase programmable voltage source increases 15%, and the series active power increases about 25% when the same voltage goes back to the original value. The control objectives of the SSSC controller are achieved in six full cycles, as shown

the SSSC.

passive filter.

in this figure.

Fig. 9. Test system including the SSSC.

Fig. 11. Selected transient waveforms of the SSSC without passive filter. (Top left) Series active power. (Top right) Amplitude modulation ratio. (Bottom left) Voltage across the dc capacitor. (Bottom right) Phase angle of the voltage at the ac terminals.

Analysis of Power Electronic Controllers in Electric Power Systems Using Simulink 13

Fig. 13. Selected transient waveforms of the SSSC with passive filter. (Top left) Series active

Fig. 14. Steady state waveform of the voltage at the bus 1 with passive filter (top), and its

harmonic spectrum (bottom).

0

0.1

0.2

Mag (% of Fundamental)

0.3

0.4

0.5



0

100

200

power. (Top right) Amplitude modulation ratio. (Bottom left) Voltage across the dc

capacitor. (Bottom right) Phase angle of the voltage at the ac terminals.

FFT window: 1 of 60 cycles of selected signal

0.984 0.986 0.988 0.99 0.992 0.994 0.996 0.998

Time (s)

Fundamental (60Hz) = 191.7 , THD= 0.60%

0 10 20 30 40 50 60 70 80

Harmonic order

Figure 12 shows the steady state waveform of the voltage at bus 1 without passive filter. In this operating scenario, the voltage is highly distorted; the THD is around 22.85% and the harmonics 39 and 43 have a magnitude of around 12% of the fundamental component. Notice that THD is high even when the switching frequency is 2.46 kHz. On the other hand, of some selected variables, the transient and steady state solutions of the SSSC test system including the passive filter are shown in Figure 13 and Figure 14. Comparing Figure 11 and Figure 13, it is easy to notice that difference between these figures is negligible. The most remarkable difference is the reduction of the harmonic distortion in all the system, especially in the voltage at bus 1.

Fig. 12. Steady state waveform of the voltage at the bus 1 without passive filter (top), and its harmonic spectrum (bottom).

Figure 12 shows the steady state waveform of the voltage at bus 1 without passive filter. In this operating scenario, the voltage is highly distorted; the THD is around 22.85% and the harmonics 39 and 43 have a magnitude of around 12% of the fundamental component. Notice that THD is high even when the switching frequency is 2.46 kHz. On the other hand, of some selected variables, the transient and steady state solutions of the SSSC test system including the passive filter are shown in Figure 13 and Figure 14. Comparing Figure 11 and Figure 13, it is easy to notice that difference between these figures is negligible. The most remarkable difference is the reduction of the harmonic distortion in all the system,

Fig. 12. Steady state waveform of the voltage at the bus 1 without passive filter (top), and its

especially in the voltage at bus 1.


Mag (% of Fundamental)


0

200

400

0.984 0.986 0.988 0.99 0.992 0.994 0.996 0.998

Time (s)

Fundamental (60Hz) = 186.6 , THD= 22.85%

0 20 40 60 80 100 120 140 160

Harmonic order

FFT window: 1 of 60 cycles of selected signal

harmonic spectrum (bottom).

Fig. 13. Selected transient waveforms of the SSSC with passive filter. (Top left) Series active power. (Top right) Amplitude modulation ratio. (Bottom left) Voltage across the dc capacitor. (Bottom right) Phase angle of the voltage at the ac terminals.

Fig. 14. Steady state waveform of the voltage at the bus 1 with passive filter (top), and its harmonic spectrum (bottom).

Analysis of Power Electronic Controllers in Electric Power Systems Using Simulink 15

Fig. 16. UPFC and its controllers.

Fig. 17. Series controller.

## **3.2.2 Unified power flow controller (UPFC)**

The UPFC test system of Figure 15 and Figure 16 shows the Simulink implementation of the UPFC. The network parameters are the same of those of Figure 2. The UPFC including the shunt control described in (Mahyavanshi & Radman, 2006) is schematically shown in Figure 18, and the series control proposed in (Fujita, Watanabe, & Akagi, 2001) is shown in Figure 17. The initial condition is zero, except for the dc capacitor voltage, which is 500 volts.

The series controller regulates the real (*Pref=*8500 watts) and reactive (*Qref=*0 vars) power flows by adjusting the injected series voltage. The shunt converter regulates the voltage across the dc capacitor and the sending end voltage V1 at bus 1. The modulation index is *mf=*27, which represents a commutation frequency of 1.61 kHz. The RC passive filter has a capacitance of �0 �� and a resistance of 0.2 Ω. The gains for the series controller are the following: Kp=1 and Ki=500 for the Discrete PI Controller 1, with no limits; Kp=2 and Ki=1000 for the Discrete PI Controller 2, with no limits. On the other hand, the gains for the shunt controller are: Kp=0.002 and Ki=1 for the Discrete PI Controller 1, with no limits; finally, Kp=0.0012 and Ki=0.09 for the Discrete PI Controller 2, with no limits. The UPFC analysis presented in this section only includes the case when the passive filter is connected, as shown in Figure 15.

Fig. 15. Test system including the UPFC.

Fig. 16. UPFC and its controllers.

The UPFC test system of Figure 15 and Figure 16 shows the Simulink implementation of the UPFC. The network parameters are the same of those of Figure 2. The UPFC including the shunt control described in (Mahyavanshi & Radman, 2006) is schematically shown in Figure 18, and the series control proposed in (Fujita, Watanabe, & Akagi, 2001) is shown in Figure 17. The initial condition is zero, except for the dc capacitor voltage, which is 500

The series controller regulates the real (*Pref=*8500 watts) and reactive (*Qref=*0 vars) power flows by adjusting the injected series voltage. The shunt converter regulates the voltage across the dc capacitor and the sending end voltage V1 at bus 1. The modulation index is *mf=*27, which represents a commutation frequency of 1.61 kHz. The RC passive filter has a capacitance of �0 �� and a resistance of 0.2 Ω. The gains for the series controller are the following: Kp=1 and Ki=500 for the Discrete PI Controller 1, with no limits; Kp=2 and Ki=1000 for the Discrete PI Controller 2, with no limits. On the other hand, the gains for the shunt controller are: Kp=0.002 and Ki=1 for the Discrete PI Controller 1, with no limits; finally, Kp=0.0012 and Ki=0.09 for the Discrete PI Controller 2, with no limits. The UPFC analysis presented in this section only includes the case when the passive filter is connected,

**3.2.2 Unified power flow controller (UPFC)** 

volts.

as shown in Figure 15.

Fig. 15. Test system including the UPFC.

Fig. 17. Series controller.

Analysis of Power Electronic Controllers in Electric Power Systems Using Simulink 17

Fig. 20. Transient waveforms of selected variables: (Left) Voltage across the dc capacitor.

Fig. 21. Steady state waveform of the voltage at the bus 1 (top) and its harmonic spectrum

(Right) Reactive (purple) and active (yellow) power.

0.984 0.986 0.988 0.99 0.992 0.994 0.996 0.998

Time (s)

Fundamental (60Hz) = 170 , THD= 1.74%

0 20 40 60 80 100

Harmonic order

FFT window: 1 of 60 cycles of selected signal

(bottom).

0

0.2

0.4

0.6

Mag (% of Fundamental)

0.8

1

1.2



0

100

200

The dynamic response of UPFC controllers are presented in Figure 19. From this figure, it is possible to observe that the variation of the three-phase programmable voltage source significantly affects the response of the series controller. This is because the magnitude of the voltages at the ends of the line controlled by the UPFC affects the power flow across the line. On the other hand, Figure 20 shows the transient waveform of the voltage across the dc capacitor and the active and reactive power flow in the controlled line. Notice that the reactive and active power remains close to the reference during the step changes in the three-phase programmable voltage source. Finally, Figure 21 presents the periodic steady-state solution of the sending end voltage V1 and its harmonic spectrum, which has a low THD of 1.74%.

Fig. 18. Shunt controller.

Fig. 19. Transient response of the series and shunt controllers of UPFC.

The dynamic response of UPFC controllers are presented in Figure 19. From this figure, it is possible to observe that the variation of the three-phase programmable voltage source significantly affects the response of the series controller. This is because the magnitude of the voltages at the ends of the line controlled by the UPFC affects the power flow across the line. On the other hand, Figure 20 shows the transient waveform of the voltage across the dc capacitor and the active and reactive power flow in the controlled line. Notice that the reactive and active power remains close to the reference during the step changes in the three-phase programmable voltage source. Finally, Figure 21 presents the periodic steady-state solution of

the sending end voltage V1 and its harmonic spectrum, which has a low THD of 1.74%.

Fig. 19. Transient response of the series and shunt controllers of UPFC.

Fig. 18. Shunt controller.

Fig. 20. Transient waveforms of selected variables: (Left) Voltage across the dc capacitor. (Right) Reactive (purple) and active (yellow) power.

Fig. 21. Steady state waveform of the voltage at the bus 1 (top) and its harmonic spectrum (bottom).

**2** 

Titu Niculescu *University of Petrosani* 

*Romania* 

**Study of Inductive-Capacitive Series Circuits** 

This chapter presents a modern method for approaching the electrical circuits using the MATLAB-SIMULINK package programs. The simple series circuits which are switched on a DC voltage at the initial moment are presented below. For the young researchers these are very useful. We can determine the current variation forms and the reactive elements voltage, by using this virtual medium. Each presented case contains an analytical presentation of the problem, but it also contains electrical diagrams of electrical parameters.

We will consider the RL series circuit with concentrated parameters from Fig.1. At the initial moment, the k circuit switcher is closed and we intend to study the behavior and variation

The differential equation which corresponds to the transitory regime immediately after

*di Ri L E dt*

(1)

The diagrams were obtained by different methods which use this programs package.

**1. Introduction** 

**2. Study of the inductive series circuits** 

of circuit electrical parameters after connection.

Fig. 1. RL series circuits at closing

closing is the following:

**2.1 Theoretical study of the circuit** 

**Using the Simulink Software Package** 

## **4. Conclusions**

In this chapter, implementation in Simulink of three FACTS devices based on VSC has been presented. These implementations include the STATCOM, SSSC, and the UPFC. All the implementations have been carried-out taking into account the control systems. The presented models can be used in order to analyze the dynamic and the periodic steady-state behavior of these FACTS components.

## **5. Acknowledgements**

The authors thank the Univesidad Autónoma de San Luis Potosí (UASLP) and the Universidad Michoacana de San Nicolás de Hidalgo (UMSNH) for the facilities that were granted to carry out this chapter.

## **6. References**


## **Study of Inductive-Capacitive Series Circuits Using the Simulink Software Package**

Titu Niculescu *University of Petrosani Romania* 

## **1. Introduction**

18 Technology and Engineering Applications of Simulink

In this chapter, implementation in Simulink of three FACTS devices based on VSC has been presented. These implementations include the STATCOM, SSSC, and the UPFC. All the implementations have been carried-out taking into account the control systems. The presented models can be used in order to analyze the dynamic and the periodic steady-state

The authors thank the Univesidad Autónoma de San Luis Potosí (UASLP) and the Universidad Michoacana de San Nicolás de Hidalgo (UMSNH) for the facilities that were

Acha, E., Fuerte-Esquivel, C., Ambriz-Pérez, H., & Angeles-Camacho, C. (2004). *FACTS* 

Fujita, H., Watanabe, Y., & Akagi, H. (2001). Transient Analisis of a Unified Power Flow

*on Power Electronics*, Vol. 16, No. 5, (september 2001), pp. 735-740, 0885-8993 Hingorani, N. G., & Gyudyi, L. (2000). *Undestanding FACTS,* IEEE Press, 078033455, New

Mahyavanshi, B., & Radman, G. (2006). A Study of Interaction Between Dynamic Load and

Mathur, R., & Varma, R. (2002). *Thyristor Based FACTS Controllers for Electrical Transmission Systems*, IEEE Computer Society Press, ISSN, Piscataway, New Jersey Mohan, N., Underland, T. M., & Robins, W. P. (1995). *Power Electronics: Converters,* 

Padiyar, K. R. (2007). *FACTS Controller in Power Transmission and Distribution,* New Age, 978-

Segundo-Ramírez, J., & Medina, A. (2009). Modeling of FACTS Devices Based on SPWM

Segundo-Ramírez, J., & Medina, A. (2008). Periodic Steady-State Solution of Electric Systems

Zhang, X.-P., Rehtanz, C., & Pal, B. (2006). *Flexible AC Transmission Systems: Modelling and* 

VSCs. *IEEE Transaction on Power Delivery*, Vol. 24, No. 4, (November 2009), pp.

Including UPFCs by Extrapolation to the Limit Cycle. *IEEE Transaction on Power* 

*Modelling and Simulation in Power Networks,* John Wiley & Sons, 9780470852712,

Controller and its Application to Design of the DC-Link Capacitor. *IEEE Transaction* 

STATCOM. *Proceedings of the 38th southeastern symposium on system theory*, 0-7803-

**4. Conclusions** 

behavior of these FACTS components.

**5. Acknowledgements** 

England

York

9457-7, Cookeville, TN, march 2006

*Delivery*, Vol. 23, No. 3, pp. 1506-1512

81-224-2142-2, New Delhi

1815-1823, 0885-8977

*Applications, and Design,* Wiley, 0471226939, New York

*Control,* Springer-Verlag. 978-3-540-30606-1, Germany

**6. References** 

granted to carry out this chapter.

This chapter presents a modern method for approaching the electrical circuits using the MATLAB-SIMULINK package programs. The simple series circuits which are switched on a DC voltage at the initial moment are presented below. For the young researchers these are very useful. We can determine the current variation forms and the reactive elements voltage, by using this virtual medium. Each presented case contains an analytical presentation of the problem, but it also contains electrical diagrams of electrical parameters. The diagrams were obtained by different methods which use this programs package.

## **2. Study of the inductive series circuits**

We will consider the RL series circuit with concentrated parameters from Fig.1. At the initial moment, the k circuit switcher is closed and we intend to study the behavior and variation of circuit electrical parameters after connection.

Fig. 1. RL series circuits at closing

## **2.1 Theoretical study of the circuit**

The differential equation which corresponds to the transitory regime immediately after closing is the following:

$$Ri + L\frac{di}{dt} = E\tag{1}$$

Study of Inductive-Capacitive Series Circuits Using the Simulink Software Package 21


we will obtain the diagrams from Fig.3 and Fig.4.

Fig. 3. Variation of the coil voltage after closing

Fig. 4. Variation of the circuit current

electrical parameters of the circuit have the values:

**2.3 Analysis of RL series circuits using the SimPowerSistems software package** 

The SimPowerSystems software package is a component of the MATLAB program which allows analyzing an electrical circuit by drawing it in an editing window. The SimPowerSystems model is presented in Fig.5 and allows the visualization of the circuit current and the coil voltage if we apply a step voltage signal and a unitary impulse. The

The current expression through the circuit after closing is the solution of the differential equation of the circuit (1).

> ( ) (1 ) - *t <sup>T</sup> <sup>E</sup> it e R* (2)

where:

$$T = \frac{L}{R} \tag{3}$$

and it represents the time constant of the circuit.

The voltage expression on the coil after connection is:

$$
\mu(t) = L\frac{di}{dt} = E \cdot e^{-\frac{t}{T}}\tag{4}
$$

#### **2.2 SIMULINK model of the circuit**

The SIMULINK model of the circuit after closing was done on grounds of equation (1) where the derivative of the current was separated.

$$\frac{di}{dt} = \frac{1}{L}(E \text{ - } Ri) \tag{5}$$

The SIMULINK model obtained in this way is shown in Fig.2 and was created in order to allow the drawing of the current diagrams through the circuit and the voltage on the coil, for different values of the R resistance and the E D.C. voltage.

Fig. 2. SIMULINK model of the RL circuit at closing

The k switcher is realized using a voltage step signal which is applied at the terminal of the circuit, to simulate the closing of the k switcher.

If we consider the following values of the electric parameters



20 Technology and Engineering Applications of Simulink

The current expression through the circuit after closing is the solution of the differential

( ) (1 ) - 

*<sup>T</sup> <sup>E</sup> it e*

*<sup>L</sup> <sup>T</sup>*

( ) 

The SIMULINK model of the circuit after closing was done on grounds of equation (1)


The SIMULINK model obtained in this way is shown in Fig.2 and was created in order to allow the drawing of the current diagrams through the circuit and the voltage on the coil,

Product <sup>1</sup>

The k switcher is realized using a voltage step signal which is applied at the terminal of the

1 s Integrator

*<sup>T</sup> di ut L E e*

*t*

*t*

*R* (2)

*<sup>R</sup>* (3)

*dt* (4)

*dt L* (5)

L

du/dt Derivative

Scope U

Scope I

equation of the circuit (1).

and it represents the time constant of the circuit.

**2.2 SIMULINK model of the circuit** 

Step

50 R

The voltage expression on the coil after connection is:

where the derivative of the current was separated.

Add

Fig. 2. SIMULINK model of the RL circuit at closing

If we consider the following values of the electric parameters

circuit, to simulate the closing of the k switcher.


for different values of the R resistance and the E D.C. voltage.

1 1/L

where:


we will obtain the diagrams from Fig.3 and Fig.4.

Fig. 3. Variation of the coil voltage after closing

Fig. 4. Variation of the circuit current

## **2.3 Analysis of RL series circuits using the SimPowerSistems software package**

The SimPowerSystems software package is a component of the MATLAB program which allows analyzing an electrical circuit by drawing it in an editing window. The SimPowerSystems model is presented in Fig.5 and allows the visualization of the circuit current and the coil voltage if we apply a step voltage signal and a unitary impulse. The electrical parameters of the circuit have the values:

Study of Inductive-Capacitive Series Circuits Using the Simulink Software Package 23

The selection *of U\_Voltage Measurement or I\_Current Measurement* is followed by the obtaining of the coil voltage diagram and of the circuit current upon applying the step

Fig. 8. The coil voltage variation upon applying a step signal and a unitary impulse.

signal and a unitary impulse. These are presented in Fig.8 and Fig.9.

Fig. 7. The *LTI Viewer* window

R = 50[Ω]; L = 1[H].

Fig. 5. SimPowerSystems model of an inductive circuit

The *Continous powergui* analyze block is required to be present in the drawing window for launching the simulation model. We will open an analysis window by double-clicking on this block, Fig. 6.

Fig. 6. The analysis window of the circuit

The selection of the *Use LTI Viewer* button will lead to the opening of the window in Fig.7, from which we can select the current diagram or the coil voltage diagram.


Fig. 7. The *LTI Viewer* window

Current Measurement <sup>s</sup>

The *Continous powergui* analyze block is required to be present in the drawing window for launching the simulation model. We will open an analysis window by double-clicking on

The selection of the *Use LTI Viewer* button will lead to the opening of the window in Fig.7,

from which we can select the current diagram or the coil voltage diagram.

v + - Voltage Measurement

R L Scope I

<sup>i</sup> <sup>+</sup> -

Scope U

R = 50[Ω]; L = 1[H].

Step

this block, Fig. 6.

Continuous powergui

Fig. 6. The analysis window of the circuit

Fig. 5. SimPowerSystems model of an inductive circuit


> The selection *of U\_Voltage Measurement or I\_Current Measurement* is followed by the obtaining of the coil voltage diagram and of the circuit current upon applying the step signal and a unitary impulse. These are presented in Fig.8 and Fig.9.

Fig. 8. The coil voltage variation upon applying a step signal and a unitary impulse.

Study of Inductive-Capacitive Series Circuits Using the Simulink Software Package 25

We will consider the RC series circuit with concentrated parameters from Fig.12. At the initial moment, the k circuit switcher is closed and we want to study the current variation

The integral equation which corresponds to the transitory regime immediately after closing

<sup>1</sup> *Ri idt E C*

(6)

through the circuit and the capacitor voltage variation, after connection.

Fig. 11. The frequency current diagrams.

Fig. 12. RC series circuit at closing

is given by:

**3.1 Theoretical study of the circuit** 

Equation (6) is equivalent with differential equation:

**3. Study of the capacitive series circuits** 

Fig. 9. The current variation upon applying a step signal and a unitary impulse.

We can use the *Edit/Plot Configurations* and *Edit/ Viewer Preferences* options, in order to create these diagrams. We can also select the *Bode* option from these menus, which allows the obtaining of the current frequency diagrams of the RL series circuit.

Fig. 10. The amplitude frequency diagram of the voltage coil.

Fig. 11. The frequency current diagrams.

Fig. 9. The current variation upon applying a step signal and a unitary impulse.

obtaining of the current frequency diagrams of the RL series circuit.

Fig. 10. The amplitude frequency diagram of the voltage coil.

We can use the *Edit/Plot Configurations* and *Edit/ Viewer Preferences* options, in order to create these diagrams. We can also select the *Bode* option from these menus, which allows the

## **3. Study of the capacitive series circuits**

We will consider the RC series circuit with concentrated parameters from Fig.12. At the initial moment, the k circuit switcher is closed and we want to study the current variation through the circuit and the capacitor voltage variation, after connection.

Fig. 12. RC series circuit at closing

#### **3.1 Theoretical study of the circuit**

The integral equation which corresponds to the transitory regime immediately after closing is given by:

$$i\text{ Ri} + \frac{1}{C} \int \quad idt = E \tag{6}$$

Equation (6) is equivalent with differential equation:

Study of Inductive-Capacitive Series Circuits Using the Simulink Software Package 27


Fig. 14. The capacitor voltage variation

Fig. 15. The current variation after closing

impulse.

**3.3 Analysis of RC series circuits using the SimPowerSistems software package** 

The SimPowerSystems model is presented in Fig.16 and allows the visualization of the circuit current and the capacitor voltage if we apply a step voltage signal and a unitary

we will obtain the diagrams from Fig.14 and Fig.15.

$$RC\frac{du}{dt} + u = E \tag{7}$$

The expression of the capacitor voltage after closing is the solution of differential equation (7):

$$
\mu(t) = E(1 \cdot e^{-\frac{t}{T}}) \tag{8}
$$

where *T RC* , represents the time constant of the circuit.

The circuit current after closing is given by:

$$
\dot{u} = \mathbf{C} \frac{du}{dt} = \frac{\mathbf{E}}{R} e^{-\frac{\mathbf{f}}{T}} \tag{9}
$$

#### **3.2 SIMULINK model of the circuit**

The SIMULINK model of the circuit after closing was done on grounds of equation (7) where the voltage derivative was separated.

$$\frac{du}{dt} = \frac{1}{RC}(E \text{ -} u) \tag{10}$$

The SIMULINK model obtained is shown in Fig.13 and was created in order to allow the drawing of the current diagrams through the circuit and the voltage capacitor, for different values of the R resistance, of the E D.C. voltage and of the C capacitor.

Fig. 13. SIMULINK model of the RC circuit at closing

The k switcher is realized using the same voltage step signal which is applied at the terminal of the circuit, to simulate the closing of the k switcher.

If we consider the following values of the electric parameters:


26 Technology and Engineering Applications of Simulink

*du RC u E dt*

The expression of the capacitor voltage after closing is the solution of differential equation

( ) (1 ) - 

*<sup>T</sup> du E iC e*

The SIMULINK model of the circuit after closing was done on grounds of equation (7)


The SIMULINK model obtained is shown in Fig.13 and was created in order to allow the drawing of the current diagrams through the circuit and the voltage capacitor, for different

Step Scope U

1 s Integrator

Scope I <sup>1500</sup>

The k switcher is realized using the same voltage step signal which is applied at the terminal

values of the R resistance, of the E D.C. voltage and of the C capacitor.

Divide

1 1 Product1

where *T RC* , represents the time constant of the circuit.

The circuit current after closing is given by:

where the voltage derivative was separated.

Add

Product

Fig. 13. SIMULINK model of the RC circuit at closing

of the circuit, to simulate the closing of the k switcher.

If we consider the following values of the electric parameters:

**3.2 SIMULINK model of the circuit** 

R


*t*

*t*

(7):

(7)

*ut E e <sup>T</sup>* (8)

*dt R* (9)

*dt RC* (10)

Product2

du/dt Derivative


we will obtain the diagrams from Fig.14 and Fig.15.

Fig. 14. The capacitor voltage variation

## **3.3 Analysis of RC series circuits using the SimPowerSistems software package**

The SimPowerSystems model is presented in Fig.16 and allows the visualization of the circuit current and the capacitor voltage if we apply a step voltage signal and a unitary impulse.

Study of Inductive-Capacitive Series Circuits Using the Simulink Software Package 29

Fig. 18. The current variation upon applying a step signal and a unitary impulse.

presented bellow:

Fig. 19. The capacitor voltage frequency diagrams

The Bode diagrams which allow the visualization of the frequency behavior of the circuit are

Fig. 16. SimPowerSystems model of the capacitive circuit

The electrical parameters of the circuit have the values:


To study the voltage variation on the capacitor, we follow the steps:


This method allows us to obtain the voltage capacitor diagram upon applying the step signal and the unitary impulse (Fig.17).

The current variation through the circuit upon applying a step signal and a unitary impulse was obtained by selecting *I\_Current Measurement* option (Fig.18).

Fig. 17. The capacitor voltage variation upon applying a step signal and a unitary impulse.

Current Measurement <sup>s</sup>

<sup>v</sup> <sup>+</sup> - Voltage Measurement

R Scope I

i + -

Scope U

Continuous powergui



C ontrolled Voltage Source <sup>C</sup>

Fig. 16. SimPowerSystems model of the capacitive circuit

The electrical parameters of the circuit have the values:

 Select *Use LTI Wiewer* in the new window; We will select U Voltage *Measurement*.

signal and the unitary impulse (Fig.17).

To study the voltage variation on the capacitor, we follow the steps:

was obtained by selecting *I\_Current Measurement* option (Fig.18).

Select by double clicking the *Continous powerguy* block from the simulation model.

This method allows us to obtain the voltage capacitor diagram upon applying the step

The current variation through the circuit upon applying a step signal and a unitary impulse

Fig. 17. The capacitor voltage variation upon applying a step signal and a unitary impulse.

Step

Fig. 18. The current variation upon applying a step signal and a unitary impulse.

The Bode diagrams which allow the visualization of the frequency behavior of the circuit are presented bellow:

Fig. 19. The capacitor voltage frequency diagrams

Study of Inductive-Capacitive Series Circuits Using the Simulink Software Package 31

*d u du LC RC u E dt dt*

> 2 *R L*

> > 1 *LC*



> 2 2 0

*<sup>E</sup> rt rt i t e e*


 

 

We will consider the situation when δ <ω0 or *R LC* 2 . The following notation was made:




*<sup>E</sup> <sup>t</sup> it e t L* 

 

 

1 2 *r r*

0 

Consequently, the solving of the differential equation gives the following solutions:

*<sup>t</sup> ut E e t* 

*rt rt ut E re re* 

1 2 2 2 0 <sup>1</sup> ( ) [1 ( )]

 

2 1

(17)

(18)

' (19)

(21)

1 2

 <sup>0</sup> 

0

Consequently, the solving of the differential equation gives the following solutions:

2

2

*L* 


where r1 and r2 are the roots of the characteristic equation:

( )

 

(12)

(13)

(14)

(15)

(16)

(20)

or *R LC* 2 , which will be checked by the

2 2

or:

The following notations are made:

The circuit amortization:

the circuit personal pulsation:

resistor in the circuit.

We will consider the situation when 0

Fig. 20. The current frequency diagrams.

## **4. Study of the inductive-capacitive series circuits**

We will consider the RLC series circuit with concentrated parameters from Fig.21. At the initial moment, the k circuit switcher is closed and we intend to study the behavior and variation of circuit electrical parameters after connection.

Fig. 21. RLC series circuit at connecting

## **4.1 Theoretical study of the circuit**

The integral-differential equation which corresponds to the transitory regime of the considered circuit is the following:

$$\left[Ri + L\frac{di}{dt} + \frac{1}{C}\right]idt = E\tag{11}$$

or:

30 Technology and Engineering Applications of Simulink

We will consider the RLC series circuit with concentrated parameters from Fig.21. At the initial moment, the k circuit switcher is closed and we intend to study the behavior and

The integral-differential equation which corresponds to the transitory regime of the

1 *di Ri L idt E*

*dt C* (11)

Fig. 20. The current frequency diagrams.

Fig. 21. RLC series circuit at connecting

**4.1 Theoretical study of the circuit** 

considered circuit is the following:

**4. Study of the inductive-capacitive series circuits** 

variation of circuit electrical parameters after connection.

$$\text{LC}\frac{d^2u}{dt^2} + \text{RC}\frac{du}{dt} + u \,\, = \text{E} \tag{12}$$

The following notations are made:

$$
\delta = \frac{R}{2L} \tag{13}
$$

The circuit amortization:

$$
\alpha\_0 = \frac{1}{\sqrt{LC}}\tag{14}
$$

the circuit personal pulsation:

$$
\alpha = \sqrt{\delta^2 \cdot \alpha\_0^2} \tag{15}
$$

We will consider the situation when 0 or *R LC* 2 , which will be checked by the resistor in the circuit.

Consequently, the solving of the differential equation gives the following solutions:

$$u(t) = E\left[1 \cdot \frac{1}{2\sqrt{\delta^2 \cdot \alpha\_0^2}} (r\_1 e^{r\_2 t} \cdot r\_2 e^{r\_1 t})\right] \tag{16}$$

$$i(t) = \frac{E}{2L\sqrt{\delta^2 \cdot \alpha\_0^2}} \left( e^{\gamma\_1 t} \cdot e^{\gamma\_2 t} \right) \tag{17}$$

where r1 and r2 are the roots of the characteristic equation:

$$\begin{aligned} r\_1 &= \text{-}\mathcal{S} + \mathcal{O} \\ r\_2 &= \text{-}\mathcal{S} \cdot \mathcal{O} \end{aligned} \tag{18}$$

We will consider the situation when δ <ω0 or *R LC* 2 . The following notation was made:

$$
\alpha \alpha\_0^2 \cdot \delta^2 = \alpha^{\cdot 2} \tag{19}
$$

Consequently, the solving of the differential equation gives the following solutions:

$$\mu(t) = E\left[ \left[ 1 - \frac{\alpha\_0}{\alpha'} \bullet e^{\cdot \delta t} \bullet \sin(\phi' t + \beta') \right] \right] \tag{20}$$

$$\dot{a}(t) = \frac{E}{a^\prime L} e^{\therefore \delta t} \sin \alpha^\prime t \tag{21}$$

Study of Inductive-Capacitive Series Circuits Using the Simulink Software Package 33

we get the following MATLAB diagrams (Fig.23 and Fig.24) according to the equations (16) and (17) for a-periodic mode, and according to the equations (20) and (21) for

oscillating mode (Fig.25 and Fig.26).

Fig. 23. The voltage capacitor variation in the a-periodic mode

Fig. 24. The current variation in the a-periodic mode

Fig. 25. The capacitor voltage variation in the oscillating regime

where

$$
\beta' = \arccos \frac{\delta}{a\_0} \tag{22}
$$

### **4.2 SIMULINK model of the circuit**

The SIMULINK model of the circuit after closing was done on grounds of the second order differential equation (12), which is put in the form (23) where the higher order derivative is separated:

$$\frac{d^2u}{dt} = \frac{1}{LC} \left[ \left[ E \cdot RC \frac{du}{dt} \cdot u \right] \right] \tag{23}$$

The SIMULINK model from Fig.22 generates the voltage capacitor and the current through the circuit during the transitory regime. To this purpose, two values of the R resistor are considered, which correspond to two important regimes:


For each regime the capacitor voltage and the circuit current variation diagrams are plotted.

Fig. 22. SIMULINK model of the circuit

If we consider:


' arccos

The SIMULINK model of the circuit after closing was done on grounds of the second order differential equation (12), which is put in the form (23) where the higher order derivative is

> <sup>2</sup> <sup>1</sup> [ ] *d u du E RC u dt LC dt*

The SIMULINK model from Fig.22 generates the voltage capacitor and the current through the circuit during the transitory regime. To this purpose, two values of the R resistor are

For each regime the capacitor voltage and the circuit current variation diagrams are

1 s Integrator

0

(22)

(23)

ScopeU

ScopeI

du/dt


C

Derivative


1 s Integrator1


C1

where

separated:

plotted.

Step

1500

R

If we consider:

 Aperiodic regime; Oscillatory regime.

**4.2 SIMULINK model of the circuit** 

considered, which correspond to two important regimes:


1/LC

RCdu/dt

Fig. 22. SIMULINK model of the circuit


Add

we get the following MATLAB diagrams (Fig.23 and Fig.24) according to the equations (16) and (17) for a-periodic mode, and according to the equations (20) and (21) for oscillating mode (Fig.25 and Fig.26).

Fig. 23. The voltage capacitor variation in the a-periodic mode

Fig. 24. The current variation in the a-periodic mode

Fig. 25. The capacitor voltage variation in the oscillating regime

Study of Inductive-Capacitive Series Circuits Using the Simulink Software Package 35

R L

pow ergui <sup>v</sup> <sup>+</sup>

The a-periodic loading of the capacitor leads to the obtaining of the capacitor voltage variation diagrams when the unit step and the unitary impulse are applied to the input.


The POWERGUY analysis block, with the above values, allows the obtaining of the


ScopeU

ScopeI

C

Voltage Measurement

i + - Current Measurement

Continuous

Step

s -

1. *Voltage capacitor* 

These charts are presented below.





following Matlab diagrams (Fig.28 and Fig.29):


For a-periodic regime:

For oscillating regime:

+

Fig. 27. SimPowerSystems model of the circuit

The following values of electrical parameters were considered:

To study the capacitor voltage variation, we follow the steps:


Controlled Voltage Source

Fig. 26. The current variation in the oscillating regime

The k switcher is realized by using a voltage step signal which is applied at the terminal of the circuit, to simulate the closing of the k switcher. Changing the value of resistance, automatically leads to the updating of the voltage and current charts.

## **4.3. Analysis of inductive-capacitive circuits using the SimPowerSystems software package**

The SimPowerSystems software package allows the study of the circuit behavior, when it is connected to a voltage step or a unitary impulse, using *Continous powerguy* block. The current variation in the circuit, the voltage variation of the capacitive element, or the frequency behavior of the circuit for different values of circuit elements can be studied.

## **4.3.1 SimPowerSystems model of the circuit**

The MATLAB software package contains SimPowerSystems of Simulink, which can simulate the electrical circuits and analyze different operating regimes. Because the signal step response or pulse generates a transitory regime, the circuit behavior in these conditions can be studied. The simulation is shown in Fig.27:

The advantage of this simulation method is that the circuit can be tested at both signals, unit step and unitary impulse, and leads to several types of typical circuit diagrams. Two sets of values were chosen in this case for circuit parameters, which correspond to two special regimes.

In the simulation model from Fig.27 we used a *Controlled Voltage Source* controlled by a step voltage signal. In this way, the switcher closing can be simulated.

The SimPowerSystems software package allows the obtaining of a lot of diagrams for a circuit. So, we will study the capacitor voltage diagrams and current diagrams for the two occurring regimes:


Fig. 27. SimPowerSystems model of the circuit

1. *Voltage capacitor* 

34 Technology and Engineering Applications of Simulink

The k switcher is realized by using a voltage step signal which is applied at the terminal of the circuit, to simulate the closing of the k switcher. Changing the value of resistance,

**4.3. Analysis of inductive-capacitive circuits using the SimPowerSystems software** 

The SimPowerSystems software package allows the study of the circuit behavior, when it is connected to a voltage step or a unitary impulse, using *Continous powerguy* block. The current variation in the circuit, the voltage variation of the capacitive element, or the frequency behavior of the circuit for different values of circuit elements can be studied.

The MATLAB software package contains SimPowerSystems of Simulink, which can simulate the electrical circuits and analyze different operating regimes. Because the signal step response or pulse generates a transitory regime, the circuit behavior in these conditions

The advantage of this simulation method is that the circuit can be tested at both signals, unit step and unitary impulse, and leads to several types of typical circuit diagrams. Two sets of values were chosen in this case for circuit parameters, which correspond to two special

In the simulation model from Fig.27 we used a *Controlled Voltage Source* controlled by a step

The SimPowerSystems software package allows the obtaining of a lot of diagrams for a circuit. So, we will study the capacitor voltage diagrams and current diagrams for the two

Fig. 26. The current variation in the oscillating regime

**4.3.1 SimPowerSystems model of the circuit** 

can be studied. The simulation is shown in Fig.27:

voltage signal. In this way, the switcher closing can be simulated.

**package** 

regimes.

occurring regimes:

 A-periodic regime: Oscillating regime.

automatically leads to the updating of the voltage and current charts.

The a-periodic loading of the capacitor leads to the obtaining of the capacitor voltage variation diagrams when the unit step and the unitary impulse are applied to the input. These charts are presented below.

The following values of electrical parameters were considered:


To study the capacitor voltage variation, we follow the steps:


The POWERGUY analysis block, with the above values, allows the obtaining of the following Matlab diagrams (Fig.28 and Fig.29):

Study of Inductive-Capacitive Series Circuits Using the Simulink Software Package 37


Fig. 30. Frequency diagrams of the voltage swing on the capacitive element

selecting the *U voltage Measurement, I Current Measuremen*t must be selected.


So, we will study the current variation diagrams for the two occurring regimes:

the unit step and the unitary impulse are applied to the input.


To study the circuit current variation the same procedure is used, mentioning that instead of

A-periodic loading of the capacitor leads to obtaining the current variation diagrams when

The SimPowerSystems software package allows the obtaining of two diagrams for a circuit.

The a-periodical and oscillating regime according to these values are obtained in the

2. Study of circuit current

For this, we will follow these steps:


following charts (Fig.31 and Fig.32):

 A-periodical regime: Oscillating regime.


Fig. 28. The capacitor voltage variation in the a-periodic mode

Fig. 29. The capacitor voltage variation in the oscillating regime

The POWERGUY block permits the analysis and plotting of the frequency characteristics of the capacitor voltage, where the frequency in logarithmic coordinates was considered on the horizontal axis (BODE diagram).

For this, we follow these steps:



Fig. 28. The capacitor voltage variation in the a-periodic mode

Fig. 29. The capacitor voltage variation in the oscillating regime


horizontal axis (BODE diagram). For this, we follow these steps:

The POWERGUY block permits the analysis and plotting of the frequency characteristics of the capacitor voltage, where the frequency in logarithmic coordinates was considered on the

Fig. 30. Frequency diagrams of the voltage swing on the capacitive element

2. Study of circuit current

To study the circuit current variation the same procedure is used, mentioning that instead of selecting the *U voltage Measurement, I Current Measuremen*t must be selected.

A-periodic loading of the capacitor leads to obtaining the current variation diagrams when the unit step and the unitary impulse are applied to the input.

For this, we will follow these steps:


The SimPowerSystems software package allows the obtaining of two diagrams for a circuit. So, we will study the current variation diagrams for the two occurring regimes:


The a-periodical and oscillating regime according to these values are obtained in the following charts (Fig.31 and Fig.32):

Study of Inductive-Capacitive Series Circuits Using the Simulink Software Package 39


Fig. 33. Frequency diagrams of the current swing through the circuit

POWERGUY block, other electrical circuit parameters can be determined.

influence of each parameter variation in the final diagrams can be studied.

In the diagram from Fig.33 we can observe a maximum of current which correspond to a resonance regime. We can determine the resonance frequencies for an inductive-capacitive circuit using the simulation circuit model and the SimPowerSystems software package. With

An important conclusion of this chapter is that the electrical circuits, regardless of configuration, can be studied with this modern method which involves the use of virtual

Three elementary circuits are presented here, but the study modality can be extended to

If we consider an electric circuit, a first problem is that of writing the characteristic integral differential equations, which can be integrated with a simulation model and which uses the Simulink software package. These models can be conceived so that the electric circuit parameters must be electric input values in the simulation model. Thus, the obtained diagrams are automatically updated to any changes of circuit electrical parameters, and the



**5. Conclusions** 

other circuits configuration as well.

medium.

Fig. 31. The current variation for signal step and impulse in a-periodic mode

Fig. 32. The current variation for signal step and impulse in the oscillating regime

The POWERGUY block allows the analysis and plotting of frequency current characteristics, where the frequency in logarithmic coordinates was considered on the horizontal axis (BODE diagram). For this, we will follow these steps:


Fig. 31. The current variation for signal step and impulse in a-periodic mode

Fig. 32. The current variation for signal step and impulse in the oscillating regime

(BODE diagram). For this, we will follow these steps:

The POWERGUY block allows the analysis and plotting of frequency current characteristics, where the frequency in logarithmic coordinates was considered on the horizontal axis

Fig. 33. Frequency diagrams of the current swing through the circuit

In the diagram from Fig.33 we can observe a maximum of current which correspond to a resonance regime. We can determine the resonance frequencies for an inductive-capacitive circuit using the simulation circuit model and the SimPowerSystems software package. With POWERGUY block, other electrical circuit parameters can be determined.

## **5. Conclusions**

An important conclusion of this chapter is that the electrical circuits, regardless of configuration, can be studied with this modern method which involves the use of virtual medium.

Three elementary circuits are presented here, but the study modality can be extended to other circuits configuration as well.

If we consider an electric circuit, a first problem is that of writing the characteristic integral differential equations, which can be integrated with a simulation model and which uses the Simulink software package. These models can be conceived so that the electric circuit parameters must be electric input values in the simulation model. Thus, the obtained diagrams are automatically updated to any changes of circuit electrical parameters, and the influence of each parameter variation in the final diagrams can be studied.

**3** 

Rastislav Róka

*Slovakia* 

**Fixed Transmission Media** 

For successful understanding of the signal transmission in access networks that utilized fixed transmission media, it is necessary exactly to recognize essential negative influences in the real environment of metallic homogeneous symmetric lines, power distribution cables and optical fibers. This chapter discusses features and frequency characteristics of negative influences on signals transmitted by means of the VDSL technology, the PLC technology and PON networks. For the expansion of communication systems on fixed transmission media, it is necessary to have a detailed knowledge of their transmission environments and

A main attention of the metallic transmission media's parts is focused on the description of the proposed VDSL and PLC simulation models and on the explanation of simulation methods for substantial negative influences. Presented simulation models represent a reach enough knowledgebase for the extended digital signal processing techniques of the VDSL and PLC signal transmissions that can be extremely helpful for various tests and

A main attention of the optical transmission media's part is focused on the description of the proposed optical fiber's simulation model and on the explanation of simulation methods for its substantial linear effects - transmission factors. The presented simulation model represents a reach enough knowledgebase that can be helpful for various tests and performance comparisons of various novel modulation techniques suggested and intended

Propagation loss and linear distortions (distortions of the module and the phase characteristics and the group delay characteristic) are linear negative influences dependent on physical and constructional parameters, such as a line length, a core diameter of the wire, a mismatch of impedances in cross-connecting points of sections, a frequency bandwidth

We first discuss the propagation loss *LdB* in a perfectly terminated line. If *R*, *L*, *G* and *C* are

*.f*, where *f* is the frequency, then

to be used at signal transmissions in the transmission environment of optical fibers.

negative influences in the real developing of customer installations.

**2. The environment of metallic homogeneous lines 2.1 Linear negative influences on transmitted signals** 

> = *2.*

**1. Introduction** 

performance comparisons.

and so forth (Róka, 2004).

primary constants of the line and

*Slovak University of Technology, Bratislava* 

In order to realize the simulating model which integrates the differential equations, the basic idea is to separate in the left member of equation, the higher order derivative. The analytical expressions obtained in the right member of the equation underlie the achievement of the simulating model by means of specific blocks of the virtual medium. In the case of complex circuits, the simulating model is conceived on a differential equations system.

Another given facility of this package programs, is the possibility to study the circuit behavior upon applying the standard signals (step unit, unitary impulse). The specific analysis block *Continous Powerguy* allows the circuit response to these signals. It also allows the study of circuit frequency characteristics and the other specific diagrams: the coil hysteresis diagrams, line parameters, FTF analysis, Bode Diagrams, Nyquist diagrams, Nichols diagrams and others.

This study intends to be a starting point in the approach of more complex circuits.

## **6. References**


## **Fixed Transmission Media**

## Rastislav Róka

*Slovak University of Technology, Bratislava Slovakia* 

## **1. Introduction**

40 Technology and Engineering Applications of Simulink

In order to realize the simulating model which integrates the differential equations, the basic idea is to separate in the left member of equation, the higher order derivative. The analytical expressions obtained in the right member of the equation underlie the achievement of the simulating model by means of specific blocks of the virtual medium. In the case of complex

Another given facility of this package programs, is the possibility to study the circuit behavior upon applying the standard signals (step unit, unitary impulse). The specific analysis block *Continous Powerguy* allows the circuit response to these signals. It also allows the study of circuit frequency characteristics and the other specific diagrams: the coil hysteresis diagrams, line parameters, FTF analysis, Bode Diagrams, Nyquist diagrams,

Niculescu, T.; Pasculescu, D.; Pana, L. (2010). *Study of the operating states of intrinsic safety* 

Pasculescu, D.; Niculescu, T.; Pana, L. (2010). *Uses of Matlab software to size intrinsic safety* 

EQUIPMENT (EEETE '10), ISBN: 978-960-474-181-6, Bucharest, Romania Niculescu, T.; Niculescu, M. (2010). *The study of fundamental electrical circuits transitory* 

Ghinea, M.; Firţeanu, V. (1999*). MATLAB calcul numeric, grafică, aplcatii,* Teora, ISBN 973-601-

Halunga-Fratu, S.; Fratu, O. (2004) *Simularea sistemelor de transmisiune analogice şi digitale* 

Tudorache, T. (2006). *Medii de calcul in ingineria electrica MATLAB,* MatrixRom, ISBN 973-

Niculescu, T.;Costinaş, S. (1998) *Electrotehnică,* Printech, ISBN 973-9402-14-3, Bucharest,

ComputerEngineering, ISSN 1842-4449 Petrosani, Romania

*Barriers of the electric equipment intended for use in atmospheres with explosion hazard*,Main Page of the Journal WSEAS TRANSACTIONS on CIRCUITS and

*barriers of the electric equipment intended for use in atmospheres with explosion,*  International Conference on ENERGY and ENVIRONME TECHNOLOGIES and

*Phenomena using MATLAB software, UNIVERSITARIA SIMPRO*  ElectricalEngineering and Energetics System Control, Applied Informatics and

*folosind mediul MATLAB/SIMULINK,* MatrixRom, ISBN 973-685-716-6, Bucharest,

circuits, the simulating model is conceived on a differential equations system.

This study intends to be a starting point in the approach of more complex circuits.

Nichols diagrams and others.

SYSTEMS, ISSN: 1109-2734,

275-1, Bucharest, Romania

775-005-6, Bucharest, Romania

Romania

Romania

**6. References** 

For successful understanding of the signal transmission in access networks that utilized fixed transmission media, it is necessary exactly to recognize essential negative influences in the real environment of metallic homogeneous symmetric lines, power distribution cables and optical fibers. This chapter discusses features and frequency characteristics of negative influences on signals transmitted by means of the VDSL technology, the PLC technology and PON networks. For the expansion of communication systems on fixed transmission media, it is necessary to have a detailed knowledge of their transmission environments and negative influences in the real developing of customer installations.

A main attention of the metallic transmission media's parts is focused on the description of the proposed VDSL and PLC simulation models and on the explanation of simulation methods for substantial negative influences. Presented simulation models represent a reach enough knowledgebase for the extended digital signal processing techniques of the VDSL and PLC signal transmissions that can be extremely helpful for various tests and performance comparisons.

A main attention of the optical transmission media's part is focused on the description of the proposed optical fiber's simulation model and on the explanation of simulation methods for its substantial linear effects - transmission factors. The presented simulation model represents a reach enough knowledgebase that can be helpful for various tests and performance comparisons of various novel modulation techniques suggested and intended to be used at signal transmissions in the transmission environment of optical fibers.

## **2. The environment of metallic homogeneous lines**

## **2.1 Linear negative influences on transmitted signals**

Propagation loss and linear distortions (distortions of the module and the phase characteristics and the group delay characteristic) are linear negative influences dependent on physical and constructional parameters, such as a line length, a core diameter of the wire, a mismatch of impedances in cross-connecting points of sections, a frequency bandwidth and so forth (Róka, 2004).

We first discuss the propagation loss *LdB* in a perfectly terminated line. If *R*, *L*, *G* and *C* are primary constants of the line and = *2..f*, where *f* is the frequency, then

Fixed Transmission Media 43

 

The term "crosstalk" generally refers to the interference that enters a communication channel through some coupling paths. On Fig. 1, a kind of generating and propagating of

At the input of pair *j*, the information signal *us (t)* is generated. This signal, when propagating through the line, can generate two types of crosstalk signals arising in pair *i*. A crosstalk signal *xNEXT (t)* is called the near-end crosstalk NEXT. A crosstalk signal *xFEXT (t)* is called the far-end crosstalk FEXT. From a data communication point of view, the NEXT crosstalk is generally more damaging than the FEXT crosstalk, because the NEXT does not necessarily propagate through the line length and thus does not experience a propagation

If either single or multiple interferers generate a crosstalk signal, we can define a gain of the NEXT crosstalk path according to (Werner, 1991), (Róka, 2002, 2004) using a following

> 2 2 2 3 4. ( ). /2 . . (, ) <sup>1</sup> . ( ) *NEXT f l*

2 22 2. ( ). 2 2 ( , ) 4. . . . . . .3280. . ( , ) *f l FEXT FEXT FEXT l f f k le K l f l f* 

where variables are given as *KFEXT* = 3,083.10-20, *l* is the line length in km, *f* is the frequency in Hz and **H** (*l*, *f*) expresses the transfer function of a metallic homogeneous symmetric line.

**H H** (9)

**H** (8)

 *(*

*f* . We can also derive a gain of the FEXT crosstalk path

*)* of the propagation

*NEXT NEXT f k l f e Kf <sup>f</sup>*

where variables are given as *KNEXT* = 0,882.10-14.*Nd*0,6, *Nd* is the number of disturbing pairs (disturbers), *f* is the frequency in Hz. An approximation on the right in (8) is valid when the

line length *l* is large and for frequency regions where the real part

in a similar manner using a following relation

*<sup>e</sup>* ≈ 

( ) ( ) ( ) ( ) *<sup>e</sup>*

 

*d*

*e* and the phase delay

= 5,4 s/km.

*d* (7)

are approximately

 

Fig. 1. Types of crosstalks in the environment of metallic homogeneous lines

At higher frequencies, the group envelope delay

**2.2 Near-end and far-end crosstalk signals** 

loss of the signal (Werner, 1991).

constant is proportional to

relation

frequency-independent and equal to the value about

two crosstalk types in a multipair cable is presented.

$$\gamma'(o) = \alpha(o) + j. \; \beta(o) = \sqrt{(R+j.o.L). (G+j.o.C)} \tag{1}$$

and

$$\mathcal{Z}\left(\boldsymbol{\alpha}\right) = \sqrt{\frac{\left(\boldsymbol{R} + \boldsymbol{j}.\,\boldsymbol{\alpha}.\,\boldsymbol{L}\right)}{\left(\boldsymbol{G} + \boldsymbol{j}.\,\boldsymbol{\alpha}.\,\boldsymbol{C}\right)}}\tag{2}$$

where  *()* denotes the propagation constant of the line,  *()* is the specific constant of the attenuation,  *()* is the specific constant of the phase shift and **Z** *()* is the characteristic impedance of the line. For a perfectly terminated line with the length *l*, the transfer function **H** (*l*, *f*) of metallic homogeneous symmetric lines is given by

$$\mathcal{H}(l,f) = e^{-l.\gamma(f)} = e^{-l.\alpha(f)} \cdot e^{-j.l.\beta(f)} \tag{3}$$

and the propagation loss *LdB* is given as

$$\left| L\_{dB}(l,f) = -20.\log\_{10} \left| \mathcal{M}(l,f) \right| = \frac{20}{\ln 10}.l.\alpha(f) = a\_{\text{line}}(l,f) \left[ d\mathcal{B} \right] \tag{4}$$

We must place emphasis on the interchangeable use of terms - the line attenuation *aline (l, f)*  and the propagation loss *LdB (l, f)* to designate the quantity in (4) only for the case of a perfectly terminated line. We can see that a dependency of the propagation loss *LdB* on the line length *l* is linear and is also an increasing function of the frequency *f* as should be apparent from the expression for the propagation constant  *()* in (1). A power level of transmitted signals is also influenced by other important parameters - a diameter and constructional material of the core.

For lower frequency regions, for which *.L << R* is valid and *G* can be neglected, the propagation constant expressed in (1) can be simplified to

$$\gamma(o) \approx \sqrt{\frac{o o.R.C}{2}} \cdot \left[1 - \frac{o o.L}{2.R}\right] + j \cdot \sqrt{\frac{o o.R.C}{2}} \cdot \left[1 + \frac{o o.L}{2.R}\right] \tag{5}$$

For frequencies less than 20 kHz, both the real and imaginary parts  *()* and  *()* are approximately proportional to *f* . At higher frequencies, frequency dependencies of the primary constants *R* and *L* (except for *C*) become noticeable and the propagation constant in (1) can be approximated by

$$\gamma(o) \approx \frac{R(o)}{2} \cdot \sqrt{\frac{C}{L(o)}} + j \cdot o \cdot \sqrt{C \cdot L(o)}\tag{6}$$

In this case, the imaginary part  *()* is approximately a linear function of the frequency. Major variations for the real part  *()* are due to the frequency dependency of *R*, which becomes proportional to *f* . because of the skin effect. Therefore, it is necessary to take into account increased signal attenuation in the area of higher frequencies.

The phase and envelope *<sup>e</sup>* delays of the line can be expressed as following

( . .) ( ) ( ..) *Rj L Gj C* 

impedance of the line. For a perfectly terminated line with the length *l*, the transfer function

. ( ) . ( ) .. ( ) (, ) . *<sup>l</sup> <sup>f</sup> <sup>l</sup> f j <sup>l</sup> <sup>f</sup> lf e e e* 

<sup>20</sup> ( , ) 20.log ( , ) . . ( ) ( , )[ ] <sup>10</sup> ln 10 *L l <sup>f</sup> <sup>l</sup> <sup>f</sup> <sup>l</sup> <sup>f</sup> a l <sup>f</sup> dB dB line* **<sup>H</sup>**

We must place emphasis on the interchangeable use of terms - the line attenuation *aline (l, f)*  and the propagation loss *LdB (l, f)* to designate the quantity in (4) only for the case of a perfectly terminated line. We can see that a dependency of the propagation loss *LdB* on the line length *l* is linear and is also an increasing function of the frequency *f* as should be

transmitted signals is also influenced by other important parameters - a diameter and

.. . .. . ( ) .1 . .1 2 2. 2 2.

approximately proportional to *f* . At higher frequencies, frequency dependencies of the primary constants *R* and *L* (except for *C*) become noticeable and the propagation constant in

> ( ) () . . . .() 2 () *<sup>R</sup> <sup>C</sup> j CL <sup>L</sup>*

becomes proportional to *f* . because of the skin effect. Therefore, it is necessary to take

*<sup>e</sup>* delays of the line can be expressed as following

 

(6)

*)* is approximately a linear function of the frequency.

*)* are due to the frequency dependency of *R*, which

*RC L RC L <sup>j</sup> R R*

*)* is the specific constant of the phase shift and **Z** *(*

 

 

**Z** (2)

*)* is the specific constant of the

*)* is the characteristic

(4)

*)* in (1). A power level of

(5)

( ) ( ) . ( ) ( . . ).( . . ) *j Rj LGj C* (1)

 *(*

 **H** (3)

> *(*

> >

*.L << R* is valid and *G* can be neglected, the

 *()* and  *()* are

 

*)* denotes the propagation constant of the line,

**H** (*l*, *f*) of metallic homogeneous symmetric lines is given by

apparent from the expression for the propagation constant

propagation constant expressed in (1) can be simplified to

 

 *(*

> *(*

into account increased signal attenuation in the area of higher frequencies.

For frequencies less than 20 kHz, both the real and imaginary parts

 

and

where  *(*

attenuation,

 *(*

and the propagation loss *LdB* is given as

constructional material of the core.

(1) can be approximated by

In this case, the imaginary part

The phase

Major variations for the real part

and envelope

For lower frequency regions, for which

 

$$
\tau\_{\phi} \text{ (}\phi\text{)} = \sqrt{\frac{\beta \left(\alpha\right)}{\alpha}} \qquad \tau\_{e} \text{ (}\alpha\text{)} = \sqrt{\frac{d\beta \left(\alpha\right)}{d\alpha}} \tag{7}
$$

At higher frequencies, the group envelope delay *e* and the phase delay are approximately frequency-independent and equal to the value about *<sup>e</sup>* ≈ = 5,4 s/km.

#### **2.2 Near-end and far-end crosstalk signals**

The term "crosstalk" generally refers to the interference that enters a communication channel through some coupling paths. On Fig. 1, a kind of generating and propagating of two crosstalk types in a multipair cable is presented.

Fig. 1. Types of crosstalks in the environment of metallic homogeneous lines

At the input of pair *j*, the information signal *us (t)* is generated. This signal, when propagating through the line, can generate two types of crosstalk signals arising in pair *i*. A crosstalk signal *xNEXT (t)* is called the near-end crosstalk NEXT. A crosstalk signal *xFEXT (t)* is called the far-end crosstalk FEXT. From a data communication point of view, the NEXT crosstalk is generally more damaging than the FEXT crosstalk, because the NEXT does not necessarily propagate through the line length and thus does not experience a propagation loss of the signal (Werner, 1991).

If either single or multiple interferers generate a crosstalk signal, we can define a gain of the NEXT crosstalk path according to (Werner, 1991), (Róka, 2002, 2004) using a following relation

$$\left| \left| \mathfrak{M}\_{\rm NEX}(l\_{\prime}f) \right| \right|^{2} = \frac{\pi^{2} \cdot f^{2} \cdot k\_{\rm NEX}}{a(f)} \left[ 1 - e^{-4.a(f) \cdot l} \right] \approx K\_{\rm NEX} \cdot f^{3/2} \tag{8}$$

where variables are given as *KNEXT* = 0,882.10-14.*Nd*0,6, *Nd* is the number of disturbing pairs (disturbers), *f* is the frequency in Hz. An approximation on the right in (8) is valid when the line length *l* is large and for frequency regions where the real part  *()* of the propagation constant is proportional to *f* . We can also derive a gain of the FEXT crosstalk path in a similar manner using a following relation

$$\left| \left| \mathfrak{M}\_{\text{FEXT}}(l, f) \right| ^2 = 4 \cdot \pi^2 \cdot f^2 \cdot k\_{\text{FEXT}} \cdot l \cdot e^{-2a(f) \cdot l} \approx K\_{\text{FEXT}} \cdot l \cdot 3280 \cdot f^2 \cdot \left| \mathfrak{M} \left( l, f \right) \right|^2 \tag{9}$$

where variables are given as *KFEXT* = 3,083.10-20, *l* is the line length in km, *f* is the frequency in Hz and **H** (*l*, *f*) expresses the transfer function of a metallic homogeneous symmetric line.

Fixed Transmission Media 45

The lower frequency *fLOW* is given by the spectral compatibility with narrowband services POTS and BA ISDN. The VDSL frequency plan depends on installation variations, on crosstalks from different sources and on the existence of narrowband services. Therefore, PSD masks of the VDSL signal are defined on the base of specific criteria. By (ETSI, 1999, 2001), we can discriminate between the VDSL deployment with or without the existence of narrowband services in the same cable and with or without the possibility for creating frequency apertures. The FTTEx variation seems to be the most probably variation of the VDSL deployment scenario where the line termination transceiver is placed in the central office exchange. Therefore, in our analysis, we used the FTTEx power spectral density mask. A graphical representation of the selected variation is shown on Fig. 3. If necessary, it is

possible to assign any other standard spectral mask for the considered VDSL signal.

Fig. 3. The PSD mask of the VDSL signal for the FTTEx variation with narrowband services

Because crosstalk signals from the POTS service in disturbing pairs don't have significant influences on the VDSL signal in the disturbed pair, we supposed both disturbing and disturbed signals to have the same power spectral densities *PSD1 (f)* = *PSD2 (f)*. This situation is happened when in neighboring pairs are also VDSL signals – we can talk about

For local subscriber loops, we assigned the power spectral density of NEXT and FEXT

2 23/2 *PSD f PSD f l f NEXT* ( ) ( ). ( , ) , ( , ) . *NEXT NEXT NEXT* **H H** *lf K f* (10)

0.6 <sup>49</sup> . <sup>10</sup> *d*

*<sup>N</sup> K K* (12)

2 2 22 ( ) ( ). ( , ) , ( , ) . .3280. . ( , ) *PSD f PSD f l f FEXT FEXT FEXT FEXT* **H H** *lf K l f lf* **H** (11)

Equations (10) – (11) allow very well approximation of practically observed kind of multiple interferer crosstalks. Before starting of the simulation, we determined values of variables *KNEXT* and *KFEXT* in the simulation model as a function of the number of disturbing pairs *Nd*

*NEXT NEXT*

**2.5 Spectral characteristics of near-end and far-end crosstalk signals** 

the self-NEXT crosstalk and the self-FEXT crosstalk.

where variables *KNEXT* and *KFEXT* are functions of disturbed pairs.

crosstalks using relations (8) and (9) as follows

and the ADSL presence

for typical 50-pairs cable as

## **2.3 Impulse noise signal**

Due to the important effect of this negative influence, we took into account also this type of noise. The most common and the most damaging type of impulse noise seems to occur when a disturbed pair shares a common cable sheath with switched disturbing pairs – that is usual in the local access network. Sharp voltage changes can occur on analog pairs because of the opening and closing of relays. These voltage changes when are coupled into neighboring pairs through the NEXT and FEXT coupling path, create spurious, impulsivelike voltages whose amplitudes can be quite significant (Werner, 1991).

In unshielded twisted pairs, various equipments and environmental disturbances such as signaling circuits, transmission and switching gear, electrostatic discharges, lightning surges and so forth can generate an impulse noise. The impulse noise has some reasonably welldefined characteristics. Features of the typical impulse noise can be summarized as follows:


Of course, mentioned features don't characterize all possible impulse noise signals. In the simulation model, therefore, characteristics of the impulse noise signal can be randomly varied.

## **2.4 Spectral characteristics of the VDSL signals**

The VDSL modem uses a frequency bandwidth up to 20MHz. From this reason, the VDSL transmitter must solve situations that are not emergent in other xDSL modems. To these problems belong a spectral compatibility and cooperation with installed xDSL systems and a high level of different crosstalk signals.

In VDSL modems, various types of duplex methods and proposed modulation techniques are considered in (Cherubini et al., 2000), (Mestagh et al., 2000) and (Oksman & Werner, 2000). The ETSI recommendation binds producers to keep an established frequency plan (European Telecommunications Standards Institute [ETSI], 1999). The VDSL system can work in a frequency band bounded by frequencies *fLOW* and *fHIGH* (Fig. 2). In given frequency areas, the power of the VDSL signal must be adjusted to a level that can ensure the spectral compatibility with older xDSL systems. Alike, the signal level must be decreased to obviate undesirable emissions RFI, concretely caused by amateur radio stations.

Fig. 2. The general frequency plan for the VDSL system

Due to the important effect of this negative influence, we took into account also this type of noise. The most common and the most damaging type of impulse noise seems to occur when a disturbed pair shares a common cable sheath with switched disturbing pairs – that is usual in the local access network. Sharp voltage changes can occur on analog pairs because of the opening and closing of relays. These voltage changes when are coupled into neighboring pairs through the NEXT and FEXT coupling path, create spurious, impulsive-

In unshielded twisted pairs, various equipments and environmental disturbances such as signaling circuits, transmission and switching gear, electrostatic discharges, lightning surges and so forth can generate an impulse noise. The impulse noise has some reasonably welldefined characteristics. Features of the typical impulse noise can be summarized as follows:

Of course, mentioned features don't characterize all possible impulse noise signals. In the simulation model, therefore, characteristics of the impulse noise signal can be randomly

The VDSL modem uses a frequency bandwidth up to 20MHz. From this reason, the VDSL transmitter must solve situations that are not emergent in other xDSL modems. To these problems belong a spectral compatibility and cooperation with installed xDSL systems and

In VDSL modems, various types of duplex methods and proposed modulation techniques are considered in (Cherubini et al., 2000), (Mestagh et al., 2000) and (Oksman & Werner, 2000). The ETSI recommendation binds producers to keep an established frequency plan (European Telecommunications Standards Institute [ETSI], 1999). The VDSL system can work in a frequency band bounded by frequencies *fLOW* and *fHIGH* (Fig. 2). In given frequency areas, the power of the VDSL signal must be adjusted to a level that can ensure the spectral compatibility with older xDSL systems. Alike, the signal level must be decreased to obviate

like voltages whose amplitudes can be quite significant (Werner, 1991).

occurs about 1-5 times per minute (on an average 4 times per minute),

undesirable emissions RFI, concretely caused by amateur radio stations.

Fig. 2. The general frequency plan for the VDSL system

has peak values in the range 2 - 33 mV,

has time duration in the range 30 - 150 s.

has most of its energy concentrated below 40 kHz,

**2.4 Spectral characteristics of the VDSL signals** 

a high level of different crosstalk signals.

**2.3 Impulse noise signal** 

varied.

The lower frequency *fLOW* is given by the spectral compatibility with narrowband services POTS and BA ISDN. The VDSL frequency plan depends on installation variations, on crosstalks from different sources and on the existence of narrowband services. Therefore, PSD masks of the VDSL signal are defined on the base of specific criteria. By (ETSI, 1999, 2001), we can discriminate between the VDSL deployment with or without the existence of narrowband services in the same cable and with or without the possibility for creating frequency apertures. The FTTEx variation seems to be the most probably variation of the VDSL deployment scenario where the line termination transceiver is placed in the central office exchange. Therefore, in our analysis, we used the FTTEx power spectral density mask. A graphical representation of the selected variation is shown on Fig. 3. If necessary, it is possible to assign any other standard spectral mask for the considered VDSL signal.

Fig. 3. The PSD mask of the VDSL signal for the FTTEx variation with narrowband services and the ADSL presence

#### **2.5 Spectral characteristics of near-end and far-end crosstalk signals**

Because crosstalk signals from the POTS service in disturbing pairs don't have significant influences on the VDSL signal in the disturbed pair, we supposed both disturbing and disturbed signals to have the same power spectral densities *PSD1 (f)* = *PSD2 (f)*. This situation is happened when in neighboring pairs are also VDSL signals – we can talk about the self-NEXT crosstalk and the self-FEXT crosstalk.

For local subscriber loops, we assigned the power spectral density of NEXT and FEXT crosstalks using relations (8) and (9) as follows

$$PSD\_{\rm NEXT}(f) = PSD(f) \cdot \left| \mathcal{H}\_{\rm NEX}(l, f) \right|^2, \ \left| \mathcal{H}\_{\rm NEX}(l, f) \right|^2 \approx K\_{\rm NEX} \cdot f^{3/2} \tag{10}$$

$$PSD\_{\rm FET}(f) = PSD(f) \cdot \left| \mathcal{H}\_{\rm FET}(l, f) \right|^2 / \left| \mathcal{H}\_{\rm FET}(l, f) \right|^2 \approx K\_{\rm FET} . 1.3280 . f^2 \cdot \left| \mathcal{H} \left(l, f\right) \right|^2 \tag{11}$$

where variables *KNEXT* and *KFEXT* are functions of disturbed pairs.

Equations (10) – (11) allow very well approximation of practically observed kind of multiple interferer crosstalks. Before starting of the simulation, we determined values of variables *KNEXT* and *KFEXT* in the simulation model as a function of the number of disturbing pairs *Nd* for typical 50-pairs cable as

$$K\_{NEXT} = K\_{NEXT-49} \cdot \frac{N\_d^{0.6}}{10} \tag{12}$$

Fixed Transmission Media 47

Inverse precoder Demodulator QAM demapp./

The transmitted message carried to the receiving part is generated as a random binary chain with the given length. This message is also saved (for the BER calculation), encoded by a particular type of the FEC codes (RS, BCH) and modulated. It can be chosen from two kinds of modulations - the first one is the classical QAM modulation and the second one is a combination of the QAM and the convolutional coding, i.e. the TCM. The QAM modulation is chosen because of its compatibility with considered precoding techniques, a low distortion resistance and an easy implementation in the Matlab program environment.

Utilizing of local subscriber loops for the broadband access of subscribers by means of the VDSL technology assumes a replacing of the significant part of metallic lines by optical fibers. This will bring a subscriber distribution point (SDP) unit closer to subscribers, when metallic lines will distribute signals to subscriber premises. Although metallic lines will comprise only a small part of the transmission path, their influences on transmitted signals

Negative influences of the VDSL environment at the signal transmission depend on parameters of metallic homogeneous lines (a core material, a cable insulation, a core diameter, a number of neighboring lines in the cable binder, a cable length). If we want to achieve exact results from simulations, all these factors must be accepted. Of course, this acceptance leads to a complicated and complex simulation model. For modeling of all these influences, a theoretical description together with simulation methods is introduced (Róka & Cisár, 2002).

PSD filter of transmitter

PSD filter of transmitter

Viterbi decoder

Receiving part

Precoder, Modulator

line Transmitting part

NEXT coupling

FEXT coupling

Transmit Filter

> D i s t u r b i n g p a i r

D i s t u r b e d p a i r

+ White noise

Metallic homogenous

+ Impulse noise

+ Radio interference

+

Noise generator

Noise generator

coder

Data source FEC

BER

Recipient FEC

**3.2 The transmission line** 

will not negligible.

decoder

**3.1 The transmitting part of the model** 

Fig. 4. The block scheme of the VDSL simulation model

$$K\_{EXT} = K\_{EXT-49} \frac{N\_d^{0.6}}{10} \tag{13}$$

The value of the *KNEXT-49* variable is given as 8,8.10-14, the value of the *KFEXT-49* variable is empirically estimated as 8.10-20/3280 (Aslanis & Cioffi, 1992).

## **3. The simulation model for the VDSL technology**

For considering of the signal transmission on metallic homogeneous lines by means of the VDSL technology, it is necessary comprehensively to know characteristics of negative environmental influences and features of applied modulation techniques. It is difficult to realize of the exact analytical description of complex systems such as the VDSL system in the real environment of local access networks. In addition, due to dynamical natures of some processes, it is not suitable. For analyzing of various signal processing techniques used by the VDSL technologies, a suitable and flexible enough tool are computer simulations and modeling schemes of real environmental conditions at the signal transmission.

For modeling of the VDSL transmission path, we used the software program *Matlab* together with additional libraries like *Signal Processing Toolbox* and *Communication Toolbox*. A proposed and realized modeling scheme represents a transmission of high-speed data signals in downstream and upstream directions by means of the VDSL technology utilizing of metallic homogeneous lines. The realized model (Fig. 4) represents the signal transmission in the VDSL environment utilizing metallic homogenous lines for high-speed data signals in the downstream and upstream direction. This VDSL environment model is the enhanced version of the ADSL environment model introduced (Róka & Cisár, 2002). New features of this simulation model are VDSL transmission characteristics and applications of precoding techniques and trellis coded modulations.

Basic functional blocks realized in our simulation model are shown on Fig. 4. The VDSL simulation model (Fig. 4) can be divided into the three main parts:


The analysis can be based on computer simulations that cover the most important features and characteristics of the real transmission environment for the VDSL technology and result in searching for the best combination of coding and precoding techniques.

The value of the *KNEXT-49* variable is given as 8,8.10-14, the value of the *KFEXT-49* variable is

For considering of the signal transmission on metallic homogeneous lines by means of the VDSL technology, it is necessary comprehensively to know characteristics of negative environmental influences and features of applied modulation techniques. It is difficult to realize of the exact analytical description of complex systems such as the VDSL system in the real environment of local access networks. In addition, due to dynamical natures of some processes, it is not suitable. For analyzing of various signal processing techniques used by the VDSL technologies, a suitable and flexible enough tool are computer simulations and modeling schemes of real environmental conditions at the signal

For modeling of the VDSL transmission path, we used the software program *Matlab* together with additional libraries like *Signal Processing Toolbox* and *Communication Toolbox*. A proposed and realized modeling scheme represents a transmission of high-speed data signals in downstream and upstream directions by means of the VDSL technology utilizing of metallic homogeneous lines. The realized model (Fig. 4) represents the signal transmission in the VDSL environment utilizing metallic homogenous lines for high-speed data signals in the downstream and upstream direction. This VDSL environment model is the enhanced version of the ADSL environment model introduced (Róka & Cisár, 2002). New features of this simulation model are VDSL transmission characteristics and

Basic functional blocks realized in our simulation model are shown on Fig. 4. The VDSL

1. A transmitting part - it is responsible for the encoding (using the FEC technique) and for the modulation of signals into a form suitable for the transmission channel. 2. A transmission channel (the metallic homogenous line) - this part of the model realized negative influences on the transmitted signal. Above all, it goes about a propagation loss, a signal distortion, crosstalk noises, white and impulse noises, the radio interference. Because these negative influences expressively interfere into the communication and represent its main limiting factors, they present a critical part of the model and, therefore, it is necessary exactly to recognize and express their

3. A receiving part - it is conceptually inverted in a comparison with the transmitter. Its main functions are the signal amplification, the removing of the ISI, the demodulation

The analysis can be based on computer simulations that cover the most important features and characteristics of the real transmission environment for the VDSL technology and result

in searching for the best combination of coding and precoding techniques.

*FEXT FEXT*

empirically estimated as 8.10-20/3280 (Aslanis & Cioffi, 1992).

**3. The simulation model for the VDSL technology** 

applications of precoding techniques and trellis coded modulations.

simulation model (Fig. 4) can be divided into the three main parts:

characteristics by correct parameters.

and the correction of errored information bits.

transmission.

0.6

*<sup>N</sup> K K* (13)

<sup>49</sup> 10 *d*

Fig. 4. The block scheme of the VDSL simulation model

## **3.1 The transmitting part of the model**

The transmitted message carried to the receiving part is generated as a random binary chain with the given length. This message is also saved (for the BER calculation), encoded by a particular type of the FEC codes (RS, BCH) and modulated. It can be chosen from two kinds of modulations - the first one is the classical QAM modulation and the second one is a combination of the QAM and the convolutional coding, i.e. the TCM. The QAM modulation is chosen because of its compatibility with considered precoding techniques, a low distortion resistance and an easy implementation in the Matlab program environment.

## **3.2 The transmission line**

Utilizing of local subscriber loops for the broadband access of subscribers by means of the VDSL technology assumes a replacing of the significant part of metallic lines by optical fibers. This will bring a subscriber distribution point (SDP) unit closer to subscribers, when metallic lines will distribute signals to subscriber premises. Although metallic lines will comprise only a small part of the transmission path, their influences on transmitted signals will not negligible.

Negative influences of the VDSL environment at the signal transmission depend on parameters of metallic homogeneous lines (a core material, a cable insulation, a core diameter, a number of neighboring lines in the cable binder, a cable length). If we want to achieve exact results from simulations, all these factors must be accepted. Of course, this acceptance leads to a complicated and complex simulation model. For modeling of all these influences, a theoretical description together with simulation methods is introduced (Róka & Cisár, 2002).

Fixed Transmission Media 49

The influence of the transmission channel that we can derive from its transmission function is expressed above all at the attenuation of the transmitted signal. The signal attenuation is more accentuated for areas of higher frequency components of power spectral density characteristics. This influence is more expensive for longer line lengths. However, we can find out that the influence is decreased with increasing of the core diameter of wires. This results from a change of values for the primary constant of the line, concretely *R* and *L*.

We can create the NEXT crosstalk noise signal by forming of the white noise spectrum (with constant PSD = 0 dB/Hz) that is generated by a random number generator. First, we must calculate a frequency characteristic of the **H***NEXT* (*l*, *f*) crosstalk transmission function using (8). Its parameters are the number of disturbing pairs and the appropriate value of the variable *KNEXT*. On Fig. 6, the NEXT crosstalk transmission function for various numbers of disturbers is presented. For modeling of the NEXT negative influence, the NEXT crosstalk noise signal acquired by filtering is added to the transmitted signal entering the

The FEXT crosstalk signal is created in a similar manner as the NEXT crosstalk signal (its spectrum is presented on Fig. 6). Because this type of a crosstalk must be propagated through a disturbing line, we included into calculating the **H***FEXT* (*l*, *f*) crosstalk transmission function also the transmission function of the line **H** (*l*, *f*) using (9) with given parameters. The FEXT crosstalk signal is added to the transmitted information signal attenuated at

> Nd = 49 Nd = 25 Nd = 1

0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 **f (MHz)**

Fig. 6. The frequency characteristic of NEXT and FEXT crosstalk transmission functions for


0 -220

**HFEXT (dB)**

The influence of the FEXT crosstalk transmission function is characterized by the power spectral density of the FEXT crosstalk signal and by the FEXT crosstalk path. This FEXT crosstalk path is depend on the line length, on the frequency of signal and on the transmission function of the transmission line because of propagating of crosstalk signals through the disturbing pair. For longer line lengths, the influence of the FEXT crosstalk can be neglected. On other side, this influence is accentuated at higher frequency components of the transmitted signal. Therefore, it is necessary to take into account of the FEXT crosstalk

a transmission through the metallic homogeneous line.

Nd = 49 Nd = 25 Nd = 1

transmission line.

various numbers of disturbers


**HNEXT (dB)**

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

**f (MHz)**

#### **3.3 The receiving part of the model**

At the receiver side, the distorted and attenuated signal is first amplified, next demodulated and then shifted into the inverse precoder that removes constellation changes introduced by the precoder at the transmitter side. If the TCM is used, the TCM decoder follows and the Viterbi algorithm is searching the most probably binary sequence. Otherwise, the QAM demapping block converts the constellation points sequence into the binary data sequence that is corrupted by transmission errors. They are consequently removed in the FEC decoder. Finally, the corrected sequence is compared with the original transmitted message and the bit error rate is calculated.

We should notice that individual precoding techniques suppose conceptually different manner of the signal regeneration, therefore this process is not here exactly described. For both methods, it is essential to know a transmission function of metallic lines. This information can be extracted from the signal transmission of predefined symbol sequences at the initialization process.

Before starting of the simulation, we can calculate the transmission function of the line for given parameters *(l, )*. Values of this function are sampled in equal proportioned frequency intervals in the range from 0 Hz up to the half of the sampling frequency (*fsamp /2*). A number of samples is optional. For signal processing, it is desirable to choice the number of samples equal to *2.N*, where *N* is an integer number. Using sampled values, the impulse characteristic of the transmission line *h (t)* is calculated using the inverse Fourier transformation with the same number of samples (from practical viewpoint, the number of 512 samples is adequate). This sampled impulse characteristic is used as coefficients for the digital filter. A simulation of the signal transmission through the line itself is executed by digital filtering of the sampled modulated signal using the proposed filter. On Fig. 5, there are shown frequency characteristics of the transmission line ( = 0,4 mm, Cu) for various line lengths.

Fig. 5. Frequency characteristics of the transmission line for various line lengths

At the receiver side, the distorted and attenuated signal is first amplified, next demodulated and then shifted into the inverse precoder that removes constellation changes introduced by the precoder at the transmitter side. If the TCM is used, the TCM decoder follows and the Viterbi algorithm is searching the most probably binary sequence. Otherwise, the QAM demapping block converts the constellation points sequence into the binary data sequence that is corrupted by transmission errors. They are consequently removed in the FEC decoder. Finally, the corrected sequence is compared with the original transmitted message

We should notice that individual precoding techniques suppose conceptually different manner of the signal regeneration, therefore this process is not here exactly described. For both methods, it is essential to know a transmission function of metallic lines. This information can be extracted from the signal transmission of predefined symbol sequences

Before starting of the simulation, we can calculate the transmission function of the line for

intervals in the range from 0 Hz up to the half of the sampling frequency (*fsamp /2*). A number of samples is optional. For signal processing, it is desirable to choice the number of samples equal to *2.N*, where *N* is an integer number. Using sampled values, the impulse characteristic of the transmission line *h (t)* is calculated using the inverse Fourier transformation with the same number of samples (from practical viewpoint, the number of 512 samples is adequate). This sampled impulse characteristic is used as coefficients for the digital filter. A simulation of the signal transmission through the line itself is executed by digital filtering of the sampled modulated signal using the proposed filter. On Fig. 5, there

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8

Fig. 5. Frequency characteristics of the transmission line for various line lengths

**f (MHz)**

*)*. Values of this function are sampled in equal proportioned frequency

l = 3.0 km l = 3.5 km l = 4.0 km l = 4.5 km l = 5.0 km

= 0,4 mm, Cu) for various

**3.3 The receiving part of the model** 

and the bit error rate is calculated.

are shown frequency characteristics of the transmission line (


**H (dB)**

at the initialization process.

given parameters *(l,* 

line lengths.

The influence of the transmission channel that we can derive from its transmission function is expressed above all at the attenuation of the transmitted signal. The signal attenuation is more accentuated for areas of higher frequency components of power spectral density characteristics. This influence is more expensive for longer line lengths. However, we can find out that the influence is decreased with increasing of the core diameter of wires. This results from a change of values for the primary constant of the line, concretely *R* and *L*.

We can create the NEXT crosstalk noise signal by forming of the white noise spectrum (with constant PSD = 0 dB/Hz) that is generated by a random number generator. First, we must calculate a frequency characteristic of the **H***NEXT* (*l*, *f*) crosstalk transmission function using (8). Its parameters are the number of disturbing pairs and the appropriate value of the variable *KNEXT*. On Fig. 6, the NEXT crosstalk transmission function for various numbers of disturbers is presented. For modeling of the NEXT negative influence, the NEXT crosstalk noise signal acquired by filtering is added to the transmitted signal entering the transmission line.

The FEXT crosstalk signal is created in a similar manner as the NEXT crosstalk signal (its spectrum is presented on Fig. 6). Because this type of a crosstalk must be propagated through a disturbing line, we included into calculating the **H***FEXT* (*l*, *f*) crosstalk transmission function also the transmission function of the line **H** (*l*, *f*) using (9) with given parameters. The FEXT crosstalk signal is added to the transmitted information signal attenuated at a transmission through the metallic homogeneous line.

Fig. 6. The frequency characteristic of NEXT and FEXT crosstalk transmission functions for various numbers of disturbers

The influence of the FEXT crosstalk transmission function is characterized by the power spectral density of the FEXT crosstalk signal and by the FEXT crosstalk path. This FEXT crosstalk path is depend on the line length, on the frequency of signal and on the transmission function of the transmission line because of propagating of crosstalk signals through the disturbing pair. For longer line lengths, the influence of the FEXT crosstalk can be neglected. On other side, this influence is accentuated at higher frequency components of the transmitted signal. Therefore, it is necessary to take into account of the FEXT crosstalk

Fixed Transmission Media 51

a chosen spectral mask. Alike, it is easy to keep frequency apertures in given subbands at occurrences of disturbing frequencies of the RFI type. Therefore, the MCM allows a high flexibility of the PSD transmitted signal and tries as effective as possible utilizations of the available bandwidth. We can therefore suppose that the transmitted VDSL signal will achieve maximum allowable levels in particular subchannels according to the FTTEx

On Fig. 7 and 8, results of PSD characteristics of VDSL signals for the line length 0,5 km, the core diameter 0,4 mm with 24 ADSL and 9 VDSL disturbers and with the FTTEx spectral mask are introduced. On Fig. 7, the power spectral density of the SCM signal, the AWGN noise and the FEXT crosstalk are considered at the end of the line. All these characteristics are attenuated from a reason of transmitting signals through metallic homogeneous lines and, therefore, their corrections are needed. We are also using a linear equalization process to eliminate influences of the intersymbol interference (ISI). We can imitate this process by a corrector in the frequency area with a transmission function inverted to a channel transmission function. This correction in the frequency area eliminates aftereffects of the nonlinear signal attenuation by amplifying of higher frequency components. However, the correction of the received signal amplifies also the influence of noises and interferences. On Fig. 8, the PSD of the SCM signal and the total noise adjusted by the corrector are specified.

<sup>0</sup> <sup>2</sup> <sup>4</sup> <sup>6</sup> <sup>8</sup> <sup>10</sup> <sup>12</sup> -140

Fig. 7. The PSD characteristics of the SCM signal, the FEXT crosstalk and the AWGN noise

<sup>0</sup> <sup>2</sup> <sup>4</sup> <sup>6</sup> <sup>8</sup> <sup>10</sup> <sup>12</sup> -120

Fig. 8. The PSD characteristics of the SCM signal and the total noise adjusted by the corrector

f [MHz]

f [MHz]

PSD of the total noise PSD of the SCM signal

PSD of the FEXT crosstalk PSD of the SCM signal PSD of the AWGN noise



PSD [dBm/Hz]

PSD [dBm/Hz]

attenuated at the end of the line

spectral mask (Fig. 3).

for the new VDSL technology transmitting signals of asymmetric services and application at very high bit rates of information signals and on very short distances because of occupying higher frequency bandwidths of metallic homogeneous lines.

## **3.4 The analysis of environmental influences on the VDSL signals**

At the analysis of the signal transmission through metallic homogeneous lines in the VDSL environment, we need to know three basic parameters - properties of the signal transmitted into the line (mainly its PSD), a transmission function of the transmission channel and features of the noise and crosstalk environmental influences.

In (Róka, 2002, 2004), particular relationships and frequency characteristics of basic noises and crosstalks occurred at the signal transmission through metallic homogeneous lines in the environment of xDSL technologies are introduced. The analysis of negative influences of noises and crosstalks on qualitative parameters of homogeneous lines can be extended to the VDSL environment. In our analysis, the NEXT crosstalk is not considered because this one can disable a communication in the VDSL frequency bandwidth. With respect to the possible VDSL deployments in conditions of the Slovak access network, we use a spectral mask defined for the FTTEx variation and for the coexistence with narrowband services in the same pair. In this spectral mask variation, the ADSL presence is supposed.

For the SCM modulation, four individual subbands are given alternatively for upstream and downstream directions of the transmission. Band transition frequencies are introduced in Tab. 1.


Table 1. Band transition frequencies for the SCM FDD subbands according to the ETSI

Using a transmission function of the raised cosine filter and on the base of known values of carrier frequencies and symbol rates for particular subbands (Tab. 1), we can express an ideal PSD characteristic of the SCM signal. A signal transmitted into the metallic homogeneous lines must comply with the defined FTTEx spectral mask, so that a spectrum of the ideal SCM signal from the modulator must be digitally adjusted using FIR filters before transmitting. From this adjusted PSD, moreover, frequency components equivalent to subbands allocated for amateur radio stations should be eliminated (ETSI, 1999). Using appropriate FIR filters, the SCM signal can be also adjusted with respect to other FTTx spectral masks.

For the MCM modulation, a way to form the PSD of the signal transmitted from the transmitter is defined in the ETSI standard (ETSI, 2001). After simplifying, it is multiplying of every complex coefficient **Z***i* = *Xi* + *j.Yi* by a constant *gi* and resulting complex coefficients **Z***i'* = *gi* . **Z***<sup>i</sup>* enter into the IFFT block. By this way, the transmitter can easy adapt any PSD characteristic of the transmitted VDSL signal for satisfying demands that are established by

for the new VDSL technology transmitting signals of asymmetric services and application at very high bit rates of information signals and on very short distances because of occupying

At the analysis of the signal transmission through metallic homogeneous lines in the VDSL environment, we need to know three basic parameters - properties of the signal transmitted into the line (mainly its PSD), a transmission function of the transmission channel and

In (Róka, 2002, 2004), particular relationships and frequency characteristics of basic noises and crosstalks occurred at the signal transmission through metallic homogeneous lines in the environment of xDSL technologies are introduced. The analysis of negative influences of noises and crosstalks on qualitative parameters of homogeneous lines can be extended to the VDSL environment. In our analysis, the NEXT crosstalk is not considered because this one can disable a communication in the VDSL frequency bandwidth. With respect to the possible VDSL deployments in conditions of the Slovak access network, we use a spectral mask defined for the FTTEx variation and for the coexistence with narrowband services in

For the SCM modulation, four individual subbands are given alternatively for upstream and downstream directions of the transmission. Band transition frequencies are introduced in

> *f2* [kHz]

VDSL subbands 138 3000 5100 7050 12000 Optional subbands 138 3750 5200 8500 12000 - The utilization of frequencies below *f1* and above *f5* but within the overall PSD masks is

Table 1. Band transition frequencies for the SCM FDD subbands according to the ETSI

Using a transmission function of the raised cosine filter and on the base of known values of carrier frequencies and symbol rates for particular subbands (Tab. 1), we can express an ideal PSD characteristic of the SCM signal. A signal transmitted into the metallic homogeneous lines must comply with the defined FTTEx spectral mask, so that a spectrum of the ideal SCM signal from the modulator must be digitally adjusted using FIR filters before transmitting. From this adjusted PSD, moreover, frequency components equivalent to subbands allocated for amateur radio stations should be eliminated (ETSI, 1999). Using appropriate FIR filters, the SCM signal can be also adjusted with respect to other FTTx

For the MCM modulation, a way to form the PSD of the signal transmitted from the transmitter is defined in the ETSI standard (ETSI, 2001). After simplifying, it is multiplying of every complex coefficient **Z***i* = *Xi* + *j.Yi* by a constant *gi* and resulting complex coefficients

characteristic of the transmitted VDSL signal for satisfying demands that are established by

*<sup>i</sup>* enter into the IFFT block. By this way, the transmitter can easy adapt any PSD

*f3* [kHz]

*f4* [kHz]

*f5* [kHz]

higher frequency bandwidths of metallic homogeneous lines.

features of the noise and crosstalk environmental influences.

Tab. 1.

spectral masks.

**Z***i'* = *gi* . **Z**

Band transition frequencies

possible but is not covered (ETSI, 2001).

**3.4 The analysis of environmental influences on the VDSL signals** 

the same pair. In this spectral mask variation, the ADSL presence is supposed.

*f1* [kHz] a chosen spectral mask. Alike, it is easy to keep frequency apertures in given subbands at occurrences of disturbing frequencies of the RFI type. Therefore, the MCM allows a high flexibility of the PSD transmitted signal and tries as effective as possible utilizations of the available bandwidth. We can therefore suppose that the transmitted VDSL signal will achieve maximum allowable levels in particular subchannels according to the FTTEx spectral mask (Fig. 3).

On Fig. 7 and 8, results of PSD characteristics of VDSL signals for the line length 0,5 km, the core diameter 0,4 mm with 24 ADSL and 9 VDSL disturbers and with the FTTEx spectral mask are introduced. On Fig. 7, the power spectral density of the SCM signal, the AWGN noise and the FEXT crosstalk are considered at the end of the line. All these characteristics are attenuated from a reason of transmitting signals through metallic homogeneous lines and, therefore, their corrections are needed. We are also using a linear equalization process to eliminate influences of the intersymbol interference (ISI). We can imitate this process by a corrector in the frequency area with a transmission function inverted to a channel transmission function. This correction in the frequency area eliminates aftereffects of the nonlinear signal attenuation by amplifying of higher frequency components. However, the correction of the received signal amplifies also the influence of noises and interferences. On Fig. 8, the PSD of the SCM signal and the total noise adjusted by the corrector are specified.

Fig. 7. The PSD characteristics of the SCM signal, the FEXT crosstalk and the AWGN noise attenuated at the end of the line

Fig. 8. The PSD characteristics of the SCM signal and the total noise adjusted by the corrector

Fixed Transmission Media 53

also additional paths are used for a signal spreading. This multipath scenario can be easily

D

(3)

r3D

r3B

The line consists of three segments (A-B), (B-C) and (B-D) with lengths *l1*, *l2*, *l3* and characteristic impedances **Z***L1*, **Z***L2* and **Z***L3*. To simplify considerations, points A and C are assumed to be matched, which means **Z***A* = **Z***L1* and **Z***C* = **Z***L2*. Then, points B and D are reflection points with reflection factors are denoted as *r1B*, *r3D*, *r3B* and transmission factors are denoted as *t1B*, *t3B*. Because of multiple reflections, a number of propagation paths is infinitive (i.e., A → B → C, A → B → D → B → C, and so on). An affect of all reflections and transmissions can be expressed for each propagation path *i* in a form of the weighting factor *gi* that is mathematically equal to the product of reflection and transmission factors along the path. The value *gi* is always less or equal to one because all reflection and transmission factors can be only less or equal to one. The simulation model can be simplified if we approximate infinite number of paths by only *N* dominant paths and make *N* as small as possible. When more transmissions and reflections occur along the path, then the weighting factor will be smaller. When the longer path will be considered, then the signal contribution from this part to the overall signal spreading will be small due to the higher signal

Characteristics of the PLC transmission environment focused on the multipath signal propagation, the signal attenuation, the noise scenario and the electromagnetic compatibility are introduced in (Róka & Dlháň, 2005). First, we can present basic characteristics of the PLC

A total signal attenuation on the PLC channel consists of two parts: coupling losses (depending on a transmitter design) and line losses (very high and can range from 40 to 100 dB/km). To find a mathematical formulation for the signal attenuation, we have to start

> 

depending on the primary cable parameters *R, L, G, C*. Then, the frequency response of a transmission line **H** *(f)* (the transfer function) with the length *l* can be expressed as follows

   

*RjL GjC j* .. .. . (15)

  t3B

t1B

(1) (2)

C

explained by the example of a cable with one tap (Fig. 10).

A B

Fig. 10. The multipath signal propagation in the cable with one tap

attenuation (Ferreira et al., 2010).

with the complex propagation constant

(**U** *(x)* is the voltage at the distance *x*):

 

**4.2 The signal attenuation** 

channel.

r1B

On Fig. 9, results of PSD characteristics of the MCM signal, the AWGN noise and the FEXT crosstalk for the line length 0,5 km, the core diameter 0,4 mm with 24 ADSL and 9 VDSL disturbers and with the FTTEx spectral mask are introduced. A received signal is sampled and processed by the FFT block without a correction in the frequency area. Therefore, the SNR can be calculated in particular subchannels directly from the MCM signal power and the noise powers at the end of the line.

Fig. 9. The PSD characteristics of the MCM signal, the FEXT crosstalk and the AWGN noise attenuated at the end of the line

A sense of analyzing for environmental influences on the power spectral densities of VDSL signals is to identify all substantial noise resources and at the same time to determine a way for calculating of the signal-to-noise ratio for various proposed modulation techniques. For our following analysis of the VDSL system performance, the parameter *SNR* is very important. The signal-to-noise ratio for the subband given by the lowest *fLOW* and the highest *fHIGH* frequencies can be expressed as

$$\begin{aligned} \int\_{S\text{INR}}^{f\_{\text{HIGH}}} & PSD\_S\left(f\right) df\\ \text{SNR}\left(f\right) &= \frac{f\_{\text{LOW}}}{f\_{\text{HIGH}}}\\ & \int\_{f\_{\text{LOW}}}^{f} PSD\_N\left(f\right) df \end{aligned} \tag{14}$$

where *PSDS (f)* is the VDSL signal power spectral density and *PSDN (f)* is the noise power spectral density. The *SNR (f)* ratio must be calculated from the adjusted SCM signal power and the noise powers.

## **4. The environment of power distribution cables**

#### **4.1 The multipath signal propagation**

The PLC transmission channel has a tree-like topology with branches formed by additional wires tapered from the main path and having various lengths and terminated loads with highly frequency-varying impedances in a range from a few ohms to some kiloohms (Zimmermann & Dostert, 2002b), (Held, 2006). That's why the PLC signal propagation does not only take place along a direct line-of-sight path between a transmitter and a receiver but

On Fig. 9, results of PSD characteristics of the MCM signal, the AWGN noise and the FEXT crosstalk for the line length 0,5 km, the core diameter 0,4 mm with 24 ADSL and 9 VDSL disturbers and with the FTTEx spectral mask are introduced. A received signal is sampled and processed by the FFT block without a correction in the frequency area. Therefore, the SNR can be calculated in particular subchannels directly from the MCM signal power and

<sup>0</sup> <sup>2</sup> <sup>4</sup> <sup>6</sup> <sup>8</sup> <sup>10</sup> <sup>12</sup> <sup>14</sup> <sup>16</sup> <sup>18</sup> <sup>20</sup> -140

Fig. 9. The PSD characteristics of the MCM signal, the FEXT crosstalk and the AWGN noise

A sense of analyzing for environmental influences on the power spectral densities of VDSL signals is to identify all substantial noise resources and at the same time to determine a way for calculating of the signal-to-noise ratio for various proposed modulation techniques. For our following analysis of the VDSL system performance, the parameter *SNR* is very important. The signal-to-noise ratio for the subband given by the lowest *fLOW* and the highest

*HIGH*

*f*

*f f*

*LOW HIGH*

*LOW*

where *PSDS (f)* is the VDSL signal power spectral density and *PSDN (f)* is the noise power spectral density. The *SNR (f)* ratio must be calculated from the adjusted SCM signal power

The PLC transmission channel has a tree-like topology with branches formed by additional wires tapered from the main path and having various lengths and terminated loads with highly frequency-varying impedances in a range from a few ohms to some kiloohms (Zimmermann & Dostert, 2002b), (Held, 2006). That's why the PLC signal propagation does not only take place along a direct line-of-sight path between a transmitter and a receiver but

*f*

*S*

*PSD f df*

*N*

*PSD f df*

(14)

*SNR f*

**4. The environment of power distribution cables** 

f [MHz]

PSD of the FEXT crosstalk PSD of the MCM signal PSD of the AWGN noise

the noise powers at the end of the line.

attenuated at the end of the line

*fHIGH* frequencies can be expressed as

**4.1 The multipath signal propagation** 

and the noise powers.


PSD [dBm/Hz]

also additional paths are used for a signal spreading. This multipath scenario can be easily explained by the example of a cable with one tap (Fig. 10).

Fig. 10. The multipath signal propagation in the cable with one tap

The line consists of three segments (A-B), (B-C) and (B-D) with lengths *l1*, *l2*, *l3* and characteristic impedances **Z***L1*, **Z***L2* and **Z***L3*. To simplify considerations, points A and C are assumed to be matched, which means **Z***A* = **Z***L1* and **Z***C* = **Z***L2*. Then, points B and D are reflection points with reflection factors are denoted as *r1B*, *r3D*, *r3B* and transmission factors are denoted as *t1B*, *t3B*. Because of multiple reflections, a number of propagation paths is infinitive (i.e., A → B → C, A → B → D → B → C, and so on). An affect of all reflections and transmissions can be expressed for each propagation path *i* in a form of the weighting factor *gi* that is mathematically equal to the product of reflection and transmission factors along the path. The value *gi* is always less or equal to one because all reflection and transmission factors can be only less or equal to one. The simulation model can be simplified if we approximate infinite number of paths by only *N* dominant paths and make *N* as small as possible. When more transmissions and reflections occur along the path, then the weighting factor will be smaller. When the longer path will be considered, then the signal contribution from this part to the overall signal spreading will be small due to the higher signal attenuation (Ferreira et al., 2010).

#### **4.2 The signal attenuation**

Characteristics of the PLC transmission environment focused on the multipath signal propagation, the signal attenuation, the noise scenario and the electromagnetic compatibility are introduced in (Róka & Dlháň, 2005). First, we can present basic characteristics of the PLC channel.

A total signal attenuation on the PLC channel consists of two parts: coupling losses (depending on a transmitter design) and line losses (very high and can range from 40 to 100 dB/km). To find a mathematical formulation for the signal attenuation, we have to start with the complex propagation constant

$$\gamma\left(\alpha\right) = \sqrt{\left(R + j.\alpha L\right) \cdot \left(G + j.\alpha C\right)} = \alpha\left(\alpha\right) + j.\beta\left(\alpha\right) \tag{15}$$

depending on the primary cable parameters *R, L, G, C*. Then, the frequency response of a transmission line **H** *(f)* (the transfer function) with the length *l* can be expressed as follows (**U** *(x)* is the voltage at the distance *x*):

Fixed Transmission Media 55

noise can be distinguished in power distribution line channels (Zimmermann & Dostert,

1. *Colored background noise* – caused by a summation of numerous noise sources with low powers. Its PSD varies with the frequency in a range up to 30 MHz (significantly increases toward to lower frequencies) and also with the time in terms of minutes or

2. *Narrowband noise* – caused by ingress of broadcasting stations. It is generally varying with daytimes and consists mostly of sinusoidal signals with modulated amplitudes. 3. *Periodic impulsive noise asynchronous with the main frequency* – caused by rectifiers within DC power supplies. Its spectrum is a discrete line spectrum with a repetition rate

4. *Periodic impulsive noise synchronous with the main frequency* – caused by power supplies operating synchronously with the main cycle. Its PSD is decreasing with the frequency

5. *Asynchronous impulsive noise* – caused by impulses generated by the switching transients' events in the network. It is considered as the worst noise in the PLC environment, because of its magnitude that can easily reach several dB over other noise types. Fortunately, the average disturbance ratio is well below 1 percent, meaning that

The noise types 1, 2 and 3 can be summarized as background noises because they are remaining stationary over periods of seconds and minutes, sometimes even of hours. On the contrary, the noise types 4 and 5 are time-variant in terms of microseconds or milliseconds and their impact on useful signals is much more stronger and may cause single-bit or burst errors in a data transmission. Time and domain analysis of impulse noises can be found in (Zimmermann & Dostert, 2002a). We will just mention a few expressions regarding a mathematical description of the impulse noise model and the impulse energy and power.

H(f) + + + + +

A time behavior of the impulsive noise can be described by three basic figures, i.e. the impulse width *tw*, the arrival time *tarr* and the interarrival time *tiat* or the impulse distance *td*. The interarrival time (the impulse distance) means a distance between two impulse events

s(t) r(t)

f

f

*iat w d arr i arr i* ,1 , *t ttt t* (22)

PSD

f

5

4

PSD

3

PSD

f

2

99 percent of the time is absolutely free of the asynchronous impulsive noise.

2002a), (Götz et al., 2004). These five classes are (Fig. 11):

in a range between 50 and 200 kHz.

PSD

that can be described by

f

Fig. 11. The noise scenario in the PLC environment

PSD

1

and a repetition rate is 50 Hz or 100 Hz.

even hours.

$$\mathfrak{M}(f) = \frac{\mathfrak{U}(\mathfrak{x} = l)}{\mathfrak{U}(\mathfrak{x} = 0)} = e^{-\gamma(f) \cdot l} = e^{-\alpha(f) \cdot l} e^{-j \cdot \beta(f) \cdot l} \tag{16}$$

Considering frequencies in the megahertz range, the resistance *R* per length unit is dominated by the skin effect and thus is proportional to *f* . The conductance *G* per length unit is mainly influenced by a dissipation factor of the dielectric material (usually PVC) and therefore proportional to *f*. With typical geometry and material properties, we can suppose *G << .C* and *R << .L* in the frequency range of interest. Then, cables can be regarded as low lossy ones with real valued characteristic impedances and a simplified expression for the complex propagation constant can be introduced

$$
\gamma(f) = k\_1 \cdot \sqrt{f} + k\_2 \cdot f + j \cdot k\_3 \cdot f = a(f) + j \cdot \beta(f) \tag{17}
$$

where constants *k1*, *k2* and *k3* are parameters summarizing material and geometry properties. Based on these derivations and an extensive investigation of measured frequency responses, an approximating formula for the attenuation factor  *(f)* is found in a form

$$a(f) = a\_0 + a\_1 \cdot f^k \tag{18}$$

that is able to characterize the attenuation of typical power distribution lines with only three parameters, being easily derived from the measured transfer function (Zimmermann & Dostert, 2002b). Now the propagation loss *LdB* is given at the length *l* and the frequency *f* as

$$\begin{aligned} \left. L\_{dB}(l, f) = -20. \log\_{10} \left| \mathcal{H}(l, f) \right| = \frac{20}{\ln 10}. \left. l.a(f) = \frac{20}{\ln 10}. l. (a\_0 + a\_1. f^k) \right. \quad \text{[Np]}\\ & \approx 8, 686. \text{l.} (a\_0 + a\_1. f^k) \quad \text{[dB]} \end{aligned} \tag{19}$$

We can see a linear dependence of the propagation loss *LdB* on the line length *l*. Parameters *a0*, *a1* and *k* are characterized by measurements of the transfer function **H** *(f)* that is much easier then the measurement of primary line parameters *R, L, C, G*. If we now merge a signal spreading on all paths together (we can use a superposition), we can receive an expression for the frequency response **H** *(f)* in a form

$$\mathfrak{AC}(f) = \sum\_{i=1}^{N} \mathbf{g}\_i \cdot a(l\_{i'}f) \cdot e^{-j.2\,\pi.f.\,r\_i} \tag{20}$$

where *a (li, f)* is the signal attenuation proportioned with the length and the frequency and *N* is the number of paths in the transmission channel. The delay *<sup>i</sup>* of the transmission line can be calculated from the dielectric constant *<sup>r</sup>* of insulating materials, the light speed *c* and the line length *li* as follows

$$
\pi\_i = \frac{l\_i \cdot \sqrt{\varepsilon\_r}}{c} \tag{21}
$$

#### **4.3 The noise scenario**

Unfortunately, in a case of the PLC environment, we can't stay only with the additive white Gaussian noise. The noise scenario is much more complicated, since five general classes of

() () () ( ) ( ) ( 0) *x l <sup>f</sup> <sup>l</sup> <sup>f</sup> <sup>l</sup> j f <sup>l</sup> f e ee*

Considering frequencies in the megahertz range, the resistance *R* per length unit is dominated by the skin effect and thus is proportional to *f* . The conductance *G* per length unit is mainly influenced by a dissipation factor of the dielectric material (usually PVC) and therefore proportional to *f*. With typical geometry and material properties, we can suppose

low lossy ones with real valued characteristic impedances and a simplified expression for

can be introduced

( ) *f k f k f jk f f j f*

where constants *k1*, *k2* and *k3* are parameters summarizing material and geometry properties. Based on these derivations and an extensive investigation of measured frequency responses,

0 1 ( ) *<sup>k</sup>*

that is able to characterize the attenuation of typical power distribution lines with only three parameters, being easily derived from the measured transfer function (Zimmermann & Dostert, 2002b). Now the propagation loss *LdB* is given at the length *l* and the frequency *f* as

10 0 1

We can see a linear dependence of the propagation loss *LdB* on the line length *l*. Parameters *a0*, *a1* and *k* are characterized by measurements of the transfer function **H** *(f)* that is much easier then the measurement of primary line parameters *R, L, C, G*. If we now merge a signal spreading on all paths together (we can use a superposition), we can receive an expression

() (, ) *<sup>i</sup>*

*i i*

where *a (li, f)* is the signal attenuation proportioned with the length and the frequency and *N*

. *i r*

Unfortunately, in a case of the PLC environment, we can't stay only with the additive white Gaussian noise. The noise scenario is much more complicated, since five general classes of

*f g al f e*

<sup>20</sup> <sup>20</sup> ( , ) 20.log ( , ) . . ( ) . .( . ) [ ] ln10 ln 10

*L lf l f l f l a a f Np*

1

*i l c* 

*i*

is the number of paths in the transmission channel. The delay

*N*

12 3

 

*.L* in the frequency range of interest. Then, cables can be regarded as

**U** (16)

 

 *(f)* is found in a form

*f a a f* (18)

*k*

.2. . .

**<sup>H</sup>** (20)

*<sup>r</sup>* of insulating materials, the light speed *c* and the

(21)

 

*j f*

() . () (17)

0 1

8,686. .( . ) [ ]

*l a a f dB*

*k*

*<sup>i</sup>* of the transmission line can

(19)

 

*x*

**<sup>U</sup> <sup>H</sup>**

*G <<* 

*.C* and *R <<* 

*dB*

an approximating formula for the attenuation factor

**H**

for the frequency response **H** *(f)* in a form

be calculated from the dielectric constant

line length *li* as follows

**4.3 The noise scenario** 

the complex propagation constant

noise can be distinguished in power distribution line channels (Zimmermann & Dostert, 2002a), (Götz et al., 2004). These five classes are (Fig. 11):


The noise types 1, 2 and 3 can be summarized as background noises because they are remaining stationary over periods of seconds and minutes, sometimes even of hours. On the contrary, the noise types 4 and 5 are time-variant in terms of microseconds or milliseconds and their impact on useful signals is much more stronger and may cause single-bit or burst errors in a data transmission. Time and domain analysis of impulse noises can be found in (Zimmermann & Dostert, 2002a). We will just mention a few expressions regarding a mathematical description of the impulse noise model and the impulse energy and power.

Fig. 11. The noise scenario in the PLC environment

A time behavior of the impulsive noise can be described by three basic figures, i.e. the impulse width *tw*, the arrival time *tarr* and the interarrival time *tiat* or the impulse distance *td*. The interarrival time (the impulse distance) means a distance between two impulse events that can be described by

$$\mathbf{t}\_{int} = \mathbf{t}\_w + \mathbf{t}\_d = \mathbf{t}\_{arr, i+1} - \mathbf{t}\_{arr, i} \tag{22}$$

Fixed Transmission Media 57

Outdoor power line Transmitting part

Filter Modulator

Demodulator

The transmitted message carried to the receiving part is generated as a random binary chain with the given length. This message is also saved (for the BER calculation), encoded by a particular type of the FEC codes and modulated. From the coding and modulation techniques, we are intending to implement several different ones to be able to compare them

Negative influences of the PLC environment at the signal transmission depend on parameters of power distribution lines (a core material, a cable insulation, a cable length, a core diameter, a number, position and properties of additional wires tapered from the main path) as well as on number and properties of points of nonhomogenity (instrument panels, PLC signal coupling units, regenerator units, points of wires interconnections). If we want to achieve exact results from simulations, all these factors must be accepted. Of course, this acceptance leads to a complicated and complex PLC simulation model. Because of this fact we have to choose a trade-off between the model complexity and the accuracy of reality representations. For modeling of the PLC transmission channel, we chose a generalized multipath model because of its accuracy, easily implementation and understandability (Zimmermann & Dostert, 2002b). Mathematically, it can be described in a form of the

> () (, ) ( ) *<sup>k</sup> <sup>g</sup> <sup>i</sup> <sup>i</sup> i i N N <sup>f</sup> j f a af l j f*

In general, the weighting factor *gi* is complex and frequency-dependent because reflection points may have complex and frequency-dependent values. According to

*f g al f e gf e e e*

0 1 ( ) .2. . . ( . ) .2. . .

 

**<sup>H</sup>** (26)

Receiving part

1 1

*i i i i i*

 

Fig. 12. The block scheme of the PLC simulation model

Transmit

Amplifier

+

H(f)

+ Narrow-band noise

Colored backg. noise

<sup>+</sup> All kinds of impulsive noise

Data source FEC

BER

expression

Recipient FEC

decoder

**5.1 The transmitting part of the model** 

and find the most appropriate one.

**5.2 The outdoor power distribution line** 

coder

Then, a train of impulses *nimp (t)* can be described as

$$m\_{imp}(t) = \sum\_{i=1}^{N} A\_i \cdot imp\left(\frac{t - t\_{arr,i}}{t\_{w,i}}\right) \tag{23}$$

where *Ai* means the impulse amplitude and *imp (t)* is the generalized impulse function. The parameters *Ai*, *tw* and *tarr* are random variables, whose statistical properties may be investigated by measurements. More information can be found in (Róka & Urminský, 2008).

The best way how to characterize extent of the impact of impulses on a data transmission are values of the impulse energy and the impulse power. The impulse energy *Eimp* can be calculated from the time-domain representation *nimp (t)* as

$$E\_{imp} = \int\_{t\_{wr}}^{t\_{wr} + t\_w} n\_{imp}(t)^2 \, dt \tag{24}$$

As we can see from (24), the impulse energy is influenced by the impulse shape and width. Finally, the impulse power can be determined by

$$\mathcal{W}\_{imp} = \frac{1}{t\_{av}} \int\_{t\_{av}}^{t\_{avr} + t\_w} n\_{imp}(t)^2 \, dt \tag{25}$$

and can be used for a comparison of impulse and background noises.

### **5. The simulation model for the PLC technology**

The realized model (Fig. 12) represents a high-speed signal transmission in the PLC system utilizing outdoor power distribution lines in downstream and upstream directions (Róka & Dlháň, 2005). The signal transmission over outdoor power distribution lines represents the transmission between a transmitter in the transformer substation and a receiver in the customer premises.

Our realized simulation model can be divided into the three main parts:


( )

*imp i*

*N*

*n t A imp <sup>t</sup>*

1 ,

*i w i*

where *Ai* means the impulse amplitude and *imp (t)* is the generalized impulse function. The parameters *Ai*, *tw* and *tarr* are random variables, whose statistical properties may be investigated by measurements. More information can be found in (Róka & Urminský,

The best way how to characterize extent of the impact of impulses on a data transmission are values of the impulse energy and the impulse power. The impulse energy *Eimp* can be

*arr w*

*t t imp imp t E n t dt* 

*arr*

As we can see from (24), the impulse energy is influenced by the impulse shape and width.

<sup>1</sup> <sup>2</sup> ( ) *arr w*

*arr*

The realized model (Fig. 12) represents a high-speed signal transmission in the PLC system utilizing outdoor power distribution lines in downstream and upstream directions (Róka & Dlháň, 2005). The signal transmission over outdoor power distribution lines represents the transmission between a transmitter in the transformer substation and a receiver in the

1. A transmitting part - it is responsible for the encoding (because of using the FEC technique) and for the modulation of signals into a form suitable for the transmission

2. A transmission channel (the outdoor power lines) - this part realizes negative influences of the PLC environment on the transmitted signal. Above all, it goes about the propagation loss, the signal distortion, the impulsive, colored and narrow-band

3. A receiving part - it is conceptually inverted in a comparison with the transmitter. Its main functions are the signal amplification, the demodulation and the correction

*t t imp imp w t*

*t*

and can be used for a comparison of impulse and background noises.

Our realized simulation model can be divided into the three main parts:

**5. The simulation model for the PLC technology** 

,

(23)

(24)

(25)

*arr i*

*t t*

<sup>2</sup> ( )

*n t dt*

Then, a train of impulses *nimp (t)* can be described as

calculated from the time-domain representation *nimp (t)* as

Finally, the impulse power can be determined by

2008).

customer premises.

channel.

noises.

of error information bits.

Fig. 12. The block scheme of the PLC simulation model

## **5.1 The transmitting part of the model**

The transmitted message carried to the receiving part is generated as a random binary chain with the given length. This message is also saved (for the BER calculation), encoded by a particular type of the FEC codes and modulated. From the coding and modulation techniques, we are intending to implement several different ones to be able to compare them and find the most appropriate one.

## **5.2 The outdoor power distribution line**

Negative influences of the PLC environment at the signal transmission depend on parameters of power distribution lines (a core material, a cable insulation, a cable length, a core diameter, a number, position and properties of additional wires tapered from the main path) as well as on number and properties of points of nonhomogenity (instrument panels, PLC signal coupling units, regenerator units, points of wires interconnections). If we want to achieve exact results from simulations, all these factors must be accepted. Of course, this acceptance leads to a complicated and complex PLC simulation model. Because of this fact we have to choose a trade-off between the model complexity and the accuracy of reality representations. For modeling of the PLC transmission channel, we chose a generalized multipath model because of its accuracy, easily implementation and understandability (Zimmermann & Dostert, 2002b). Mathematically, it can be described in a form of the expression

$$\mathfrak{M}(f) = \sum\_{i=1}^{N} \mathbf{g}\_i \cdot a(l\_{i'}f) \cdot e^{-j.2.\pi\_i f.\pi\_i} = \sum\_{i=1}^{N} \left| \mathbf{g}\_i(f) \right| \cdot e^{\phi\_{\mathbb{R}}(f)} \cdot e^{-(a\_0 + a\_1 f^k) \cdot l\_i} \cdot e^{-j.2.\pi\_i f.\pi\_i} \tag{26}$$

In general, the weighting factor *gi* is complex and frequency-dependent because reflection points may have complex and frequency-dependent values. According to

Fixed Transmission Media 59

described by so-called the portioned Markov chain. In this model, all states are partitioned into two groups, where the first represents a case where no impulse event occurs and the second represents an occurrence of the impulse event. Transitions between states from the first group top the second and vice versa are described by two independent probability matrices U for impulse-free states and G for impulse states. The concrete values of these matrices can be found in paper (Zimmermann & Dostert, 2002a). Each impulsive noise state corresponds to an exponential distribution of the impulse width, while each impulse-free state corresponds to an exponential distribution of the impulse distance. Thus, this kind of modeling represents a superposition of several exponential distributions that approximate

At the receiver side, the distorted and attenuated signal is first amplified and then demodulated. Part of the demodulation is also demapping block as a part of modulator, which is responsible for converting the constellation points sequence into the binary data sequence corrupted by transmission errors. They are consequently removed in the FEC decoder. Finally, the corrected sequence is compared with the original transmitted message

The parametric model for the PLC channel is possible to adapt for any topology of the power distribution network (Róka & Urminský, 2008). Parameters of this model with various coefficients were presented in ETSI Technical Specifications (ETSI, 2000, 2001) and

1. *Reference channel 1* (RC1) – a channel between transformer stations with features of the HV channel. A distance between separate transformer stations is around 1000 m. 2. *Reference channel 2* (RC2) – a channel from the transformer station up to the main circuit

3. *Reference channel 3* (RC3) – a channel from the main circuit breaker up to the counting

For the presented parametric model, parameters for various PLC reference channels were assumed from the paper (Zimmermann & Dostert, 2002b). In spite of their simplification, it is still accurate enough for the PLC system performance analyses. The values of other parameters like *k, a0, a1, gi, li* for the multi-path signal propagation in reference channels can be found in (Róka & Urminský, 2008). Computer simulations at appropriate frequency characteristics of particular reference channels used values from a specific table. These

As it can be noticed from simulation results, the signal attenuation in reference channels is straightforward proportioned with the length and the frequency. For some specific frequencies only is shown the selective attenuation caused by the multi-path effect with

**5.4 Characteristics of the parametric model for reference channels** 

breaker, a distance is approximately 150 m.

frequency responses are graphically shown in Fig. 13.

approximately 30 to 40 dB.

4. *Reference channel 4* (RC4) – a home scenario.

a following set of reference channels for a practical utilization was established:

box of consumed energy in the house, a distance is maximum 250 m.

real scenarios very well.

**5.3 The receiving part of the model** 

and the bit error rate is calculated.

extended measurements campaigns, it is possible to consider *gi* as a complex but not frequency-dependent value or as a real value even in many practical models it can be considered.

For the presented model, parameters were assumed from the paper (Zimmermann & Dostert, 2002b). In spite of its simplification, it is still accurate enough for the PLC system performance analyses. It goes about the model of the 110 m link supposing *N* = 15 main paths. The values of other parameters like *k, a0, a1, gi, li* (*k, a0, a1* are attenuation factors, *gi* is weighting factor and finally *li* means length of *i*-th branch) can be found in Tab. 2.


Table 2. Parameters of the 15-path PLC simulation model

In the PLC transmission environment, not only a signal distortion expressed by the channel transfer function **H** *(f)* is presented. Also different types of noise have very negative influence on transmitted signals in a form of the time-invariant behavior of the SNR on powerline channels. The first type of noise – the colored background noise is modeled by filtering the AWGN noise through a filter with the exponentially decreasing transfer function for increasing frequencies with the average 35 dB/decade in the low frequency range up to 10 kHz and a low rate in the high frequency range (Hrasnica et al., 2004). The narrowband noise is generated in a similar way only with a difference in band-pass filters with a random selection of the lower passband edge frequency. The power of these narrow spikes is varying around the –80 dBm/Hz. The impulsive noise can be described by expression (23). From (Zimmermann & Dostert, 2002a), the parameters of periodic impulsive noises (type 3 and 4) are more and less deterministic. Concretely, the width of noise impulse is about 200 μs, the impulse amplitude is concentrated around two values; about 0.4 V and then between 0.7 and 1 V. The interarrival time values are 10 ms, 6 ms and 12 ms.

The biggest problem for modeling represents the asynchronous impulsive noise because of its random occurrence and random durations from some microseconds up to a few milliseconds. It can't be ignored since its influence with the PSD more than 50 dB is particularly devastating of the transmitted signal. As it goes about a random process, whose a future behavior only depends on the present state or on limited periods in the past, may be

extended measurements campaigns, it is possible to consider *gi* as a complex but not frequency-dependent value or as a real value even in many practical models it can be

For the presented model, parameters were assumed from the paper (Zimmermann & Dostert, 2002b). In spite of its simplification, it is still accurate enough for the PLC system performance analyses. It goes about the model of the 110 m link supposing *N* = 15 main paths. The values of other parameters like *k, a0, a1, gi, li* (*k, a0, a1* are attenuation factors, *gi* is weighting factor and finally *li* means length of *i*-th branch) can

*N* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

*gi* 0,029 0,043 0,103 -0,058 -0,045 -0,040 0,038 -0,038 0,071 -0,035 0,065 -0,055 0,042 -0,059 0,049

*li [m]* 90 102 113 143 148 200 260 322 411 490 567 740 960 1130 1250

In the PLC transmission environment, not only a signal distortion expressed by the channel

influence on transmitted signals in a form of the time-invariant behavior of the SNR on powerline channels. The first type of noise – the colored background noise is modeled by filtering the AWGN noise through a filter with the exponentially decreasing transfer function for increasing frequencies with the average 35 dB/decade in the low frequency range up to 10 kHz and a low rate in the high frequency range (Hrasnica et al., 2004). The narrowband noise is generated in a similar way only with a difference in band-pass filters with a random selection of the lower passband edge frequency. The power of these narrow spikes is varying around the –80 dBm/Hz. The impulsive noise can be described by expression (23). From (Zimmermann & Dostert, 2002a), the parameters of periodic impulsive noises (type 3 and 4) are more and less deterministic. Concretely, the width of noise impulse is about 200 μs, the impulse amplitude is concentrated around two values; about 0.4 V and then between 0.7 and 1 V. The interarrival time values are 10 ms, 6 ms and

The biggest problem for modeling represents the asynchronous impulsive noise because of its random occurrence and random durations from some microseconds up to a few milliseconds. It can't be ignored since its influence with the PSD more than 50 dB is particularly devastating of the transmitted signal. As it goes about a random process, whose a future behavior only depends on the present state or on limited periods in the past, may be

*(f)* is presented. Also different types of noise have very negative

*k* 1

*a0* 0

*a1 [m/s]* 7,8.10-10

**H**

Table 2. Parameters of the 15-path PLC simulation model

considered.

be found in Tab. 2.

transfer function

12 ms.

described by so-called the portioned Markov chain. In this model, all states are partitioned into two groups, where the first represents a case where no impulse event occurs and the second represents an occurrence of the impulse event. Transitions between states from the first group top the second and vice versa are described by two independent probability matrices U for impulse-free states and G for impulse states. The concrete values of these matrices can be found in paper (Zimmermann & Dostert, 2002a). Each impulsive noise state corresponds to an exponential distribution of the impulse width, while each impulse-free state corresponds to an exponential distribution of the impulse distance. Thus, this kind of modeling represents a superposition of several exponential distributions that approximate real scenarios very well.

## **5.3 The receiving part of the model**

At the receiver side, the distorted and attenuated signal is first amplified and then demodulated. Part of the demodulation is also demapping block as a part of modulator, which is responsible for converting the constellation points sequence into the binary data sequence corrupted by transmission errors. They are consequently removed in the FEC decoder. Finally, the corrected sequence is compared with the original transmitted message and the bit error rate is calculated.

## **5.4 Characteristics of the parametric model for reference channels**

The parametric model for the PLC channel is possible to adapt for any topology of the power distribution network (Róka & Urminský, 2008). Parameters of this model with various coefficients were presented in ETSI Technical Specifications (ETSI, 2000, 2001) and a following set of reference channels for a practical utilization was established:


For the presented parametric model, parameters for various PLC reference channels were assumed from the paper (Zimmermann & Dostert, 2002b). In spite of their simplification, it is still accurate enough for the PLC system performance analyses. The values of other parameters like *k, a0, a1, gi, li* for the multi-path signal propagation in reference channels can be found in (Róka & Urminský, 2008). Computer simulations at appropriate frequency characteristics of particular reference channels used values from a specific table. These frequency responses are graphically shown in Fig. 13.

As it can be noticed from simulation results, the signal attenuation in reference channels is straightforward proportioned with the length and the frequency. For some specific frequencies only is shown the selective attenuation caused by the multi-path effect with approximately 30 to 40 dB.

Fixed Transmission Media 61

The optical fiber is an ideal medium that can be used to carry optical signals over long distances. There are several sources that contribute to the fiber attenuation, such as an absorption, a scattering and a radiation. The attenuation leads to a reduction of the signal power as the signal propagates over some distance. When determining the maximum distance that a signal propagate for a given transmitter power and receiver sensitivity, the

can be obtained by measuring the input and the output optical power and then the optical

<sup>10</sup> ( ) 10 . (0) [ ]

where *P (0)* is the optical power at the transmitter, *P (L)* is the optical pulse power at the distance *L*. For the link length *L*, the *P (L)* must be greater than or equal to the receiver

The dispersion is a widening of the pulse duration as it travels through the optical fiber. As a pulse widens, it can broaden enough to interfere with neighboring pulses (bits) on the fiber leading to the intersymbol interference ISI. The dispersion thus limits the maximum transmission rate on a fiber-optic channel. We distinguished two basic dispersive forms - the intermodal dispersion and the chromatic dispersion. Both cause an optical signal distortion in multimode optical fibers MMF, whereas a chromatic dispersion is the only cause of the

(m)

The chromatic dispersion CD represents a fact that different wavelengths travel at different speeds, even within the same mode. In a dispersive medium, the index of refraction *n (*

a function of the wavelength. Thus, certain wavelengths of the transmitted signal will propagate faster than other wavelengths. The CD dispersion is the result of material dispersion, waveguide dispersion and profile dispersion. On Fig. 15, characteristic curves of the CD as a function of available wavelengths for various optical fiber types (USF, NZDF,

.

*L PL P W* (27)

 *(*

[dB/km] of the optical fiber

*)* as a function of available

*)* is

attenuation must be considered. The attenuation coefficient

power level along the fiber length *L* [km] can be expressed as

sensitivity *Pr*. On Fig. 14, a characteristic curve of the

Fig. 14. The wavelength characteristic of the attenuation coefficient

optical signal distortion in singlemode fibers SMF.

DSF) are presented (Black, 2002).

wavelengths is presented (Black, 2002).

**6.3 The dispersion** 

**6.2 The attenuation** 

Fig. 13. Frequency responses of the RC1, RC2, RC3 and RC4 channels

## **6. The environment of optical fibers**

## **6.1 Transmission parameters of the optical fiber**

Basic transmission factors of the singlemode standard optical fiber are following (Čuchran & Róka, 2006):

	- the chromatic dispersion CD,
	- the polarization mode dispersion PMD,
	- the cross phase modulation XPM,
	- the cross polarization modulation XPolM,
	- the four wave mixing FWM,
	- the stimulated Raman scattering SRS,
	- the stimulated Brillouin scattering SBS.

Nonlinear effects in the optical fiber may potentially have a significant impact on the performance of WDM optical communication systems. In a WDM system, these effects place constraints on the spacing between adjacent wavelength channels and they limit the maximum power per channel, the maximum bit rate and the system reach (Mukherjee, 2006).

Knowing which fundamental linear and nonlinear interactions dominate is helpful to conceive techniques that improve a transmission of optical signals, including advanced modulation formats, a digital signal processing and a distributed optical nonlinearity management.

#### **6.2 The attenuation**

60 Technology and Engineering Applications of Simulink

Fig. 13. Frequency responses of the RC1, RC2, RC3 and RC4 channels

Basic transmission factors of the singlemode standard optical fiber are following (Čuchran &

Nonlinear effects in the optical fiber may potentially have a significant impact on the performance of WDM optical communication systems. In a WDM system, these effects place constraints on the spacing between adjacent wavelength channels and they limit the maximum

Knowing which fundamental linear and nonlinear interactions dominate is helpful to conceive techniques that improve a transmission of optical signals, including advanced modulation formats, a digital signal processing and a distributed optical nonlinearity

power per channel, the maximum bit rate and the system reach (Mukherjee, 2006).

**6. The environment of optical fibers** 




Róka, 2006):

management.

 the attenuation, the dispersion

**6.1 Transmission parameters of the optical fiber** 




$$P(L) = 10^{\frac{-\alpha \cdot L}{10}} \cdot P(0) \tag{1\%} \tag{27}$$

where *P (0)* is the optical power at the transmitter, *P (L)* is the optical pulse power at the distance *L*. For the link length *L*, the *P (L)* must be greater than or equal to the receiver sensitivity *Pr*. On Fig. 14, a characteristic curve of the  *()* as a function of available wavelengths is presented (Black, 2002).

Fig. 14. The wavelength characteristic of the attenuation coefficient 

#### **6.3 The dispersion**

The dispersion is a widening of the pulse duration as it travels through the optical fiber. As a pulse widens, it can broaden enough to interfere with neighboring pulses (bits) on the fiber leading to the intersymbol interference ISI. The dispersion thus limits the maximum transmission rate on a fiber-optic channel. We distinguished two basic dispersive forms - the intermodal dispersion and the chromatic dispersion. Both cause an optical signal distortion in multimode optical fibers MMF, whereas a chromatic dispersion is the only cause of the optical signal distortion in singlemode fibers SMF.

The chromatic dispersion CD represents a fact that different wavelengths travel at different speeds, even within the same mode. In a dispersive medium, the index of refraction *n ()* is a function of the wavelength. Thus, certain wavelengths of the transmitted signal will propagate faster than other wavelengths. The CD dispersion is the result of material dispersion, waveguide dispersion and profile dispersion. On Fig. 15, characteristic curves of the CD as a function of available wavelengths for various optical fiber types (USF, NZDF, DSF) are presented (Black, 2002).

Fixed Transmission Media 63

transmission in the environment utilizing optical fibers for very high-speed data signals in both directions. Optical communication technologies will always be facing the limits of high-speed signal processing and modulation, which is an important factor to take into account when discussing advanced optical modulation formats. The main task of the simulation model is an analysis of various modulation techniques (Xiong, 2000), (Kaminow

Basic functional blocks realized in the optocommunication simulation model can be divided

1. A transmitting part - it is responsible for the generating (using the Bernoulli generator) and for the modulation of generated signals according to required information inputs into a form suitable for the transmission channel. The modulation block contains a basic

3. A receiving part - it is conceptually inverted in a comparison with the transmitter. At the receiver side, a signal is demodulated by appropriate demodulator and the BER ratio is calculated. Also, blocks for graphical presenting of transmitted optical signals

Fig. 17. The block scheme of the optocommunication simulation model

set OOK modulation and its variations with DBPSK and DQPSK modulations. 2. A transmission channel (the optical fiber) - this part of the model realized negative influences on the transmitted signal. Above all, it goes about an attenuation, a dispersion and a noise. Because these negative influences expressively interfere into the communication and represent its main limiting factors, they present a critical part of the model and, therefore, it is necessary exactly to recognize and express their

et al., 2008), (Shieh & Djordjevic, 2010).

characteristics by correct parameters.

can be utilized (Fig. 18).

into the three main parts:

Fig. 15. Wavelength characteristics of the dispersion for USF, NZDF and DSF fibers

The polarization mode dispersion PMD is another complex optical effect that can occur in singlemode optical fibers (Black, 2002). The SMF support two perpendicular polarizations of the original transmitted signal. If a fiber is not perfect, these polarization modes may travel at different speeds and, consequently, arrive at the end of the fiber at different times. The difference in arrival times between the fast and slow mode axes is the PMD (Fig. 16). Like the CD, the PMD causes digitally-transmitted pulses to spread out as the polarization modes arrive at their destination at different times.

Fig. 16. The PMD generation in the environment of optical fibers

The main problem with the PMD in optical fiber systems is its stochastic nature, letting the principal state of polarization PSP and the differential group delay DGD vary on timescales between milliseconds and months (Kaminow et al., 2008).

#### **6.4 The insertion loss**

The fiber loss is not only source of the optical signal attenuation along transmission lines. Fiber splices and fiber connectors also cause the signal attenuation. The number of optical splices and connectors depends on the transmission length and must be taken into account unless the total attenuation due to fiber joints is distributed and added to the optical fiber attenuation.

## **7. The simulation model for the optical communications**

For modeling of the optical transmission path, we used the software program *Matlab 2010 Simulink* together with additional libraries like *Communication Blockset* and *Communication Toolbox* (Schiff, 2006), (Binh, 2010). The realized model (Fig. 17) represents the signal

Fig. 15. Wavelength characteristics of the dispersion for USF, NZDF and DSF fibers

arrive at their destination at different times.

Fig. 16. The PMD generation in the environment of optical fibers

**7. The simulation model for the optical communications** 

between milliseconds and months (Kaminow et al., 2008).

**6.4 The insertion loss** 

attenuation.

The polarization mode dispersion PMD is another complex optical effect that can occur in singlemode optical fibers (Black, 2002). The SMF support two perpendicular polarizations of the original transmitted signal. If a fiber is not perfect, these polarization modes may travel at different speeds and, consequently, arrive at the end of the fiber at different times. The difference in arrival times between the fast and slow mode axes is the PMD (Fig. 16). Like the CD, the PMD causes digitally-transmitted pulses to spread out as the polarization modes

> .

The main problem with the PMD in optical fiber systems is its stochastic nature, letting the principal state of polarization PSP and the differential group delay DGD vary on timescales

The fiber loss is not only source of the optical signal attenuation along transmission lines. Fiber splices and fiber connectors also cause the signal attenuation. The number of optical splices and connectors depends on the transmission length and must be taken into account unless the total attenuation due to fiber joints is distributed and added to the optical fiber

For modeling of the optical transmission path, we used the software program *Matlab 2010 Simulink* together with additional libraries like *Communication Blockset* and *Communication Toolbox* (Schiff, 2006), (Binh, 2010). The realized model (Fig. 17) represents the signal

*D L PMD* (28)

transmission in the environment utilizing optical fibers for very high-speed data signals in both directions. Optical communication technologies will always be facing the limits of high-speed signal processing and modulation, which is an important factor to take into account when discussing advanced optical modulation formats. The main task of the simulation model is an analysis of various modulation techniques (Xiong, 2000), (Kaminow et al., 2008), (Shieh & Djordjevic, 2010).

Basic functional blocks realized in the optocommunication simulation model can be divided into the three main parts:


Fig. 17. The block scheme of the optocommunication simulation model

Fixed Transmission Media 65

The second part of the paper analyzes basic features of the real transmission environment of the outdoor power distribution lines and presents possibilities for modeling and simulation of the information signal transmission in this environment by means of the PLC technology. We focused on transmission characteristics of the PLC channel, namely the multipath signal propagation, the signal attenuation and the interference scenario revealing different classes of the impulsive noise. We created a model of the complex frequency response in a range from 500 kHz up to 30 MHz. Moreover, we realized experimental measurements for verification of the parametric model for reference channels. According the transfer functions, it has been observed the decreasing linear performance in the measured frequencies range where the number of imperfect matching points is minimum. It can be concluded that if the line length path grows it is more probable that the number of reflections produced by imperfect matching points grows too. Moreover, the transfer

function slope increasing in lower frequencies is proportional to the line length.

noises and interferences incident in the PLC environment.

performance of WDM optical communication systems.

nonlinearity management.

**9. Acknowledgment** 

Basic features of negative environmental influences at the signal transmission in the power distribution environment can be used for modeling spectral characteristics of PLC signals of the transmission path. The PLC simulation model is verified by measurements in the real PLC transmission environment that confirmed its satisfactory conformity with real transmission conditions. Using the PLC simulation model, it is possible to verify a correctness of the proposed model, to compare with other ones and to demonstrate its suitability for searching the most appropriate coding and modulation techniques that belong among critical requirements of the development of the next generation PLC communication systems with higher data rates. In spite of problems with a high-frequency signal transmission, power distribution lines remain a very interesting transmission medium. Therefore, it is necessary to evolve a technology that is able to overcome various

The third part of the paper analyzes transmission parameters for the transmission medium of optical fibers and presents possibilities for modeling and simulation of the information signal transmission in the environment of optical channels. We focused on linear transmission factors – the attenuation and the dispersion - and on nonlinear effects. Nonlinear effects in the optical fiber may potentially have a significant impact on the

The simulation model for the optical communications represents the signal transmission in optical fibers for very high-speed data signals in both directions. Knowing which fundamental linear and nonlinear interactions dominate in the optical transmission medium is helpful to conceive techniques that improve a transmission of optical signals, including advanced modulation formats, a digital signal processing and a distributed optical

This work is a part of research activities conducted at Slovak University of Technology Bratislava, Faculty of Electrical Engineering and Information Technology, Institute of Telecommunications, within the scope of the project VEGA No. 1/0106/11 "Analysis and proposal for advanced optical access networks in the NGN converged infrastructure

utilizing fixed transmission media for supporting multimedia services".

Fig. 18. Symbol constellation and eye diagrams of the DQPSK modulations

## **8. Conclusion**

The first part of the paper analyzes basic features of the real transmission environment of metallic homogeneous lines and presents possibilities for modeling and simulating of the information signal transport in this environment by means of the VDSL technology. We focused on the determination and the analysis of concrete characteristic features for substantial negative influences of internal and external environments and on the representation of frequency dependencies of transmitted VDSL signals. The attenuation determined by the channel's transmission function is more damaged for areas of higher frequency components of power spectral density characteristics for transmitted signals. The influence of the NEXT crosstalk signal is accentuated at higher frequency components of the transmitted signal. The influence of the FEXT crosstalk signal is depending on the line length, on the frequency of signal and on the transmission function of the transmission line because of propagating of crosstalk signals through the disturbing pair. For long enough line lengths, the influence of the FEXT crosstalk can be neglected. Therefore, for the VDSL technology that transmits information signals of asymmetric and symmetric services at very high bit rates on very short distances, it is necessary to take into account both NEXT and FEXT crosstalks at signals occupying higher frequency bandwidths of metallic homogeneous lines. Due to damaging effects of the impulse noise, we must take into account also this type of negative environmental influence.

Basic features and characteristics of negative environmental influences at the signal transmission in the VDSL environment can be used for modeling spectral characteristics of signals on the transmission path. The VDSL simulation model allows determining main problems that can arise at the VDSL signal transmission. For realizing of individual model blocks, we concentrated on the choice of appropriate parameters so that these blocks could be adjusted and modified for future demands. The knowledge of the PSD characteristics of the VDSL signal can be very effectively utilized for characterizing the VDSL signal transmission on metallic homogeneous symmetric lines, especially for a determination of the SNR ratio. In addition, they can be used for analyzing singlecarrier and multicarrier modulation techniques in the overall VDSL system performance including theoretical and practical limits of transmission channels used by the VDSL technology.

The first part of the paper analyzes basic features of the real transmission environment of metallic homogeneous lines and presents possibilities for modeling and simulating of the information signal transport in this environment by means of the VDSL technology. We focused on the determination and the analysis of concrete characteristic features for substantial negative influences of internal and external environments and on the representation of frequency dependencies of transmitted VDSL signals. The attenuation determined by the channel's transmission function is more damaged for areas of higher frequency components of power spectral density characteristics for transmitted signals. The influence of the NEXT crosstalk signal is accentuated at higher frequency components of the transmitted signal. The influence of the FEXT crosstalk signal is depending on the line length, on the frequency of signal and on the transmission function of the transmission line because of propagating of crosstalk signals through the disturbing pair. For long enough line lengths, the influence of the FEXT crosstalk can be neglected. Therefore, for the VDSL technology that transmits information signals of asymmetric and symmetric services at very high bit rates on very short distances, it is necessary to take into account both NEXT and FEXT crosstalks at signals occupying higher frequency bandwidths of metallic homogeneous lines. Due to damaging effects of the impulse noise, we must take into account also this type of negative environmental

Basic features and characteristics of negative environmental influences at the signal transmission in the VDSL environment can be used for modeling spectral characteristics of signals on the transmission path. The VDSL simulation model allows determining main problems that can arise at the VDSL signal transmission. For realizing of individual model blocks, we concentrated on the choice of appropriate parameters so that these blocks could be adjusted and modified for future demands. The knowledge of the PSD characteristics of the VDSL signal can be very effectively utilized for characterizing the VDSL signal transmission on metallic homogeneous symmetric lines, especially for a determination of the SNR ratio. In addition, they can be used for analyzing singlecarrier and multicarrier modulation techniques in the overall VDSL system performance including theoretical and

practical limits of transmission channels used by the VDSL technology.

Fig. 18. Symbol constellation and eye diagrams of the DQPSK modulations

**8. Conclusion** 

influence.

The second part of the paper analyzes basic features of the real transmission environment of the outdoor power distribution lines and presents possibilities for modeling and simulation of the information signal transmission in this environment by means of the PLC technology. We focused on transmission characteristics of the PLC channel, namely the multipath signal propagation, the signal attenuation and the interference scenario revealing different classes of the impulsive noise. We created a model of the complex frequency response in a range from 500 kHz up to 30 MHz. Moreover, we realized experimental measurements for verification of the parametric model for reference channels. According the transfer functions, it has been observed the decreasing linear performance in the measured frequencies range where the number of imperfect matching points is minimum. It can be concluded that if the line length path grows it is more probable that the number of reflections produced by imperfect matching points grows too. Moreover, the transfer function slope increasing in lower frequencies is proportional to the line length.

Basic features of negative environmental influences at the signal transmission in the power distribution environment can be used for modeling spectral characteristics of PLC signals of the transmission path. The PLC simulation model is verified by measurements in the real PLC transmission environment that confirmed its satisfactory conformity with real transmission conditions. Using the PLC simulation model, it is possible to verify a correctness of the proposed model, to compare with other ones and to demonstrate its suitability for searching the most appropriate coding and modulation techniques that belong among critical requirements of the development of the next generation PLC communication systems with higher data rates. In spite of problems with a high-frequency signal transmission, power distribution lines remain a very interesting transmission medium. Therefore, it is necessary to evolve a technology that is able to overcome various noises and interferences incident in the PLC environment.

The third part of the paper analyzes transmission parameters for the transmission medium of optical fibers and presents possibilities for modeling and simulation of the information signal transmission in the environment of optical channels. We focused on linear transmission factors – the attenuation and the dispersion - and on nonlinear effects. Nonlinear effects in the optical fiber may potentially have a significant impact on the performance of WDM optical communication systems.

The simulation model for the optical communications represents the signal transmission in optical fibers for very high-speed data signals in both directions. Knowing which fundamental linear and nonlinear interactions dominate in the optical transmission medium is helpful to conceive techniques that improve a transmission of optical signals, including advanced modulation formats, a digital signal processing and a distributed optical nonlinearity management.

## **9. Acknowledgment**

This work is a part of research activities conducted at Slovak University of Technology Bratislava, Faculty of Electrical Engineering and Information Technology, Institute of Telecommunications, within the scope of the project VEGA No. 1/0106/11 "Analysis and proposal for advanced optical access networks in the NGN converged infrastructure utilizing fixed transmission media for supporting multimedia services".

Fixed Transmission Media 67

Aslanis, J. T.; Cioffi, J. M. (1992). Achievable information rates on digital subscriber loops:

*Communications*, Vol.40, No.2, (February 1992), pp. 361-372, ISSN 0090-6778 Binh, L.N. (2010). *Optical Fiber Communications Systems*, CRC Press, ISBN 978-1-4398-0620-3,

Black, U. (2002). *Optical Networks – 3rd Generation Transport Systems*, Prentice Hall PTR Inc.,

Čuchran, J.; Róka, R. (2006). *Optocommunication Systems and Networks*, STU Publishing house,

ETSI TS 101 475 (2000). Broadband Radio Access Networks (BRAN), HIPERLAN Type 2,

ETSI TS 101 761-1 (2001). Broadband Radio Access Networks (BRAN), HIPERLAN Type 2,

Ferreira, H.C.; Lampe, L.; Newbury, J.; Swart, T.G. (2010). *Power Line Communications*, John Wiley & Sons, ISBN 978-0-470-74030-9, Chichester, United Kingdom Götz, M.; Rapp, M.; Dostert, K. (2004). Power Line Channel Characteristics and Their Effect

Held, G. (2006). *Understanding Broadband over Power Line*, Auerbach Publications, ISBN

Hrasnica, H.; Haidine, A.; Lehnert, R. (2004). *Broadband Powerline Communications Networks*, John Wiley & Sons, ISBN 0-470-85741-2, Chichester, United Kingdom Cherubini, G. et al. (2000). Filter Bank Modulation Techniques for Very High-Speed Digital

Kaminow, I.P.; Li, T.; Willner, A.E. (2008). *Optical Fiber Telecommunications V B: Systems and* 

Mukherjee, B. (2006). *Optical WDM Networks*, Springer Science+Business Media Inc., ISBN

Mestagh, D. et al. (2000). Zipper VDSL –A Solution for Robust Duplex Communication over

Oksman, V.; Werner J.-J. (2000). Single-Carrier Modulation Technology for Very High-Speed

Róka, R. (2002). Theoretical and practical limits of transmission channels used by the ADSL

Róka, R.; Cisár, R. (2002). The Analysis of Negative Influences in the Environment of

Data Link Control (DLC) Layer, Part 1: Basic Data Transport Functions, (December

on Communication System Design. *IEEE Communications Magazine*, Vol.42, No.4,

Subscriber Lines. *IEEE Communication Magazine*, Vol.38, No.5, (May 2000), pp. 98-

*Networks*, Elsevier Inc., ISBN 978-0-12-374172-1, San Diego, United States of

Telephone Lines. *IEEE Communications Magazine*, Vol.38, No.5, (May 2000), pp. 90-

Digital Subscriber Line. *IEEE Communications Magazine*, Vol.38, No.5, (May 2000),

technology in the metallic lines environment in the access network in Slovakia. *Journal of Electrical Engineering - EČ*, Vol. 53, No. 3-4, (March 2002), pp. 91-96, ISSN

Homogeneous Symmetric Lines at the Signal Transmission by Means of the ADSL

ISBN 0-13-060726-6, New Jersey, United States of America

Physical (PHY) Layer, Technical Specification, (April 2000)

ETSI TS 101 270-1 (1999). VDSL, Part 1 - Functional requirements, (October 1999) ETSI TS 101 270-2 (2001). VDSL, Part 2 - Transceiver specification, (February 2001)

Boca Raton, United States of America

ISBN 80-227-2437-8, Bratislava, Slovakia

(April 2004), pp. 78-86, ISSN 0163-6804

104, ISSN 0163-6804

96, ISSN 0163-6804

pp. 82-89, ISSN 0163-6804

America

1335-3632

0-8493-9846-0, Boca Raton, United States of America

978-0387-29055-3, New York, United States of America

Limiting information rates with crosstalk noise. *IEEE Transactions on* 

**11. References** 

2001)

## **10. Abbreviations**


## **11. References**

66 Technology and Engineering Applications of Simulink

**10. Abbreviations** 

ADSL Asymmetric DSL

BA ISDN Basic Access ISDN BER Bit Error Rate

CD Chromatic Dispersion

DGD Differential Group Delay

DSF Dispersion Shifted Fiber

FEC Forward Error Correction

FDD Frequency Division Duplex FTTEx Fiber To The Exchange FWM Four Wave Mixing ISI Inter-Symbol Interference MCM Multi-Carrier Modulation

NZDF Non-Zero Dispersion shifted Fiber

PLC Power Line Communication PMD Polarization Mode Dispersion POTS Plain Old Telephone Service PSD Power Spectral Density PSP Principal State of Polarization QAM Quadrature Amplitude Modulation

RFI Radio Frequency Interference

SBS Stimulated Brillouin Scattering SCM Single-Carrier Modulation SDP Subscriber Distribution Point

WDM Wavelength Division Multiplexing

xDSL "x" Digital Subscriber Line XPM Cross Phase Modulation XPolM Cross Polarization Modulation

FEXT Far-End Crosstalk

MMF Multi-Mode Fiber NEXT Near-End Crosstalk

OOK On-Off Keying

RC Reference Channel

SMF Single-Mode Fiber SNR Signal-to-Noise Ratio SPM Self Phase Modulation SRS Stimulated Raman Scattering TCM Trellis-Coded Modulation USF Dispersion Unshifted Fiber VDSL Very high bit rate DSL

RS Reed-Solomon

AWGN Additive White Gaussian Noise

BCH Bose-Chaudury-Hocquenghem

DBPSK Differential Binary Phase Shift Keying

DQPSK Differential Quadrature Phase Shift Keying

ETSI European Telecommunications Standards Institute


**4** 

*São Paulo University* 

*Brazil* 

**Co-Simulation Procedure for PID and Fuzzy** 

Cristiano Okada Pontelli and Mario Francisco Mucheroni

**Sprayers Boom Suspension** 

**Logic Active Controls Strategies Applied to a** 

The boom sprayers are responsible for applying chemical products on cultures in order to maximize agricultural production. The spray is the fractionation of liquid droplets in order to distribute uniformly over the target. So smaller is the liquid volume to be distributed through the area, so smaller is the required drop diameter. The sprayers are designed just to generate drops and throwing them over the target with the required

The spray distribution uniformity of sprayers boom is given by the assembly and operation conditions such as, nozzle spacing and opening angle, boom distance from soil, liquid pressure and dynamic stability of the boom. The liquid volume distributed along the boom

The vertical boom oscillations caused by irregularities in the terrain modifies the distance between each nozzle and the target, distorting the distribution. Moreover, when the oscillations are excessive the tips of the boom can touch the ground, causing damages. These oscillations may increase with walking speed of the tractor vehicle, Musillami (1977). The horizontal boom oscillations also change the sprays uniformity, but in a smaller proportion

Another fairly common problem that can also change the application uniformity is the error in the juxtaposition of culture bands covered by the spray. Insufficient or excessive spacing

Various methods to study the quality of spray distribution under the dynamical aspects of the movement are known. These methods differ in the way of exciting the sprayer. One of them uses the excitation by a vehicle walking on a standard grass track prepared (POCHI et al., 2002, MILLER et al., 1989), or translating on a track prepared with artificial obstacles (CHAPLIN and WU, 1989). Other methods develop and use a shake driver to simulate a

Herbst and Wolf (2001) developed a servo-mechanism to perform excitations on sprayers. They measured the sprays of various equipments, pulled sprayers and tractor mounted

between these bands can cause a variation in liquid volume used up to 100%.

**1. Introduction** 

uniformity.

than the vertical ones.

should be as constant as possible, Sinfort (1994).

track with obstacles (SINFORT et al., 1997).

Technology. *Journal of Electrical Engineering - EČ*, Vol.53, No.9-10, (September 2002), pp. 241-249, ISSN 1335-3632


## **Co-Simulation Procedure for PID and Fuzzy Logic Active Controls Strategies Applied to a Sprayers Boom Suspension**

Cristiano Okada Pontelli and Mario Francisco Mucheroni *São Paulo University Brazil* 

## **1. Introduction**

68 Technology and Engineering Applications of Simulink

Róka, R. (2004). Environmental Influences on the Power Spectral Densities of VDSL Signals.

Róka, R.; Dlháň, S. (2005). Modeling of transmission channels over the low-voltage power

Róka, R.; Urminský, J. (2008). Experimental Measurements for Verification of the Parametric

Schiff, M. (2006). *Introduction to Communication Systems Simulation*, Artech House Inc., ISBN

Shieh, W.; Djordjevic, I. (2010). *OFDM for Optical Communications*, Elsevier Inc., ISBN 978-0-

Werner, J. J. (1991). The HDSL Environment. *IEEE Journal on Selected Areas in Communications*, Vol.SAC-9, No.6, (August 1991), pp. 785-800, ISSN 0733-8716 Xiong, F. (2000). *Digital Modulation Techniques*, Artech House Inc., ISBN 0-89006-970-0,

Zimmermann, M.; Dostert, K. (2002a). Analysis and Modeling of Impulsive Noise in

*Compatibility*, Vol.44, No.1, (February 2002), pp. 249 – 258, ISSN 0018-9375 Zimmermann, M.; Dostert, K. (2002b). Multipath Model for the Powerline Channel. *IEEE* 

Broadband Powerline Communications. *IEEE Transactions on Electromagnetic* 

*Transactions on Communications*, Vol.50, No.4, (April 2002), pp. 553-559, ISSN 0090-

*Engineering – EČ*, Vol. 59, No. 3, (May 2008), pp. 146-152, ISSN 1335-3632 Róka, R. (2009). Modeling of Environmental Influences at the Signal Transmission by means

pp. 241-249, ISSN 1335-3632

(September 2005), pp. 237-245, ISSN 1335-3632

1-59693-002-0, Norwood, United States of America

12-374879-9, San Diego, United States of America

Norwood, United States of America

1335-3632

2073-607X

6778

Technology. *Journal of Electrical Engineering - EČ*, Vol.53, No.9-10, (September 2002),

*Journal of Electrical Engineering – EČ*, Vol.55, No.1-2, (January 2004), pp. 18-24, ISSN

distribution network. *Journal of Electrical Engineering – EČ*, Vol. 56, No. 9-10,

Model for Reference Channels in the Real PLC Environment. *Journal of Electrical* 

of the VDSL and PLC Technologies. *International Journal of Electrical Communication Networks and Information Security – IJCNIS*, Vol. 1, No. 1, (April 2009), pp. 6-13, ISSN

> The boom sprayers are responsible for applying chemical products on cultures in order to maximize agricultural production. The spray is the fractionation of liquid droplets in order to distribute uniformly over the target. So smaller is the liquid volume to be distributed through the area, so smaller is the required drop diameter. The sprayers are designed just to generate drops and throwing them over the target with the required uniformity.

> The spray distribution uniformity of sprayers boom is given by the assembly and operation conditions such as, nozzle spacing and opening angle, boom distance from soil, liquid pressure and dynamic stability of the boom. The liquid volume distributed along the boom should be as constant as possible, Sinfort (1994).

> The vertical boom oscillations caused by irregularities in the terrain modifies the distance between each nozzle and the target, distorting the distribution. Moreover, when the oscillations are excessive the tips of the boom can touch the ground, causing damages. These oscillations may increase with walking speed of the tractor vehicle, Musillami (1977). The horizontal boom oscillations also change the sprays uniformity, but in a smaller proportion than the vertical ones.

> Another fairly common problem that can also change the application uniformity is the error in the juxtaposition of culture bands covered by the spray. Insufficient or excessive spacing between these bands can cause a variation in liquid volume used up to 100%.

> Various methods to study the quality of spray distribution under the dynamical aspects of the movement are known. These methods differ in the way of exciting the sprayer. One of them uses the excitation by a vehicle walking on a standard grass track prepared (POCHI et al., 2002, MILLER et al., 1989), or translating on a track prepared with artificial obstacles (CHAPLIN and WU, 1989). Other methods develop and use a shake driver to simulate a track with obstacles (SINFORT et al., 1997).

> Herbst and Wolf (2001) developed a servo-mechanism to perform excitations on sprayers. They measured the sprays of various equipments, pulled sprayers and tractor mounted

Co-Simulation Procedure for PID and

simulations are presented.

body software (ADAMS).

**2.1.1 Passive model** 

**2. Models, simulations and results comparisons** 

**2.1 Description of the models used in simulations** 

Fig. 2.1. Passive suspension model with its main dimensions.

**2.1.2 Model with sensor fusion and proportional control** 

Fig. 2.2. Boom model with 3 sensors for fusion and proportional control.

Fuzzy Logic Active Controls Strategies Applied to a Sprayers Boom Suspension 71

We used a calibrated virtual model that was developed for some simulations to test control strategies. The performances of these strategies are compared with the performance of a passive suspension model. Following a brief description of the models and all the

This part will show the main configurations of the models used in simulations with the rigid

Figure 2.1 shows a trapezoidal type passive boom suspension model with its main dimensions.

We used a boom suspension of trapezoidal type with the same dimensions listed in Figure 2.1. We used three position measurement sensors uniformily distributed along the length of the boom. The sensor 1 was placed at 4 meters from the center of the equipment, the sensor 2 at 8 meters from the center and the sensor 3 at 12 meters from the center, as illustrated in Figure 2.2.

sprayers from different manufacturers. In these experiments they found coefficients of variation from 5 to 22%, depending of the boom length, the walking speed and excitation method used. According to these researchers a coefficient of variation in order of 15% would be an acceptable value for the usual ground conditions founded.

One procedure to minimize the coefficient of variation of spray distribution is to design and use mechanisms to stabilize the boom within acceptable parameters. These mechanisms are known as boom suspensions for sprayers.

On many sprayers there are control of spray mean height and systems of boom movement management with passive boom suspensions. The active controls are still less used. However unstable movements have been characterized as a great limitation for chemical products applications with precision and good uniformity, (RAMON and BAERDEMAEKER 1997, POCHI and VANNUCCI, 2001).

Womac et al. (2001) investigated the effect of nozzle height and the equipment walking speed in the uniformity of chemical products application in field conditions. The coefficient of variation founded stays from 5% to 17% for boom static conditions and 6% to 37% for boom in motion (6 to 26 km.h-1).

Sinfort and Herbst (1996) studied the boom movement and the spray pattern in terms of practical use. The movements of the spray boom were evaluated by a simulator with hydraulic cylinders and the spray pattern was simulated by software. It is concluded that the roll motions are responsible for major non-uniformity of liquid application.

Ramon et al. (1997) developed a polynomial model to predict the distribution of a single spray nozzle that moves on a channels table 15 meters long. The difference founded between the measured and the simulated values was below 7%. They observed also that the boom downward movements affect the liquid distribution more than the boom upward movements.

Speelman and Jansen (1974) determined that the amount of vibrations on the sprayer boom is influenced by the structure of the boom, ground surface irregularities and walking speed. Using an initial condition of 0.5 meters spray height, they observed that as amplitudes of boom vertical motion increase, the uniformity of spray distribution decreases.

On cereals spraying, Nation (1980) determined that the spray deposit variation is proportional to the movement of the sprayer boom end. He also observed that random vertical movements of the sprayer boom are more influenced by roll movements than vertical translation motions of the boom.

Considering a boom as rigid body subjected to sinusoidal inputs, Iyer and Wills (1978) proved that the bigest source of the spray distribution variation comes from the own movement of the boom

Langenakens et al. (1999) founded that increasing the vehicle translation speed, the boom oscillation amplitude also increases. They obtained for applied liquid volume coefficients of variation from 2% to 173%, caused mainly by boom rolling movement resulting from vehicle translation.

## **2. Models, simulations and results comparisons**

We used a calibrated virtual model that was developed for some simulations to test control strategies. The performances of these strategies are compared with the performance of a passive suspension model. Following a brief description of the models and all the simulations are presented.

## **2.1 Description of the models used in simulations**

This part will show the main configurations of the models used in simulations with the rigid body software (ADAMS).

## **2.1.1 Passive model**

70 Technology and Engineering Applications of Simulink

sprayers from different manufacturers. In these experiments they found coefficients of variation from 5 to 22%, depending of the boom length, the walking speed and excitation method used. According to these researchers a coefficient of variation in order of 15% would

One procedure to minimize the coefficient of variation of spray distribution is to design and use mechanisms to stabilize the boom within acceptable parameters. These mechanisms are

On many sprayers there are control of spray mean height and systems of boom movement management with passive boom suspensions. The active controls are still less used. However unstable movements have been characterized as a great limitation for chemical products applications with precision and good uniformity, (RAMON and

Womac et al. (2001) investigated the effect of nozzle height and the equipment walking speed in the uniformity of chemical products application in field conditions. The coefficient of variation founded stays from 5% to 17% for boom static conditions and 6% to 37% for

Sinfort and Herbst (1996) studied the boom movement and the spray pattern in terms of practical use. The movements of the spray boom were evaluated by a simulator with hydraulic cylinders and the spray pattern was simulated by software. It is concluded that

Ramon et al. (1997) developed a polynomial model to predict the distribution of a single spray nozzle that moves on a channels table 15 meters long. The difference founded between the measured and the simulated values was below 7%. They observed also that the boom downward movements affect the liquid distribution more than the boom upward

Speelman and Jansen (1974) determined that the amount of vibrations on the sprayer boom is influenced by the structure of the boom, ground surface irregularities and walking speed. Using an initial condition of 0.5 meters spray height, they observed that as amplitudes of boom vertical motion increase, the uniformity of spray distribution

On cereals spraying, Nation (1980) determined that the spray deposit variation is proportional to the movement of the sprayer boom end. He also observed that random vertical movements of the sprayer boom are more influenced by roll movements than

Considering a boom as rigid body subjected to sinusoidal inputs, Iyer and Wills (1978) proved that the bigest source of the spray distribution variation comes from the own

Langenakens et al. (1999) founded that increasing the vehicle translation speed, the boom oscillation amplitude also increases. They obtained for applied liquid volume coefficients of variation from 2% to 173%, caused mainly by boom rolling movement resulting from vehicle

the roll motions are responsible for major non-uniformity of liquid application.

be an acceptable value for the usual ground conditions founded.

BAERDEMAEKER 1997, POCHI and VANNUCCI, 2001).

known as boom suspensions for sprayers.

boom in motion (6 to 26 km.h-1).

vertical translation motions of the boom.

movement of the boom

movements.

decreases.

translation.

Figure 2.1 shows a trapezoidal type passive boom suspension model with its main dimensions.

Fig. 2.1. Passive suspension model with its main dimensions.

## **2.1.2 Model with sensor fusion and proportional control**

We used a boom suspension of trapezoidal type with the same dimensions listed in Figure 2.1. We used three position measurement sensors uniformily distributed along the length of the boom. The sensor 1 was placed at 4 meters from the center of the equipment, the sensor 2 at 8 meters from the center and the sensor 3 at 12 meters from the center, as illustrated in Figure 2.2.

Fig. 2.2. Boom model with 3 sensors for fusion and proportional control.

Co-Simulation Procedure for PID and

the left sensor position 3 (at the boom left tip).

name and it will measure this variable, as shown in Figure 2.4.

Fig. 2.4. Box dialog for creating an input state variable.

Fig. 2.5. Dialog box for creating an output state variable.

the zero default value, as shown in Figure 2.5.

Fuzzy Logic Active Controls Strategies Applied to a Sprayers Boom Suspension 73

forces are calculated according to strategy and then applied to a control designed into the Adams. The first step is to define what are the input and output variables for the Adams model. Here the input variable is the force law and force the actuator to the actuator left. The output variables are the right sensor position 1, the right sensor position 2, the right sensor position 3 (at the boom right tip), the left sensor position 1, the left sensor position 2,

The second step is to create these variables in the Adams; so we need to create one variable for each state variable. To create a new state variable we need to select in the menu, following the instructions: Build, System Elements - state variability - New. Then insert the

For the output variables follow the same steps except that F (time ,...) should be maintained

The control strategy we used takes information from three position sensors making an weighted average with coefficients related to the distance from the center of the equipment. These coefficients increase from sensor 1 to sensor 3 to give more weight on rolling motion, because the boom pivoted at the point A. To keep the boom at a constant height of 500 mm from the ground is the main target. Therefore the control equation, using the force variable, is:

$$Fa = -Fe + k \left[ -500 + \left( \frac{1}{6} \right) sensor1 + \left( \frac{1}{3} \right) sensor2 + \left( \frac{1}{2} \right) sensor3 \right] \tag{1}$$

where:

Fa: actuator force (N);

Fe: actuator static force relative to the weight of the boom (N) k: gain sensor 1: ground position measurement (mm) - 4 m from equipment center sensor 2: ground position measurement (mm) - 8 m from equipment center sensor 3: ground position measurement (mm) - 12 m from equipment center

## **2.1.3 Model with sensor fusion and fuzzy logic**

We used a boom suspension of trapezoidal type with the dimensions listed in Figure 2.1. We used three position measurement sensors uniformly distributed along the length of the boom. The first sensor is placed at 4 meters from the center of the equipment, the second at 8 meters from the center and the third at 12 meters from the center, as illustrated in Figure 2.2.

Here we used a procedure identified as a co-simulation method between ADAMS and MATLAB softwares, with the goal of the model of interacting rigid body capabilities of Adams software with the control plant capabilities of fuzzy system simulations in Matlab software. This procedure is showed schematically in Figure 2.3.

Fig. 2.3. Co-Simulation between ADAMS and MATLAB software.

Figure 2.3 is a simple diagram that shows how co-simulation is performed. The output variables of the model of Adams are exported to the plant control in Matlab. The actuator

The control strategy we used takes information from three position sensors making an weighted average with coefficients related to the distance from the center of the equipment. These coefficients increase from sensor 1 to sensor 3 to give more weight on rolling motion, because the boom pivoted at the point A. To keep the boom at a constant height of 500 mm from the ground is the main target. Therefore the control equation, using the force variable,

*Fa Fe k sensor sensor sensor*

Fe: actuator static force relative to the weight of the boom (N)

software. This procedure is showed schematically in Figure 2.3.

Fig. 2.3. Co-Simulation between ADAMS and MATLAB software.

**2.1.3 Model with sensor fusion and fuzzy logic** 

sensor 1: ground position measurement (mm) - 4 m from equipment center sensor 2: ground position measurement (mm) - 8 m from equipment center sensor 3: ground position measurement (mm) - 12 m from equipment center

We used a boom suspension of trapezoidal type with the dimensions listed in Figure 2.1. We used three position measurement sensors uniformly distributed along the length of the boom. The first sensor is placed at 4 meters from the center of the equipment, the second at 8 meters from the center and the third at 12 meters from the center, as

Here we used a procedure identified as a co-simulation method between ADAMS and MATLAB softwares, with the goal of the model of interacting rigid body capabilities of Adams software with the control plant capabilities of fuzzy system simulations in Matlab

Figure 2.3 is a simple diagram that shows how co-simulation is performed. The output variables of the model of Adams are exported to the plant control in Matlab. The actuator

11 1 <sup>500</sup> <sup>1</sup> <sup>2</sup> <sup>3</sup> 63 2

(1)

is:

where:

k: gain

Fa: actuator force (N);

illustrated in Figure 2.2.

forces are calculated according to strategy and then applied to a control designed into the Adams. The first step is to define what are the input and output variables for the Adams model. Here the input variable is the force law and force the actuator to the actuator left. The output variables are the right sensor position 1, the right sensor position 2, the right sensor position 3 (at the boom right tip), the left sensor position 1, the left sensor position 2, the left sensor position 3 (at the boom left tip).

The second step is to create these variables in the Adams; so we need to create one variable for each state variable. To create a new state variable we need to select in the menu, following the instructions: Build, System Elements - state variability - New. Then insert the name and it will measure this variable, as shown in Figure 2.4.


Fig. 2.4. Box dialog for creating an input state variable.

For the output variables follow the same steps except that F (time ,...) should be maintained the zero default value, as shown in Figure 2.5.


Fig. 2.5. Dialog box for creating an output state variable.

Co-Simulation Procedure for PID and

applied to the boom.

the Adams.

Figure 2.8.

Fig. 2.8. Block diagram of Adams in the Simulink.

Fuzzy Logic Active Controls Strategies Applied to a Sprayers Boom Suspension 75

The input and output variables are listed in the same order in which the respective connecting pins will appear in the control block. It is necessary that input and output pins are connected correctly each other to assure the proper simulation of the control systems

This export process will show three kinds of files, each one with a prefix defined in the dialog box of Figure 2.7. In this case we can see the files controleMP.adm, controleMP.cmd and controleMP.m. These files will be saved in the working directory of

The next step is to connect the block generated at the Adams model to the Simulink control plant. To adjust the control system with the Adams model we must first open the Adams block diagram in Matlab. To do this we must start Matlab and change the Matlab working directory to the same one used by Adams, that is, at the same location where the files are generated in the previous step. Once this is done we should write at the Matlab prompt the extension of the file we have created, in this case controleMP. This initializes the Adams input and output variables as Matlab variables. The next command used is Adams\_sys, that opens a window with a block diagram of Adams as shown in

With the input and output variables defined, the values of input variables obtained from Simulink must to be applied (referenced) in the model components of the Adams. In this case, the intensity of the actuator force obtained in Simulink must be referenced to its respective force in the Adams model. To reference the input variable, we should select the menu Edit - Modify and open the right force variable. This will open a dialog box as shown in Figure 2.6.


Fig. 2.6. Dialog box for an input variable allocation as a force component of the Adams.

The next step is the creation of the control plant to be exported to Simulink. To export the model, we select the Controls menu - Export Plant. A dialog box, shown in Figure 2.7, opens.


Fig. 2.7. Dialog box for export control plant to Adams.

With the input and output variables defined, the values of input variables obtained from Simulink must to be applied (referenced) in the model components of the Adams. In this case, the intensity of the actuator force obtained in Simulink must be referenced to its respective force in the Adams model. To reference the input variable, we should select the menu Edit - Modify and open the right force variable. This will open a dialog box as shown in Figure 2.6.

Fig. 2.6. Dialog box for an input variable allocation as a force component of the Adams.

Fig. 2.7. Dialog box for export control plant to Adams.

The next step is the creation of the control plant to be exported to Simulink. To export the model, we select the Controls menu - Export Plant. A dialog box, shown in Figure 2.7, opens.

The input and output variables are listed in the same order in which the respective connecting pins will appear in the control block. It is necessary that input and output pins are connected correctly each other to assure the proper simulation of the control systems applied to the boom.

This export process will show three kinds of files, each one with a prefix defined in the dialog box of Figure 2.7. In this case we can see the files controleMP.adm, controleMP.cmd and controleMP.m. These files will be saved in the working directory of the Adams.

The next step is to connect the block generated at the Adams model to the Simulink control plant. To adjust the control system with the Adams model we must first open the Adams block diagram in Matlab. To do this we must start Matlab and change the Matlab working directory to the same one used by Adams, that is, at the same location where the files are generated in the previous step. Once this is done we should write at the Matlab prompt the extension of the file we have created, in this case controleMP. This initializes the Adams input and output variables as Matlab variables. The next command used is Adams\_sys, that opens a window with a block diagram of Adams as shown in Figure 2.8.

Fig. 2.8. Block diagram of Adams in the Simulink.

Co-Simulation Procedure for PID and

Fig. 2.10. Dialog box of function block parameters.

Fuzzy Logic Active Controls Strategies Applied to a Sprayers Boom Suspension 77

A double click on the block subsystem at Adams\_Sub opens a new window that shows the available components, as seen in Figure 2.9.

A double click on the block plant at Adams opens a dialog box with the parameters that must be adjusted. The communication interval field specifies how often the Adams communicates with Simulink and the number of communications between them for each step of writing output. The animation mode field can be adjusted to be interactive, that is, the simulation can be shown graphically as the model is computed. These parameters can be seen in Figure 2.10.

Fig. 2.9. Subsystem model in Adams.

A double click on the block subsystem at Adams\_Sub opens a new window that shows the

A double click on the block plant at Adams opens a dialog box with the parameters that must be adjusted. The communication interval field specifies how often the Adams communicates with Simulink and the number of communications between them for each step of writing output. The animation mode field can be adjusted to be interactive, that is, the simulation can be shown graphically as the model is computed. These parameters can be

available components, as seen in Figure 2.9.

Fig. 2.9. Subsystem model in Adams.

seen in Figure 2.10.


Fig. 2.10. Dialog box of function block parameters.

Co-Simulation Procedure for PID and

average height obtained from equation 2.

Fig. 2.12. Input inference of weighted average height.

The input linguistic variables are:

Fig. 2.13. Force output inference.

AN: Negative Height; AZ: Zero Height; AP: Positive Height;

to the system.

Fuzzy Logic Active Controls Strategies Applied to a Sprayers Boom Suspension 79

The Figure 2.12 shows a graphic of input inference, where the variable is the weighted

The Figure 2.13 shows a graphic of output inference, where the variable is the force applied

After the necessary adjustments they should be copied into the block Adams\_sub plant control Simulink and then connect the inputs and outputs properly. Figure 2.11 shows an overview of the control system.

To construct the fuzzy system block we used a model with the method of centroid defuzzification Mamdani type. The weighted average height obtained from the sensors was used as input as follows:

$$A = \left[ -500 + \left(\frac{1}{6}\right)sensor \, 1 + \left(\frac{1}{3}\right)sensor \, 2 + \left(\frac{1}{2}\right)sensor \, 3 \right] \tag{2}$$

where:

A: value of weighted average height from the three sensors [mm].

Fig. 2.11. Fuzzy control system integrated with Adams.

The Figure 2.12 shows a graphic of input inference, where the variable is the weighted average height obtained from equation 2.

Fig. 2.12. Input inference of weighted average height.

The input linguistic variables are:

AN: Negative Height; AZ: Zero Height; AP: Positive Height;

78 Technology and Engineering Applications of Simulink

After the necessary adjustments they should be copied into the block Adams\_sub plant control Simulink and then connect the inputs and outputs properly. Figure 2.11 shows an

To construct the fuzzy system block we used a model with the method of centroid defuzzification Mamdani type. The weighted average height obtained from the sensors was

> <sup>111</sup> <sup>500</sup> <sup>1</sup> <sup>2</sup> <sup>3</sup> 632 *A sensor sensor sensor*

A: value of weighted average height from the three sensors [mm].

Fig. 2.11. Fuzzy control system integrated with Adams.

(2)

overview of the control system.

used as input as follows:

where:

The Figure 2.13 shows a graphic of output inference, where the variable is the force applied to the system.

Fig. 2.13. Force output inference.

Co-Simulation Procedure for PID and

Fe: actuator static force relative to the weight of the boom (N)

Fa: actuator force (N);

**2.2 Simulations** 

control suspension.

where:

control.

control.

2.16.

type of control.

**2.2.1 Step inputs** 

Fig. 2.16. Model for step type input.

Fuzzy Logic Active Controls Strategies Applied to a Sprayers Boom Suspension 81

f (fuzzy): the function obtained by defuzzification of the fuzzy model shown in Figure 2.15.

The simulations were conducted in order to evaluate the three kinds of suspension in analysis, that are a passive suspension, an active PID control suspension and active Fuzzy

The input conditions were grouped into three sets: the first set corresponds to step type

In the first set of inputs, we used two step sizes. With this kind of analysis we expected to evaluate the system overshoot, settling time and the power consumed for each type of

In the second set of inputs, we used two amplitudes and two frequencies in order to be able to measure the conditions of the boom oscillations and the power consumed by each type of

In the third set of inputs, we used random signals, taking from tractors standards (ASABE / ISO 5008, 2002) to evaluate the conditions of boom oscillation and power consumed for each

In this first set of simulation analysis we used a step type input with angle amplitudes of 5 and 10 degrees, which corresponds to the equipment transposing a 160 and 320 mm step obstacles, respectively, with a 1800 mm distance between tires, as shown in Figure

input, the second to harmonic type input and the third to random type of input.

The output linguistic variables are:

FN: Negative Force; ZP: Zero Force; FP: Positive Force;

We find the rules for defuzzification of the input variables on output variables though the bos shown in Figure 2.14.


Fig. 2.14. Box of fuzzy rules used in the equipment model.

We can also define the curve of relationship between output and input using the rules previously established, as shown in Figure 2.15.


Fig. 2.15. Input versus output curve.

Therefore the control equation, using the fuzzy control power variable is:

$$Fa = -Fe + f\left(fuxzy\right) \tag{3}$$

where:

80 Technology and Engineering Applications of Simulink

We find the rules for defuzzification of the input variables on output variables though the

We can also define the curve of relationship between output and input using the rules

The output linguistic variables are:

Fig. 2.14. Box of fuzzy rules used in the equipment model.

previously established, as shown in Figure 2.15.

Fig. 2.15. Input versus output curve.

Therefore the control equation, using the fuzzy control power variable is:

*Fa Fe f fuzzy* ( ) (3)

FN: Negative Force; ZP: Zero Force; FP: Positive Force;

bos shown in Figure 2.14.

Fa: actuator force (N); Fe: actuator static force relative to the weight of the boom (N) f (fuzzy): the function obtained by defuzzification of the fuzzy model shown in Figure 2.15.

## **2.2 Simulations**

The simulations were conducted in order to evaluate the three kinds of suspension in analysis, that are a passive suspension, an active PID control suspension and active Fuzzy control suspension.

The input conditions were grouped into three sets: the first set corresponds to step type input, the second to harmonic type input and the third to random type of input.

In the first set of inputs, we used two step sizes. With this kind of analysis we expected to evaluate the system overshoot, settling time and the power consumed for each type of control.

In the second set of inputs, we used two amplitudes and two frequencies in order to be able to measure the conditions of the boom oscillations and the power consumed by each type of control.

In the third set of inputs, we used random signals, taking from tractors standards (ASABE / ISO 5008, 2002) to evaluate the conditions of boom oscillation and power consumed for each type of control.

## **2.2.1 Step inputs**

In this first set of simulation analysis we used a step type input with angle amplitudes of 5 and 10 degrees, which corresponds to the equipment transposing a 160 and 320 mm step obstacles, respectively, with a 1800 mm distance between tires, as shown in Figure 2.16.

Fig. 2.16. Model for step type input.

Co-Simulation Procedure for PID and

each suspension system used.

sensor position.

Fuzzy Logic Active Controls Strategies Applied to a Sprayers Boom Suspension 83

Fig. 2.18. Behavior of active systems subjected to a 5 degrees step input amplitude.

The Figure 2.19 shows the displacement behavior of the three positions of the boom right side of the passive system, active PID system and active Fuzzy system subjected to a step type input with angle amplitude of 10 degrees. It is also shown the power consumed by

Fig. 2.19. Behavior of suspension systems subjected to a step input amplitude of 10 degrees.

From the analysis of Figure 2.19 it is possible to note the great advantage of active systems when compared with passive system considering boom displacements, independently of the

Figure 2.20 shows the behaviors of active systems. We can observe that the active Fuzzy system stabilizes in less time interval than the active PID system but has a larger overshoot

The Figure 2.17 shows the displacement behavior of the three positions of the boom right side with the passive system, active PID system and active Fuzzy system, all subjected to a step type input with an angle amplitude of 5 degrees. It is also shown the power consumed by each suspension system used.

From the analysis of Figure 2.17 it is possible to note a great advantage of active systems when compared with passive system considering boom displacements, independently of the sensor position.

The Figure 2.18 shows the behaviors of active systems. We can observe that the Fuzzy active system stabilizes the boom quicker than the active PID system, but it has a larger overshoot signal for all the three sensors than PID. The RMS power value of active PID system is 0.30 kW and for Fuzzy active system is 0.32 kW.

The Figure 2.17 shows the displacement behavior of the three positions of the boom right side with the passive system, active PID system and active Fuzzy system, all subjected to a step type input with an angle amplitude of 5 degrees. It is also shown the power consumed

From the analysis of Figure 2.17 it is possible to note a great advantage of active systems when compared with passive system considering boom displacements, independently of the

The Figure 2.18 shows the behaviors of active systems. We can observe that the Fuzzy active system stabilizes the boom quicker than the active PID system, but it has a larger overshoot signal for all the three sensors than PID. The RMS power value of active PID system is 0.30

Fig. 2.17. Behavior of suspension systems subjected to a step input amplitude of 5 degrees.

by each suspension system used.

kW and for Fuzzy active system is 0.32 kW.

sensor position.

Fig. 2.18. Behavior of active systems subjected to a 5 degrees step input amplitude.

The Figure 2.19 shows the displacement behavior of the three positions of the boom right side of the passive system, active PID system and active Fuzzy system subjected to a step type input with angle amplitude of 10 degrees. It is also shown the power consumed by each suspension system used.

Fig. 2.19. Behavior of suspension systems subjected to a step input amplitude of 10 degrees.

From the analysis of Figure 2.19 it is possible to note the great advantage of active systems when compared with passive system considering boom displacements, independently of the sensor position.

Figure 2.20 shows the behaviors of active systems. We can observe that the active Fuzzy system stabilizes in less time interval than the active PID system but has a larger overshoot

Co-Simulation Procedure for PID and

amplitude and 0.1 Hz frequency.

amplitude and 0.1 Hz frequency.

consumed by each suspension system used.

Fuzzy Logic Active Controls Strategies Applied to a Sprayers Boom Suspension 85

Fig. 2.21. Behavior of suspension systems subjected to harmonic input with 5 degrees

Fig. 2.22. Behavior of active suspension systems subjected to harmonic input of 5 degrees

Figure 2.23 shows the displacement behavior of the three positions of the boom right side of the passive system, active PID system and active Fuzzy system subjected to a harmonic input with amplitude of 5 degrees and frequency of 2 Hz. It is also shown the power

signal for all three sensors. The RMS power value of the active PID system is 0.49 kW and for Fuzzy active system is 0.50 kW.

Fig. 2.20. Behavior of active systems subjected to a 10 degrees step input amplitude.

## **2.2.2 Harmonics inputs**

The following Table 2.1 shows the harmonic parameters of the simulation signal used. We use two amplitudes and two frequencies for sinusoidal signals. Therefore four sinusoidal inputs were used in the systems simulations developed, as shown in Table 2.1.


Table 2.1. Amplitudes and frequencies of 4 sinusoidal inputs.

The Figure 2.21 shows the displacement behavior of the three positions of the boom right side of passive system, active PID system and active Fuzzy system subjected to a harmonic input with amplitude of 5 degrees and frequency of 0.1 Hz. It is also shown the power consumed by each suspension system used.

From the analysis of Figure 2.21 it is possible to note the great advantage of the active systems when compared with the passive system considering boom displacements, independently of the sensor position.

In Figure 2.22 we can see that there are no significant differences between the active system PID and fuzzy active system behavior for any simulated positions.

signal for all three sensors. The RMS power value of the active PID system is 0.49 kW and

Fig. 2.20. Behavior of active systems subjected to a 10 degrees step input amplitude.

inputs were used in the systems simulations developed, as shown in Table 2.1.

Table 2.1. Amplitudes and frequencies of 4 sinusoidal inputs.

PID and fuzzy active system behavior for any simulated positions.

consumed by each suspension system used.

independently of the sensor position.

The following Table 2.1 shows the harmonic parameters of the simulation signal used. We use two amplitudes and two frequencies for sinusoidal signals. Therefore four sinusoidal

Simulations Amplitude (degree) Frequency (Hz) Simulation Code 1 5 0,1 A5F0,1 2 5 2,0 A5F2 3 10 0,1 A10F0,1 4 10 2,0 A10F2

The Figure 2.21 shows the displacement behavior of the three positions of the boom right side of passive system, active PID system and active Fuzzy system subjected to a harmonic input with amplitude of 5 degrees and frequency of 0.1 Hz. It is also shown the power

From the analysis of Figure 2.21 it is possible to note the great advantage of the active systems when compared with the passive system considering boom displacements,

In Figure 2.22 we can see that there are no significant differences between the active system

for Fuzzy active system is 0.50 kW.

**2.2.2 Harmonics inputs** 

Fig. 2.21. Behavior of suspension systems subjected to harmonic input with 5 degrees amplitude and 0.1 Hz frequency.

Fig. 2.22. Behavior of active suspension systems subjected to harmonic input of 5 degrees amplitude and 0.1 Hz frequency.

Figure 2.23 shows the displacement behavior of the three positions of the boom right side of the passive system, active PID system and active Fuzzy system subjected to a harmonic input with amplitude of 5 degrees and frequency of 2 Hz. It is also shown the power consumed by each suspension system used.

Co-Simulation Procedure for PID and

amplitude and 0.1 Hz frequency.

and active Fuzzy system for any position simulated.

sensor position.

and 0.1 Hz frequency.

consumed by each active system used.

Fuzzy Logic Active Controls Strategies Applied to a Sprayers Boom Suspension 87

with amplitude of 10 degrees and a frequency of 0.1 Hz. It is also shown the power

Fig. 2.25. Behavior of suspension systems subjected to harmonic input with 10 degrees

From the analysis of Figure 2.25 is possible to note the great advantage of active systems when compared with passive system considering boom displacements, independently of the

In Figure 2.26 we can see that there are no significant differences between active PID system

Fig. 2.26. Behavior of active systems subjected to harmonic input with 10 degrees amplitude

Fig. 2.23. Behavior of suspension systems subjected to harmonic input with 5 degrees amplitude and 2 Hz frequency.

From the analysis of Figure 2.23 we can see that active control systems are more efficient than passive system for all positions simulated.

From Figure 2.24 we can see that there are significant differences between active PID system and active Fuzzy system at position 3, the tip of the boom. The RMS value of power consumed by the active PID system is 3.32 kW while the RMS value of power consumed by active Fuzzy system is 1.57 kW.

Fig. 2.24. Behavior of active systems subjected to harmonic input with 5 degrees amplitude and 2 Hz frequency.

Figure 2.25 shows the displacement behavior of the three positions of the boom right side of passive system, active PID system and active Fuzzy system subjected to a harmonic input

Fig. 2.23. Behavior of suspension systems subjected to harmonic input with 5 degrees

From the analysis of Figure 2.23 we can see that active control systems are more efficient

From Figure 2.24 we can see that there are significant differences between active PID system and active Fuzzy system at position 3, the tip of the boom. The RMS value of power consumed by the active PID system is 3.32 kW while the RMS value of power consumed by

Fig. 2.24. Behavior of active systems subjected to harmonic input with 5 degrees amplitude

Figure 2.25 shows the displacement behavior of the three positions of the boom right side of passive system, active PID system and active Fuzzy system subjected to a harmonic input

amplitude and 2 Hz frequency.

active Fuzzy system is 1.57 kW.

and 2 Hz frequency.

than passive system for all positions simulated.

with amplitude of 10 degrees and a frequency of 0.1 Hz. It is also shown the power consumed by each active system used.

Fig. 2.25. Behavior of suspension systems subjected to harmonic input with 10 degrees amplitude and 0.1 Hz frequency.

From the analysis of Figure 2.25 is possible to note the great advantage of active systems when compared with passive system considering boom displacements, independently of the sensor position.

In Figure 2.26 we can see that there are no significant differences between active PID system and active Fuzzy system for any position simulated.

Fig. 2.26. Behavior of active systems subjected to harmonic input with 10 degrees amplitude and 0.1 Hz frequency.

Co-Simulation Procedure for PID and

**2.2.3 Random inputs** 

ground.

ground.

Fuzzy Logic Active Controls Strategies Applied to a Sprayers Boom Suspension 89

For this simulation set, we use input signals from a vibration analysis of tractors standard (ASABE / ISO 5008, 2002). This standard establishes two pavement types (smooth and rough), and gives the Cartesian coordinates for each type of track. These coordinates are put

Figure 2.29 shows the smooth pavement condition with equipment travel speed of 5 km/h.

From the analysis of Figure 2.29 it is possible to note the efficiency of active control to keep

In Figure 2.30 it is possible to note the equivalence of both active control systems, ie, there are no significant differences in maintaining the height of the boom from the

Figure 2.31 shows the smooth condition of pavement with equipment travel speed of 7.5 km/h. It also shows the boom displacement at the three sensor positions (1, 2 and 3).

From the analysis of Figure 2.31 it is possible to note the efficiency of active control to

In Figure 2.32 it is possible to note the equivalence of both active control systems, ie, there are no significant differences in maintaining the height of the boom from the

It also shows the boom displacement at the three sensor positions (1, 2 and 3).

through ADAMS software and then the simulations can be run.

keep constant the distance between the boom and the ground.

Fig. 2.29. Suspension systems submitted to a smooth track at 5 km/h.

constant the distance between the boom and the ground.

From the analysis of Figure 2.27 it is possible to see the best performance of active systems when compared with passive system considering boom displacements, independently regardless of sensor position.

Fig. 2.27. Behavior of suspension systems subjected to a harmonic input of 10 degrees amplitude and frequency of 2 Hz.

In Figure 2.28 we can see that there are no significant differences between active PID system and active Fuzzy system for any position simulated.

Fig. 2.28. Behavior of active systems subjected to a harmonic input range of 10 degrees amplitude and 2 Hz frequency.

## **2.2.3 Random inputs**

88 Technology and Engineering Applications of Simulink

From the analysis of Figure 2.27 it is possible to see the best performance of active systems when compared with passive system considering boom displacements, independently

Fig. 2.27. Behavior of suspension systems subjected to a harmonic input of 10 degrees

Fig. 2.28. Behavior of active systems subjected to a harmonic input range of 10 degrees

In Figure 2.28 we can see that there are no significant differences between active PID system

regardless of sensor position.

amplitude and frequency of 2 Hz.

amplitude and 2 Hz frequency.

and active Fuzzy system for any position simulated.

For this simulation set, we use input signals from a vibration analysis of tractors standard (ASABE / ISO 5008, 2002). This standard establishes two pavement types (smooth and rough), and gives the Cartesian coordinates for each type of track. These coordinates are put through ADAMS software and then the simulations can be run.

Figure 2.29 shows the smooth pavement condition with equipment travel speed of 5 km/h. It also shows the boom displacement at the three sensor positions (1, 2 and 3).

From the analysis of Figure 2.29 it is possible to note the efficiency of active control to keep constant the distance between the boom and the ground.

In Figure 2.30 it is possible to note the equivalence of both active control systems, ie, there are no significant differences in maintaining the height of the boom from the ground.

Figure 2.31 shows the smooth condition of pavement with equipment travel speed of 7.5 km/h. It also shows the boom displacement at the three sensor positions (1, 2 and 3).

From the analysis of Figure 2.31 it is possible to note the efficiency of active control to keep constant the distance between the boom and the ground.

In Figure 2.32 it is possible to note the equivalence of both active control systems, ie, there are no significant differences in maintaining the height of the boom from the ground.

Fig. 2.29. Suspension systems submitted to a smooth track at 5 km/h.

Co-Simulation Procedure for PID and

Fuzzy Logic Active Controls Strategies Applied to a Sprayers Boom Suspension 91

Fig. 2.32. Active suspension systems submitted to a smooth track at 7.5 km/h.

Fig. 2.33. Suspension systems submitted to a smooth track at 10 km/h.

constant the distance between the boom and the ground.

From the analysis of Figure 2.33 it is possible to note the efficiency of active control to keep

In Figure 2.34 it is possible to note the equivalence of both active control systems, ie, there

are no significant differences in maintaining the height of the boom from the ground.

Figure 2.33 shows the smooth condition of pavement with equipment travel speed of 10

km/h. It also shows the boom displacement at the three sensor positions (1, 2 and 3).

Fig. 2.30. Active suspension systems submitted to a smooth track at 5 km/h.

Fig. 2.31. Suspensions submitted to a smooth track at 7.5 km/h.

Fig. 2.30. Active suspension systems submitted to a smooth track at 5 km/h.

Fig. 2.31. Suspensions submitted to a smooth track at 7.5 km/h.

Fig. 2.32. Active suspension systems submitted to a smooth track at 7.5 km/h.

Figure 2.33 shows the smooth condition of pavement with equipment travel speed of 10 km/h. It also shows the boom displacement at the three sensor positions (1, 2 and 3).

Fig. 2.33. Suspension systems submitted to a smooth track at 10 km/h.

From the analysis of Figure 2.33 it is possible to note the efficiency of active control to keep constant the distance between the boom and the ground.

In Figure 2.34 it is possible to note the equivalence of both active control systems, ie, there are no significant differences in maintaining the height of the boom from the ground.

Co-Simulation Procedure for PID and

Fuzzy Logic Active Controls Strategies Applied to a Sprayers Boom Suspension 93

Fig. 2.36. Active suspension systems submitted to a rough track at 5 km/h.

Fig. 2.37. Suspension systems submitted to a rough track at 7.5 km/h.

constant the distance between the boom and the ground.

Figure 2.37 shows the rough condition of pavement with equipment travel speed of 7.5

From the analysis of Figure 2.37 it is possible to note the efficiency of active control to keep

In Figure 2.38 it is possible to note the equivalence of both active control systems, i.e., there

are no significant differences in maintaining the height of the boom from the ground.

km/h. It also shows the boom displacement at the three sensor positions (1, 2 and 3).

Fig. 2.34. Active suspension systems submitted to a smooth track at 10 km/h.

Figure 2.35 shows the rough condition of pavement with equipment travel speed of 5 km/h. It also shows the boom displacement at the three sensor positions (1, 2 and 3).

Fig. 2.35. Suspension systems submitted to a rough track at 5 km/h.

From the analysis of Figure 2.35 it is possible to note the efficiency of active control to keep constant the distance between the boom and the ground.

In Figure 2.36 it is possible to note the equivalence of both active control systems, ie, there are no significant differences in maintaining the height of the boom from the ground.

Fig. 2.34. Active suspension systems submitted to a smooth track at 10 km/h.

It also shows the boom displacement at the three sensor positions (1, 2 and 3).

Fig. 2.35. Suspension systems submitted to a rough track at 5 km/h.

constant the distance between the boom and the ground.

Figure 2.35 shows the rough condition of pavement with equipment travel speed of 5 km/h.

From the analysis of Figure 2.35 it is possible to note the efficiency of active control to keep

In Figure 2.36 it is possible to note the equivalence of both active control systems, ie, there

are no significant differences in maintaining the height of the boom from the ground.

Fig. 2.36. Active suspension systems submitted to a rough track at 5 km/h.

Figure 2.37 shows the rough condition of pavement with equipment travel speed of 7.5 km/h. It also shows the boom displacement at the three sensor positions (1, 2 and 3).

Fig. 2.37. Suspension systems submitted to a rough track at 7.5 km/h.

From the analysis of Figure 2.37 it is possible to note the efficiency of active control to keep constant the distance between the boom and the ground.

In Figure 2.38 it is possible to note the equivalence of both active control systems, i.e., there are no significant differences in maintaining the height of the boom from the ground.

Co-Simulation Procedure for PID and

**3. Conclusion** 

**4. References** 

CNEEMA.

59, 245–252.

(1989) (6), pp. 1857–1863.

406.

222.

the Fuzzy control strategy in sprayer booms.

what presents no significant advantage in our practical design.

Fuzzy Logic Active Controls Strategies Applied to a Sprayers Boom Suspension 95

Fig. 2.40. Active suspension systems submitted to a rough track at 10 km/h.

input signals are significantly attenuated if compared to a passive suspension.

We can conclude that independently of control strategy adopted, PID or Fuzzy control, the

The PID control strategy has a practical advantage of being more easily implemented than

The power consumed by the active Fuzzy system was slightly lower than the PID controller,

Musillami, S. (1977). Les mouvements des rampes de pulverization pour culture basses, a

Sinfort, C.; Miralles, A.; Sevila, F.; Maniere, M. (1994). Study and development of a test

Pochi D; Vannucci D. (2002). A system with potentiometric transducers to record spray

Miller, P.C.H. Mawer, C.J. (1989). Effect of roll angle and nozzle spray pattern on the

Chaplin, J.; Wu,C.(1989). Dynamic modelling of field sprayers, Transactions of the ASAE 32

fixation classique, etudiés a travers les repartitions au banc a gouttieres.

method for spray boom suspensions. Journal of Agricultural Engineering Resource,

boom movements under operating conditions. Biosystems Engineering, 84(4), 393–

uniformity of spray volume distribution below a boom. Crop Protection. Vol.8: 217-

Fig. 2.38. Active suspension systems submitted to a rough track at 7.5 km/h.

Figure 2.39 shows the rough condition of pavement with equipment travel speed of 10 km/h. It also shows the boom displacement at the three sensor positions (1, 2 and 3).

Fig. 2.39. Suspension systems submitted to rough track at 10 km/h.

From the analysis of Figure 2.39 it is possible to note the efficiency of active control to keep constant the distance between the boom and the ground.

In Figure 2.40 it is possible to note the equivalence of both active control systems, i.e., there are no significant differences in maintaining the height of the boom from the ground.

Fig. 2.40. Active suspension systems submitted to a rough track at 10 km/h.

## **3. Conclusion**

94 Technology and Engineering Applications of Simulink

Fig. 2.38. Active suspension systems submitted to a rough track at 7.5 km/h.

Fig. 2.39. Suspension systems submitted to rough track at 10 km/h.

constant the distance between the boom and the ground.

Figure 2.39 shows the rough condition of pavement with equipment travel speed of 10

From the analysis of Figure 2.39 it is possible to note the efficiency of active control to keep

In Figure 2.40 it is possible to note the equivalence of both active control systems, i.e., there

are no significant differences in maintaining the height of the boom from the ground.

km/h. It also shows the boom displacement at the three sensor positions (1, 2 and 3).

We can conclude that independently of control strategy adopted, PID or Fuzzy control, the input signals are significantly attenuated if compared to a passive suspension.

The PID control strategy has a practical advantage of being more easily implemented than the Fuzzy control strategy in sprayer booms.

The power consumed by the active Fuzzy system was slightly lower than the PID controller, what presents no significant advantage in our practical design.

## **4. References**


**1. Introduction**

**1.1 How is S-function useful?**

B. Umesh Rai

*India*

**5**

*Indian Institute of Science, Bangalore*

S-functions are short for system-functions. They are used for extending the capabilities of Simulink®. S-functions allows us to add our own algorithms to Simulink models. The process of creating S-function blocks is quite simple. Simulink provides a S-function API which can be used to write a S-function routine observing a set of laid down rules. The compiled routine is enclosed inside a Simulink block, which can be subsequently customised by masking. A library of customised S-function blocks are created for an application specific task. This library

**S-Function Library for Bond Graph Modeling** 

S-function can also be described as a computer language description of the Simulink block. S-function is written in any one of the popular languages viz C, C++, Fortran or Ada besides MATLAB's own M programming language and compiled as MEX files, where MEX stands for *MATLAB Executable*. S-functions use a special calling syntax called the S-function API that interacts with the Simulink engine. This interaction is very similar to the interaction that takes

In MATLAB S-functions, the S-function routines are implemented as MATLAB functions. In C MEX S-functions, they are implemented as C functions. All the S-function routines available to MATLAB S-functions exist for C MEX S-functions as well. However, Simulink provides a

S-function routines can be written for continuous, discrete or hybrid systems. A set of S-function blocks created by us can be placed in a tool box or library and distributed for working in MATLAB environment. S-functions allow creation of customised blocks for Simulink. By following a set of rules, any block algorithms can be implemented in an S-function. It can also be deployed for using an existing C code into a simulation. After compiling the S-function, the run time file has to be placed in an S-function block. User interface can then be customised by using masking. An advantage of using S-functions is that a general purpose block can be built that can be used many times in a model, varying

The most common usage of S-functions is for creating a set of custom Simulink blocks for an application. Existing C code in the application is easily encapsulated into S-function block and used as a separate Simulink block. This is used alongside the other blocks of Simulink.

can be subsequently distributed to work in MATLAB® environment.

place between the engine and built-in Simulink blocks.

larger set of S-function routines for C MEX S-functions.

parameters with each instance of the block.


## **S-Function Library for Bond Graph Modeling**

B. Umesh Rai *Indian Institute of Science, Bangalore India*

## **1. Introduction**

96 Technology and Engineering Applications of Simulink

Sinfort, C.; Lardoux, Y.; Miralles, A.; Enf.alt, P.; Alness, K., Andersson, S. (1997).

Herbst, A., and P. Wolf. (2001). Spray deposit distribution from agricultural boom sprayer in dynamic conditions. Paper Number: 011054, ASAE, St. Joseph. Mich. Ramon, H. and J. De Baerdemaeker. (1997). Spray boom motions and spray distribution:

Pochi, D. and D. Vannucci. (2001). Laboratory evaluation and angular potentiometer for

Womac, A. R. R.; Etheridge, A.; Seibert, D.; Hogan, ; Ray, S. (2001). Sprayer speed and

Sinfort, C.; Herbst, A. (1996). Evaluation of the quality of spray distribution from boom

Ramon, H., B. Missotten, and J. De Baerdemaeker. (1997). Spray boom motions and

Speelman, L.; Jasen, J.W. (1979). The effect of spray-boom movement on the liquid

Nation, H.J. (1980). The performance and stability of spray boom. Journal Agricultural

Iyer, A.M. and B.M.D. Wills. (1978). Factors determining the design of tractor-mounted

Langenakens Jan J; Clijmans L; Ramon H; De Baerdemaker J. (1999). The effects of vertical

ASABE/ISO 5008. (2002). Agricultural wheeled tractors and field machinery – measurement

moving boom sprayer. Aspects Applied Biology, 48.

Research, 66(1): 23-29.

ASAE, 44(6): 1437-1444.

Plant Protection Organization) 26: 27-36.

Engineering Resource, 27(1), 61-70.

Agricultural Engineering Research, 74, 281–291.

of whole-body vibration of the operator.

80(2): 153-161.

39.

19, 117-129.

Research. 23(1): 37-43.

Comparison between measurements and predictions of spray pattern from a

part 1, derivation of a mathematical relation. Journal of Agricultural Engineering

measuring spray boom movement. Journal of Agricultural Engineering Research.

venturi-nozzle effects on broadcast application uniformity. Transactions of the

sprayer in practical condition, Bulletin OEPP/EPPO (European and Mediterranean

spray distribution: part 2, experimental validation of the mathematical relation and simulation results. Journal of Agricultural Engineering Research, 66(1): 31-

distribution of field crop sprayers. Journal of Agricultural Engineering Resource,

sprayer boom–spray nozzle characteristics. Journal of Agricultural Engineering

sprayer boom movements on the uniformity of spray distribution. Journal of

S-functions are short for system-functions. They are used for extending the capabilities of Simulink®. S-functions allows us to add our own algorithms to Simulink models. The process of creating S-function blocks is quite simple. Simulink provides a S-function API which can be used to write a S-function routine observing a set of laid down rules. The compiled routine is enclosed inside a Simulink block, which can be subsequently customised by masking. A library of customised S-function blocks are created for an application specific task. This library can be subsequently distributed to work in MATLAB® environment.

## **1.1 How is S-function useful?**

S-function can also be described as a computer language description of the Simulink block. S-function is written in any one of the popular languages viz C, C++, Fortran or Ada besides MATLAB's own M programming language and compiled as MEX files, where MEX stands for *MATLAB Executable*. S-functions use a special calling syntax called the S-function API that interacts with the Simulink engine. This interaction is very similar to the interaction that takes place between the engine and built-in Simulink blocks.

In MATLAB S-functions, the S-function routines are implemented as MATLAB functions. In C MEX S-functions, they are implemented as C functions. All the S-function routines available to MATLAB S-functions exist for C MEX S-functions as well. However, Simulink provides a larger set of S-function routines for C MEX S-functions.

S-function routines can be written for continuous, discrete or hybrid systems. A set of S-function blocks created by us can be placed in a tool box or library and distributed for working in MATLAB environment. S-functions allow creation of customised blocks for Simulink. By following a set of rules, any block algorithms can be implemented in an S-function. It can also be deployed for using an existing C code into a simulation. After compiling the S-function, the run time file has to be placed in an S-function block. User interface can then be customised by using masking. An advantage of using S-functions is that a general purpose block can be built that can be used many times in a model, varying parameters with each instance of the block.

The most common usage of S-functions is for creating a set of custom Simulink blocks for an application. Existing C code in the application is easily encapsulated into S-function block and used as a separate Simulink block. This is used alongside the other blocks of Simulink.

• Update discrete states in the major time step. In this call, all blocks should perform once-per-time-step activities such as updating discrete states for next time around the

S-Function Library for Bond Graph Modeling 99

• Integration: This applies to models with continuous states and/or nonsampled zero crossings. If S-function has continuous states, Simulink calculates the derivative of the continuous state at minor time steps. Simulink computes the states for S-function. If S-function (C MEX only) has nonsampled zero crossings, then Simulink will call the output and zero crossings portion of S-function at minor time steps, so that it can locate the zero

Initialise Model (SimStruct, Port width etc.)

Calculate time of Next Sample hit (for Variable Sample time)

> Calculate Outputs (in Major Time step)

Update Discrete states (in Major Time step)

Integration (Minor Time Step)

Simulation

Fig. 2. S-function simulation cycle

**2.2 Flags in MATLAB S-function**

 Loop

Calculate Derivatives

Calculate Outputs

Calculate Derivatives

Zero Crossings

At termination perform any required tasks

An MATLAB file that defines an S-Function block must provide information about the model. Simulink needs this information during simulation. The MATLAB S-function has to be of the

simulation loop.

crossings.

If the system model has been already modeled as a set of mathematical equations, it becomes easy to convert each equation into a S-function block, and and develop the system model in Simulink.

## **1.2 Vectors in S-function**

In a Simulink block, a vector of input, u, are processed by a vector of states, x to output a vector of output, y (Fig. 1) (Mathworks, 2011). The state vector may consist of continuous states, discrete states, or a combination of both.

Fig. 1. Generalised Simulink block

In S-functions written in the MATLAB programming language, the MATLAB S-function, Simulink partitions the state vector into two spaces. The first part of the state vector is occupied by the continuous state, and the discrete states occupy the second part. But in the other programming language written S-function, MEX-file S-functions, there are two separate state vectors for the continuous and discrete states.

## **2. Steps in simulation**

Routines have to be written in S-function to carry out the simulation steps required by the Simulink engine. To cross-reference the routine required for the simulation step, two different approaches are used. For an MATLAB S-function, Simulink passes a flag parameter to the S-function. The flag indicates the current simulation stage. Routines in M-code calls the appropriate functions for each flag value. For a C MEX S-function, Simulink calls the S-function routines directly. This is done by following a naming convention for the routines.

## **2.1 Steps in S-function block simulation**

Simulink engine first calls the S-function Routine to perform initialisation of all S-functions block in the model. Later, the engine makes repeated calls during simulation loop to each S-function block in the model, directing it to perform tasks such as computing its outputs, updating its discrete states, or computing its derivatives. Finally, the engine invokes a call to each S-function Routine for a termination task (Fig. 2). The tasks required at various stages, include:

	- **–** Initialising the SimStruct, a structure that contains information about the S-function.
	- **–** Setting the number and size of input and output ports.
	- **–** Setting the block sample times.
	- **–** And allocating storage areas and the sizes array.

2 Will-be-set-by-IN-TECH

If the system model has been already modeled as a set of mathematical equations, it becomes easy to convert each equation into a S-function block, and and develop the system model in

In a Simulink block, a vector of input, u, are processed by a vector of states, x to output a vector of output, y (Fig. 1) (Mathworks, 2011). The state vector may consist of continuous

x

In S-functions written in the MATLAB programming language, the MATLAB S-function, Simulink partitions the state vector into two spaces. The first part of the state vector is occupied by the continuous state, and the discrete states occupy the second part. But in the other programming language written S-function, MEX-file S-functions, there are two separate

Routines have to be written in S-function to carry out the simulation steps required by the Simulink engine. To cross-reference the routine required for the simulation step, two different approaches are used. For an MATLAB S-function, Simulink passes a flag parameter to the S-function. The flag indicates the current simulation stage. Routines in M-code calls the appropriate functions for each flag value. For a C MEX S-function, Simulink calls the S-function routines directly. This is done by following a naming convention for the routines.

Simulink engine first calls the S-function Routine to perform initialisation of all S-functions block in the model. Later, the engine makes repeated calls during simulation loop to each S-function block in the model, directing it to perform tasks such as computing its outputs, updating its discrete states, or computing its derivatives. Finally, the engine invokes a call to each S-function Routine for a termination task (Fig. 2). The tasks required at various stages,

**–** Initialising the SimStruct, a structure that contains information about the S-function.

• Calculation of next sample hit - for a variable step integration routine, this stage calculates the time of the next variable hit, that is, it calculates the next stepsize in the variable step. • Calculation of outputs in the major time step. After this call is complete, all the output

• Initialization: Simulink initializes the S-function as a first step. The tasks are:

**–** Setting the number and size of input and output ports.

**–** And allocating storage areas and the sizes array.

ports of the blocks are valid for the current time step.

(states) <sup>y</sup> (output)

Simulink.

**1.2 Vectors in S-function**

**2. Steps in simulation**

include:

states, discrete states, or a combination of both.

Fig. 1. Generalised Simulink block

u (input)

state vectors for the continuous and discrete states.

**2.1 Steps in S-function block simulation**

**–** Setting the block sample times.


Fig. 2. S-function simulation cycle

## **2.2 Flags in MATLAB S-function**

An MATLAB file that defines an S-Function block must provide information about the model. Simulink needs this information during simulation. The MATLAB S-function has to be of the

Simulink defines in a general way the task of each callback and their sequence (Fig.3) (Mathworks, 2011). The green box in Fig.3 are the compulsorily present routines and the blue box are the optional routines. The S-function is free to perform any task according to the functionality it implements. For example, Simulink specifies that the S-function's mdlOutput method must compute that block's outputs at the current simulation time. It does not specify what those outputs must be. The callback-based API allows to create S-functions, and hence custom blocks, of any desired functionality. The contents of the routines can be as complex and any logic can reside in the S-function routines as long as the routines conform to their

S-Function Library for Bond Graph Modeling 101

mdlInitializeSizes mdlSetInputPortWidth / mdlSetOutputPortWidth mdlSetInputPortSampleTime / mdlSetOutputPortSampleTime mdlInitializeSampleTimes mdlSetWorkWidths mdlStart mdlInitializeConditions mdlProcessParameters mdlGetTimeOfNextVarHit mdlInitializeConditions mdlOutputs (major time step) mdlUpdate (major time step) mdlDerivatives mdlOutputs mdlDerivatives mdlOutputs mdlZeroCrossings mdlTerminate

Both the approaches of MATLAB and MEX S-functions development have some inherent advantages due to their origin in the programming language they are coded in. The advantage of MATLAB S-functions is speed of its development. Developing MATLAB S-functions avoids the time consuming compile-link-execute cycle required when developing in a compiled language like C. MATLAB S-functions also have easier access to MATLAB toolbox functions

⎫

⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎬

Integration

(Minor Step)

⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎭

⎧

⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎨

Initialization

⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎩

Simulation

 Loop

mdlCheckParameters

Fig. 3. Calling sequence of C MEX S-function Blocks

**2.4 MEX versus MATLAB S-functions**

required formats.

following form:

$$f(\text{sys}\_\prime \ge 0, \text{str}\_\prime \text{ts}) = f(t, \ge \mu, f \text{lag}\_\prime \not\ge 1, \text{p2}, \ldots)$$

where f is the name of the S-function. Simulink passes t, the current time, x, state vector, u, input vector, integer flag in argument to S-function. In an MATLAB S-function flags are used for indicating the current simulation stage. S-function code calls the appropriate functions for each flag value. Table 1 lists the simulation stages, the corresponding S-function routines, and the associated flag value for MATLAB S-functions.


Table 1. M-File flags

An MATLAB S-function returns an output vector having the following elements:


## **2.3 C MEX S-function callback methods**

As with MATLAB S-functions, Simulink interacts with a C MEX-file S-function by invoking callback methods that the S-function implements. C MEX-file S-functions have the same structure and perform the same functions as MATLAB S-functions. In addition, C MEX S-functions provide more functionality than MATLAB S-functions. C MEX-files can access and modify the data structure that Simulink uses internally to store information about the S-function. This gives it an ability to handle matrix signals and multiple data types.

C MEX-file that defines an S-Function block provides information about the model to Simulink during the simulation. Unlike MATLAB S-functions, no explicit flag parameter is associated with C MEX S-function routine. But the routines have to follow the naming convention. Simulink then automatically calls each S-function routine at the appropriate time during its interaction with the S-function. It defines specific tasks which include defining initial conditions and block characteristics, and computing derivatives, discrete states, and outputs.

4 Will-be-set-by-IN-TECH

[*sys*, *x*0,*str*, *ts*] = *f*(*t*, *x*, *u*, *flag*, *p*1, *p*2, ...) where f is the name of the S-function. Simulink passes t, the current time, x, state vector, u, input vector, integer flag in argument to S-function. In an MATLAB S-function flags are used for indicating the current simulation stage. S-function code calls the appropriate functions for each flag value. Table 1 lists the simulation stages, the corresponding S-function routines, and

Simulation Stage S-Function Routine Flag

mdlDerivatives flag = 1

mdlUpdate flag = 2

mdlGetTimeOfNextVarHit flag = 4

Initialization mdlInitializeSizes flag = 0

Calculation of outputs mdlOutputs flag = 3

End of simulation tasks mdlTerminate flag = 9

An MATLAB S-function returns an output vector having the following elements:

• sys - the values returned depend on the flag value (for flag = 3, sys contains the S-function

As with MATLAB S-functions, Simulink interacts with a C MEX-file S-function by invoking callback methods that the S-function implements. C MEX-file S-functions have the same structure and perform the same functions as MATLAB S-functions. In addition, C MEX S-functions provide more functionality than MATLAB S-functions. C MEX-files can access and modify the data structure that Simulink uses internally to store information about the

C MEX-file that defines an S-Function block provides information about the model to Simulink during the simulation. Unlike MATLAB S-functions, no explicit flag parameter is associated with C MEX S-function routine. But the routines have to follow the naming convention. Simulink then automatically calls each S-function routine at the appropriate time during its interaction with the S-function. It defines specific tasks which include defining initial conditions and block characteristics, and computing derivatives, discrete states, and outputs.

S-function. This gives it an ability to handle matrix signals and multiple data types.

following form:

the associated flag value for MATLAB S-functions.

Calculation of derivatives of continous state variables

Update discrete states,

Calculation of next sample hit (Only when discrete-time sample time specified)

• x0 - the initial state values at flag = 0 (otherwise ignored).

• ts - two-column matrix containing sample time and offset.

sample times

• str - reserved for future use.

**2.3 C MEX S-function callback methods**

Table 1. M-File flags

outputs).

Simulink defines in a general way the task of each callback and their sequence (Fig.3) (Mathworks, 2011). The green box in Fig.3 are the compulsorily present routines and the blue box are the optional routines. The S-function is free to perform any task according to the functionality it implements. For example, Simulink specifies that the S-function's mdlOutput method must compute that block's outputs at the current simulation time. It does not specify what those outputs must be. The callback-based API allows to create S-functions, and hence custom blocks, of any desired functionality. The contents of the routines can be as complex and any logic can reside in the S-function routines as long as the routines conform to their required formats.

Fig. 3. Calling sequence of C MEX S-function Blocks

## **2.4 MEX versus MATLAB S-functions**

Both the approaches of MATLAB and MEX S-functions development have some inherent advantages due to their origin in the programming language they are coded in. The advantage of MATLAB S-functions is speed of its development. Developing MATLAB S-functions avoids the time consuming compile-link-execute cycle required when developing in a compiled language like C. MATLAB S-functions also have easier access to MATLAB toolbox functions

error(['Unhandled flag = ',num2str(flag)]);

The routines that are called by *timestwo.m* are *mdlInitializeSizes* and *mdlOutputs*. The routine *mdlInitializeSizes* passes on the block information to the *size* structure. The information on number of outputs, inputs, continuous and discrete states, sample times and whether direct feed through is present, is passed on to the structure variable. The output variables, *x0*, *str* and ts are also set to the desired values. The second routine *mdlOutputs* just doubles the input

S-Function Library for Bond Graph Modeling 103

%============================================================== % Function mdlInitializeSizes initializes the states, sample % times, state ordering strings (str), and sizes structure. %==============================================================

% Load the sizes structure with the initialization information.

%==============================================================

function [sys,x0,str,ts] = mdlInitializeSizes

% Load the sys vector with the sizes information.

% Function mdlOutputs performs the calculations.

% Call function simsizes to create the sizes structure.

end;

sizes = simsizes;

sizes.NumContStates= 0; sizes.NumDiscStates= 0; sizes.NumOutputs=1; sizes.NumInputs=1; sizes.DirFeedthrough=1; sizes.NumSampleTimes=1;

sys = simsizes(sizes);

x0 = []; % No continuous states

ts = [-1 0]; % Inherited sample time

str = []; % No state ordering

% End of mdlInitializeSizes.

scalar.

%

%

%

% End of function timestwo.

and can utilize the MATLAB Editor/Debugger. MEX S-functions are more appropriate for integrating legacy code into a Simulink model. For more complicated systems, MEX S-functions may simulate faster than MATLAB S-functions because the MATLAB S-function has to call the MATLAB interpreter for every callback routine.

## **3. S-function examples**

The ease of writing an S-function is demonstrated here by taking a simple example. Both MATLAB file and C Mex approaches will be demonstrated. A block '*timestwo*' is implemented in S-function. This simple block has no states. Functionally, the block takes an input scalar signal, doubles it and outputs to a connected device (Fig.4).

Fig. 4. timestwo S-function in model

## **3.1 MATLAB S-function implementation of timestwo**

The S-function will be defined with four input arguments from Simulink. They are, the current time *t*, state *x*, input *u*, and flag *flag*. The output vector contains the variable listed in Sec.2.2. For the simple example chosen, two routines will be sufficient. A routine for initialisation and another for calculating the output. Below is the MATLAB code for the *timestwo.m* S-function:

```
function [sys,x0,str,ts] = timestwo(t,x,u,flag)
 % Dispatch the flag. The switch function controls the calls to
  % S-function routines at each simulation stage.
  switch flag,
    % Initialization
    case 0
       [sys,x0,str,ts] = mdlInitializeSizes;
    % Calculate outputs
    case 3
       sys = mdlOutputs(t,x,u);
    % Unused flags
    case { 1, 2, 4, 9 }
       sys = [];
    % Error handling
    otherwise
```
6 Will-be-set-by-IN-TECH

and can utilize the MATLAB Editor/Debugger. MEX S-functions are more appropriate for integrating legacy code into a Simulink model. For more complicated systems, MEX S-functions may simulate faster than MATLAB S-functions because the MATLAB S-function

The ease of writing an S-function is demonstrated here by taking a simple example. Both MATLAB file and C Mex approaches will be demonstrated. A block '*timestwo*' is implemented in S-function. This simple block has no states. Functionally, the block takes an input scalar

timestwo

Sine Source S-function Scope Sink

The S-function will be defined with four input arguments from Simulink. They are, the current time *t*, state *x*, input *u*, and flag *flag*. The output vector contains the variable listed in Sec.2.2. For the simple example chosen, two routines will be sufficient. A routine for initialisation and another for calculating the output. Below is the MATLAB code for the *timestwo.m* S-function:

% Dispatch the flag. The switch function controls the calls to

has to call the MATLAB interpreter for every callback routine.

signal, doubles it and outputs to a connected device (Fig.4).

**3.1 MATLAB S-function implementation of timestwo**

function [sys,x0,str,ts] = timestwo(t,x,u,flag)

% S-function routines at each simulation stage.

[sys,x0,str,ts] = mdlInitializeSizes;

**3. S-function examples**

Fig. 4. timestwo S-function in model

switch flag,

case 0

case 3

% Initialization

% Calculate outputs

% Unused flags case { 1, 2, 4, 9 } sys = [];

% Error handling

otherwise

sys = mdlOutputs(t,x,u);

```
error(['Unhandled flag = ',num2str(flag)]);
    end;
% End of function timestwo.
```
The routines that are called by *timestwo.m* are *mdlInitializeSizes* and *mdlOutputs*. The routine *mdlInitializeSizes* passes on the block information to the *size* structure. The information on number of outputs, inputs, continuous and discrete states, sample times and whether direct feed through is present, is passed on to the structure variable. The output variables, *x0*, *str* and ts are also set to the desired values. The second routine *mdlOutputs* just doubles the input scalar.

```
%==============================================================
% Function mdlInitializeSizes initializes the states, sample
% times, state ordering strings (str), and sizes structure.
%==============================================================
function [sys,x0,str,ts] = mdlInitializeSizes
% Call function simsizes to create the sizes structure.
sizes = simsizes;
% Load the sizes structure with the initialization information.
sizes.NumContStates= 0;
sizes.NumDiscStates= 0;
sizes.NumOutputs=1;
sizes.NumInputs=1;
sizes.DirFeedthrough=1;
sizes.NumSampleTimes=1;
% Load the sys vector with the sizes information.
sys = simsizes(sizes);
%
x0 = []; % No continuous states
%
str = []; % No state ordering
%
ts = [-1 0]; % Inherited sample time
% End of mdlInitializeSizes.
```

```
%==============================================================
% Function mdlOutputs performs the calculations.
```
#define S\_FUNCTION\_NAME timestwo /\* Defines and Includes \*/

if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {

return; /\* Parameter mismatch reported by the Simulink engine\*/

S-Function Library for Bond Graph Modeling 105

static void mdlInitializeSizes(SimStruct \*S) {

if (!ssSetNumInputPorts(S, 1)) return;

ssSetInputPortWidth(S, 0, DYNAMICALLY\_SIZED); ssSetInputPortDirectFeedThrough(S, 0, 1); if (!ssSetNumOutputPorts(S,1)) return;

ssSetOutputPortWidth(S, 0, DYNAMICALLY\_SIZED);

ssSetOptions(S, SS\_OPTION\_EXCEPTION\_FREE\_CODE);

static void mdlInitializeSampleTimes(SimStruct \*S) { ssSetSampleTime(S, 0, INHERITED\_SAMPLE\_TIME);

static void mdlOutputs(SimStruct \*S, int\_T tid) {

real\_T \*y = ssGetOutputPortRealSignal(S,0); int\_T width = ssGetOutputPortWidth(S,0);

static void mdlTerminate(SimStruct \*S){}

InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);

#ifdef MATLAB\_MEX\_FILE/\*Is this file being compiled as a MEX-file?\*/

We start by two define statements, and give the name to our S-function and tell the Simulink engine that the code is written in Level 2 format. Later we include the header file *simstruc.h*,

#include "cg\_sfun.h" /\* Code generation registration function \*/

#include "simulink.c" /\* MEX-file interface mechanism \*/

#define S\_FUNCTION\_LEVEL 2

ssSetNumSFcnParams(S, 0);

ssSetNumSampleTimes(S, 1);

ssSetOffsetTime(S, 0, 0.0);

for (i=0; i<width; i++) { \*y++ = 2.0 \*(\*uPtrs[i]);

**3.3 Explanation of C MEX timestwo code**

#include "simstruc.h"

}

}

}

} }

#else

#endif

int\_T i;

```
%==============================================================
function sys = mdlOutputs(t,x,u)
sys = 2*u;
% End of mdlOutputs.
```
The timestwo MATLAB S-function can now be used in the Simulink model, by first dragging an S-Function block from the User-Defined Functions block library into the model. Then entering the name *timestwo* in the S-function name field of the S-Function block's Block Parameters dialog box (Fig. 5).


Fig. 5. timestwo S-function in Simulink model file

## **3.2 C MEX S-function implementation of timestwo**

C MEX S-function will contain the callback methods mdlInitializeSizes, mdlInitializeSampleTimes, mdlOutputs and mdlTerminate. The simulation steps will have setting of intial condition by the first two blocks, the simulation loop in the third block and final termination by the last block (Fig.6 ). The code is reproduced below:

Fig. 6. C MEX S-function timestwo Blocks

8 Will-be-set-by-IN-TECH

%==============================================================

The timestwo MATLAB S-function can now be used in the Simulink model, by first dragging an S-Function block from the User-Defined Functions block library into the model. Then entering the name *timestwo* in the S-function name field of the S-Function block's Block

C MEX S-function will contain the callback methods mdlInitializeSizes, mdlInitializeSampleTimes, mdlOutputs and mdlTerminate. The simulation steps will have setting of intial condition by the first two blocks, the simulation loop in the third block

Start

mdlInitializeSizes

mdlInitializeSampleTimes

mdlOutputs

mdlTerminate

and final termination by the last block (Fig.6 ). The code is reproduced below:

function sys = mdlOutputs(t,x,u)

Fig. 5. timestwo S-function in Simulink model file

**3.2 C MEX S-function implementation of timestwo**

Fig. 6. C MEX S-function timestwo Blocks

sys = 2\*u;

% End of mdlOutputs.

Parameters dialog box (Fig. 5).

```
#define S_FUNCTION_NAME timestwo /* Defines and Includes */
#define S_FUNCTION_LEVEL 2
#include "simstruc.h"
static void mdlInitializeSizes(SimStruct *S) {
  ssSetNumSFcnParams(S, 0);
  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
    return; /* Parameter mismatch reported by the Simulink engine*/
  }
  if (!ssSetNumInputPorts(S, 1)) return;
  ssSetInputPortWidth(S, 0, DYNAMICALLY_SIZED);
  ssSetInputPortDirectFeedThrough(S, 0, 1);
  if (!ssSetNumOutputPorts(S,1)) return;
  ssSetOutputPortWidth(S, 0, DYNAMICALLY_SIZED);
  ssSetNumSampleTimes(S, 1);
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
}
static void mdlInitializeSampleTimes(SimStruct *S) {
  ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
  ssSetOffsetTime(S, 0, 0.0);
}
static void mdlOutputs(SimStruct *S, int_T tid) {
  int_T i;
  InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);
  real_T *y = ssGetOutputPortRealSignal(S,0);
  int_T width = ssGetOutputPortWidth(S,0);
  for (i=0; i<width; i++) {
    *y++ = 2.0 *(*uPtrs[i]);
  }
}
static void mdlTerminate(SimStruct *S){}
#ifdef MATLAB_MEX_FILE/*Is this file being compiled as a MEX-file?*/
#include "simulink.c" /* MEX-file interface mechanism */
#else
#include "cg_sfun.h" /* Code generation registration function */
#endif
```
#### **3.3 Explanation of C MEX timestwo code**

We start by two define statements, and give the name to our S-function and tell the Simulink engine that the code is written in Level 2 format. Later we include the header file *simstruc.h*,

Energy *f eq p* domain flow effort Generalised Generalised

Electromagnetic *i*, [A] *v*, [V] *q*, [C] *λ*, [V-s]

S-Function Library for Bond Graph Modeling 107

Mechanical *V*, [m/s] *F*, [N] *x*, [m] *p*, [N-s] translation Velocity Force Displacement Momentum Angular *ω*, [rad/s] *T*, [N m] *θ*, [rad] *pω*, [N-m-s] translation Velocity Torque Angle Momentum Hydraulic *ϕ*, [*m*3/s] *P*, [N/*m*2] *V*, [*m*3] Γ, [N-s/*m*2]

Temperature Entopy flow Entropy Chemical *μ*, [mol/s] *FN*, [J/mol] *N*, [mol]

Behaviour of a physical system is constrained, either implicitly or explicitly by laws of physics viz. mass and energy conservation, laws of momentum and positive entropy production. Furthermore, various physical domains are each characterized by a particular quantity that is conserved. Each of these domains have analogous ideal behaviour with respect to energy (Table 2). This analogy led to the concept of energy port, the building block of bond graph modeling language. Here, the interaction between physical systems is through energy port and is always bidirectional. There will be an input signal and a consequent output signal ('*back effect*') and their product will signify the '*power that is transacted*'. From a computational point of view, the effort could be computed by 'Port 1', while the flow is computed in 'Port 2'. It could be the other way around as well. Apriori the computational direction of signal is not

Bond graphs are labelled, directed graphs. The vertices of a bond graph denote subsystems, system components or elements, while the edges, called power bonds or bonds for short, represent energy flows between them. The nodes of a bond graph have power ports where energy can enter or exit. As energy can flow back and forth between power ports of different nodes, a half arrow is added to each bond indicating a reference direction of the energy flow. The amount of power, *P(t)*, at each given time, *t*, is given by the product of the two conjugate

*P*(*t*) = *e*(*t*) · *f*(*t*) (1)

There can be five groups of physical behaviour by elements handling energy:

Thermal *T*, [K] *FS*, [J/K/s] *S*, [J/K]

Table 2. Flow and effort variables in different domains

known, except the fact that they are in opposite direction (Fig.7).

variables, which are called effort, *e*, and flow, *f*, respectively.

**4.2 Bond graph elements**

1. **Storing** of energy. 2. **Supply** on demand. current voltage charge linked flux

Volume Pressure Volume Momentum of flow flow tube

Molar flow Chemical Number of potential moles

momentum displacement

which is a header file that defines a data structure, called the SimStruct, that the Simulink engine uses to maintain information about the S-function. A more complex S-function will include more header files.

The callback routine *mdlInitializeSizes* tells the Simulink engine that the function has no parameters, has one input and output port. It also declares that only one sample time will be specified later in *mdlInitializeSampleTimes*. Simulink is also informed that the code is exception free code. This declaration speeds up the execution time. The next callback routine *mdlInitializeSampleTimes* declares the sample time to be inherited i.e the block executes whenever the driving block executes.

The callback routine *mdlOutputs* calculates outputs at each time step. The input and output port signals is accessed through a vector of pointers. The width of the output port which is defined to be dynamically set is then read and the program loops for the width while calculating the output signal to be two times the input signal. The final callback mandatory routine *mdlTerminate* performs the end of the simulation task, which in the present case is a *NIL* set. following this routine the mandatory trailer code for compiler is present. Its absence will lead to compile errors.

The C MEX S-function has to be now compiled. Simulink gives a choice of C compiler to be used. We can use either the built in MEX compiler or any other C compiler already loaded in the system. The following command at the command line

mex -setup

allows us to locate all the compilers available in the system and the option to use one for compiling and linking in the MATLAB environment. Later the command

mex timestwo.c

compiles and links the timestwo.c file to create a dynamically loadable executable for the Simulink software to use. The resulting executable is referred to as a MEX S-function. The MEX file extension varies from platform to platform. For example, on a 32-bit Microsoft Windows system, the MEX file extension is .mexw32. The compiled run time file is then put into the S-function block similer to MATLAB S-function file (Fig. 5).

## **4. Bond graph modeling**

## **4.1 Analogous behaviour of physical systems**

The bond graph approach to physical system modeling was conceptualized by Hank Paynter on April 24, 1959 (Paynter & Briggs, 1961), inspired by the earlier work of Gabriel Kron (Kron, 1962). Bond graph language is a port based graphical approach for modeling energy exchange between subsystems. This technique was further developed by Karnopp and Rosenberg (Karnopp et al., 1990; 2006; Karnopp & Rosenberg, 1968; Rosenberg & Karnopp, 1983). Several books, special issues and articles on bond graph technique have popularised it for growing usage (Borutzky, 2009; Borutzky et al., 2004; Breedveld, 1984; 1991; 2004; Breedveld et al., 1991; Cellier et al., 1995; Dauphin-Tanguy, 2000; Gawthrop, 1995; Gawthrop & Smith, 1996; Mukherjee & Karmakar, 2000; Thoma, 1990; Thoma & Perelson, 1976).

10 Will-be-set-by-IN-TECH

which is a header file that defines a data structure, called the SimStruct, that the Simulink engine uses to maintain information about the S-function. A more complex S-function will

The callback routine *mdlInitializeSizes* tells the Simulink engine that the function has no parameters, has one input and output port. It also declares that only one sample time will be specified later in *mdlInitializeSampleTimes*. Simulink is also informed that the code is exception free code. This declaration speeds up the execution time. The next callback routine *mdlInitializeSampleTimes* declares the sample time to be inherited i.e the block executes

The callback routine *mdlOutputs* calculates outputs at each time step. The input and output port signals is accessed through a vector of pointers. The width of the output port which is defined to be dynamically set is then read and the program loops for the width while calculating the output signal to be two times the input signal. The final callback mandatory routine *mdlTerminate* performs the end of the simulation task, which in the present case is a *NIL* set. following this routine the mandatory trailer code for compiler is present. Its absence

The C MEX S-function has to be now compiled. Simulink gives a choice of C compiler to be used. We can use either the built in MEX compiler or any other C compiler already loaded in

allows us to locate all the compilers available in the system and the option to use one for

compiles and links the timestwo.c file to create a dynamically loadable executable for the Simulink software to use. The resulting executable is referred to as a MEX S-function. The MEX file extension varies from platform to platform. For example, on a 32-bit Microsoft Windows system, the MEX file extension is .mexw32. The compiled run time file is then put

The bond graph approach to physical system modeling was conceptualized by Hank Paynter on April 24, 1959 (Paynter & Briggs, 1961), inspired by the earlier work of Gabriel Kron (Kron, 1962). Bond graph language is a port based graphical approach for modeling energy exchange between subsystems. This technique was further developed by Karnopp and Rosenberg (Karnopp et al., 1990; 2006; Karnopp & Rosenberg, 1968; Rosenberg & Karnopp, 1983). Several books, special issues and articles on bond graph technique have popularised it for growing usage (Borutzky, 2009; Borutzky et al., 2004; Breedveld, 1984; 1991; 2004; Breedveld et al., 1991; Cellier et al., 1995; Dauphin-Tanguy, 2000; Gawthrop, 1995; Gawthrop & Smith, 1996;

include more header files.

will lead to compile errors.

mex -setup

mex timestwo.c

**4. Bond graph modeling**

**4.1 Analogous behaviour of physical systems**

whenever the driving block executes.

the system. The following command at the command line

compiling and linking in the MATLAB environment. Later the command

into the S-function block similer to MATLAB S-function file (Fig. 5).

Mukherjee & Karmakar, 2000; Thoma, 1990; Thoma & Perelson, 1976).


Table 2. Flow and effort variables in different domains

Behaviour of a physical system is constrained, either implicitly or explicitly by laws of physics viz. mass and energy conservation, laws of momentum and positive entropy production. Furthermore, various physical domains are each characterized by a particular quantity that is conserved. Each of these domains have analogous ideal behaviour with respect to energy (Table 2). This analogy led to the concept of energy port, the building block of bond graph modeling language. Here, the interaction between physical systems is through energy port and is always bidirectional. There will be an input signal and a consequent output signal ('*back effect*') and their product will signify the '*power that is transacted*'. From a computational point of view, the effort could be computed by 'Port 1', while the flow is computed in 'Port 2'. It could be the other way around as well. Apriori the computational direction of signal is not known, except the fact that they are in opposite direction (Fig.7).

#### **4.2 Bond graph elements**

Bond graphs are labelled, directed graphs. The vertices of a bond graph denote subsystems, system components or elements, while the edges, called power bonds or bonds for short, represent energy flows between them. The nodes of a bond graph have power ports where energy can enter or exit. As energy can flow back and forth between power ports of different nodes, a half arrow is added to each bond indicating a reference direction of the energy flow. The amount of power, *P(t)*, at each given time, *t*, is given by the product of the two conjugate variables, which are called effort, *e*, and flow, *f*, respectively.

$$P(t) = e(t) \cdot f(t) \tag{1}$$

There can be five groups of physical behaviour by elements handling energy:


If differentiation with respect to time is used, the information on initial condition or *history* is lost. If sensors are included in the bond graph modeling and used for determining the factor of the algebraic relationship between the conjugate variable, we rename the bond as *modulated*

S-Function Library for Bond Graph Modeling 109

Element Effort causal Flow causal

*<sup>R</sup>* : *<sup>R</sup> <sup>e</sup>*

*<sup>R</sup> <sup>e</sup>* <sup>=</sup> *<sup>f</sup>* · *<sup>R</sup>*

*<sup>C</sup>* : *<sup>C</sup> <sup>e</sup>*

*<sup>I</sup>* : *<sup>L</sup> <sup>e</sup>*

*<sup>L</sup>* · *dt <sup>e</sup>* <sup>=</sup> *<sup>L</sup> d f*

*e* = *V f* = *I*

Element Effort causal Flow causal

*<sup>M</sup> <sup>e</sup>*<sup>1</sup>

*<sup>M</sup> <sup>e</sup>*<sup>1</sup>

*TF <sup>e</sup>*<sup>2</sup> *f*2

*GY <sup>e</sup>*<sup>2</sup> *f*2

*<sup>M</sup>*; *<sup>f</sup>*<sup>2</sup> <sup>=</sup> *<sup>e</sup>*<sup>1</sup>

Each bond connects two power ports of different primitive elements and carries two power variables as can be seen in Fig.7. One of the two power variables may be determined by one of the two sub-models, while the other is determined by the other model. A short stroke, called *causal stroke*, perpendicular to the bond is placed at one of its ends of the bond. This indicates the computational direction of the effort variable. Consequently the other *open* end is the decider of the flow variable. The nine basic elements with their constitutive relationships

◦◦

◦◦

*dt <sup>e</sup>* <sup>=</sup>

*f*

*f*

*f*

 *f <sup>C</sup>* · *dt*

*dt*

*f*

*f*1

*f*1

*<sup>M</sup> <sup>e</sup>*<sup>1</sup> <sup>=</sup> *<sup>M</sup>* · *<sup>f</sup>*2; *<sup>e</sup>*<sup>2</sup> <sup>=</sup> *<sup>M</sup>* · *<sup>f</sup>*<sup>1</sup>

*TF <sup>e</sup>*<sup>2</sup> *f*2

*GY <sup>e</sup>*<sup>2</sup> *f*2

*<sup>M</sup>*; *<sup>f</sup>*<sup>2</sup> <sup>=</sup> *<sup>f</sup>*<sup>1</sup> *M*

◦◦ *M*

◦◦ *M*

*R* : *R*

*C* : *C*

*I* : *L*

*e f*

*e f*

> *e f*

*f* = *e*

> *e*1 *f*1

modulating parameter = M *<sup>e</sup>*<sup>2</sup> <sup>=</sup> *<sup>M</sup>* · *<sup>e</sup>*1; *<sup>f</sup>*<sup>1</sup> <sup>=</sup> *<sup>M</sup>* · *<sup>f</sup>*<sup>2</sup> *<sup>e</sup>*<sup>1</sup> <sup>=</sup> *<sup>e</sup>*<sup>2</sup>

*e*1 *f*1

that are dependent on their causal stroke are shown in Table 3,4 and 5

*<sup>f</sup>* <sup>=</sup> *<sup>e</sup>*

*<sup>f</sup>* <sup>=</sup> *<sup>C</sup> de*

*Se* : *<sup>V</sup> <sup>e</sup> Sf* : *<sup>I</sup>*

bond with prefix *M* for the modulated element name.

Resistor, R

Capacitor, C

Inductor, I

Source, *Se*/ *<sup>f</sup>*

Transformer, TF

Gyrator, GY

modulating parameter = M *<sup>f</sup>*<sup>1</sup> <sup>=</sup> *<sup>e</sup>*<sup>2</sup>

Table 3. One-port elements

Table 4. Two-port elements

**5. Computational causality**

Fig. 7. Computational direction of flow and effort between ports


These five behaviour are represented by nine basic elements.


The elements can also be segregated based on their port structure:


#### **4.3 Constitutive relations**

A constitutive relation with a constant parameter characterises each element. For sources, the imposed variable is independent of the conjugate variable, and for the rest of elements, the relationship is algebraic between its conjugate variables. The storage elements are classified as *memory* elements. The preferred constitutive equation is integration with respect to time. 12 Will-be-set-by-IN-TECH

• Two types of *storage* elements, effort or *Capacitive*- storage and flow or *Inductive* - storage.

• Two types of Reversible transformators, non-mixing, reciprocal *Transformer* or **TF**-type

• Irreversible transducer is an energy *Dissipater* or can be also classified as entropy producing

• Distributor junction are also in dual form, **0**-junction and **1**-junction. The 0-junction represents a generalised domain independent Kirchoff current law and similarly a

A constitutive relation with a constant parameter characterises each element. For sources, the imposed variable is independent of the conjugate variable, and for the rest of elements, the relationship is algebraic between its conjugate variables. The storage elements are classified as *memory* elements. The preferred constitutive equation is integration with respect to time.

1-junction represents a generalised domain independent Kirchoff voltage law.

transducer and mixing anti- reciprocal *Gyrator* or **GY**-type transducer.

The elements can also be segregated based on their port structure:

• Five one-port elements: *C*, *L*(*orI*), *R*, *Se*, *Sf* .

• Two n-port junctions: *0-junction, 1-junction*.

• Two two-port elements: *TF, GY*.

(Direction of arrow signifies

the 'Computational' direction)

Port 1 Port 2

or

Port 1 Port 2

flow

Fig. 7. Computational direction of flow and effort between ports

3. **Reversible** transformation (including inter-domain transfers). 4. **Irreversible** transformation (positive entropy production).

These five behaviour are represented by nine basic elements.

• Two types of *sources*, *Source - effort* and *Source - flow*.

effort

5. **Distribution** to connected ports.

**R**-type transducer.

**4.3 Constitutive relations**

flow

effort

If differentiation with respect to time is used, the information on initial condition or *history* is lost. If sensors are included in the bond graph modeling and used for determining the factor of the algebraic relationship between the conjugate variable, we rename the bond as *modulated* bond with prefix *M* for the modulated element name.


Table 3. One-port elements


Table 4. Two-port elements

## **5. Computational causality**

Each bond connects two power ports of different primitive elements and carries two power variables as can be seen in Fig.7. One of the two power variables may be determined by one of the two sub-models, while the other is determined by the other model. A short stroke, called *causal stroke*, perpendicular to the bond is placed at one of its ends of the bond. This indicates the computational direction of the effort variable. Consequently the other *open* end is the decider of the flow variable. The nine basic elements with their constitutive relationships that are dependent on their causal stroke are shown in Table 3,4 and 5

#define SAMPLE\_TIME\_0 CONTINUOUS\_SAMPLE\_TIME

#define PARAM\_DEF0(S) ssGetSFcnParam(S, 0) #define PARAM\_DEF1(S) ssGetSFcnParam(S, 1)

ssSetNumSFcnParams(S, NPARAMS);

ssSetNumSampleTimes(S, 1);

ssSetOffsetTime(S, 0, 0.0);

real\_T \*xC = ssGetContStates(S);

static void mdlInitializeSizes(SimStruct \*S) {

ssSetNumContStates(S, NUM\_CONT\_STATES);

if (!ssSetNumInputPorts(S, NUM\_INPUTS)) return; ssSetInputPortWidth( S, 0, INPUT\_0\_WIDTH);

if (!ssSetNumOutputPorts(S,NUM\_OUTPUTS)) return; ssSetOutputPortWidth(S, 0, OUTPUT\_0\_WIDTH);

static void mdlInitializeSampleTimes(SimStruct \*S) {

static void mdlInitializeConditions(SimStruct \*S) {

static void mdlOutputs(SimStruct \*S, int\_T tid) {

boolean\_T yIsComplex = ssGetOutputPortComplexSignal(S, 0) ==

ssSetSampleTime(S, 0, SAMPLE\_TIME\_0);

if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {

S-Function Library for Bond Graph Modeling 111

ssSetInputPortComplexSignal( S, 0, COMPLEX\_INHERITED); ssSetInputPortDirectFeedThrough(S, 0, INPUT\_0\_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 0, 1); /\*direct input signal

ssSetOutputPortComplexSignal(S, 0, COMPLEX\_INHERITED);

return; /\* Parameter mismatch will be reported by Simulink \*/

#define NUM\_CONT\_STATES 2 #define CONT\_STATES\_IC [0]

#include "simstruc.h"

}

}

}

}

access\*/

xC[0] = 0; xC[1] = 0;

COMPLEX\_YES;


Table 5. Junction elements

#### **5.1 S-function implementation for C bond**

We will now use the C MEX S-function code to develop a continuous state Simulink block. An One-port element which stores energy is chosen for illustration. Effort causal Capacitor C element in Table 3 is one such element. The code, which is an extension of code at Sec. 3.2 (added routines for continuous state) is given below:

```
#define S_FUNCTION_NAME C_complex_bond
#define S_FUNCTION_LEVEL 2
#define NUM_INPUTS 1 /* Input Port 0 */
#define IN_PORT_0_NAME u0
#define INPUT_0_WIDTH DYNAMICALLY_SIZED
#define INPUT_0_FEEDTHROUGH 0
#define NUM_OUTPUTS 1 /* Output Port 0 */
#define OUT_PORT_0_NAME y0
#define OUTPUT_0_WIDTH DYNAMICALLY_SIZED
#define NPARAMS 2 /* Parameter Capacitance */
#define PARAMETER_0_NAME C /* Capacitance Value*/
#define PARAMETER_1_NAME bias /* Initial Charge */
```
14 Will-be-set-by-IN-TECH

Element Symbol Governing Law

*I* : *l*

*er*2 *fr*2

*R* : *r*2

*R* : *r*2

*Effort Law* General equation

and *e*<sup>1</sup> = *e*<sup>2</sup> = *e*<sup>3</sup> = ... = *em* For bond graph model at left *fs* − *fr*<sup>1</sup> − *fl* − *fr*<sup>2</sup> − ... = 0 and *el* = *er*<sup>1</sup> = *er*<sup>2</sup> = ... = *es* The element having causal bar toward the junction decides the effort for all bonds associated

with the junction.

with the junction.

and *f*<sup>1</sup> = *f*<sup>2</sup> = *f*<sup>3</sup> = ... = *fm* For bond graph model at left *Vs* − *er*<sup>1</sup> − *el* − *er*<sup>2</sup> − ... = 0 and *fs* = *fr*<sup>1</sup> = *fr*<sup>2</sup> = ... = *fl* The element having causal bar away from the junction decides the flow for all bonds associated

*Flow Law* General equation

*m* ∑ *i*=1 *ei* = 0

*m* ∑ *i*=1 *fi* = 0

*el*

*fl*

*o*

*el*

*fl*

*o*

*I* : *l*

*er*2 *fr*2

We will now use the C MEX S-function code to develop a continuous state Simulink block. An One-port element which stores energy is chosen for illustration. Effort causal Capacitor C element in Table 3 is one such element. The code, which is an extension of code at Sec. 3.2

0-junction

1-junction

Table 5. Junction elements

**5.1 S-function implementation for C bond**

#define S\_FUNCTION\_LEVEL 2

#define IN\_PORT\_0\_NAME u0

#define INPUT\_0\_FEEDTHROUGH 0

#define OUT\_PORT\_0\_NAME y0

(added routines for continuous state) is given below:

#define S\_FUNCTION\_NAME C\_complex\_bond

#define NUM\_INPUTS 1 /\* Input Port 0 \*/

#define NUM\_OUTPUTS 1 /\* Output Port 0 \*/

#define PARAMETER\_0\_NAME C /\* Capacitance Value\*/ #define PARAMETER\_1\_NAME bias /\* Initial Charge \*/

#define NPARAMS 2 /\* Parameter Capacitance \*/

#define INPUT\_0\_WIDTH DYNAMICALLY\_SIZED

#define OUTPUT\_0\_WIDTH DYNAMICALLY\_SIZED

*Se* : *Vs* 0 *es fs*

*Se* : *Vs* 1 *es fs*

*<sup>r</sup>*1 : *R*

*<sup>r</sup>*1 : *R*

*er*1

*fr*1

*o*

*er*1

*fr*1

*o*

*o*

*o*

```
#define SAMPLE_TIME_0 CONTINUOUS_SAMPLE_TIME
#define NUM_CONT_STATES 2
#define CONT_STATES_IC [0]
#include "simstruc.h"
#define PARAM_DEF0(S) ssGetSFcnParam(S, 0)
#define PARAM_DEF1(S) ssGetSFcnParam(S, 1)
static void mdlInitializeSizes(SimStruct *S) {
    ssSetNumSFcnParams(S, NPARAMS);
    if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
        return; /* Parameter mismatch will be reported by Simulink */
    }
    ssSetNumContStates(S, NUM_CONT_STATES);
    if (!ssSetNumInputPorts(S, NUM_INPUTS)) return;
    ssSetInputPortWidth( S, 0, INPUT_0_WIDTH);
    ssSetInputPortComplexSignal( S, 0, COMPLEX_INHERITED);
    ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal
    access*/
    if (!ssSetNumOutputPorts(S,NUM_OUTPUTS)) return;
    ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH);
    ssSetOutputPortComplexSignal(S, 0, COMPLEX_INHERITED);
    ssSetNumSampleTimes(S, 1);
}
static void mdlInitializeSampleTimes(SimStruct *S) {
    ssSetSampleTime(S, 0, SAMPLE_TIME_0);
    ssSetOffsetTime(S, 0, 0.0);
}
static void mdlInitializeConditions(SimStruct *S) {
   real_T *xC = ssGetContStates(S);
    xC[0] = 0;
    xC[1] = 0;
}
static void mdlOutputs(SimStruct *S, int_T tid) {
    boolean_T yIsComplex = ssGetOutputPortComplexSignal(S, 0) ==
    COMPLEX_YES;
```
Fig. 8. 0-junction

the algorithm for one-port elements.

Table 6. One-port element variables

summarised in Table 7 (Umarikar et al., 2006).

Fig. 9. Algorthim for 2 port element

*J*1

*e*1 *f*1 *GY <sup>e</sup>*<sup>2</sup>

*f*2

*J*2

flow into the junction as individual *Jin*. This completes the cycle for junction. Table 6 tabulates

S-Function Library for Bond Graph Modeling 113

Element Decider Non-decider

R,C,L *Jsum Jout Jout Jin Se*, *Sf Jout Jin*

It can be seen that for an element connected to a junction, the causal variable can take either of the two values, *Jsum* or *Jout*, depending on whether the connection bond is a decider or a non-decider, respectively. Similarly the non-causal variable can have either the value of *Jout* or *Jin*, again depending on whether the connection bond is a decider or a non-decider.

A two-port is connected to two junctions at either end. These junction could be either 0-junction or 1-junction. But as a two-port element allows only two combinations of causality out of available four, there will be only 2 × 2 alternatives for a variable. Looking at the two-port junction in Fig.9, if the element is decider bond for junction *J*1, and the junction is 0-junction, then the flow at input port will be *J*1*sum*. And if junction is a 1-junction the effort will be *J*1*sum*. Similarly for the output junction connected to *J*2. Note that the direction of two-port half arrows is reversed in the two junctions. Thus if two-port element with flow causal at input port is decider bond for the first junction, the junction has to necessarily be an 0-junction, but flow casual at output port as decider bond indicates a 1-junction. The modulus of the two-port element decides the value of the variable on the conjugate port, while the junction decides the conjugate variable value of the port. In a similar manner for all combination of causality and decider bond, the variables can be listed out. The algorithm is

Causal Non-causal Causal Non-causal

```
real_T *y0 = ssGetOutputPortRealSignal(S,0);
   const real_T *xC = ssGetContStates(S);
   const real_T *C = mxGetData(PARAM_DEF0(S));
   const real_T *B = mxGetData(PARAM_DEF1(S));
   y0[0] = *B + xC[0] / (*C);
   if(yIsComplex){ /* Process imag part */
        y0[1] = *B + xC[1] / (*C);
   }
}
static void mdlDerivatives(SimStruct *S) {
   const real_T *u0 = (const real_T*) ssGetInputPortSignal(S,0);
   real_T *dx = ssGetdX(S);
   dx[0]=u0[0] ;
   dx[1]=u0[1] ;
}
static void mdlTerminate(SimStruct *S) {}/* mdlTerminate */
#ifdef MATLAB_MEX_FILE
#include "simulink.c"
#else
#include "cg_sfun.h"
#endif
```
## **6. Junction algorithm**

In a bond graph model a set of elements is connected at the junction. One of the elements in the set takes up the role of *decider* bond. Remaining bonds in the set *per-se* take up the role of *non-decider* bonds. The junction algorithm is illustrated by taking O-junction as an example. The 0-junction block is a common effort junction (Fig.8). The effort is decided by a decider bond attached to it and having the causal bar towards the junction. Similarly for a 1-junction, decider bond will have its causal bar away from the junction, thus complementing the 0-junction behaviour. In the figure, *Jin*'s are the input from the non-decider bonds into the junction, and *Jsum* is the output of the junction.

The governing law of the 0-junction, *Effort Law (or KCL)*, states that the flow of the decider bond is the sum of the flows of all the non-decider bonds. In Fig.8, the decider bond of the junction has *Jsum*, the sum of all *Jin*, as its causal (flow) variable. Value of the conjugate variable (effort) of the decider bond, *Jout* is decided by the bond's constitutive equation. The second part he governing law of the 0-junction, states that the all the bonds connected to the junction share a common effort. Thus the effort of the decider bond becomes the causal variable for all the non-decider bonds. For each non-decider bond, its non-causal variable

Fig. 8. 0-junction

16 Will-be-set-by-IN-TECH

const real\_T \*u0 = (const real\_T\*) ssGetInputPortSignal(S,0);

real\_T \*y0 = ssGetOutputPortRealSignal(S,0);

const real\_T \*xC = ssGetContStates(S);

if(yIsComplex){ /\* Process imag part \*/ y0[1] = \*B + xC[1] / (\*C);

static void mdlDerivatives(SimStruct \*S) {

real\_T \*dx = ssGetdX(S);

y0[0] = \*B + xC[0] / (\*C);

}

dx[0]=u0[0] ; dx[1]=u0[1] ;

#ifdef MATLAB\_MEX\_FILE #include "simulink.c"

#include "cg\_sfun.h"

**6. Junction algorithm**

junction, and *Jsum* is the output of the junction.

}

}

#else

#endif

const real\_T \*C = mxGetData(PARAM\_DEF0(S)); const real\_T \*B = mxGetData(PARAM\_DEF1(S));

static void mdlTerminate(SimStruct \*S) {}/\* mdlTerminate \*/

In a bond graph model a set of elements is connected at the junction. One of the elements in the set takes up the role of *decider* bond. Remaining bonds in the set *per-se* take up the role of *non-decider* bonds. The junction algorithm is illustrated by taking O-junction as an example. The 0-junction block is a common effort junction (Fig.8). The effort is decided by a decider bond attached to it and having the causal bar towards the junction. Similarly for a 1-junction, decider bond will have its causal bar away from the junction, thus complementing the 0-junction behaviour. In the figure, *Jin*'s are the input from the non-decider bonds into the

The governing law of the 0-junction, *Effort Law (or KCL)*, states that the flow of the decider bond is the sum of the flows of all the non-decider bonds. In Fig.8, the decider bond of the junction has *Jsum*, the sum of all *Jin*, as its causal (flow) variable. Value of the conjugate variable (effort) of the decider bond, *Jout* is decided by the bond's constitutive equation. The second part he governing law of the 0-junction, states that the all the bonds connected to the junction share a common effort. Thus the effort of the decider bond becomes the causal variable for all the non-decider bonds. For each non-decider bond, its non-causal variable flow into the junction as individual *Jin*. This completes the cycle for junction. Table 6 tabulates the algorithm for one-port elements.


Table 6. One-port element variables

It can be seen that for an element connected to a junction, the causal variable can take either of the two values, *Jsum* or *Jout*, depending on whether the connection bond is a decider or a non-decider, respectively. Similarly the non-causal variable can have either the value of *Jout* or *Jin*, again depending on whether the connection bond is a decider or a non-decider.

A two-port is connected to two junctions at either end. These junction could be either 0-junction or 1-junction. But as a two-port element allows only two combinations of causality out of available four, there will be only 2 × 2 alternatives for a variable. Looking at the two-port junction in Fig.9, if the element is decider bond for junction *J*1, and the junction is 0-junction, then the flow at input port will be *J*1*sum*. And if junction is a 1-junction the effort will be *J*1*sum*. Similarly for the output junction connected to *J*2. Note that the direction of two-port half arrows is reversed in the two junctions. Thus if two-port element with flow causal at input port is decider bond for the first junction, the junction has to necessarily be an 0-junction, but flow casual at output port as decider bond indicates a 1-junction. The modulus of the two-port element decides the value of the variable on the conjugate port, while the junction decides the conjugate variable value of the port. In a similar manner for all combination of causality and decider bond, the variables can be listed out. The algorithm is summarised in Table 7 (Umarikar et al., 2006).

*J*1 *e*1 *f*1 *GY <sup>e</sup>*<sup>2</sup> *f*2 *J*2

Fig. 9. Algorthim for 2 port element

through its constitutive equation and writes it on to the labelled memory address. The label, as discussed earlier is unique to a junction. The next element in hierarchy, designated as *Consumer*, in turn reads the data and by using its constitutive equations, *Produces* the next set of data which is written on to the next labelled memory address. There can be many *Consumer* of the data but there is only one unique *Provider*. An analogy to bond graph junction concept of one decider and many non-decider can be clearly seen here. It is also seen that a *Consumer* element of previous step becomes the *Provider* element in the next step. As the model is hierarchical, all the elements are in turn *Provider* and *Consumer* to their respective memory address block in one integration step. The memory location is released and freed when the

S-Function Library for Bond Graph Modeling 115

*Memory Block B Data* · · · · ·

The port of the bond graph element as discussed above is the pointer to the shared memory address. When we specify a input/output port for a bond graph element, we have to supply

• Whether the element is a decider bond or not for the producer - consumer correspondence

The complete C MEX S-function code for input junction of a bond is given below:

read Process write

*Memory Block C Data* · · · · ·

read

Bond 2

1 integration step *Tk*<sup>+</sup><sup>1</sup>

data is not needed.

write

*Tk*

*Memory Block A Data* · · · · ·

read Process write

Bond 1

Fig. 10. Propagation of data in a integral time step

three parameters to the S-function. They are:

to the input - output port to be decided.

#define S\_FUNCTION\_NAME inPort #define S\_FUNCTION\_LEVEL 2

#define NPARAMS 3

#include "shm\_com.h" #include "windows.h"

• The name of the junction to which it is connected.

#define PARAMETER\_0\_NAME decider #define PARAMETER\_0\_DTYPE boolean\_T #define PARAMETER\_1\_NAME element #define PARAMETER\_2\_NAME junction

• The bond graph element name.

**7.2 S-function implementation for shared memory link**


Table 7. two-port element variables

## **7. Linking elements**

A bond graph model on paper does not explicitly use a connector as in block diagram model, to link one element to another element. To retain the look and feel of a paper model when transferred to computer terminal, the connection between the elements has to be invisible. The masking properties of the Simulink block is utilised for this purpose in the tool box. A junction is considered as a node, to which the elements are connected. The bond graph element, as in paper model, is placed next to its associated junction. The link to the junction is made by entering the junction label in the mask parameter box. *Shared Memory*' algorithm is then used to implicitly connect the element.

In bond graph modeling two or more elements will be linked to a junction. Their data have to be shared. Shared data structure is used in the toolbox. The memory locations are earmarked for a junction by assigning it a unique label by *character aggregation*' during its first run. An S-function's initialisation callback method is used for memory allocation as this callback is used only once during the simulation run. The associated elements using the notation listed out in Table 6 and Table 7, share their respective memory address, thereby their data.

The elements in the tool box are masked and have screen interfaces. For a one-port element the following details need to be entered.


For a two-port element the extra information of the second port is also entered. Similarly a junction screen interface will have all entries of the elements that are linked to it, along with their energy flow direction signs.

### **7.1 Propagation of data**

The propagation of data from one element to the next is by reading and writing into a common block address (Fig.10). The input element, designated as *Provider*, produces the data 18 Will-be-set-by-IN-TECH

*e*1 *f*1

*e*1 *f*1

*J*1

TF (flow causality) *J*1*out J*1*sum J*1*in J*1*out J*2*sum J*2*out J*2*out J*2*in* TF (effort causality) *J*1*sum J*1*out J*1*out J*1*in J*2*out J*2*sum J*2*in J*2*out*

*J*1

GY (flow causality) *J*1*out J*1*sum J*1*in J*1*out J*2*out J*2*sum J*2*in J*2*out* GY (effort causality) *J*1*sum J*1*out J*1*out J*1*in J*2*sum J*2*out J*2*out J*2*in*

A bond graph model on paper does not explicitly use a connector as in block diagram model, to link one element to another element. To retain the look and feel of a paper model when transferred to computer terminal, the connection between the elements has to be invisible. The masking properties of the Simulink block is utilised for this purpose in the tool box. A junction is considered as a node, to which the elements are connected. The bond graph element, as in paper model, is placed next to its associated junction. The link to the junction is made by entering the junction label in the mask parameter box. *Shared Memory*' algorithm is then used

In bond graph modeling two or more elements will be linked to a junction. Their data have to be shared. Shared data structure is used in the toolbox. The memory locations are earmarked for a junction by assigning it a unique label by *character aggregation*' during its first run. An S-function's initialisation callback method is used for memory allocation as this callback is used only once during the simulation run. The associated elements using the notation listed

The elements in the tool box are masked and have screen interfaces. For a one-port element

For a two-port element the extra information of the second port is also entered. Similarly a junction screen interface will have all entries of the elements that are linked to it, along with

The propagation of data from one element to the next is by reading and writing into a common block address (Fig.10). The input element, designated as *Provider*, produces the data

out in Table 6 and Table 7, share their respective memory address, thereby their data.

Input Port Output Port

Decider Non-decider Decider Non-decider *e*<sup>1</sup> *f*<sup>1</sup> *e*<sup>1</sup> *f*<sup>1</sup> *e*<sup>2</sup> *f*<sup>2</sup> *e*<sup>2</sup> *f*<sup>2</sup>

*TF <sup>e</sup>*<sup>2</sup>

*GY <sup>e</sup>*<sup>2</sup>

*f*2

*f*2

*J*2

*J*2

Port

Table 7. two-port element variables

to implicitly connect the element.

the following details need to be entered.

1. Name of the element. 2. Parametric value.

3. Whether decider bond or not. 4. Associated junction name.

their energy flow direction signs.

**7.1 Propagation of data**

**7. Linking elements**

through its constitutive equation and writes it on to the labelled memory address. The label, as discussed earlier is unique to a junction. The next element in hierarchy, designated as *Consumer*, in turn reads the data and by using its constitutive equations, *Produces* the next set of data which is written on to the next labelled memory address. There can be many *Consumer* of the data but there is only one unique *Provider*. An analogy to bond graph junction concept of one decider and many non-decider can be clearly seen here. It is also seen that a *Consumer* element of previous step becomes the *Provider* element in the next step. As the model is hierarchical, all the elements are in turn *Provider* and *Consumer* to their respective memory address block in one integration step. The memory location is released and freed when the data is not needed.

Fig. 10. Propagation of data in a integral time step

## **7.2 S-function implementation for shared memory link**

The port of the bond graph element as discussed above is the pointer to the shared memory address. When we specify a input/output port for a bond graph element, we have to supply three parameters to the S-function. They are:


The complete C MEX S-function code for input junction of a bond is given below:

```
#define S_FUNCTION_NAME inPort
#define S_FUNCTION_LEVEL 2
#define NPARAMS 3
#define PARAMETER_0_NAME decider
#define PARAMETER_0_DTYPE boolean_T
#define PARAMETER_1_NAME element
#define PARAMETER_2_NAME junction
#include "shm_com.h"
#include "windows.h"
```
char\_T istr[sizeof("fbnbn00")];

strcpy(str,temp); //junction name

strcpy(str,temp); //junction name

INVALID\_HANDLE\_VALUE, // use paging file

hMapObject, // object to map view of FILE\_MAP\_WRITE, // read/write access 0, // high offset: map from 0, // low offset: beginning 0); // default: map entire file

ssSetPWorkValue(S,1, shared\_memory\_loc);

INVALID\_HANDLE\_VALUE, // use paging file

ihMapObject, // object to map view of FILE\_MAP\_WRITE, // read/write access

NULL, // no security attributes PAGE\_READWRITE, // read/write access 0, // size: high 32-bits

NULL, // no security attributes PAGE\_READWRITE, // read/write access 0, // size: high 32-bits

sizeof(struct shared\_struct), // size: low 32-bits

memset(shared\_memory\_loc, '\0', sizeof(struct shared\_struct));

sizeof(struct shared\_struct), // size: low 32-bits

strcpy(istr,"j"); // prefix 'j'

hMapObject = CreateFileMapping(

str); // name of map object ssSetPWorkValue(S,0, hMapObject);

shared\_memory\_loc = MapViewOfFile(

if (shared\_memory\_loc == NULL ) {

ihMapObject = CreateFileMapping(

istr); // name of map object ssSetPWorkValue(S,2, ihMapObject);

ishared\_memory\_loc = MapViewOfFile(

CloseHandle(hMapObject);

return; } else {

}

if(\*decider){

} else {

}

strcat(str,"sum");

strcat(str,"out");

strcat(istr,str);

mxGetString(PARAM\_DEF1(S),str,sizeof(str)); //element name mxGetString(PARAM\_DEF2(S),temp,sizeof(str)); //junction name

S-Function Library for Bond Graph Modeling 117

```
#include "mex.h"
#include <malloc.h>
#include "simstruc.h"
#define PARAM_DEF0(S) ssGetSFcnParam(S, 0)
#define PARAM_DEF1(S) ssGetSFcnParam(S, 1)
#define PARAM_DEF2(S) ssGetSFcnParam(S, 2)
#define IS_PARAM_DOUBLE(pVal)
  (mxIsNumeric(pVal) && !mxIsLogical(pVal) &&\
!mxIsEmpty(pVal) && !mxIsSparse(pVal) && !mxIsComplex(pVal)\
   && mxIsDouble(pVal))
static void mdlInitializeSizes(SimStruct *S) {
  ssSetNumSFcnParams(S, NPARAMS);/* Number of expected parameters*/
  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
      return; /* Parameter mismatch will be reported by Simulink */
  }
  ssSetNumContStates(S, 0);
  ssSetNumDiscStates(S, 0);
  if (!ssSetNumInputPorts(S, 0)) return;
  if (!ssSetNumOutputPorts(S, 1)) return;
  ssSetOutputPortWidth(S, 0, DYNAMICALLY_SIZED);
  ssSetOutputPortComplexSignal(S, 0, COMPLEX_YES);
  ssSetNumSampleTimes(S, 1);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 4);
  ssSetNumModes(S, 0);
  ssSetNumNonsampledZCs(S, 0);
  ssSetOptions(S, 0);
}
static void mdlInitializeSampleTimes(SimStruct *S) {
  ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME);
  ssSetOffsetTime(S, 0, 0.0);
}
static void mdlStart(SimStruct *S) {
  const boolean_T *decider = mxGetData(PARAM_DEF0(S));
  void *shared_memory_loc = NULL;
  void *ishared_memory_loc = NULL;
  HANDLE hMapObject = NULL; // handle to real data file mapping
  HANDLE ihMapObject = NULL; // handle to file mapping
  char_T str[sizeof("fbnbn00")];
  char_T temp[sizeof("fbnbn00")];
```
20 Will-be-set-by-IN-TECH

#include "mex.h" #include <malloc.h> #include "simstruc.h"

}

}

}

#define PARAM\_DEF0(S) ssGetSFcnParam(S, 0) #define PARAM\_DEF1(S) ssGetSFcnParam(S, 1) #define PARAM\_DEF2(S) ssGetSFcnParam(S, 2)

(mxIsNumeric(pVal) && !mxIsLogical(pVal) &&\

static void mdlInitializeSizes(SimStruct \*S) {

if (!ssSetNumInputPorts(S, 0)) return; if (!ssSetNumOutputPorts(S, 1)) return;

ssSetOutputPortWidth(S, 0, DYNAMICALLY\_SIZED); ssSetOutputPortComplexSignal(S, 0, COMPLEX\_YES);

static void mdlInitializeSampleTimes(SimStruct \*S) { ssSetSampleTime(S, 0, CONTINUOUS\_SAMPLE\_TIME);

const boolean\_T \*decider = mxGetData(PARAM\_DEF0(S));

HANDLE ihMapObject = NULL; // handle to file mapping

HANDLE hMapObject = NULL; // handle to real data file mapping

!mxIsEmpty(pVal) && !mxIsSparse(pVal) && !mxIsComplex(pVal)\

if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {

ssSetNumSFcnParams(S, NPARAMS);/\* Number of expected parameters\*/

return; /\* Parameter mismatch will be reported by Simulink \*/

#define IS\_PARAM\_DOUBLE(pVal)

ssSetNumContStates(S, 0); ssSetNumDiscStates(S, 0);

ssSetNumSampleTimes(S, 1);

ssSetNumNonsampledZCs(S, 0);

ssSetOffsetTime(S, 0, 0.0);

static void mdlStart(SimStruct \*S) {

void \*shared\_memory\_loc = NULL; void \*ishared\_memory\_loc = NULL;

char\_T str[sizeof("fbnbn00")]; char\_T temp[sizeof("fbnbn00")];

ssSetNumRWork(S, 0); ssSetNumIWork(S, 0); ssSetNumPWork(S, 4); ssSetNumModes(S, 0);

ssSetOptions(S, 0);

&& mxIsDouble(pVal))

```
char_T istr[sizeof("fbnbn00")];
mxGetString(PARAM_DEF1(S),str,sizeof(str)); //element name
mxGetString(PARAM_DEF2(S),temp,sizeof(str)); //junction name
if(*decider){
 strcpy(str,temp); //junction name
 strcat(str,"sum");
} else {
 strcpy(str,temp); //junction name
 strcat(str,"out");
}
strcpy(istr,"j"); // prefix 'j'
strcat(istr,str);
hMapObject = CreateFileMapping(
 INVALID_HANDLE_VALUE, // use paging file
 NULL, // no security attributes
 PAGE_READWRITE, // read/write access
 0, // size: high 32-bits
 sizeof(struct shared_struct), // size: low 32-bits
 str); // name of map object
ssSetPWorkValue(S,0, hMapObject);
shared_memory_loc = MapViewOfFile(
 hMapObject, // object to map view of
 FILE_MAP_WRITE, // read/write access
 0, // high offset: map from
 0, // low offset: beginning
 0); // default: map entire file
if (shared_memory_loc == NULL ) {
 CloseHandle(hMapObject);
 return;
} else {
 ssSetPWorkValue(S,1, shared_memory_loc);
 memset(shared_memory_loc, '\0', sizeof(struct shared_struct));
}
ihMapObject = CreateFileMapping(
 INVALID_HANDLE_VALUE, // use paging file
 NULL, // no security attributes
 PAGE_READWRITE, // read/write access
 0, // size: high 32-bits
 sizeof(struct shared_struct), // size: low 32-bits
 istr); // name of map object
ssSetPWorkValue(S,2, ihMapObject);
ishared_memory_loc = MapViewOfFile(
 ihMapObject, // object to map view of
 FILE_MAP_WRITE, // read/write access
```
#include "cg\_sfun.h" /\*Code generation registration function\*/

S-Function Library for Bond Graph Modeling 119

Bond graph modeling is an emerging field especially in electrical, mechatronics and electro-mechanics, and a bond graph engineer may feel the necessity to define his own element while making a model. With the set of callback routine and function available to MEX files, any complex constitutive equation can be written for a new element. To provide support for complex variables and vectors in Bond Graph, a tool library using C-MEX S-functions with data propagation through shared memory, is developed. The MEX file for the library has been written in C/C++. After compiling and debugging, C/C++ MEX S-Function are masked with

Each element of the bond graph library has two common input/output blocks along with with a middle block (Fig.11). The code for the middle block is specific to the element it implements. After placing the three S-functions block in the subsystem, the subsystem is masked. The element's mask screen has a help at the top and parameter entry text boxes, below. There is a check box to specify whether the bond is decider (Fig.12). The parameters entered in the mask screen are manipulated by the S-functions underneath to initialise the element before

The capability of S-functions to support arbitrary input dimensions is exploited in the tool box. The actual input dimensions can be determined dynamically when a simulation is started by evaluating the dimensions of the input vector driving the S-function. This feature allows the same element to handle a scalar or a vector input as the case may be, without declaring it

inPort bond constitutive equation outPort

Input Bond specific block Output

All blocks are coded in C-MEX S-functions

The library is available in the standard format of simulink (Fig:13). The required elements can be had for *Pick and Place* from library after navigating down (Fig:13(a) and Fig:13(b)). The tools available in the mask's - icon graphics support, is utilised to give a natural iconic

Using the tool box, the circuit in Fig.14(a) is modeled in bond graph (Fig.14(b)). The simulation results are given in Fig.14(c) and Fig.14(d). As can be observed the library is able to handle

Fig. 11. Typical blocks under the mask of a bond graph element

representation to the element subsystem.

complex quantities quite accurately.

**8.1 Examples of tool box**

**8. S-function library for bond graph elements**

bond graph icons to distinguish between different elements.

#endif

the simulation cycle starts.

apriori.

```
0, // high offset: map from
   0, // low offset: beginning
   0); // default: map entire file
 if ( ishared_memory_loc == NULL) {
   CloseHandle(ihMapObject);
   return;
   } else {
   ssSetPWorkValue(S,3, ishared_memory_loc);
   memset(ishared_memory_loc, '\0', sizeof(struct shared_struct));
 }
}
static void mdlOutputs(SimStruct *S, int_T tid) {
 boolean_T yIsComplex=ssGetOutputPortComplexSignal(S, 0)
   ==COMPLEX_YES;
 real_T *y = ssGetOutputPortRealSignal(S,0);
 struct shared_struct *shared_stuff, *ishared_stuff;
 shared_stuff = (struct shared_struct *)ssGetPWorkValue(S,1);
 ishared_stuff = (struct shared_struct *)ssGetPWorkValue(S,3);
 y[0] = shared_stuff->some_data;
 y[1] = ishared_stuff->some_data;
 CloseHandle((HANDLE)ssGetPWorkValue(S,0));
 CloseHandle((HANDLE)ssGetPWorkValue(S,2));
}
static void mdlTerminate(SimStruct *S) {
 struct shared_struct *shared_stuff, *ishared_stuff;
 HANDLE c = (HANDLE) ssGetPWork(S)[0]; // retrieve and destroy C++
 HANDLE ic = (HANDLE) ssGetPWork(S)[2]; // retrieve and destroy C++
 shared_stuff = (struct shared_struct *)ssGetPWorkValue(S,1);
 ishared_stuff = (struct shared_struct *)ssGetPWorkValue(S,3);
 free(c);
 if(ic != NULL) {
   free(ic);
 }
 free(shared_stuff);
 if(ishared_stuff !=NULL) {
   free(ishared_stuff);
 }
}
#ifdef MATLAB_MEX_FILE /* Is this file being compiled as
   a MEX-file? */
#include "simulink.c" /* MEX-file interface mechanism */
#else
```
22 Will-be-set-by-IN-TECH

memset(ishared\_memory\_loc, '\0', sizeof(struct shared\_struct));

0, // high offset: map from 0, // low offset: beginning 0); // default: map entire file

ssSetPWorkValue(S,3, ishared\_memory\_loc);

static void mdlOutputs(SimStruct \*S, int\_T tid) {

real\_T \*y = ssGetOutputPortRealSignal(S,0);

CloseHandle((HANDLE)ssGetPWorkValue(S,0)); CloseHandle((HANDLE)ssGetPWorkValue(S,2));

static void mdlTerminate(SimStruct \*S) {

struct shared\_struct \*shared\_stuff, \*ishared\_stuff;

struct shared\_struct \*shared\_stuff, \*ishared\_stuff;

boolean\_T yIsComplex=ssGetOutputPortComplexSignal(S, 0)

shared\_stuff = (struct shared\_struct \*)ssGetPWorkValue(S,1); ishared\_stuff = (struct shared\_struct \*)ssGetPWorkValue(S,3);

HANDLE c = (HANDLE) ssGetPWork(S)[0]; // retrieve and destroy C++ HANDLE ic = (HANDLE) ssGetPWork(S)[2]; // retrieve and destroy C++

shared\_stuff = (struct shared\_struct \*)ssGetPWorkValue(S,1); ishared\_stuff = (struct shared\_struct \*)ssGetPWorkValue(S,3);

#ifdef MATLAB\_MEX\_FILE /\* Is this file being compiled as

#include "simulink.c" /\* MEX-file interface mechanism \*/

if ( ishared\_memory\_loc == NULL) {

CloseHandle(ihMapObject);

y[0] = shared\_stuff->some\_data; y[1] = ishared\_stuff->some\_data;

return; } else {

==COMPLEX\_YES;

} }

}

free(c);

}

} }

#else

if(ic != NULL) { free(ic);

free(shared\_stuff);

a MEX-file? \*/

if(ishared\_stuff !=NULL) { free(ishared\_stuff);

```
#include "cg_sfun.h" /*Code generation registration function*/
#endif
```
## **8. S-function library for bond graph elements**

Bond graph modeling is an emerging field especially in electrical, mechatronics and electro-mechanics, and a bond graph engineer may feel the necessity to define his own element while making a model. With the set of callback routine and function available to MEX files, any complex constitutive equation can be written for a new element. To provide support for complex variables and vectors in Bond Graph, a tool library using C-MEX S-functions with data propagation through shared memory, is developed. The MEX file for the library has been written in C/C++. After compiling and debugging, C/C++ MEX S-Function are masked with bond graph icons to distinguish between different elements.

Each element of the bond graph library has two common input/output blocks along with with a middle block (Fig.11). The code for the middle block is specific to the element it implements. After placing the three S-functions block in the subsystem, the subsystem is masked. The element's mask screen has a help at the top and parameter entry text boxes, below. There is a check box to specify whether the bond is decider (Fig.12). The parameters entered in the mask screen are manipulated by the S-functions underneath to initialise the element before the simulation cycle starts.

The capability of S-functions to support arbitrary input dimensions is exploited in the tool box. The actual input dimensions can be determined dynamically when a simulation is started by evaluating the dimensions of the input vector driving the S-function. This feature allows the same element to handle a scalar or a vector input as the case may be, without declaring it apriori.

Fig. 11. Typical blocks under the mask of a bond graph element

The library is available in the standard format of simulink (Fig:13). The required elements can be had for *Pick and Place* from library after navigating down (Fig:13(a) and Fig:13(b)). The tools available in the mask's - icon graphics support, is utilised to give a natural iconic representation to the element subsystem.

## **8.1 Examples of tool box**

Using the tool box, the circuit in Fig.14(a) is modeled in bond graph (Fig.14(b)). The simulation results are given in Fig.14(c) and Fig.14(d). As can be observed the library is able to handle complex quantities quite accurately.

Bond Graph Elements

S-Function Library for Bond Graph Modeling 121

(a) Bond Graph tool Box level 1

One Port Elements

Transformer Gyrator

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

Modulated Gyrator

mTF rGY

mGY

Two Port Elements

Connector

cos *<sup>α</sup>*(*i*, *<sup>k</sup>*) refers to the spatial angle between the *<sup>k</sup>th* winding's axis and the *<sup>i</sup>*

of the magnetic core, *Pm* is the reactive power required to magnetise the core.

(b) Effort Causual Elements at level 2

respect to the bond under consideration. Λ*<sup>m</sup>* is the mutual permeance (inverse of reluctance)

A bond graph model of 3*φ* doubly fed induction motor using the Axis Rotator element is shown in Fig.16. There are six sets of electric energy input ports, three each for stator and rotor, in the model. The motor shaft represents a mechanical output port. The air gap is represented by the AR with six connection bonds terminating at it, each representing a set of

Effort source

mSe

R L

Resistance Inductance Capacitance

Effort Causual Elements

Effort source Modulated

Modulated Transformer

Fig. 13. Bond Graph library

**8.2.2 Induction motor model**

TF

Se

Flow Causual Elements

C

Rotary Gyrator

*th* winding axis with

GY


Fig. 12. Input mask screen

For another example of switched junction, one model of the switched mode power converter in Fig.14(f) is used. The circuit is of a boost converter. There are two switches *S*<sup>1</sup> and *S*<sup>2</sup> driven by complementary signals. This ensures that only one switch is on at any given time. The circuit is modeled in bond graph using the switched junction as shown in Fig.14(e). The simulation result of the effected state variable is shown in Fig.14(g).

#### **8.2 Simulation results for IM model**

A rotating electrical machine can be viewed as a machinery which converts one form of energy into another. More specifically it converts electrical energy into mechanical energy or vice-versa. Magnetic energy is used as a conversion medium between electrical and mechanical energy.

#### **8.2.1 Axis rotator element**

This generalised concept for electrical machine modeling needs 'Axis Rotator', a new bond graph element (Umesh Rai & Umanand, 2008; 2009a;b) to mathematically model a electrical commutator (Fig.15). The constitutive relationship for the flow and effort in the bonds is given by Eqn.(2) and Eqn.(3).

$$f\_i = \frac{d}{dt} \left( \Lambda\_m \left( \sum\_{k=1}^n e\_k \cos \mathfrak{a}\_{(i,k)} \right) \right) \quad where, \quad \mathfrak{a}\_{(i,k)} = \mathfrak{a}\_i - \mathfrak{a}\_k \tag{2}$$

$$\sum\_{k=1}^{n} e\_k f\_k = P\_m \tag{3}$$

24 Will-be-set-by-IN-TECH

For another example of switched junction, one model of the switched mode power converter in Fig.14(f) is used. The circuit is of a boost converter. There are two switches *S*<sup>1</sup> and *S*<sup>2</sup> driven by complementary signals. This ensures that only one switch is on at any given time. The circuit is modeled in bond graph using the switched junction as shown in Fig.14(e). The

A rotating electrical machine can be viewed as a machinery which converts one form of energy into another. More specifically it converts electrical energy into mechanical energy or vice-versa. Magnetic energy is used as a conversion medium between electrical and

This generalised concept for electrical machine modeling needs 'Axis Rotator', a new bond graph element (Umesh Rai & Umanand, 2008; 2009a;b) to mathematically model a electrical commutator (Fig.15). The constitutive relationship for the flow and effort in the bonds is given

*ek fk* = *Pm* (3)

*where*, *α*(*i*, *<sup>k</sup>*) = *α<sup>i</sup>* − *α<sup>k</sup>* (2)

*ek* cos *α*(*i*, *<sup>k</sup>*)

simulation result of the effected state variable is shown in Fig.14(g).

Fig. 12. Input mask screen

mechanical energy.

**8.2.1 Axis rotator element**

by Eqn.(2) and Eqn.(3).

*fi* <sup>=</sup> *<sup>d</sup> dt*

*n* ∑ *k*=1  Λ*<sup>m</sup>*  *n* ∑ *k*=1

**8.2 Simulation results for IM model**

(a) Bond Graph tool Box level 1


(b) Effort Causual Elements at level 2

Fig. 13. Bond Graph library

cos *<sup>α</sup>*(*i*, *<sup>k</sup>*) refers to the spatial angle between the *<sup>k</sup>th* winding's axis and the *<sup>i</sup> th* winding axis with respect to the bond under consideration. Λ*<sup>m</sup>* is the mutual permeance (inverse of reluctance) of the magnetic core, *Pm* is the reactive power required to magnetise the core.

## **8.2.2 Induction motor model**

A bond graph model of 3*φ* doubly fed induction motor using the Axis Rotator element is shown in Fig.16. There are six sets of electric energy input ports, three each for stator and rotor, in the model. The motor shaft represents a mechanical output port. The air gap is represented by the AR with six connection bonds terminating at it, each representing a set of

*AR*:Λ*<sup>m</sup>*

*αn*

S-Function Library for Bond Graph Modeling 123

winding. The permeance parameter of the AR represents the mutual coupling effect of the flux. The iron loss is represented by the dissipative port. The stator and rotor energy ports are

The dissipative, entropy producing fields, *Ras*, *Rbs*, *Rcs*, *Rar*, *Rbr*, *Rcr* and *Ri* are non-equal non-linear resistances depending on the underlying physical system. *Ri* represents the iron losses of the core. In a similar manner, the model represents the permeances *Lasl*, *Lbsl*, *Lcsl*, *Larl*, *Lbrl*, *Lcrl* and *Lm* . There is no linearity restriction on the above parameters. They could be constants, functions or even a lookup table, without loss of generality. The value of the lumped parameters are different for different phases, dependent on the electric and the magnetic energy they represent. Similarly the energy sources feeding the different windings are represented by *s*1, *s*<sup>2</sup> and *s*3. For balanced supply voltages the voltage peaks and frequency would be same, with a phase difference of (2*π*/3) to one another. The three domains of

At the shaft the developed electromagnetic torque as a function of the stator, rotor currents and the angle between them is represented as an effort source. The electromagnetic torque provides the effort at the one junction against the inertial, frictional and load torque components. The feedback information on flow at this junction, which gives the measure of rotor speed is transmitted to the AR for calculating the instantaneous angle of the rotor

The power of S-function is demonstrated by firstly implementing the complex AR element using C Mex S-function and making it a part of bond graph library. As discussed in the above section, there is no linearity or balance supply constraint on the model. The increased complexity can easily be handled by the bond graph library. The causal model implementation of squirrel cage induction motor is shown in Simulink (Fig.17). The machine starts from stall. A step load is applied to the motor at 0.5sec. The simulation results of speed curve for various step load are presented in Fig.18(a). Similarly the current curves and the torque curve for a specific load are at Fig.18(c) and Fig.18(e) respectively. The transition of rotor currents to slip frequency can be distinctly seen at Fig.18(c). The simulation results of the bond graph model in S-function co-related well with the speed curves obtained by d-q model of the induction motor implemented by functional block in Simulink (Fig.18(b), Fig.18(d) and

··· ··· *en fn* *jn*

*α*<sup>1</sup>

···

*α*2

*e*1 *f*1

*e*2 *f*2

Fig. 15. Axis rotator connected with bonds representing windings

electrical, magnetic and mechanical are clearly brought out in Fig.16.

*j*1

*j*2

described with different set of port parameters.

**8.2.3 S-function model of induction motor**

windings.

Fig.18(f)).

(e) Boost converter model built using switched junction

Inductor Flow

Fig. 14. Bond graph tool box examples

26 Will-be-set-by-IN-TECH

Im

−2 −1.5 −1 −0.5 0 0.5 1 1.5 2 2.5

Volts

R1 = 2 ohm R2 = 3 ohm

Real In Img In Real Out Img Out Element Probe (b) Bond graph model of RC circuit

mSe <sup>1</sup> <sup>0</sup> Re

<sup>0</sup> <sup>1000</sup> <sup>2000</sup> <sup>2500</sup> <sup>−</sup>2.5

(d) Plots of C-bond effort

4 Ic

IL1 [Ub]

C

3 Vo

[e6] Vo1

[f6] Ubar\*IL1

> 10 20 30

Volts

Amps

time

Real

R

Capacitor Effort

Imaginary

c1 =0.001 farad

2 VL

[e2] VL1

[f2]

<sup>0</sup> 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 <sup>−</sup><sup>5</sup>

Time

Capacitor Effort

<sup>0</sup> 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 <sup>0</sup>

Time

(g) Plot of effected state variables

Inductor Flow

1 IL

2\*sin (50 \*t)

1.5 \* sin (50\*t)

Switched junction

1 0s 0

Se

[U] Goto

Goto1

*Rc C*

(e) Boost converter model built using switched junction

*Vt* = 2*sin*(50*t*) +*j*1.5*sin*(50*t*)

*R*1 2 Ω *i*

> *R*2 3 Ω

(a) RC circuit

Se

Imaginary

−0.1 −0.05 0 0.05 0.1 0.15

Amps

Repeating Sequence

> 1 d

> > *Rl L i*

Fig. 14. Bond graph tool box examples

*Vg*

*C*1 0.001 F

0 1000 2000 2500

Time

(c) Plots of C-bond flow

Relay

R

u[2]¿=u[1] Fcn

*S*1

*S*2

(f) A Boost converter

L

Real

Capacitor Flow

Fig. 15. Axis rotator connected with bonds representing windings

winding. The permeance parameter of the AR represents the mutual coupling effect of the flux. The iron loss is represented by the dissipative port. The stator and rotor energy ports are described with different set of port parameters.

The dissipative, entropy producing fields, *Ras*, *Rbs*, *Rcs*, *Rar*, *Rbr*, *Rcr* and *Ri* are non-equal non-linear resistances depending on the underlying physical system. *Ri* represents the iron losses of the core. In a similar manner, the model represents the permeances *Lasl*, *Lbsl*, *Lcsl*, *Larl*, *Lbrl*, *Lcrl* and *Lm* . There is no linearity restriction on the above parameters. They could be constants, functions or even a lookup table, without loss of generality. The value of the lumped parameters are different for different phases, dependent on the electric and the magnetic energy they represent. Similarly the energy sources feeding the different windings are represented by *s*1, *s*<sup>2</sup> and *s*3. For balanced supply voltages the voltage peaks and frequency would be same, with a phase difference of (2*π*/3) to one another. The three domains of electrical, magnetic and mechanical are clearly brought out in Fig.16.

At the shaft the developed electromagnetic torque as a function of the stator, rotor currents and the angle between them is represented as an effort source. The electromagnetic torque provides the effort at the one junction against the inertial, frictional and load torque components. The feedback information on flow at this junction, which gives the measure of rotor speed is transmitted to the AR for calculating the instantaneous angle of the rotor windings.

#### **8.2.3 S-function model of induction motor**

The power of S-function is demonstrated by firstly implementing the complex AR element using C Mex S-function and making it a part of bond graph library. As discussed in the above section, there is no linearity or balance supply constraint on the model. The increased complexity can easily be handled by the bond graph library. The causal model implementation of squirrel cage induction motor is shown in Simulink (Fig.17). The machine starts from stall. A step load is applied to the motor at 0.5sec. The simulation results of speed curve for various step load are presented in Fig.18(a). Similarly the current curves and the torque curve for a specific load are at Fig.18(c) and Fig.18(e) respectively. The transition of rotor currents to slip frequency can be distinctly seen at Fig.18(c). The simulation results of the bond graph model in S-function co-related well with the speed curves obtained by d-q model of the induction motor implemented by functional block in Simulink (Fig.18(b), Fig.18(d) and Fig.18(f)).

voltage

current

torque

speed

To File

R4

R5 g10 g9 ms5

R6 ms6 g12 g11

mSe

0

1 mL

0

mSe

mSe

g7 g8

j10 j11

GY

j12 j13

GY

j15 j14

GY

c4

0

C

C

c5

0

C

AG

c6

cn4

GY <sup>0</sup>

AG

cn5

cn6

AG

4

2 I

<sup>s</sup> P/2 <sup>−</sup><sup>1</sup>

0

md <sup>3</sup>

i md Torque

wm

ms4

j21 ms12 ms11

L1

1

1

R

1

R

R

R11

1

L

R

mSe mSe

Vra im

ω

Torque

Induction Machine

S-Function Library for Bond Graph Modeling 125

(a) Model in Solver

j3

j6

AR

j9

P theta

1

(b) Model in MATLAB/Simulink)

Currents

Vsa

Vsb

Vsc

Vra

Vrb

Vrc

Load

L

0 Vrc

Step

Nonlinear Inductance

> c1 cn1

C

0

C

> c2 cn2

0

C

> c3 cn3

> > AG

AG

AG

0

j1 j2

j4 j5

GY

j7 j8

GY

R1 ms1 g1 g2

1

R

R

R2 ms2 g3 g4

1

R

R3 ms3 g5 g6

1

Fig. 17. 3*φ* Induction motor model in Matlab

1 Vs

mSe

mSe

mSe

0 Vrb

0

Ph C

−C− Freq

−C− Amplitude

Ph B

Ph A

Fig. 16. 3*φ DFIM* bond graph model

28 Will-be-set-by-IN-TECH

1 j1

R : Rbs

1 j3

R : Rcs

1 j5

Fig. 16. 3*φ DFIM* bond graph model

GY g1

GY g2

GY g3

0 j2

C : Λbsl

cn<sup>1</sup>

cn<sup>2</sup>

cn<sup>3</sup>

B : R

mS<sup>e</sup> 1 <sup>T</sup><sup>e</sup> ω

0 j4

AR:Λ*<sup>m</sup>* α<sup>1</sup>

Stator (Electric) Stator (Magnetic) air gap (Magnetic) Rotor (Magnetic) Rotor (Electric)

j<sup>15</sup>

R : Ri

> α6 α5 α4

cn<sup>4</sup>

0 j8

C : Λbrl

0 j<sup>10</sup>

> C : Λcrl

0 j<sup>12</sup>

S<sup>e</sup> : −T

GY g4

GY g5

GY g6

1 j9

R : Rbr

1 j<sup>11</sup>

> R : Rcr

1 j<sup>13</sup>

Torque (Mechanical)

Var iar

Vbr ibr

Vcr icr

<sup>V</sup>crsin(ωt <sup>−</sup> <sup>4</sup><sup>π</sup> 3 )

<sup>V</sup>brsin(ωt <sup>−</sup> <sup>2</sup><sup>π</sup> 3 )

mS<sup>e</sup> s4

mS<sup>e</sup> s5

mS<sup>e</sup> s6

Varsin(ωt)

R : Rar

C : Λarl

cn<sup>5</sup>

cn<sup>6</sup>

L : J

α2

α3

C : Λcsl

0 j6

f<sup>n</sup> (isabc, irabc, θr)

C : Λasl

R : Ras

vas ias

Vbs ibs

Vcs ics

<sup>V</sup>cssin(ωt <sup>−</sup> <sup>4</sup><sup>π</sup> 3 )

<sup>V</sup>bssin(ωt <sup>−</sup> <sup>2</sup><sup>π</sup> 3 )

mS<sup>e</sup>

s1

mS<sup>e</sup>

s2

mS<sup>e</sup>

s3

Vassin(ωt)

#### (a) Model in Solver

(b) Model in MATLAB/Simulink)

Fig. 17. 3*φ* Induction motor model in Matlab

**9. Conclusion**

data values.

**10. References**

Electrotechniek.

*in Simulation* 66(2-3): 99–128.

*Franklin Institute* 332(3): 285–305.

*Handbook* pp. 99–108.

Wiley & Sons, Inc., NY.

URL: *www.mathworks.com*

The power of S-function in customising MATLAB/Simulink®

a specific modeling need is illustrated in this chapter. Two different approaches for implementing a customised Simulink element is then discussed with their advantages and disadvantages. Later the Bond graph approach of modeling is briefly introduced. Level 2 C

S-Function Library for Bond Graph Modeling 127

This library of bond graph elements can handle both the scalar and vector or complex variables without declaring apriori, a distinct advantage. A new element - *Axis Rotator*, used for representing rotating magnetic field is included in the library. The ability to handle complex variables along with the rotation enables the elements in the library to be used for modeling rotating frames as that existing in an electric machine. The library also incorporates switched junctions, which allows for the modeling of switches in any circuit. In developing the library, the *Shared Memory Concept* is used. By using shared memory concept, the memory requirement comes down as only the pointer to the memory location are passed and not the

MEX S-function technique is then used to develop a library of bond graph element.

Borutzky, W. (2009). *Bond Graph Modelling*, Simulation Modelling Practice and Theory. Borutzky, W., for Modeling, S. & International, S. (2004). *Bond Graphs: A Methodology for*

Modeling and Simulation International.

*Modelling Multidisciplinary Dynamic Systems*, SCS Publishing House e. V.: Society for

Breedveld, P. (1984). *Physical Systems Theory in Terms of Bond Graphs*, THT-Afdelin

Breedveld, P. (1991). *Special Issue on Current Topics in Bond Graph Related Research*, Pergamon. Breedveld, P. (2004). Port-based modeling of mechatronic systems, *Mathematics and Computers*

Breedveld, P., Rosenberg, R. & ZHOU, T. (1991). Bibliography of bond graph theory and

Cellier, F., Elmqvist, H. & Otter, M. (1995). Modeling from physical principles, *The Control*

Gawthrop, P. (1995). Physical model-based control: A bond graph approach, *Journal of the*

Gawthrop, P. & Smith, L. (1996). *Metamodelling: for bond graphs and dynamic systems*, Prentice

Karnopp, D., Margolis, D. & Rosenberg, R. (1990). *System Dynamics: A Unified Approach*, John

Karnopp, D., Margolis, D. & Rosenberg, R. (2006). *System Dynamics: Modeling and Simulation*

Karnopp, D. & Rosenberg, R. (1968). *Analysis and Simulation of Multiport Systems: The Bond*

*of Mechatronic Systems*, John Wiley & Sons, Inc. New York, NY, USA.

Kron, G. (1962). *Diakoptics: The Piecewise Solution of Large-scale Systems*, Macdonald.

application, *Franklin Institute, Journal* 328(5): 1067–1109.

Dauphin-Tanguy, G. (2000). *Les bond graphs*, Hermès science publications.

Hall International (UK) Ltd. Hertfordshire, UK, UK.

*Graph Approach to Physical System Dynamics*, MIT Press.

Mathworks (2011). *Developing S-Functions*, The MathWorks, Inc.

environment suitable for

Fig. 18. Simulation results of the bond graph model

### **9. Conclusion**

30 Will-be-set-by-IN-TECH

0

−20

0

Developed torque in N-m

20

40

Current in amps

0

20

40

50

Speed in rad/sec 100 150 200

0 250 500 750 1000 <sup>−</sup><sup>50</sup>

(b) Speed curves dq model

0 250 500 750 1000 <sup>−</sup><sup>40</sup>

(d) Current curves dq model

0 250 500 750 1000 <sup>−</sup><sup>20</sup>

(f) Torque curves dq model

Time in mSec

Time in mSec

time in mSecs

Speed from full load to no load

0 250 500 750 1000 <sup>−</sup><sup>50</sup>

(a) Speed curves proposed model

0 250 500 750 1000 <sup>−</sup><sup>40</sup>

(c) Current curves proposed model

0 250 500 750 1000 <sup>−</sup><sup>20</sup>

(e) Torque curves proposed model

Fig. 18. Simulation results of the bond graph model

Time in mSec

Time in mSec

Time in mSec

Speed from no load to overload load (0 to 30)

Step load

−20

0

Developed torque (N-m)

20

40

Currnt in amps

0

20

40

Speed in rad/sec The power of S-function in customising MATLAB/Simulink® environment suitable for a specific modeling need is illustrated in this chapter. Two different approaches for implementing a customised Simulink element is then discussed with their advantages and disadvantages. Later the Bond graph approach of modeling is briefly introduced. Level 2 C MEX S-function technique is then used to develop a library of bond graph element.

This library of bond graph elements can handle both the scalar and vector or complex variables without declaring apriori, a distinct advantage. A new element - *Axis Rotator*, used for representing rotating magnetic field is included in the library. The ability to handle complex variables along with the rotation enables the elements in the library to be used for modeling rotating frames as that existing in an electric machine. The library also incorporates switched junctions, which allows for the modeling of switches in any circuit. In developing the library, the *Shared Memory Concept* is used. By using shared memory concept, the memory requirement comes down as only the pointer to the memory location are passed and not the data values.

## **10. References**

Borutzky, W. (2009). *Bond Graph Modelling*, Simulation Modelling Practice and Theory.


URL: *www.mathworks.com*

**0**

**6**

*Germany*

*Ilmenau University of Technology*

**From Control Design to FPGA Implementation**

As a modelling and simulation tool, MATLAB/Simulink plays a significant role in industrial control design. To allow the deployment of the designed control solutions a number of code generation facilities have been developed, that aim on implementing PC-based control units or embedded controllers based on micro-controllers or digital signal processors (DSP). This has enabled MATLAB/Simulink to cover the model-based development process from conceptual design over simulative validation to rapid-prototyping (Krasner (2004)). Although not a new technology per se, since the first commercial field-programmable gate array (FPGA) has been released by Xilinx in 1985, recent development in the field of reconfigurable hardware has created FPGAs, the capabilities of which apply to the requirements of industrial control in a growing number of application domains (Monmasson & Cirstea (2007)). Therefore, also code generation facilities targeting FPGAs have emerged, that link the modelling level to the level of hardware description languages (HDL), from which the lower-level descriptions (RTL) and chip-specific implementations are derived using hardware

MATLAB/Simulink manages to incorporate the processes of high level control design, system modelling on various levels of abstraction and, the availability of respective tool boxes provided, the target-specific code generation. Yet, there is a semantic gap between the control system model, and the model describing an implementation of the controller. The former is a platform-independent simulation model, an executable specification for a controller design, that fulfills the control task within the given simulation scenario. From such a model various implementations can be derived, but not without a step via a platform-specific model, that, to a certain extend, has to incorporate the characteristics of the target platform. An important issue to consider at this point is, that the modelling semantics changes from a functional view to the execution view. The question is no longer "What is being computed?", but "How is it computed?" - a question, that has even more impact on models aimed on generating hardware

Especially models targeting HDL code generation and hardware synthesis have to undergo an explicit change of the abstraction level, i.e. *model refinement*, towards a hardware-specific implementation model. The Simulink model has to very closely resemble the hardware

This chapter will illustrate the characteristics of this semantic gap and demonstrate a number of techniques on how to make a consistent transition. An overview of control system modelling using Simulink as well as the HDL Coder code generation flow will be given. As

**1. Introduction**

synthesis tool chains.

designs, than on those targeting software generation.

structure as well as the behaviour of the data flowing through the chip.

Marcus Müller, Hans-Christian Schwannecke and Wolfgang Fengler


#### **0 6**

## **From Control Design to FPGA Implementation**

Marcus Müller, Hans-Christian Schwannecke and Wolfgang Fengler *Ilmenau University of Technology Germany*

## **1. Introduction**

32 Will-be-set-by-IN-TECH

128 Technology and Engineering Applications of Simulink

Mukherjee, A. & Karmakar, R. (2000). *Modelling And Simulation of Engineering Systems Through*

Rosenberg, R. & Karnopp, D. (1983). *Introduction to Physical System Dynamics*, McGraw-Hill,

Umarikar, A., Mishra, T. & Umanand, L. (2006). Bond graph simulation and symbolic extraction toolbox in MATLAB/SIMULINK, *J. Indian Inst. Sci* 86: 45–68. Umesh Rai, B. & Umanand, L. (2008). Bond graph model of doubly fed three phase induction

Umesh Rai, B. & Umanand, L. (2009a). Bond graph model of an induction machine with hysteresis nonlinearities, *Nonlinear Analysis: Hybrid Systems* 4(3): 395–405. Umesh Rai, B. & Umanand, L. (2009b). Generalised bond graph model of a rotating machine,

motor using the Axis Rotator element for frame transformation, *Simulation Modelling*

Paynter, H. & Briggs, P. (1961). *Analysis and Design of Engineering Systems*, MIT Press.

Thoma, J. (1990). *Simulation by bondgraphs*, Berlin and New York, Springer-Verlag, 194 p. Thoma, J. & Perelson, A. (1976). Introduction to Bond Graphs and Their Applications, *Systems,*

*Man and Cybernetics, IEEE Transactions on* 6(11): 797–798.

*International Journal of Power Electronics* 1(4): 397–413.

*Bondgraphs*, Alpha Science Int'l Ltd.

*Practice and Theory* 16(10): 1704–1712.

Inc. New York, NY, USA.

As a modelling and simulation tool, MATLAB/Simulink plays a significant role in industrial control design. To allow the deployment of the designed control solutions a number of code generation facilities have been developed, that aim on implementing PC-based control units or embedded controllers based on micro-controllers or digital signal processors (DSP). This has enabled MATLAB/Simulink to cover the model-based development process from conceptual design over simulative validation to rapid-prototyping (Krasner (2004)). Although not a new technology per se, since the first commercial field-programmable gate array (FPGA) has been released by Xilinx in 1985, recent development in the field of reconfigurable hardware has created FPGAs, the capabilities of which apply to the requirements of industrial control in a growing number of application domains (Monmasson & Cirstea (2007)). Therefore, also code generation facilities targeting FPGAs have emerged, that link the modelling level to the level of hardware description languages (HDL), from which the lower-level descriptions (RTL) and chip-specific implementations are derived using hardware synthesis tool chains.

MATLAB/Simulink manages to incorporate the processes of high level control design, system modelling on various levels of abstraction and, the availability of respective tool boxes provided, the target-specific code generation. Yet, there is a semantic gap between the control system model, and the model describing an implementation of the controller. The former is a platform-independent simulation model, an executable specification for a controller design, that fulfills the control task within the given simulation scenario. From such a model various implementations can be derived, but not without a step via a platform-specific model, that, to a certain extend, has to incorporate the characteristics of the target platform. An important issue to consider at this point is, that the modelling semantics changes from a functional view to the execution view. The question is no longer "What is being computed?", but "How is it computed?" - a question, that has even more impact on models aimed on generating hardware designs, than on those targeting software generation.

Especially models targeting HDL code generation and hardware synthesis have to undergo an explicit change of the abstraction level, i.e. *model refinement*, towards a hardware-specific implementation model. The Simulink model has to very closely resemble the hardware structure as well as the behaviour of the data flowing through the chip.

This chapter will illustrate the characteristics of this semantic gap and demonstrate a number of techniques on how to make a consistent transition. An overview of control system modelling using Simulink as well as the HDL Coder code generation flow will be given. As

Mathworks (2011b) Simulink HDL Coder, which has undergone an extensive development during recent MATLAB revisions, and conducts the HDL code generation from a growing subset of Simulink library blocks (Auger (2008)), allowing a more hardware-independent design approach. Similar within all approaches is the final utilization of the vendor-specific implementation tool chains, that conduct the synthesis and FPGA implementation of the generated HDL code and provide the option to conduct a further validation step on code

From Control Design to FPGA Implementation 131

**-**

 ! 

 ! 

 ! 

**-#**

**-#**

**!"#** 

**!"#** 

level via HDL simulation.

 

hardware.

 

 

 

**-**

**-**

**-**

**#** 

 

 

Fig. 1. Overview of the Simulink-based controller development flow targeting FPGA

Result of Simulink control system modelling is a controller design that fulfills the specified control task and quality, which has been validated by simulation within the bounds of the

 

 

**!"#** 

**!"#** 


**#** 

**-**

**#** 

**#** 

 

"


 

an example the model of a 3D trajectory tracking controller for deployment in high-precision positioning and measuring stages will be introduced. The main parts of this chapter regard the structural and behavioural changes, that create a HDL-compatible implementation model from a given simulation model in a top-down manner.

In conclusion a modelling flow is proposed, that - in the course of a model-based top-down development process - precedes the utilization of MATLAB-associated HDL code generation facilities and describes the transition from a platform-independent control system model to a hardware-specific implementation model of the controller. This flow incorporates all discussed modelling activities in a consistent manner, aims on minimizing redesign iterations and allows a simulative validation during all design steps.

## **2. Control design using Simulink**

The extent of MATLAB/Simulink allows the design of control systems on various levels of abstraction. A *system* model is comprised of:


While the plant model can be of a very abstract form, only describing the transfer function or functional behaviour of the controlled process, the controller model is the part, that undergoes the model-based development from control design over refinement to implementation.

The *control design* incorporates the functional design of the controller with regard to the requirements of the plant. As a result, a controller structure and parametrization is achieved, that fulfills the required control task and quality, which can be validated by simulation. This model is called a *platform-independent model* (PIM) of the controller.

When aiming on deploying this solution to the real world, the subsequent step would be the generation of an executable implementation for a processing platform. MATLAB/Simulink provides a variety of possibilities to generate software for PC-based or embedded targets using the MATLAB tool boxes Real-Time Workshop and Embedded Coder plus several vendor-specific extensions, that require no or little additional modelling effort to build a compatible model - a *platform-specific model* (PSM). All code generation facilities provide an abstraction of the targeted processing platform in form of a platform-specific block library and the according tools to transform the blocks in adequate code fragments. For single-processor targets this is quite straight-forward. More difficult is the targeting of multi-processor hardware, since the inter-processor communication has to be incorporated on modelling level (Müller et al. (2009)), and embedded hardware, that often includes the addressing of peripherals.

Figure 1 depicts a Simulink-based development flow tailored for an FPGA implementation of the controller. Regarding the *Target platform abstraction libraries and tools* for HDL, two methods of tool integration can be distinguished, that greatly ease the transition from model to HDL code and the implementation on hardware. First, there are the tool boxes provided by hardware vendors, like the Altera Corporation (2011) DSP Builder and the Xilinx, Inc. (2011) System Generator for DSP, that provide proprietary block sets as additional Simulink libraries and access the respective synthesis tools. Second, there is the HDL generation process via The 2 Will-be-set-by-IN-TECH

an example the model of a 3D trajectory tracking controller for deployment in high-precision positioning and measuring stages will be introduced. The main parts of this chapter regard the structural and behavioural changes, that create a HDL-compatible implementation model

In conclusion a modelling flow is proposed, that - in the course of a model-based top-down development process - precedes the utilization of MATLAB-associated HDL code generation facilities and describes the transition from a platform-independent control system model to a hardware-specific implementation model of the controller. This flow incorporates all discussed modelling activities in a consistent manner, aims on minimizing redesign iterations

The extent of MATLAB/Simulink allows the design of control systems on various levels of

While the plant model can be of a very abstract form, only describing the transfer function or functional behaviour of the controlled process, the controller model is the part, that undergoes the model-based development from control design over refinement to implementation.

The *control design* incorporates the functional design of the controller with regard to the requirements of the plant. As a result, a controller structure and parametrization is achieved, that fulfills the required control task and quality, which can be validated by simulation. This

When aiming on deploying this solution to the real world, the subsequent step would be the generation of an executable implementation for a processing platform. MATLAB/Simulink provides a variety of possibilities to generate software for PC-based or embedded targets using the MATLAB tool boxes Real-Time Workshop and Embedded Coder plus several vendor-specific extensions, that require no or little additional modelling effort to build a compatible model - a *platform-specific model* (PSM). All code generation facilities provide an abstraction of the targeted processing platform in form of a platform-specific block library and the according tools to transform the blocks in adequate code fragments. For single-processor targets this is quite straight-forward. More difficult is the targeting of multi-processor hardware, since the inter-processor communication has to be incorporated on modelling level (Müller et al. (2009)), and embedded hardware, that often includes the addressing of

Figure 1 depicts a Simulink-based development flow tailored for an FPGA implementation of the controller. Regarding the *Target platform abstraction libraries and tools* for HDL, two methods of tool integration can be distinguished, that greatly ease the transition from model to HDL code and the implementation on hardware. First, there are the tool boxes provided by hardware vendors, like the Altera Corporation (2011) DSP Builder and the Xilinx, Inc. (2011) System Generator for DSP, that provide proprietary block sets as additional Simulink libraries and access the respective synthesis tools. Second, there is the HDL generation process via The

from a given simulation model in a top-down manner.

and allows a simulative validation during all design steps.

model is called a *platform-independent model* (PIM) of the controller.

**2. Control design using Simulink**

peripherals.

abstraction. A *system* model is comprised of: • a model of the controlled process/plant, • environment and instrumentation, and • the controller, the *device under development*. Mathworks (2011b) Simulink HDL Coder, which has undergone an extensive development during recent MATLAB revisions, and conducts the HDL code generation from a growing subset of Simulink library blocks (Auger (2008)), allowing a more hardware-independent design approach. Similar within all approaches is the final utilization of the vendor-specific implementation tool chains, that conduct the synthesis and FPGA implementation of the generated HDL code and provide the option to conduct a further validation step on code level via HDL simulation.

Fig. 1. Overview of the Simulink-based controller development flow targeting FPGA hardware.

Result of Simulink control system modelling is a controller design that fulfills the specified control task and quality, which has been validated by simulation within the bounds of the


 -

Fig. 3. Internal view of a single axis controller module.

the actual controller function can be processed.

the embedded platform.

**2.2 Controller partition and the embedded hardware realization**

 & 

% - 

\$ 

 

 "

  "

> 

domain, these are mainly friction forces, as described by Amthor et al. (2008). The filter works on the current measured position and velocity values, as well as on the last control step's accumulated output value, to correct its internal state and predict the current step's friction compensation value. The x-axis control output value is accumulated from the PID controller's and Kalman filter's outputs and represents a current to drive a linear electromagnetic actuator.

Since the purpose of this model is to design a controller for the specified plant and control task, the properties of the hardware interface and the future implementation hardware are omitted. In this model, digital measurement and set point values are submitted to the controller at discrete points in time without any delay - a behaviour, that in a physically realized control unit requires the passing of peripheral hardware, including A/D and D/A converters, before

The developer targeting an FPGA as processing resource for the controller has to be aware of the questions, how far towards the platform-specific properties the controller implementation model can be refined, and how the resulting generated component has to be integrated into

> **- -**

Fig. 4. A generated controller component embedded in a possible FPGA design.

 - 

From Control Design to FPGA Implementation 133

""

!"#

 

given scenario. The critical activity is the *transformation of the PIM into the PSM* - the creation of a model, that conforms to the characteristics of hardware execution and fulfills all the requirements to seamlessly run the respective HDL code generators. Therefore, the given controller design and behaviour serves as specification, against which the derived and refined HDL-compatible implementation model has to be validated.

Before the Simulink model characteristics, that may not conform with HDL code generation and/or hardware implementation, are discussed, the example system will be introduced, which will provide the *device under development* for this contribution.

## **2.1 Example control system**

Fig. 2. Top level view of multi-axis trajectory control system model.

As an example the model of a 3D trajectory tracking controller for deployment in high-precision positioning and measuring stages, as presented by Zschäck et al. (2010), will be used. As depicted in Figure 2 the system model is comprised of three partitions. The yellow part contains the *Plant Model*, a SimMechanics model of the positioning stage of a nano-metre positioning and measuring machine, short NPMM. The stage receives input currents to power the electro-magnetic actuators for all three spacial axes, while the lateral positions and velocities as well as the angles and turn velocities of the stage leave the plant model as measured values. The green partition, the *Environment and Instrumentation* partition, consists of a sequence control to manage the system's general modes of operation and a trajectory generator to provide the set points for the controller partition. The control sample rate of the process is 10kHz, so the model is simulated with a base sample time of 100*μs*.

The *Controller* partition itself, coloured in orange, consists of PID controllers coupled with Kalman filter disturbance observers for each axis, supplemented by additional controllers for angle correction between the axes. The controller is divided into separate modules for z-axis and x-y-plane control. In the course of this contribution a closer look will be taken on the x-axis controller, that is depicted in Figure 3.

In the x-axis controller module first the tracking errors of both position and velocity are determined, before both are subjected to the *P* and *D* gains, respectively. From the position error a nonlinear *I* gain is obtained from a look-up table, after which the values are submitted to the actual discrete integrator. A limiting block after the summation of the P, I and D components and an integrator anti-windup function complete the PID controller. A *Kalman filter* block serves as a disturbance observer for the non-measurable effects - in this application 4 Will-be-set-by-IN-TECH

given scenario. The critical activity is the *transformation of the PIM into the PSM* - the creation of a model, that conforms to the characteristics of hardware execution and fulfills all the requirements to seamlessly run the respective HDL code generators. Therefore, the given controller design and behaviour serves as specification, against which the derived and refined

Before the Simulink model characteristics, that may not conform with HDL code generation and/or hardware implementation, are discussed, the example system will be introduced,

output z-axis [A]

output x-axis [A]

output y-axis [A]

As an example the model of a 3D trajectory tracking controller for deployment in high-precision positioning and measuring stages, as presented by Zschäck et al. (2010), will be used. As depicted in Figure 2 the system model is comprised of three partitions. The yellow part contains the *Plant Model*, a SimMechanics model of the positioning stage of a nano-metre positioning and measuring machine, short NPMM. The stage receives input currents to power the electro-magnetic actuators for all three spacial axes, while the lateral positions and velocities as well as the angles and turn velocities of the stage leave the plant model as measured values. The green partition, the *Environment and Instrumentation* partition, consists of a sequence control to manage the system's general modes of operation and a trajectory generator to provide the set points for the controller partition. The control sample rate of the process is 10kHz, so the model is simulated with a base sample time of 100*μs*.

The *Controller* partition itself, coloured in orange, consists of PID controllers coupled with Kalman filter disturbance observers for each axis, supplemented by additional controllers for angle correction between the axes. The controller is divided into separate modules for z-axis and x-y-plane control. In the course of this contribution a closer look will be taken on the

In the x-axis controller module first the tracking errors of both position and velocity are determined, before both are subjected to the *P* and *D* gains, respectively. From the position error a nonlinear *I* gain is obtained from a look-up table, after which the values are submitted to the actual discrete integrator. A limiting block after the summation of the P, I and D components and an integrator anti-windup function complete the PID controller. A *Kalman filter* block serves as a disturbance observer for the non-measurable effects - in this application

Plant model NPMM SimMechanics

positions

velocities

angles

turn rates

Instrumentation

In

input z [A]

input x [A]

input y [A]

HDL-compatible implementation model has to be validated.

measured values control signals reference

control signals measured values reference

x-axis controller, that is depicted in Figure 3.

**2.1 Example control system**

Trajectory generator reference trajectory

Sequence control control signals

which will provide the *device under development* for this contribution.

Controller z-axis HDL

Controller xy-axes HDL

Fig. 2. Top level view of multi-axis trajectory control system model.

Fig. 3. Internal view of a single axis controller module.

domain, these are mainly friction forces, as described by Amthor et al. (2008). The filter works on the current measured position and velocity values, as well as on the last control step's accumulated output value, to correct its internal state and predict the current step's friction compensation value. The x-axis control output value is accumulated from the PID controller's and Kalman filter's outputs and represents a current to drive a linear electromagnetic actuator.

## **2.2 Controller partition and the embedded hardware realization**

Since the purpose of this model is to design a controller for the specified plant and control task, the properties of the hardware interface and the future implementation hardware are omitted. In this model, digital measurement and set point values are submitted to the controller at discrete points in time without any delay - a behaviour, that in a physically realized control unit requires the passing of peripheral hardware, including A/D and D/A converters, before the actual controller function can be processed.

The developer targeting an FPGA as processing resource for the controller has to be aware of the questions, how far towards the platform-specific properties the controller implementation model can be refined, and how the resulting generated component has to be integrated into the embedded platform.

Fig. 4. A generated controller component embedded in a possible FPGA design.

By default, MATLAB uses the data type DOUBLE for all its algorithm descriptions, be it in MATLAB script language or Simulink block models. DOUBLE represents a 64 bit wide floating-point number, which covers a range of up to <sup>±</sup>2<sup>1024</sup> <sup>≈</sup> <sup>2</sup> <sup>×</sup> 10308 and a precision of up to 2−<sup>52</sup> <sup>≈</sup> <sup>2</sup> <sup>×</sup> <sup>10</sup>−16, which is supposed to cover the needs of any modelling and simulation task. Any code generation without interference would map the model signals to variables of a supported floating-point type. Difficulties could arise when trying to deploy this code to a processing hardware - floating-point units are quite complex and comparatively slow in general-purpose processors, some support only single-precision (32 bit), some micro-controllers and DSPs do not even feature any, and in custom hardware designs they can only be used in very limited numbers. So double-precision floating-point arithmetic has to be time-intensively emulated, limited hardware units have to be reused in a time-multiplexed fashion, requiring a complex execution flow, or the arithmetic functionality cannot be realized at all. The hardware description language VHDL supports the double-precision floating-point data type REAL, which allows direct code generation from Simulink. The VHDL simulation of floating-point arithmetic is possible, but the REAL data type is not synthesizable, as stated e.g. by Rushton (2011). Therefore, any platform-specific Simulink model, that is intended to

From Control Design to FPGA Implementation 135

resemble a hardware description, has to feature integer or fixed-point arithmetic.

transform the model behaviour to the hardware execution behaviour.

• the insertion of HDL-compatible substitutes,

**3.1 HDL-Coder supported substitute constructs**

• the fixed-point data type conversions.

**3. Data path design**

The following sections will exemplify several activities to create a HDL compliant and hardware implementable model from the controller design introduced above. Since the 2010 version of MATLAB introduced the HDL Workflow Advisor for the Simulink HDL Coder, a tool is featured that guides the code generation, and via utilization of vendor-specific synthesis tools, also allows the rapid-prototyping synthesis and FPGA implementation of Simulink models. The model transformations will be described with regard to the Simulink HDL Coder, since no change in the basic block set will be required. First, structural changes to the data path of the model will be discussed, followed by behavioural modifications, that

The structural changes to a model in order to facilitate both successful HDL code generation

The substitution of blocks is necessary, since only a subset of the modelling blocks and block configurations available in Simulink supports the generation of HDL code. The blocks that do are compiled into the so called "Supported Blocks Library" by the hdllib command - refer to The Mathworks (2011b) HDL Coder user guide for details. Still some blocks can feature modes or configurations, that are not synthesizable. Common examples are the arithmetic function blocks that polymorphically work on scalars, as well as on vectors and matrices. Since matrix operations are not supported these blocks have to be substituted by explicit constructs.

Regarding the controller model displayed in Figure 3, the first block to consider is the *Discrete Integrator* block. This block can be configured to a mode of computation, e.g. Forward-Euler,

and successful hardware implementation, that are considered in this section, include

• the utilization of black-box blocks to incorporate predefined HDL components, and

As stated e.g. in Xilinx, Inc. (2011), some parts of a chip design require a level of design control, that cannot easily abstracted from and therefore cannot be adequately dealt with on modelling level. This includes the connection to restricted on-chip resources like peripheral and memory interfaces and the clock management. Figure 4 illustrates the generic structure of an FPGA design, which includes a component generated from a model. This component is likely to reside on the chip with other logic modules, side by side or in hierarchical relations each will have to be connected to a clock source, but there might exist different clocks driving different components. The modules may also be connected to predefined interfaces to off-chip resources, with which they exchange data and synchronisation signals like triggers.

In some cases it might be possible to manage the complete chip design from the modelling level, but the general case will be to generate a component to be integrated in a chip design. This integration, however, will be the more seamless, the more the model of the controller component is refined to correspond to the structural and behavioural requirements of the embedding design.

## **2.3 Simulink model properties and HDL code generation**

At this point a closer look will be taken at a couple of properties of a Simulink model, that need special consideration when aiming on generating HDL code from this model and implementing this HDL description on a chip.

A Simulink "time-based block diagram" model resembles a synchronous data flow graph, the signal outputs and states of which are computed every simulation time step. One simulation time step defines the time interval in which a significant change of values is to be recorded. In principle, simulation modes with variable time steps can be used in order to decrease the time intervals in cases of rapidly changing values, so that the discretization error can be minimized. For details on the block diagram and time simulation semantics the reader is referred to The Mathworks (2011a) Simulink User Guide. For this control design, the simulation time resolution is determined by the fixed sample period of the time-discrete controller, which here will be referred to as T\_Control with 100*μs*. For a hardware-oriented model, the simulation time interval resembles the fixed period of the clock signal (T\_Clk) driving the generated logic. Due to this fact, the notion of time resolution has to be changed - from the sample time of the controller, the interval, in which new input values are acquired, to the execution cycle period, the time interval a logic stage computes one cycle.

MATLAB and Simulink allow heterogeneous modelling and the integration of models with different levels of functional abstraction. This is majorly supported by the MATLAB functions and Simulink blocks being polymorph. That means, they work on scalar, vector and matrix data alike, as well handle different data types transparently to the engineer. The library functions/blocks are designed to easily create complex models from reusable, parametrizable blocks, hiding the actual implementation details. But these details are significant when considering a hardware design, because some function, as e.g. division operators, cannot be trivially mapped to binary logic. As a consequence, only a subset of the Simulink libraries feature corresponding synthesizable HDL constructs. For any non-synthesizable blocks adequate substitute constructs have to be modelled or the block has to be treated as an abstract black-box, that is to be replaced by a pre-implemented external HDL-component during code generation.

6 Will-be-set-by-IN-TECH

As stated e.g. in Xilinx, Inc. (2011), some parts of a chip design require a level of design control, that cannot easily abstracted from and therefore cannot be adequately dealt with on modelling level. This includes the connection to restricted on-chip resources like peripheral and memory interfaces and the clock management. Figure 4 illustrates the generic structure of an FPGA design, which includes a component generated from a model. This component is likely to reside on the chip with other logic modules, side by side or in hierarchical relations each will have to be connected to a clock source, but there might exist different clocks driving different components. The modules may also be connected to predefined interfaces to off-chip

In some cases it might be possible to manage the complete chip design from the modelling level, but the general case will be to generate a component to be integrated in a chip design. This integration, however, will be the more seamless, the more the model of the controller component is refined to correspond to the structural and behavioural requirements of the

At this point a closer look will be taken at a couple of properties of a Simulink model, that need special consideration when aiming on generating HDL code from this model and

A Simulink "time-based block diagram" model resembles a synchronous data flow graph, the signal outputs and states of which are computed every simulation time step. One simulation time step defines the time interval in which a significant change of values is to be recorded. In principle, simulation modes with variable time steps can be used in order to decrease the time intervals in cases of rapidly changing values, so that the discretization error can be minimized. For details on the block diagram and time simulation semantics the reader is referred to The Mathworks (2011a) Simulink User Guide. For this control design, the simulation time resolution is determined by the fixed sample period of the time-discrete controller, which here will be referred to as T\_Control with 100*μs*. For a hardware-oriented model, the simulation time interval resembles the fixed period of the clock signal (T\_Clk) driving the generated logic. Due to this fact, the notion of time resolution has to be changed - from the sample time of the controller, the interval, in which new input values are acquired, to the execution cycle

MATLAB and Simulink allow heterogeneous modelling and the integration of models with different levels of functional abstraction. This is majorly supported by the MATLAB functions and Simulink blocks being polymorph. That means, they work on scalar, vector and matrix data alike, as well handle different data types transparently to the engineer. The library functions/blocks are designed to easily create complex models from reusable, parametrizable blocks, hiding the actual implementation details. But these details are significant when considering a hardware design, because some function, as e.g. division operators, cannot be trivially mapped to binary logic. As a consequence, only a subset of the Simulink libraries feature corresponding synthesizable HDL constructs. For any non-synthesizable blocks adequate substitute constructs have to be modelled or the block has to be treated as an abstract black-box, that is to be replaced by a pre-implemented external HDL-component

resources, with which they exchange data and synchronisation signals like triggers.

**2.3 Simulink model properties and HDL code generation**

period, the time interval a logic stage computes one cycle.

implementing this HDL description on a chip.

embedding design.

during code generation.

By default, MATLAB uses the data type DOUBLE for all its algorithm descriptions, be it in MATLAB script language or Simulink block models. DOUBLE represents a 64 bit wide floating-point number, which covers a range of up to <sup>±</sup>2<sup>1024</sup> <sup>≈</sup> <sup>2</sup> <sup>×</sup> 10308 and a precision of up to 2−<sup>52</sup> <sup>≈</sup> <sup>2</sup> <sup>×</sup> <sup>10</sup>−16, which is supposed to cover the needs of any modelling and simulation task. Any code generation without interference would map the model signals to variables of a supported floating-point type. Difficulties could arise when trying to deploy this code to a processing hardware - floating-point units are quite complex and comparatively slow in general-purpose processors, some support only single-precision (32 bit), some micro-controllers and DSPs do not even feature any, and in custom hardware designs they can only be used in very limited numbers. So double-precision floating-point arithmetic has to be time-intensively emulated, limited hardware units have to be reused in a time-multiplexed fashion, requiring a complex execution flow, or the arithmetic functionality cannot be realized at all. The hardware description language VHDL supports the double-precision floating-point data type REAL, which allows direct code generation from Simulink. The VHDL simulation of floating-point arithmetic is possible, but the REAL data type is not synthesizable, as stated e.g. by Rushton (2011). Therefore, any platform-specific Simulink model, that is intended to resemble a hardware description, has to feature integer or fixed-point arithmetic.

The following sections will exemplify several activities to create a HDL compliant and hardware implementable model from the controller design introduced above. Since the 2010 version of MATLAB introduced the HDL Workflow Advisor for the Simulink HDL Coder, a tool is featured that guides the code generation, and via utilization of vendor-specific synthesis tools, also allows the rapid-prototyping synthesis and FPGA implementation of Simulink models. The model transformations will be described with regard to the Simulink HDL Coder, since no change in the basic block set will be required. First, structural changes to the data path of the model will be discussed, followed by behavioural modifications, that transform the model behaviour to the hardware execution behaviour.

## **3. Data path design**

The structural changes to a model in order to facilitate both successful HDL code generation and successful hardware implementation, that are considered in this section, include


#### **3.1 HDL-Coder supported substitute constructs**

The substitution of blocks is necessary, since only a subset of the modelling blocks and block configurations available in Simulink supports the generation of HDL code. The blocks that do are compiled into the so called "Supported Blocks Library" by the hdllib command - refer to The Mathworks (2011b) HDL Coder user guide for details. Still some blocks can feature modes or configurations, that are not synthesizable. Common examples are the arithmetic function blocks that polymorphically work on scalars, as well as on vectors and matrices. Since matrix operations are not supported these blocks have to be substituted by explicit constructs.

Regarding the controller model displayed in Figure 3, the first block to consider is the *Discrete Integrator* block. This block can be configured to a mode of computation, e.g. Forward-Euler,


 -  

Fig. 6. Substitute for Simulink Look-up table block with linear *Interpolation/Extrapolation*

automated Fixed-Point Advisor conversion process relies on the default data type definitions for *classes* of values, even if the hardware implementation option is set to FPGA/ASIC. So, globally fixed word lengths for all the input values, constant values and internal outputs, respectively, have to be set by the designer. Based on the globally set word length definitions the fixed-point tools move the radix point to achieve the maximum precision while covering the maximally necessary value range. Only afterwards can be determined, if the resulting precision meets the specified precision requirements, usually leading to an iterative process

From Control Design to FPGA Implementation 137

For FPGA implementations there are per se no such restrictions as globally predefined operand word lengths. On the contrary, for each operation the operand and result widths can be determined with bit accuracy, therefore allowing to tailor the word lengths exactly to the algorithms' requirements, especially regarding the fact, that the specified precision can be

Regarding this, it should be noted, that a decimal fraction cannot easily be expressed using a binary fraction, since each additional fraction bit only enhances precision to the next negative power of two, resulting in a decimal precision with a maximum numerical error . Based on the approach presented by Carletta & Veillette (2005), the required positions for the most significant bit (MSB) and the least significant bit (LSB) in a binary representation of the decimal value *x* with a desired decimal precision can be computed by *PMSB*(*x*) = �*log*2|*x*|� + 1, and *PLSB*(*x*)*s* = �*log*2( ∗ |*x*|)� − 1, respectively. The required binary word length *L* is given by

A successive fixed-point conversion is conducted based on the minimal fixed-point expression

• for binary Multiplication of two operands: *PMSB*(*result*) = ∑ *PMSB*(*operandi*) and

between arbitrarily distributed sampling points.

 

of re-adapting the word lengths.

used as a-priori information.

*L* = *PMSB* − *PLSB* plus the sign bit, if required.

*PLSB*(*result*) = ∑ *PLSB*(*operandi*)

of all inputs, constants and coefficients, and on the following rules:

• for binary Addition of two operands: *Lresult* = *maxi*(*Loperand*\_*i*) + 1,

 

 

 

 

 

 

 

 

 

 

Backward-Euler, etc. In this case the integrator is required to be resettable, since the internal value has to be set to zero in case of de- and reactivation of the controller module. The *resettable* feature is documented as not being HDL compatible, so the block has to be substituted by the self-tailored subsystem, that is depicted in Figure 5. It resembles a forward-Euler integrator with the discrete sample time interval of T\_Control, the internal state of which can be reset by an external signal.

Fig. 5. Substitute for the Forward-Euler Discrete Integrator block with external reset.

A further aspect for consideration is the use of *Look-up tables* (LUT), like the one determining the variable *I*-gain in Figure 3. Simulink LUT blocks can be configured to determine an output value according to a set of sampling points and an interpolation method, like in this case linear *Interpolation/Extrapolation*.

Starting with MATLAB Release 2011a the HDL Coder supports the code generation from LUTs configured to linear interpolation, but only based on evenly distributed sampling points. For certain LUT mappings the minimal distance between sampling points would require a large number of them to cover the input data value range, resulting in a large memory requirement for the on-chip LUT implementation.

A method to substitute a Simulink look-up table with linear interpolation/extrapolation between sparsely and arbitrarily distributed sampling points is presented in Figure 6. Here, the input value range is subdivided into intervals according to the sampling points. The input value *x* is compared to the interval boundaries, the comparison results are accumulated to an index value. A switch assigns a respective set of coefficients *A*, *B* to the actual linear interpolation *y* = *Ax* + *B*.

### **3.2 Fixed-point conversion**

To effectively implement an algorithm into hardware, it is advised to utilize an integer or fixed-point representation of both data and algorithm. Since the initially designed executable specification model uses double-precision floating-point data representation, a conversion to fixed-point data types has to be performed.

The key steps are to determine the maximum/minimum values to be covered, and the minimal discretization step width. From these information, the fixed-point format consisting of *sign bit*, *word length* and *position of radix point* can be derived, which in MATLAB is denoted as e.g. fixdt(1,16,4)1.

MATLAB features the Fixed-Point Tool and the Fixed-Point Advisor process, documented by The Mathworks (2010), to aid the determination of the respective fixed-point formats. The

<sup>1</sup> for a 16 bit wide signed number with the four least significant bits being fraction bits

8 Will-be-set-by-IN-TECH

Backward-Euler, etc. In this case the integrator is required to be resettable, since the internal value has to be set to zero in case of de- and reactivation of the controller module. The *resettable* feature is documented as not being HDL compatible, so the block has to be substituted by the self-tailored subsystem, that is depicted in Figure 5. It resembles a forward-Euler integrator with the discrete sample time interval of T\_Control, the internal state of which can be reset

> -

A further aspect for consideration is the use of *Look-up tables* (LUT), like the one determining the variable *I*-gain in Figure 3. Simulink LUT blocks can be configured to determine an output value according to a set of sampling points and an interpolation method, like in this case linear

Starting with MATLAB Release 2011a the HDL Coder supports the code generation from LUTs configured to linear interpolation, but only based on evenly distributed sampling points. For certain LUT mappings the minimal distance between sampling points would require a large number of them to cover the input data value range, resulting in a large memory requirement

A method to substitute a Simulink look-up table with linear interpolation/extrapolation between sparsely and arbitrarily distributed sampling points is presented in Figure 6. Here, the input value range is subdivided into intervals according to the sampling points. The input value *x* is compared to the interval boundaries, the comparison results are accumulated to an index value. A switch assigns a respective set of coefficients *A*, *B* to the actual linear

To effectively implement an algorithm into hardware, it is advised to utilize an integer or fixed-point representation of both data and algorithm. Since the initially designed executable specification model uses double-precision floating-point data representation, a conversion to

The key steps are to determine the maximum/minimum values to be covered, and the minimal discretization step width. From these information, the fixed-point format consisting of *sign bit*, *word length* and *position of radix point* can be derived, which in MATLAB is denoted

MATLAB features the Fixed-Point Tool and the Fixed-Point Advisor process, documented by The Mathworks (2010), to aid the determination of the respective fixed-point formats. The

<sup>1</sup> for a 16 bit wide signed number with the four least significant bits being fraction bits


Fig. 5. Substitute for the Forward-Euler Discrete Integrator block with external reset.

  -

 

by an external signal.

*Interpolation/Extrapolation*.

interpolation *y* = *Ax* + *B*.

**3.2 Fixed-point conversion**

as e.g. fixdt(1,16,4)1.

for the on-chip LUT implementation.

fixed-point data types has to be performed.

 

Fig. 6. Substitute for Simulink Look-up table block with linear *Interpolation/Extrapolation* between arbitrarily distributed sampling points.

automated Fixed-Point Advisor conversion process relies on the default data type definitions for *classes* of values, even if the hardware implementation option is set to FPGA/ASIC. So, globally fixed word lengths for all the input values, constant values and internal outputs, respectively, have to be set by the designer. Based on the globally set word length definitions the fixed-point tools move the radix point to achieve the maximum precision while covering the maximally necessary value range. Only afterwards can be determined, if the resulting precision meets the specified precision requirements, usually leading to an iterative process of re-adapting the word lengths.

For FPGA implementations there are per se no such restrictions as globally predefined operand word lengths. On the contrary, for each operation the operand and result widths can be determined with bit accuracy, therefore allowing to tailor the word lengths exactly to the algorithms' requirements, especially regarding the fact, that the specified precision can be used as a-priori information.

Regarding this, it should be noted, that a decimal fraction cannot easily be expressed using a binary fraction, since each additional fraction bit only enhances precision to the next negative power of two, resulting in a decimal precision with a maximum numerical error . Based on the approach presented by Carletta & Veillette (2005), the required positions for the most significant bit (MSB) and the least significant bit (LSB) in a binary representation of the decimal value *x* with a desired decimal precision can be computed by *PMSB*(*x*) = �*log*2|*x*|� + 1, and *PLSB*(*x*)*s* = �*log*2( ∗ |*x*|)� − 1, respectively. The required binary word length *L* is given by *L* = *PMSB* − *PLSB* plus the sign bit, if required.

A successive fixed-point conversion is conducted based on the minimal fixed-point expression of all inputs, constants and coefficients, and on the following rules:


Fig. 7. Declaring a black-box component.

filter component at code level.

**3.4 Resulting model**

**4. Behavioral design**

ports from the Simulink block - to fit the predefined component interface, as documented in The Mathworks (2011b) HDL Coder guide. The clock port clk, that is added, matches the hardware port connected to the clock of the surrounding design, which completes the replication of the referenced component's interface. At this point the black-box declared subsystem ensures both, the correct simulation using the platform-independent filter model, and the structurally correct instantiation and therefore seamless integration of the Kalman

From Control Design to FPGA Implementation 139

The model of the x-axis controller module after the completed data path design steps is depicted in Figure 8. It includes the substituted discrete integrator and look-up table blocks, the black-box interface of the Kalman block, as well as additional compatibility issues like the resolved bus signals, and shows the resulting fixed-point data widths for the operands. At

The behavioural changes the model has to undergo during its transformation into an implementation model are mainly characterized by a changed notion of time3. In the simulation model the base sample rate describes the interval, in which the change of relevant physical values is observed - the control system sample time T\_Control. The computation of the outputs of the controller and the reaction of the plant is done "timelessly" at one point in simulation time. In reality, as illustrated in Figure 9, the begin of the time interval T\_Control marks the time, when measured values are acquired (DAQ), before they are submitted to the controller module and the computation of the controller function can begin. The computation

<sup>3</sup> Prerequisites for behavioural compatibility to the HDL Coder code generation process are set by the

hdlsetup command - refer to the The Mathworks (2011b) HDL Coder documentation.

this point the HDL Coder compatibility check should complete successfully.

The Simulink block parametrization option Data type inheritance via internal rule works similarly, but can not resolve feed back loops without major restrictions. In those cases definitely manual parametrization based on good knowledge of the process parameters is expedient.

The operand bit widths can be regarded as a measure for chip area utilization, since they influence the complexity of the synthesized register and routing structures on the target chip. The use of the Fixed-Point Advisor will produce valid solutions for hardware implementation, which therefore makes it a valuable tool for rapid prototyping, but the advantage of a manual minimization of the fixed-point representation and its effect on chip resource utilisation becomes obvious.

## **3.3 Excluding externally provided black-box blocks**

The utilization of black-box components is a means to include externally available implementations as substitutes for Simulink modelling blocks, that are not or not feasibly synthesizable. The model element regarded as black box will still be simulated, but neglected during HDL code generation, where an interface-compatible predefined HDL component will be referenced instead. For details on the declaration of a black box subsystem refer to The Mathworks (2011b) HDL Coder documentation.

For the presented controller design these circumstances will be illustrated by the example of the Kalman filter, the design of which has been presented by Amthor et al. (2008). For this Simulink module no feasible hardware implementation could be generated using a model-driven HDL generation process. This is not at least caused by the fact, that for the high-precision application domain this filter has no feasible fixed-point solution in terms of required data widths and resulting chip area requirements. So, the computation of this function on the hardware is conducted using a highly optimized VHDL-designed core, based on the floating-point processing architecture presented by Pacholik et al. (2011). According to its specification, the IP2 component executing the Kalman filter function has the following properties, which are of significance for the model integration:


In order for the IP component to be correctly referenced during the synthesis process the Simulink black-box subsystem requires the exact replication of the IP components interface and motivates the following adaptions in the HDL-oriented Simulink model.

Figure 7 shows the configuration of the Kalman filter subsystem as a black-box component. A closer look reveals that the data ports of the Simulink subsystem block have been supplemented with a CLK\_120MHz, a Trigger and Valid port. The dialog shows options to configure the appearance of the interface of the HDL instance - in addition to the data

<sup>2</sup> "Intellectual property" cores describe pre-designed logic blocks to be reused for FPGA/ASIC design

10 Will-be-set-by-IN-TECH

The Simulink block parametrization option Data type inheritance via internal rule works similarly, but can not resolve feed back loops without major restrictions. In those cases definitely manual parametrization based on good knowledge of the process parameters

The operand bit widths can be regarded as a measure for chip area utilization, since they influence the complexity of the synthesized register and routing structures on the target chip. The use of the Fixed-Point Advisor will produce valid solutions for hardware implementation, which therefore makes it a valuable tool for rapid prototyping, but the advantage of a manual minimization of the fixed-point representation and its effect on chip resource utilisation

The utilization of black-box components is a means to include externally available implementations as substitutes for Simulink modelling blocks, that are not or not feasibly synthesizable. The model element regarded as black box will still be simulated, but neglected during HDL code generation, where an interface-compatible predefined HDL component will be referenced instead. For details on the declaration of a black box subsystem refer to The

For the presented controller design these circumstances will be illustrated by the example of the Kalman filter, the design of which has been presented by Amthor et al. (2008). For this Simulink module no feasible hardware implementation could be generated using a model-driven HDL generation process. This is not at least caused by the fact, that for the high-precision application domain this filter has no feasible fixed-point solution in terms of required data widths and resulting chip area requirements. So, the computation of this function on the hardware is conducted using a highly optimized VHDL-designed core, based on the floating-point processing architecture presented by Pacholik et al. (2011). According to its specification, the IP2 component executing the Kalman filter function has the following

• clock port for external clock (to allow synchronisation with the surrounding design),

• result availability signalled by Valid signal (pulse with width of one external clock

In order for the IP component to be correctly referenced during the synthesis process the Simulink black-box subsystem requires the exact replication of the IP components interface

Figure 7 shows the configuration of the Kalman filter subsystem as a black-box component. A closer look reveals that the data ports of the Simulink subsystem block have been supplemented with a CLK\_120MHz, a Trigger and Valid port. The dialog shows options to configure the appearance of the interface of the HDL instance - in addition to the data <sup>2</sup> "Intellectual property" cores describe pre-designed logic blocks to be reused for FPGA/ASIC design

and motivates the following adaptions in the HDL-oriented Simulink model.

is expedient.

becomes obvious.

period).

**3.3 Excluding externally provided black-box blocks**

Mathworks (2011b) HDL Coder documentation.

• clock port for internal clock (up to 120 MHz), • latency: 215 clock cycles @ 120 MHz ≈ 1.8*μs*,

properties, which are of significance for the model integration:

• execution triggered on rising edge of Trigger signal,

Fig. 7. Declaring a black-box component.

ports from the Simulink block - to fit the predefined component interface, as documented in The Mathworks (2011b) HDL Coder guide. The clock port clk, that is added, matches the hardware port connected to the clock of the surrounding design, which completes the replication of the referenced component's interface. At this point the black-box declared subsystem ensures both, the correct simulation using the platform-independent filter model, and the structurally correct instantiation and therefore seamless integration of the Kalman filter component at code level.

## **3.4 Resulting model**

The model of the x-axis controller module after the completed data path design steps is depicted in Figure 8. It includes the substituted discrete integrator and look-up table blocks, the black-box interface of the Kalman block, as well as additional compatibility issues like the resolved bus signals, and shows the resulting fixed-point data widths for the operands. At this point the HDL Coder compatibility check should complete successfully.

## **4. Behavioral design**

The behavioural changes the model has to undergo during its transformation into an implementation model are mainly characterized by a changed notion of time3. In the simulation model the base sample rate describes the interval, in which the change of relevant physical values is observed - the control system sample time T\_Control. The computation of the outputs of the controller and the reaction of the plant is done "timelessly" at one point in simulation time. In reality, as illustrated in Figure 9, the begin of the time interval T\_Control marks the time, when measured values are acquired (DAQ), before they are submitted to the controller module and the computation of the controller function can begin. The computation

<sup>3</sup> Prerequisites for behavioural compatibility to the HDL Coder code generation process are set by the hdlsetup command - refer to the The Mathworks (2011b) HDL Coder documentation.

this entity will be transformed into *combinational logic*. The unit delays in the feedback path, see Figure 8, and in the integrator block, see Figure 5 storing the control cycle state will be realized as *registers*. The update of these registers will be triggered by a rising edge of the

From Control Design to FPGA Implementation 141

At this level of abstraction, although the Kalman filter subsystem is still simulated as an abstract black box, the integration of the underlying HDL component in the logic path has to be prepared. This includes the connection to a 120 MHz clock source, which is best designed at chip level. Therefore, the according clock port CLK\_120MHz is linked to the controller component's interface to the top level. Furthermore, the Kalman filter component has to be triggered at a point in time defined by outside prerequisites, which requires the connection of

 

the Trigger port to an outside source. Both modifications are shown in Figure 10.

! "-

\$ % &'
