DC Motor Speed Control via RTDX™
This example shows how to control the speed of a DC motor in a closed-loop fashion using C28x peripherals and DMC library blocks.
Required Hardware:
- Spectrum Digital® F2812 eZdsp board
- DC motor with an optical encoder
- Power supply
- Amplifier
Note: Match the characteristics of the power supply and the amplifier with the input characteristics of the selected motor.
Available versions of this example:
- Spectrum Digital F2812 eZdsp: c2812speedcontrolDC.mdl
Contents
Model
The following figure shows the DC Motor Speed Control example model.
Description
The target speed of the motor is set by the user in the MATLAB® GUI. The speed setting is sent to the controller code running on the processor via RTDX™. The controller constantly adjusts the duty cycle of the PWM waveform driving the motor to maintain the desired speed. A variable loading of the motor results in variable PWM waveform duty cycle. The speed and PWM duty cycles values are sent via RTDX™ to the host for display in MATLAB®. Note: The GUI allows setting the speed between 0 and 4000. The PID parameters have to be tuned to a specific motor.
Hardware Connections
- Connect the output of the F2812 PWM1 to the amplifier
- Connect the amplifier to the motor
- Connect the encoder output to the F2812 QEP input
How to Run the Example
- Open the model
- Click "Build/Reload & Run" to generate, build, load and run the controller code
- Observe the current motor speed and the PWM duty cycle value applied to maintain it
- Change the desired motor speed using the dialog slider and click on "Apply"
- Observe the changes in the motor speed and the PWM duty cycle applied to attain it