Lab 08 Modeling of Electrical and Electronics Systems
Lab 08 Modeling of Electrical and Electronics Systems
FACULTY OF ENGINEERING
MECHATRONICS ENGINEERING DEPARTMENT
Credit Hours Programs
Contents*
simscape Electronics™ (formerly SimElectronics®) provides component libraries for modelling and simulating
electronic and mechatronic systems. It includes models of semiconductors, motors, drives, sensors, and actuators. You
can use these components to develop electromechanical actuation systems and to build behavioural models for evaluating
analog circuit architectures in Simulink®. You can integrate mechanical, hydraulic, pneumatic, and other physical
systems into your model using components from the Simscape™ family of products.
Simscape Electronics helps you develop control algorithms in electronic and mechatronic systems, including vehicle body
electronics, aircraft servomechanisms, and audio power amplifiers. The semiconductor models include nonlinear and
dynamic temperature effects, enabling you to select components in amplifiers, motor drives, analog-to-digital converters,
phase-locked loops, and other circuits. You can parameterize your models using MATLAB® variables and expressions.
To deploy models to other simulation environments, including hardware-in-the-loop (HIL) systems, Simscape Electronics
supports C-code generation.
Simscape Power Systems™ (formerly SimPowerSystems™) provides component libraries and analysis tools for
modelling and simulating electrical power systems. It includes models of electrical power components, including three-
phase machines, electric drives, and components for applications such as flexible AC transmission systems (FACTS) and
renewable energy systems. Harmonic analysis, calculation of total harmonic distortion (THD), load flow, and other key
electrical power system analyses are automated, helping you investigate the performance of your design.
Visit:
https://www.youtube.com/watch?v=jCZ2vZzDO1U
https://www.youtube.com/watch?v=WF_QhnjsvSs
https://www.mathworks.com/help/pdf_doc/physmod/elec/elec_ug.pdf
Description: This example shows how to build a Permanent Magnet DC Motor using Simscape Foundation
Electrical Library.
Build Model
Library Block
Simscape > Foundation > Electrical >Electrical elements Electrical Reference
Simscape > Foundation > Electrical >Electrical elements Resistor
*
Parts of this lab sheet are based on the Simscape documentation, provided by Mathworks
Library Block
Simscape > Foundation > Electrical >Electrical elements Inductor
Simscape > Foundation > Electrical >Electrical elements Rotational Electromechanical Converter
Simscape > Foundation > Electrical >Electrical Sources DC Voltage Source
Simscape> Utilities Solver Configuration
2. Connect the blocks as shown below
Page 2 of 24
6. Specify the Inertia to be 0.01 Kg*m^2
7. For the rotational Friction Block, specify the following parameters
10. Now we will apply an external load to the motor. Open the Simscape > Mechanical >Mechanical Sources
library and copy the Ideal Torque Source block into the model.
The block represents an ideal source of torque that generates torque at its terminals proportional to the
input physical signal. The source is ideal in a sense that it is assumed to be powerful enough to maintain
specified torque regardless of the angular velocity at source terminals.
11. Open the Simulink > Sources library and copy the Step block into the model.
12. Open the Simscape> Utilities library and copy the Simulink-PS Converter block into the model.
13. Connect the blocks as shown below
Page 3 of 24
14. For the Step Block, specify the following parameters
15. Ensure that the simulation stop time is equal to or greater than 100
16. Run the simulation. The simulation results are shown in the following illustration.
Page 4 of 24
17. Change the final value of the Step Block to be: -0.5, 0, 0.5 and comment on the Motor RPM.
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
Set point
Error Signal
Gain Circuit PI Signal
− +
Summing
Circuit
𝐼 Summing
Sensor Signal Circuit
Integrating
Circuit
Page 5 of 24
The previous schematic could be implemented using the following circuits:
𝑉𝑜 𝑅𝑓 𝑉1 𝑉2 𝑉𝑛
Inverting amplifier =− Summing Amplifier 𝑉𝑜 = −𝑅𝑓 ( + +⋯+ )
𝑉𝑖𝑛 𝑅𝑖𝑛 𝑅1 𝑅2 𝑅𝑛
𝑉0 1
Integrating amplifier = − 𝑅𝐶𝑆
𝑉𝑖𝑛
Description: In this exercise, given the information above, you should construct and validate a practical
implementation for a PI controller using Opamp circuits. This will be done by comparing the output of an
ideal PID block from Simulink to the output of your circuit.
Build Model
1. At the MATLAB® command line, enter scc_new to create a new Simscape model.
Page 6 of 24
3. In the dialog box of the PID block input the following parameters:
Parameter Value
Proportional (P): 20
Integeral (I): 10
Derivative (D): 0
4. The previous Figure shows a closed loop system implemented using a summing and a PID block available
in Simulink. You should design an electric circuit that does the same functionality using the circuits
shown in the background section of this exercise. Your circuit should have the same proportional and
integral gains as the ideal PID controller.
If you design and model the circuit correctly, the two signals on the scope should be the same.
………………………………………………………………………………………………………………
………………………………………………………………………………………………………………
………………………………………………………………………………………………………………
B. or type elec_lib in the command window to open the electronics library then type ssc_new_elec to open
simscape template that contain the most commonly used electrical components and also opens an Electrical
Starter Palette then use File > Save As to save the example model under the desired name. Then delete the
unwanted blocks and add new ones from the Electrical Starter Palette and from the block libraries.
Page 7 of 24
Exercise 1: explore the components of each section of the library.
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
……………………………………………………………………………………….
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
……………………………………………………………………………………….
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
……………………………………………………………………………………….
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
……………………………………………………………………………………….
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
……………………………………………………………………………………….
Page 8 of 24
………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………
……………………………………………………………………………………….
Description: In this example, you model a DC motor driven by a constant input signal that approximates a pulse-width
modulated signal and look at the current and rotational motion at the motor output.
Build Model:
block function
Solver Configuration Defines solver settings that apply to all physical modelling blocks.
DC Voltage Source Generates a DC signal.
Controlled PWM Voltage Generates the signal that approximates a pulse-width modulated motor input signal.
H-Bridge Drives the DC motor.
Current Sensor Converts the electrical current that drives the motor into a physical signal proportional
to the current.
Ideal Rotational Motion Converts the rotational motion of the motor into a physical signal proportional to the
Sensor motion.
DC Motor Converts input electrical signal into mechanical motion.
PS-Simulink Converter Converts the input physical signal to a Simulink® signal.
Scope Displays motor current and rotational motion.
Electrical Reference Provides the electrical ground.
Mechanical Rotational Provides the mechanical ground.
Reference
Page 9 of 24
4-Arrange and connect blocks as shown in the following illustration.
Page 10 of 24
7-Set the H-Bridge block parameters as follows:
This value tells the block to generate an output signal whose value is the average value of the PWM signal. Simulating
the motor with an averaged signal estimates the motor behaviour in the presence of a PWM signal. To validate this
approximation, use value of PWM for this parameter.
Page 11 of 24
8- Set the motor parameters.
Mechanical tab:
In the model window, select Simulation > Model Configuration Parameters to open the Configuration Parameters dialog
box.
Expand Additional options and enter 1 for the Max step size parameter value.
Click OK.
Page 12 of 24
Reference:
https://www.mathworks.com/help/physmod/elec/ug/example--modeling-a-dc-motor.html
Description: This example shows an audio amplifier circuit based on an N-channel JFET. The junction gate field-effect
transistor (JFET) is the simplest type of field-effect transistor. They are three-terminal semiconductor devices that can be
used as electronically-controlled switches, amplifiers, or voltage-controlled resistors.
Build Model:
1-Build the following model using simscape electronics library.
Page 13 of 24
3- The desired operating point is taken to be Vds=5V, Id=2mA and Vgs=-2V.
Rload=500 ohm.
C3 has to be large enough such that at the lowest frequency of interest (20Hz), it is effectively a short circuit as follows.
C4 is chosen so that the loss in gain compared to the mid-band gain is about 6dB as follow.
Page 14 of 24
C1 is value is
The sine wave source frequency is set to 2*pi*1000 rad/s and the amplitude to 0.1
5- Find the current consumed at the controlled voltage source and compare it to the current at the load
6- Plot the frequency response, select Analysis->Control Design-> Linear Analysis to open the Linear Analysis Tool.
Change the Plot Result to New Bode, and then click on Linearize. The linearization points were defined in this model by
right-clicking on a Simulink® line, and selecting Linearization Points.
Page 15 of 24
Reference : https://www.mathworks.com/help/physmod/elec/examples/jfet-amplifier-and-frequency-response-
analysis.html
Exercise 1: The resistor and capacitor in the circuits shown in the Figure below are connected to obtain the model of
the capacitor voltage v1. Assume that the values of the supply voltage vs , is, R, C, L and plot v1 and vo on scopes. Then
similar to previous example find the frequency response of these systems. Note: frequency response, select Analysis-
>Control Design-> Linear Analysis to open the Linear Analysis Tool. Change the Plot Result to New Bode, and then
click on Linearize. The linearization points were defined in this model by right-clicking on a Simulink® line, and
selecting Linearization Points.
(a) (b)
(d)
(c)
Page 16 of 24
(f)
(e)
(g)
Exercise 4: Modelling of Linear Electric Actuator with worm gear and screw.
Description: This example shows a detailed implementation model of a controlled linear actuator. The actuator consists
of a DC motor driving a worm gear which in turn drives a lead screw to produce linear motion. The model includes
quantization effects of the Hall-effect sensor and the implementation of the control. There are multiple variant subsystems
in this model that have models at varying levels of fidelity.
The speed control and current control models are implemented using pure Simulink blocks. This permits us to easily
specify the control algorithm and identify the requirements for an analog circuit implementation, which is shown in
another variant
The motor drive circuit model is implemented in an abstract circuit which can simulate in two different simulation modes.
In average mode, the voltage applied to the motor varies continuously between the maximum and minimum values
depending upon the voltages at its input pins. In PWM mode, a PWM voltage is applied to the motor and its duty cycle
depends on the voltage applied at its input pins.
Page 17 of 24
2- Examine the speed controller subsystem and identify the function of each block.
3- Examine the current controller subsystem and identify the function of each block.
4- Examine the PWM and H-bridge subsystem and identify the function of each block.
Page 18 of 24
5- Open the motor current scope and comment on the result.
6- Change the simulation mode to PWM in both the Controlled PWM and H-Bridge blocks.
Page 19 of 24
Reference:
https://www.mathworks.com/examples/simelectronics/mw/elec_product-elec_motor_linact_control-linear-electric-
actuator-with-control
Page 20 of 24
Exercise 5: Modelling of Automotive Electrical System.
Description:This example shows a simplified dynamic model of an automotive electrical system. The model contains
electrical, mechanical, and thermal systems, and is able to simulate the effect of engine starting on the electrical network.
Page 21 of 24
2- Examine the alternator subsystems (look under musk) and identify its operation.
Page 22 of 24
3- Examine the alternator thermal environment model.
4- Examine the starter solenoid subsystem and identify the rotational and translational and electric domains.
Page 23 of 24
5- Open the script file and identify its function.
7-try to start the engine with the light turned on, what is the change in battery voltage?
Reference:
https://www.mathworks.com/examples/simelectronics/mw/elec_product-elec_auto_network-automotive-electrical-
system
Page 24 of 24