Brushed DC Motor Identification with Simulink: Estimating Pololu Metal Gearmotor Parameters as an Example

keywords: Arduino, DC motor identification, DC motor drive, parameter estimation

The Pololu Metal Gearmotor parameters are estimated using Arduino and Matlab. All of the codes are available for download at the identification process section at the end of the webpage.

Hardware

Microcontroller. I used an Arduino UNO to drive the dc motor and to read the encoder outputs. Any microcontroller with 2 interrupt pins and 2 digital outputs can be used instead.

DC Motor. A 30:1 Metal Gearmotor 37Dx68L mm with 64 CPR Encoder is the DC motor in the example. The motor is intented to be driven at 12 volts. The stall current is 5 A and the maximum speed is 350 rpm.

DC Motor Driver. Microcontoller’s output current is not enough to drive a DC motor so we need power circuits. As the stall current is 5 A, a motor driver circuit which is capable of supplying more than 5 A is required. Also the driver’s operating range should involve 12 volts. Pololu 18v7 motor driver can supply up to 7 A and the operating voltage range is 5.5 V – 30 V.

Power Supply. In order to drive Metal Gearmotor, we require 12 V and 5 A at most. Hence, the electrical power requirement is P > (5 A)\cdot(12 V) = 60 W. I used a Mean Well RS-75-12 Power Supply which operates at 12 V and has 75 Watts power.

Table 1: Hardware list with prices.
HardwarePrice
Total$102.89
Arduino UNO $4.99
30:1 Metal Gearmotor with 64 CPR Encoder$39.95
Pololu 18v7 Motor Driver $33.99
Mean Well RS-75-12 Power Supply $23.96

Dynamics

dc_motor_estimation_motor_equivalent

Figure 1 – DC Motor electrical equivalent.

DC motor behaviour includes both electrical and mechanical dynamics. The electrical equivalent of a DC motor can be seen in Figure 1. The relation between the armature current i and the rotor torque \tau is a linear function as follows
\tau(t) = K_t i(t).

As motor rotates, the motor produces a back EMF voltage proportional to the rotor speed \dot{\theta}
V_B(t) = K_e \dot{\theta}(t).

For the DC motor K_t = K_e.. The dynamics can be represented as
(1) J_m\ddot{\theta}(t) + b_m\dot{\theta}(t)=K_ti(t)
(2) L\dfrac{di(t)}{dt} + Ri(t) = V(t) - K_e\dot{\theta}(t).
where V is the voltage applied to the motor and the other parameters are explained in Table 2. The Equation (1) represents the mechanical dynamics of the motor, whereas the Equation (2) is about the electrical behaviour. Simulink block diagram of a DC motor model is shown in Figure 3.

Table 2: DC motor parameters and the resulting values after identification

 ParameterEstimated ValueUnit
(J_m)Moment of inertia3.1321\times 10^{-6}kg\cdot m^2
(b)Viscous friction9.8734\times 10^{-7}
(K_e)Back EMF constant0.0106V/ rad/ s
(K_t)Torque constant0.0106N\cdot m/ A
(R)Resistance2.3417\Omega
(L)Inductance 0.0211H

Driving DC Motor with Arduino

hardware_diagram-1

Figure 2 – Hardware diagram.

The motor driver has 2 inputs, which are ROT and PWM, commanded by the microcontroller.

The input voltage V(t) of the DC motor is not an analog signal but a PWM signal during digital control. The analog equivalent of the applied voltage is related to power supply voltage and the PWM signal as follows
\vert V(t) \vert = (12~\mbox{V}) \cdot \%\mbox{Duty}_{\mbox{PWM}}.

The sign of the voltage (direction of the current) is determined by the ROT input of the motor driver.

 

I obtain the code of reading incremental encoders from a Youtube Video (link), one can refer to related Youtube video and links therein for more information.

In order to force the microcontroller to react only at sampling time instants, I use the following method

The rotor speed is approximated with Backward-Euler method
\dot{\theta}(t)=\dfrac{\theta(t)-\theta(t-T_s)}{T_s}

Identification of the DC Motor Parameters

The DC motor is excited with two different signals, and resulting rotor speeds are observed for identification. For more accurate results, the DC motor should excited with a signal involving different frequencies. My first signal is a square input to excite DC components of the motor. The second experiment conducted with a mixed signal which is a summation of sinusoids with different frequencies.
V_2(t)=3.7\cdot (\sin (2\pi 0.1t)+\sin (2\pi 0.2t)+\sin (2\pi 0.4t)+\sin (2\pi t))
More harmonics can be added up to 50 Hz as our sampling period 10 milliseconds (100 Hz) (Nyquist Rate). The fourier signal input can be seen in Figure 3 with the comparison of simulation and experiment. As seen in the figure, simulation results are very similar to the experimental results.

dc_motor_estimation_fourier_signal

Figure 3 – Comparison of experimental and simulation results with the fourier input signal.

Simulink diagram of the DC motor model is below.

dc_motor_system_block_diagram

Figure 3 – Simulink block diagram of the DC motor

The identification Arduino code is below

Identification Process

Identification can end up with diffent solutions since optimization algorithm can terminate at any local minimum. Only one of them is the real parameters. Here are some steps to get real parameters.

  • Download the arduino code from here. Manage the code according to your DC motor, power supply voltage and encoder.
  • Upload the code to the Arduino when estimationMode = 1.  Copy the results in Serial Monitor and paste it to Matlab Command Window and enter the following commands.
  • Upload the code to the Arduino when estimationMode = 2.  Copy the results in Serial Monitor and paste it to Matlab Command Window and enter the following commands.

    • Measure the resistance (R) between two terminals of your DC motor with help of a multimeter. It will our initial guess before identification. Or you can simply select the resistnace as Supply Voltage / Stall Current of your DC motor.
    • Create five variables J, b, R, L, K with your initial guess for the parameters. The initial value of R is the measurement of the resistance. Table 2 can be helpful for the other parameters.
    • Create two input and two output signals in Command Window which represents our experiments.

  • Download the simulink file here and open the simulink model. Open The Parameter Estimation window from the Analysis menu at top.
  • Select the parameters to estimate (Select Parameters). The resistance value is a narrow range including our initial guess, e.g., between 2 and 3 ohms in my case. The minimum value for all parameters should be 0 since they can not be negative values.

DC_motor_ident_set_variables

  • Add two new experiments. Choose inputs as fourierInput and squareInput and outputs as fourierOutput and squareOutput for each, seperately. Select Measured Output Signal as DC Motor:1 (Speed) and Select Input as DC Motor: 1 (Voltage). Choose both experiments for validation and estimation.dc_motor_estimation_choose_experiments
  • Start the estimation. At the end of the estimation in my case, the cost function f(x) is 0.64 and 1.61 for fourier and square wave input, respectively. The resulting parameters for my experiment can be seen in Table 2 at the top of the page.

dc_motor_estimation_resulting_simulink

One thought on “Brushed DC Motor Identification with Simulink: Estimating Pololu Metal Gearmotor Parameters as an Example

  1. Rubén de los Santos Reyes

    Nice man!!!, that´s a great and very practical way to implement the parameter estimator. Thanks a lot, i been needed it for a class project.

    Regards.

    Reply

Bir Cevap Yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir