# Connexions

You are here: Home » Content » DC Motor Control

### 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?

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

#### 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.
• TI DSP

This module is included inLens: Texas Instruments DSP Lens
By: Texas Instruments

Click the "TI DSP" link to see all content affiliated with them.

Click the tag icon to display tags associated with this content.

#### Also in these lenses

• Lens for Engineering

This module is 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:

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.
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:

 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 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 )

### 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.

#### 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

## 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.

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 8 shows the model that will be used to generate the control voltage.

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).

#### 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.

### 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.

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

#### 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:

 τ 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.

### 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.

## 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.

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).
2. Double-click the Speed Correction Block, and you will see:
3. Configure the C28x PWM block as follows:
4. Configure the "PID Controller" block as follows:
5. Double-click the Speed Correction Block, and you will see:
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:
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:
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:
9. Activate the motor
10. Activate CCS.
11. Click the Build/Reload&Run box, the following window should appear:
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.

## Content actions

PDF | EPUB (?)

### What is an EPUB file?

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

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?

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