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: U<em>AE</em>AU<em>A - E</em>A, where U<em>AU<em>A is rotor voltage and E</em>AE</em>A is back electromotive force.

    • U<em>AE</em>AU<em>A - E</em>A divided by LS+RLS + R gives the current, II.

    • EA=kωE_A = k \cdot \omega, where kk is a constant and ω\omega is motor speed.

    • Equation Summary

    • UAkΩ=I(R+LS)U_A - k \cdot \Omega = I \cdot (R + LS)

  • Mechanical Side:

    • Torque, TT, is kIk \cdot I. This torque overcomes inertia, JJ, and viscous friction, BB.

    • Equation: T=Jωdot+BωT = J \cdot \omega_{dot} + B \cdot \omega.

    • kI=JSΩ+BΩk \cdot I = JS \cdot \Omega + B \cdot \Omega.

    • Ω=kIJS+B\Omega = \frac{k \cdot I}{JS + B}.

  • Rotor Position:

    • Integrate velocity, ω\omega, to get the angular position, θ\theta.

Connecting Electrical and Mechanical Parts

  • UAkωU_A - k\omega divided by LS+RLS + R equals current, II.

  • II multiplied by kk is torque.

  • Torque divided by JS+BJS + B becomes Ω\Omega.

  • Integrate Ω\Omega to get position, θ\theta.

Model Inputs and Outputs

  • Input: Rotor voltage, UAU_A.

  • Outputs:

    • Current, II.

    • Velocity, ω\omega.

    • Position, θ\theta.

  • 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:
  - S2+aS+b=0S^2 + aS + b = 0, where the sum of the poles is ba\frac{-b}{a}, and the product of the poles is ca\frac{c}{a}.

## Transfer Function Examples
- Example transfer function:
  - bS2+aS+c\frac{b}{S^2 + aS + c}
- 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: S3+bS2+cS=0S^3 + bS^2 + cS = 0.
- 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 S=0S = 0 in the transfer function.

## DC Gain Example
- Transfer function: bJS+B\frac{b}{JS + B}.
- 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 is

  • U = 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.