• DC Motor Speed Measurement with an Encoder Exercise | ACE-Lab

    DC Motor Speed Measurement with an Encoder

    This exercise introduces encoder-based speed measurement for a DC motor controlled by an Arduino Uno and Maker Drive motor driver. A PWM input signal is applied to the motor, while encoder counts are captured in Simulink and converted into revolutions per minute. The measured RPM data can then be used to analyse the motor response and develop a mathematical model of the system.

    Introduction video for the DC Motor Speed Measurement with an Encoder exercise, supporting the Arduino Uno, Maker Drive, encoder feedback, and Simulink workflow.

    1. Learning Outcomes

    After completing this exercise, learners should refer back to these outcomes and check that they can connect the motor system, explain encoder-based speed measurement, configure Simulink data capture, and use measured RPM data for modelling.

    Assemble the DC motor control circuit

    Build a circuit using an Arduino Uno, Maker Drive motor driver, external power supply, and encoder feedback.

    Explain encoder speed measurement

    Describe how encoder counts can be used to calculate the rotational speed of a DC motor in revolutions per minute.

    Configure Simulink for PWM and encoder capture

    Apply a PWM input signal and capture encoder-based speed data from the motor using Simulink.

    Use measured RPM data for modelling

    Use the measured speed response to develop and evaluate a mathematical model of the motor system.

    2. Hardware Set-Up

    This circuit builds on the previous motor-driver exercise by controlling a DC motor using an Arduino Uno and Maker Drive motor driver, with additional wiring for encoder feedback. The Arduino sends signals to the Maker Drive to control the motor speed, while the 9V battery provides the higher-power supply needed to operate the DC motor. The Arduino and motor driver must share a common ground so that the control signals are correctly recognised.

    Required hardware:

    • Arduino Uno
    • Maker Drive motor driver board
    • DC motor with encoder
    • 9V battery and clip
    • Breadboard
    • Breadboard wires, various
    • USB cable

    Set-up guidance

    Begin by setting up the circuit in the same way as the previous exercise: connect the motor to the Maker Drive output terminals and connect the 9V battery to the motor power input. Then add the Arduino control wires to the Maker Drive input pins so that the Arduino can set motor direction and use PWM to vary motor speed.

    Hardware set-up for DC Motor Speed Measurement using an Encoder
    Figure 1: Hardware set-up for DC Motor Speed Measurement using an Encoder, showing the DC motor, Maker Drive motor driver, Arduino Uno, 9V battery, breadboard, and encoder/control wiring.
    1

    Connect the DC motor wires to the Maker Drive motor output terminals. Use one motor channel, such as M1A and M1B.

    2

    Connect the 9V battery positive wire to the Maker Drive motor power input, usually labelled VIN, VM, or +.

    3

    Connect the 9V battery negative wire to the Maker Drive GND terminal.

    4

    Connect a GND pin on the Arduino to the Maker Drive GND. This is essential because both boards need a shared reference voltage.

    5

    Connect the Arduino 5V pin to the Maker Drive logic supply pin if required by the board.

    6

    Use the breadboard to organise the shared 5V and GND connections if needed.

    7

    Connect the Arduino control pins to the Maker Drive input pins. These wires are used to control the motor direction and speed.

    8

    Connect the Maker Drive motor input pins for the selected motor channel to suitable Arduino digital or PWM pins.

    9

    Check that the motor is connected only to the Maker Drive output terminals and not directly to the Arduino.

    10

    Connect the Arduino to the computer using the USB cable.

    4. Additional Exercise

    Use the revolutions per minute output data obtained from the Simulink scope to develop a mathematical model that captures the key dynamics of the motor system.

    Develop a mathematical model

    Use the measured input-output data to develop a model that captures the main behaviour of the motor response.

    Compare measured and model outputs

    Plot the measured RPM output data alongside the model output data so that the two responses can be compared visually.

    Calculate the model fit

    Assess the model accuracy by calculating the mean squared error between the measured RPM output and the model output.

    5. Concluding Remarks

    This exercise introduced the use of encoder feedback to measure the speed of a DC motor controlled by an Arduino Uno and Maker Drive motor driver. By applying a PWM input and processing the encoder counts in Simulink, the motor speed can be estimated in RPM and displayed for analysis.

    The additional modelling task extends the practical work by using the measured data to develop a mathematical model of the motor response and assess its accuracy using the mean squared error.