DC Motor Modeling and Validation
Server Technology & Stereo Technique
Last Week Recap
Setup: Installed software & initial tests.
Modeling of the server: Continued from last week.
This Week's Agenda
MATLAB model for servo.
Modeling completion: Model of the permanent magnet DC motor.
Model validation: Introduction (continuation in period four if needed).
Brightspace Resources
Brush DC motor model: Download from Brightspace.
MATLAB project structure: Create a new project for servo.
Different projects for different workshops (Discretive, CSips, Modeling, Servo, Advanced Control).
Creating a New MATLAB Project
Name: SRV6.
Folders:
Functions
Models
Data (potentially needed)
Add all folders (including subfolders) to the project path.
Adding the DC Motor Model
Download the DC motor model from Brightspace.
Save it in the "Models" folder of your SRV6 project.
Add the model to the project.
Model Overview
Electrical Part:
Kirchhoff's Voltage Law (KVL).
Equation:
Time representation: Sum of voltage drops across resistance, inductance, and back electromotive force.
Frequency representation: , where is rotor voltage and is back electromotive force.
divided by gives the current, .
, where is a constant and is motor speed.
Equation Summary
Mechanical Side:
Torque, , is . This torque overcomes inertia, , and viscous friction, .
Equation: .
.
.
Rotor Position:
Integrate velocity, , to get the angular position, .
Connecting Electrical and Mechanical Parts
divided by equals current, .
multiplied by is torque.
Torque divided by becomes .
Integrate to get position, .
Model Inputs and Outputs
Input: Rotor voltage, .
Outputs:
Current, .
Velocity, .
Position, .
Application-Specific Outputs:
Electric car: Velocity of wheels.
Dentist drill: Velocity control.
3D printer/Robotic arm: Position control.
Transfer Functions
Definition:
The link between one input and one output.
With one input and three outputs, there are three different transfer functions.
Transfer functions for this model:
Rotor voltage to rotor current.
Rotor voltage to rotor velocity.
Rotor voltage to rotor position.
Calculating Transfer Functions in Simulink
Commands:
linmod: Returns the state-space representation (A, B, C, D matrices) of the system.ss: Creates a state-space system model from the state-space matrices.tf: Converts a state-space system model to a transfer function representation.
Example:
```Matlab
[a,b,c,d] = linmod('brushDCmotormodel'); sys = ss(a,b,c,d); tfsys = tf(sys);
- If there are multiple outputs, `tf_sys` will be a vector of transfer functions.
## Analyzing Transfer Functions
- Order: Determined by the denominator.
- Poles: Roots of the denominator.
- Zeros: Roots of the numerator.
- Stability: Determined by the location of poles.
- Poles in the left-half plane: Stable system.
- Poles in the right-half plane: Unstable system.
- Pole locations calculated by using the following rules:
- , where the sum of the poles is , and the product of the poles is .
## Transfer Function Examples
- Example transfer function:
-
- The system is stable if both poles are on the real axis or are complex conjugates that lie in the left half plane
- System stability: uncontrolled system is stable if voltage applied to rotor results in constant speed.
- Zeros in the right half plane: tracking is not possible.
## Transfer Function linking Voltage to Rotor Velocity
- Form: .
- Has a pole at the origin, indicating an integrator in the plant.
- Velocity plant already has an integrator.
## Transfer Function Observations
- The transfer function is different from what was shown on the previous slide.
- Slides will be updated and posted on Brightspace.
## DC Gain of Transfer Functions
- Definition: The ratio of the DC output to the DC input when a DC input is applied to the system.
- To find the DC gain, set in the transfer function.
## DC Gain Example
- Transfer function: .
- DC gain: b/B
- Used to validate simulation results in Simulink.
## Script for Calculating Transfer Functions
- Create a new script in the "Functions" folder.
- Example script:
- ```matlab
%This script calculates the transfer functions for the Simulink model, brush DC motor.
[a,b,c,d] = linmod('brush_DC_motor_model');
sys = ss(a,b,c,d);
tf_sys = tf(sys);
Run the script to generate the transfer functions.
Simulink Model Requirements for Transfer Function Calculation
Inputs and outputs must be replaced with input and output ports, not signal blocks.
Simulink can then calculate the transfer functions.
Saving Parameters of the Model
In the callback functions, go to model settings -> Model Properties -> Callback -> Init function.
r = 1, l = 1 microhenry, kt and ke = 10 to the power of minus 1.
Units included (e.g., kg meter square for J).
Best practices:
Save parameters in a central place (e.g., callback function, script, model workspace).
Allows easy parameter changes and overview of all parameters.
Version control: Stores every file/product, with these included.
Example: Copy these values into parameters set in MATLAB.Set parameters can then be set by using Set DC motor parameters function.
Simulation
clear: clears workspace values.clc: Clears Command Window.Model is initialized.
Simulation Model: Replacing the input output ports (not signal blocks, see above). With assigned blocks.
Simulation Model Setup
Replace input and output ports with appropriate signals.
Use a signal generator for the input voltage (square wave).
Set simulation stop time (e.g., 2000 seconds).
Configure the signal generator for a square wave:
Set frequency to 0.001 Hz.
Amplitude: 10 volts.
Apply a square wave: 500 secs at 10 volts; 500 secs at 0 volts
Remove notes (for cleaner setup).
Analyzing Simulation Results
Using Data Inspector. Signal values and data. Layout in rows and columns.
Check if the results make sense using the transfer functions we have previously calculated.
Determining the settling time from transfer function
Settling time for single real pole: 4.6/sigma or 4.6 x Tau.
Settling time for pair of complex conjugate poles: use the same formula ( 4.6/sigma or 4.6 x Tau).
Tau = 1/(real part of pole)
Using Pole-Zero Plots
Useful commands:
Pzplot of sys. shows locations of poles (denoted by x) and zeros (denoted by O.
Pole (shows poles of the system).
Example: use zero plot from tfsys 1 (voltage to current).
Zeros do not determine stability. The roots should be near the axis when zoom is used.
Time to steady state, and the inverse of that is the pole.
Oscillatory Response
Oscillatory responses are expected when poles are complex, as real poles do not result in oscillations (although they may exponentially go up or down).
Model Validation and Parameter Estimation
Goal: Find the best values for the model parameters (R, L, B, J, K).
Method: Use the data sheet of the motor or perform experiments.
In the modeling workshop, the parameters were estimated using simulations.
Data Sheet Parameters
Nominal voltage: Voltage at which the motor is expected to run
No-load speed: Speed when the rotor is unloaded
No-load current: Current required to achieve no-load speed
Nominal speed, nominal torque, and nominal current: Measurements made under nominal conditions.
Stall torque: Maximum force the motor can generate.
Starting current: Current at motor start.
Data Sheet Values Interpretation
If control for controller is to be designed, it must always consider values like rpm, torque and maximum to ensure this is feasible within range described by datasheet.
Calculating Parameters from the Given parameters
Use terminal resistance to find it. Terminal = end of rotor wire.
Use inductance for L.
Use constant, which should be dimensionally the same (can convert from mm to A).
Rotor inertia: J. From grams to cm squared.
Calculations should be used to see what to do to get correct result (with RPM).
Calculating B (Viscous Friction)
Viscous friction is calculated from formula at no load.
B equals what: the speed is 0.
Key formulas isU = R I + K omega
KI = b omega
B euals KI divide by omega, with no load.
Check all units (milli amperes to amperes, etc) with load.