Skip to content Skip to navigation Skip to collection information

OpenStax_CNX

You are here: Home » Content » From MATLAB and Simulink to Real-Time with TI DSP's » DC Motor Control

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.

Also in these lenses

  • Lens for Engineering

    This module and collection are included inLens: Lens for Engineering
    By: Sidney Burrus

    Click the "Lens for Engineering" link to see all content selected in this lens.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

DC Motor Control

Module by: Jacob Fainguelernt. E-mail the author

Summary: This module demonstrates the use of the c28x peripherals and DMC library blocks to control the speed of a DC motor in a closed-loop fashion. This example is based on the "DC Motor Speed Control via RTDX" SIMULINK demo.

Introduction

This chapter demonstrates the use of the c28x peripherals and DMC library blocks to control the speed of a DC motor in a closed-loop fashion. This example is based on the "DC Motor Speed Control via RTDX" SIMULINK demo.

The target speed of the motor is set by the user in the MATLAB GUI. This value is fed to the Controller (based on the eZDSP-F2812) to change the motor speed. The loop is closed by a tachometer. The controller constantly adjusts the value of the DC voltage applied to the motor to maintain the desired speed. The control loop is shown in the following figure:

Figure 1: DC Motor Control Loop
Figure 1 (fig1.JPG)

The Speed controller comprises two blocks (please refer to Figure 2):

  1. Speed Control:: This block compares the desired speed with the measured speed and generates a digital value proportional to the DC value to be applied to the motor.
    Figure 2: The Speed Controller
    Figure 2 (fig2.JPG)
  2. Digital to Analog converter:: This block is implemented using a PWM signal generator and a Low Pass Filter as shown in Figure 3. This method is described in . The output voltage, generated at the LPF output will be:
V = D V ss V = D V ss size 12{V=D cdot V rSub { size 8{ ital "ss"} } } {}
(1)

Where:

Table 1
V V size 12{V} {} - Generated Voltage
D D size 12{D} {} - PWM Duty Cycle
V ss V ss size 12{V rSub { size 8{ ital "ss"} } } {} - Supply Voltage (3.3 V)
Figure 3: Digital to Analog Converter Implementation
Figure 3 (fig3.JPG)

Figure 4 shows the loop control implementation, based on three components:

  1. eZDSP-F2812 (Please refer to )
  2. Interface circuit (Please refer to Section )
  3. DC Motor Kit (Please refer to Section )

Figure 4: DC Motor Control Loop Implementation
Figure 4 (fig4.JPG)

Setup

This demo is based on the Spectrum Digital eZdsp-F2812 that is connected to a DC Motor Kit through a dedicated interface circuit. The setup is shown in Figure 5.

Figure 5: Setup
Figure 5 (fig5.JPG)

The DC Motor Kit

Servo amplifier [SA150D]:

This unit operates the motor from signals applied to the input sockets 1 or 2, enabling control of the motor speed and reversing its rotation. This example shows speed control only, and will make use input socket 1 only. The servo amplifier is connected to the servo motor by an 8-pin plug and able. Terminals for ± 15 volts and ground (common) are available on this unit.

Servo motor with Tachometer [MT150F]:

This unit is a DC motor that produces a torque of the order of 8 oz-in (600 gm-cm) at 2A input current. The inertia is about 3x10−5 Kg −m2. The output shaft may be fitted with a brake disc and/or an inertia disc to load the motor. A second shaft on the side of the motor is coupled to the main shaft by 30:1 gears (the smaller shaft rotates slower than the main shaft). The tachometer with terminals +, - and common (ground) is attached to the motor.

Power supply [PS150E]:

This unit provides the various voltages supplies required for the servo components. There are terminals for ±15 volts, and common (ground). An ammeter is also included. The maximum current is 2 A. An 8-pin socket and cable connects this unit to the servo amplifier.

I/F Circuit

This circuit was designed as part of the demo that will be described in detail in chapter .

Measurement Equipment

  1. Signal Generator
  2. Voltmeter
  3. Oscilloscope.
  4. Stroboscope

Related Files

System Identification

The transfer function of a DC motor can be approximated by a first order model with unknown constants. These constants can be identified experimentally.

The tachometer provides the feedback signal for speed control systems. A schematic diagram of the tachometer is given in Figure 6.

Figure 6: DC Motor with Tachometer
Figure 6 (fig6.JPG)

In this section we will identify the constants in the mathematical models of a DC motor and the tachometer experimentally. The process consists of consists of two parts:

  1. Measurement of the tachometer coefficient and the motor constant
  2. Measurement of the motor time constant.

Measurement Equipment

  • Signal Generator
  • Voltmeter
  • Oscilloscope.
  • Stroboscope

Measurement of Tachometer Coefficient and Motor Constant

The tachometer coefficient and motor constant can be measured by generating a control voltage, using the PWM block of the DSP, and measuring:

  1. The motor speed using a stroboscope
  2. The tachometer output using a voltmeter

The setup is shown in Figure 7.

Figure 7: Calibration of the Motor and Tachometer
Figure 7 (fig7.JPG)

Figure 8 shows the model that will be used to generate the control voltage.

Figure 8: System Identification Model
Figure 8 (graphics8.png)

The PWM block will be configured to generate a PWM signal with a period of 4096 clock cycles of 75 MHz (please refer to Figure 9).

Figure 9: PWM Configuration
Figure 9 (graphics9.png)

Measurement Procedure:

  1. Connect the circuit shown in Figure 7.
  2. Generate a 0 V input to the DC Motor Kit (Compile Build and Run the model with Duty Cycle=0)
  3. Measure the motor speed using the stroboscope and the tachometer voltage using a voltmeter.
  4. Repeat step 3 for input voltages in the range 0-15 V. Change the Duty Cycle from 0 to 100% in steps of 10 %.
  5. Obtain a plot of tachometer voltage vs. servo amplifier input voltage.

The ADC input voltage of the DSP should be in the range 0-3V, the therefore the tachometer output voltage must be inverted and scaled down. This is done with the circuit shown in Figure 19. The gain of this circuit is G = - 100/270 = - 0.37, i.e., inverting and attenuating approximately 1/3. The results obtained are shown in Figure 10.

Figure 10: Speed Measurement
Figure 10 (graphics10.jpg)

Measurement of the motor time constant

The measurement of the time constant will be obtained by generating a square pulse and measuring the motor response to this stimulus. The principle of operation is shown in Figure 11; the experimental setup is shown in Figure 12.

Figure 11: Measurement of the motor time constant
Figure 11 (fig11.JPG)
Figure 12: Measurement of the motor time constantMeasurement
Figure 12 (fig12.JPG)

The Function Generator generates pulses, as shown in Figure 13.

Figure 13: Pulse Parameters
Figure 13 (fig13.JPG)

Measurement Procedure

  1. Connect the circuit shown in Figure 12.
  2. Generate the pulse shown in Figure 13.
  3. Measure the rising and falling times of the motor response.

The DC motor was modeled as a first-order linear system where τrise=τfallτrise=τfall size 12{τ rSub { size 8{ ital "rise"} } =τ rSub { size 8{ ital "fall"} } } {}; however, the actual motor is not linear (due to friction, for example), therefore the measured values were:

Table 2
τ rise τ rise size 12{τ rSub { size 8{ ital "rise"} } } {} = .13 secs
τ fall τ fall size 12{τ rSub { size 8{ ital "fall"} } } {} = .23 secs

We used the average of these readings, i.e., (0.13+0.23)/2 = 0.18  and rounded to 0.2 sec. 

Ω s E s = K m 1 1 + m Ω s E s = K m 1 1 + . 2s Ω s E s = K m 1 1 + m Ω s E s = K m 1 1 + . 2s size 12{ matrix { { { %OMEGA left (s right )} over {E left (s right )} } =K rSub { size 8{m} } { {1} over {1+sτ rSub { size 8{m} } } } {} # dlrarrow {} # { { %OMEGA left (s right )} over {E left (s right )} } =K rSub { size 8{m} } { {1} over {1+ "." 2s} } {} } } {}
(2)

Real-Time System Design

The system design comprises two parts:

  1. Simulation, to determine the parameters of the Speed Control Transfer Function
  2. Hardware Design of the interface circuit.

Simulation

The speed control is a PID controller. A DC motor model (Figure 14) was created. The complete control loop model is shown in Figure 15. Figure 16 shows the parameters chosen for the PID controller.

Figure 14: DC Motor Model
Figure 14 (graphics14.png)
Figure 15: Loop Control Model
Figure 15 (graphics15.png)
Figure 16: PID Controller Parameters
Figure 16 (graphics16.png)

Hardware Design

The connection between the eZDSP and the Motor Kit requires a dedicated interface circuit, implementing the Low Pass Filter (used for the Digital to Analog conversion) and adapting the voltage levels at the eZDSP (0 to 3V) to those of the DC Motor Kit (0-15V). The various signal types and their voltage range are shown in .

The interface circuit contains two blocks. The first is LPF with an amplifier (shown in Figure 18), connected between the PWM output and the servo amplifier input. The second block is an attenuator (shown in Figure 19) connected between the tachometer output and the Analog to Digital Input of the eZDSP.

Figure 17: Signal Types and Voltage Levels
Figure 17 (fig17.JPG)

Figure 18: LPF + Amplifier Circuit
Figure 18 (graphics18.jpg)
Figure 19: The Inverting Amplifier with LPF
Figure 19 (graphics19.jpg)

Real Time Implementation

The control loop was implemented in the eZDSP F2812 as shown in Figure 20. The PID controller obtained in the previous chapter was implemented in the DSP. The environment is shown in Figure 21.

The real-time implementation model will be created from the "DC Motor Speed Control via RTDX" SIMULINK demo. In the original demo model the loop is closed by QEP block, we will use a tachometer connected to the Analog to Digital Converter module for speed measurement.

The Model and its subsystems are shown in Figures Figure 22, Figure 23 and Figure 24.

Figure 20: LPF + Amplifier Circuit>
Figure 20 (fig20.JPG)

Procedure:

  1. Navigate into the following directory:

..\MATLAB\R2006b\toolbox\rtw\targets\tic2000\tic2000demos

  1. Copy the following files into your working directory:
    • c2812speedcontrolDC.mdl
    • runc2812speedcontrolDC.m
    • runc2812speedcontrolDC.m
    • Open the c2812speedcontrolDC.mdl model and save it as "DCMotorControlc2812.mdl"(please refer to Figure 211).
    Figure 21: Real-Time Implementation Model
    Figure 21 (graphics21.png)
  2. Double-click the Speed Correction Block, and you will see:
    Figure 22: Figure 22: Speed Control
    Figure 22 (graphics22.png)
  3. Configure the C28x PWM block as follows:
    Figure 23: Figure 23: PWM Configuration
    Figure 23 (graphics23.png)
  4. Configure the "PID Controller" block as follows:
    Figure 24: PID Configuration
    Figure 24 (graphics24.png)
  5. Double-click the Speed Correction Block, and you will see:
    Figure 25: QEP Based Speed Measurement
    Figure 25 (graphics25.png)
  6. Delete the selected blocks and replace them by the ADC block from Open the ADC block from the C281x Chip support group from the C2000 Target Preferences, and connect is as follows:
    Figure 26: ADC+Tachometer Based Speed Measurement
    Figure 26 (graphics26.png)
  7. Now the model is ready for real-time, we need however to update the MATLAB script file. Open the “Model Properties” from “File” menu. Change the PostLoadFcn callback to runc2812speedcontrolIDC, as shown:
    Figure 27: Model Callback
    Figure 27 (graphics27.png)
  8. The next step is to change the original PWM range (up to 64000) to the desired range (up to 4000). Open the “speddControlIDCLoop.m” file with the MATLAB editor, an change on line 48 the command:
            
    cycle = (double(pid).*100./64000);
    to
    cycle = (double(pid).*100./4000); 
    Please refer to the following picture:
    Figure 28: Changing the PWM range
    Figure 28 (graphics28.png)
  9. Activate the motor
  10. Activate CCS.
  11. Click the Build/Reload&Run box, the following window should appear:
    Figure 29: Speed Control GUI
    Figure 29 (graphics29.png)
  12. You may change the speed of the motor using the slider in the right hand side and the “Apply” button.

References

  1. "eZdspTM F2812 Technical Reference", Spectrum Digital, 2003 http://c2000.spectrumdigital.com/ezf2812/docs/ezf2812_techref.pdf
  2. David M. Alter, " Using PWM Output as a Digital-to-Analog Converter on a TMS320F280x", TI Application Report SPRAA88 , September 2008 http://www.ti.com/litv/pdf/spraa88a

Footnotes

  1. The model is shown here after deleting the “Info” box.

Collection Navigation

Content actions

Download:

Collection as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Module as:

PDF | More downloads ...

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks