Skip to content
Adaptive AgroTech NetworkUniversity of Southern Denmark · SDU Drone Center
Course2026
← Lectures: DC motor controlModule 11

DC Motor Control 11 | Industrial PLC Speed Control

InstructorDr. Redmond R. Shamshiri
AffiliationAssistant Professor of Robotics · University of Southern Denmark (SDU)
Study time75 minutes
Watch & study

Lecture video

Open on YouTube ↗

Video unavailable here? Watch on YouTube. Captions and playback speed are available in the player.

Study companion. These editable notes, worked examples and exercises supplement the source material. They are not a verbatim video transcript or a reproduction of the book.

Implement a documented start/stop sequence, encoder scaling and a discrete PI speed loop with actuator limits. This is an authored companion lab; no unverified YouTube video is attached.

Learning Objectives

  • Specify the PLC I/O and run-state logic.
  • Convert encoder counts into rpm and a speed reference into a bounded drive command.
  • Implement and explain discrete PI control with conditional integration.
  • Test stop priority, communication loss, saturation recovery and restart prevention.

Purpose and system boundary

Build a teaching speed-control loop: HMI reference → PLC PI controller → rated motor drive → DC motor → encoder → PLC. The PLC sends a command; the drive switches motor power. This companion lesson is independent of any unverified video-specific hardware configuration.

Use a secured, low-energy motor rig and a current-limited supply. An emergency stop must act through the appropriate independent hardwired protective circuit or rated drive safety function; ordinary PLC application logic and a web/HMI button do not establish a safety-rated stop.

I/O and state design

SignalMeaningInitial/fault behavior
StartRequestMomentary operator startDoes not auto-restart after power recovery
StopOKPermissive stop chain feedbackFalse removes run request
DriveReady / DriveFaultDrive statusFault latches a diagnostic
EncoderCountSigned, decoded output-shaft countMissing/implausible data inhibits control
SpeedSet_rpmBounded HMI referenceClamped to validated rig limit
DriveEnable / SpeedCommandSeparate enable and demandDisabled and zero demand
\[Run_{k+1}=Ready\land StopOK\land\neg Fault\land(Start\lor Run_k)\]

Stop and fault dominate Start. Reset clears the fault only after its cause is removed; it does not start the motor. Define a separate deliberate Start action.

Encoder speed and command scaling

\[n_k=\frac{60(N_k-N_{k-1})}{N_{rev}T_s}\]

Nrev is effective decoded counts per output-shaft revolution, including quadrature mode and gearing; Ts is seconds. Handle count rollover and timestamp jitter. A nominal PLC scan period is not a substitute for measured elapsed time.

\[RawCommand=Raw_{min}+\operatorname{clip}(u,0,1)(Raw_{max}-Raw_{min})\]

The raw command endpoints must come from the actual drive/interface manual. They are not universal PLC constants. A 0–10 V output might encode a 0–100% demand, but speed still depends on the drive mode and feedback implementation.

Discrete PI with conditional anti-windup

\[e_k=r_k-n_k,\quad I^*=I_{k-1}+K_iT_s e_k,\quad u^*=K_pe_k+I^*\]
\[u_k=\operatorname{clip}(u^*,0,1)\]

Accept I* only when the output is unsaturated, or when the error would drive a saturated output back toward its valid range. Otherwise retain the previous integral. When Run is false, apply zero command and reset the integrator for this teaching design.

// Illustrative Structured Text; adapt types and I/O to the PLC.
IF NOT Run THEN
    Integral := 0.0;
    SpeedDemand := 0.0;
ELSE
    Error := SetpointRpm - MeasuredRpm;
    CandidateI := Integral + Ki * SampleSeconds * Error;
    CandidateU := Kp * Error + CandidateI;
    IF ((CandidateU >= 0.0) AND (CandidateU <= 1.0))
       OR ((CandidateU > 1.0) AND (Error < 0.0))
       OR ((CandidateU < 0.0) AND (Error > 0.0)) THEN
        Integral := CandidateI;
    END_IF;
    SpeedDemand := LIMIT(0.0, Kp * Error + Integral, 1.0);
END_IF;

This is a conceptual unidirectional loop, not a complete machine program. Add input validity checks, drive handshake, current/temperature limits and a measured sample time appropriate to the actual rig.

Numerical example

Assume 2,048 effective counts/revolution and 512 counts measured in 0.25 s: measured speed = 60 rpm. With reference 80 rpm, Kp = 0.01 duty/rpm, Ki = 0.02 duty/(rpm·s), Ts = 0.02 s and previous integral 0.10, the proposed integral is 0.108 and output is 0.308, or 30.8% demand. The 0.25 s speed-estimation window and 20 ms controller period are different; analyze the measurement delay before tuning aggressively.

If demand is constrained to 0–100% and the motor cannot reach the reference under load, continuing to integrate positive error creates windup. Confirm saturation handling by lowering the reference after a deliberately limited run.

Commissioning sequence

  • Document wiring, drive mode, protective circuit, current limit and validated maximum speed.
  • With power disabled, test truth-table transitions and restart prevention in simulation.
  • Verify encoder count direction and counts/revolution at low energy.
  • Test the open-loop drive demand, then start with low proportional gain and zero integral gain.
  • Log reference, measured rpm, error, requested/applied duty, integral and sample timestamps.
  • Add integral action gradually and test load steps, stop priority, stale feedback and saturation recovery.

Evidence: I/O table, state transition trace, a time plot for reference/speed/demand, and a failure-test table including observed stop time. Acceptance thresholds must be defined for the actual apparatus before testing.

Exercise with solution

A 1,000-count/revolution encoder produces 100 counts in 0.1 s. Reference is 90 rpm. Kp = 0.005 duty/rpm, Ki = 0.01 duty/(rpm·s), Ts = 0.02 s and previous integral = 0.20. Calculate the next unsaturated PI output.

Show calculation

Measured speed = 60 rpm; error = 30 rpm. Integral candidate = 0.20 + 0.01×0.02×30 = 0.206. Output = 0.005×30 + 0.206 = 0.356, or 35.6%. It is inside the assumed 0–1 range, so accept the integral update.

Summary

PLC scan, latching and interlocks: keep units, assumptions and timing explicit. Check the numerical model against an independent observation before using it in a larger system.

Suggested Reading & Resources

  • Reading
    CODESYS Structured Text reference

    Primary documentation or original technical reference; check the version used in your lab.

    Open ↗
  • Reading
    Espressif LEDC PWM peripheral

    Primary documentation or original technical reference; check the version used in your lab.

    Open ↗
  • Reading
    MathWorks control-system modeling

    Primary documentation or original technical reference; check the version used in your lab.

    Open ↗