Opening the book…
After completing this section, you will be able to:
- Discuss the relationship between mechatronic system hardware and its architecture.
- Explain the Arduino MKR motor carrier board functionality and know how to use it.
- Describe the Simulink software for DC-motor speed control for the Arduino MKR 1000 Wi-Fi.
Section 7.1 introduced the overall hardware and software architectures of mechatronic control systems. In this section, we will use an example—mechatronic DC-motor speed control system—to relate each component to the physical domain, interface, and information domain in a mechatronic system. In addition, control system analysis and design block diagrams, as shown in Figure 7.2, present a simplified system architecture. Because only mathematical relationships are considered, they are good for control system performance analysis. Using the DC-motor speed control mechatronic system as an example, this section demonstrates how to convert a mechatronic system architecture to a control system block diagram.
Next, let’s look at details of the Arduino MKR motor carrier board. It will be used in the DC-motor speed control system and other mechatronic system hardware as presented earlier. The MKR motor carrier board is an open-source add-on board designed to control servo, DC, and stepper motors; see Figure 7.17 for its picture and pin definitions. The board’s circuit and Eagle PCB (printed circuit board) files are provided in references [23] and [24], respectively.
The Arduino MKR motor carrier board is compatible with all the boards in the MKR family. It has four servo motor outputs, four DC-motor outputs (two high performance and two standard performance), current feedback signals for the high-performance motors, two encoder sensors for pulses A and B, four analog inputs for sensors, an on-off switch with LED, a LiPo battery connector, and an I2C connector. Figure 7.17 shows the associated pins for the inputs and outputs mentioned. The board also features two H-bridge MC33926 motor drivers for high-performance DC-motor control with direct connection to the Arduino MKR 1000 Wi-Fi board through the two connectors in the center of the board, as well as current feedback, and capacity for up to 5 Amps (peak) motor drive current. In addition, there are two DRV8871 drivers that are controlled by the plug-in Arduino MKR 1000 Wi-Fi via I2C. The Arduino MKR 1000 Wi-Fi can be used to control the servo and DC motors, read the encoder signals, and read the battery voltage. For extended use or high-current motors, an extra heat sink might be required for the drivers.
When plugging the Arduino MKR 1000 Wi-Fi into the MKR motor carrier board, some of the Arduino MKR 1000 pins will no longer be available; they are used to control features of the carrier board. For example, the current feedback from the two MC33926 drivers is connected directly to some of the analog input pins on the MKR 1000 Wi-Fi board. To use the carrier board, we must plug an MKR board (the Arduino MKR 1000 Wi-Fi, MKR Zero, or other) onto the headers at the center of the Wi-Fi board, making sure it is connected in the proper direction. Check that the information printed on the side of the headers matches for both the Wi-Fi board and the carrier board.
Now, we can discuss the interface hardware for a DC-motor speed control mechatronic system. Figure 7.18 shows the hardware located in the information and physical domains, based on the mechatronic system architecture presented in Figure 7.1. The Arduino MKR 1000 Wi-Fi board is located in the information domain. Its 3.3V power is supplied by the Arduino MKR motor carrier board. This connection is completed by inserting the Wi-Fi board onto the carrier board.
In the information domain, a host computer with Simulink GUI is connected to the Arduino MKR 1000 Wi-Fi board through the local Wi-Fi network. The GUI can be calibrated through control buttons in real time. Both the host computer and the Wi-Fi board are connected. In addition, the host computer can also be connected to the Wi-Fi board through the mini-USB connection (not shown). This connection is used mainly to load the Simulink software to the Wi-Fi board.
To control the DC motor in a closed-loop, the Wi-Fi board sends the desired PWM duty and sign signals to the carrier board through the I2C communication (orange lines). The I2C communication is connected to the carrier board after the Wi-Fi board is inserted onto the carrier board. The motor speed encoder counts are also sent by the carrier board to the Wi-Fi board via an I2C communication protocol (orange lines).
The interface hardware is formed by the carrier board. The dedicated microcontroller on the carrier board reads the two-encoder pulse trains. It then transmits them to the Wi-Fi board through the I2C pins (SDA and SCL) on the designated pins. This allows the Wi-Fi board to access and process the encoder information.
The other task for the carrier board is to use the PWM motor control signals sent via the I2C communication to precisely control both the motor speed and direction. The signals are sent to the H-bridge drive of MC33926. The carrier board also converts the battery voltage to 3.3V power supply for the Wi-Fi board.
The physical domain has two main components: the battery and a DC motor with encoder. The battery supplies power to both the Wi-Fi and carrier boards. The DC motor with encoder has six pins. Two pins are associated positive and negative sides of the DC-motor armature winding. The other four pins help measure the motor shaft speed and direction. Within these four pins, two are for ground and 3.3V power supply. The other two are for the encoder pulse trains A and B (see Section 6.2). The Arduino MKR motor carrier board pin definition can be found in Figures 7.17 and 7.18 with detailed signal flow and wire connection definitions.
The control system block diagram essentially presents the mathematical relation of a mechatronic system without considering its power flow. As a result, details such as power amplification, signal transmission through serial communication, and signal A/D digital and D/A conversion errors due to digitization, are often ignored. However, when analyzing a digital control problem, consider the sample and hold process for the cases using zero-order sample and hold and other sample and hold situations [26], [27].
The control system block diagram of mechatronic systems can be divided into two groups. One is a continuous-time system block diagram; see Figure 7.19 for DC-motor speed control system. The other is a hybrid control system block diagram; see Figure 7.20 which combines a continuous-time physical system model with a discrete-time controller in the information domain. The continuous-time block diagram synthesizes the continuous-time controller and then discretizes it for implementation to the microcontroller. The hybrid block diagram enables designing a discrete-time controller directly.
Control theories are developed for synthesizing both continuous- and discrete-time systems. Most, practical physical systems are in the continuous-time domain. However, the system controllers are implemented into a microcontroller with a CPU or MPU. As a result, discrete-time controllers must be designed for implementation purposes.
There are two approaches for designing or synthesizing a discrete-time controller. The first approach uses the control system block diagram from Figure 7.19. Design the continuous-time controller, then discretize it to obtain a discrete-time controller based on the selected sample and hold such as zero-order sample and hold (see Section 4.2) [13]. The second approach is to design a discrete-time controller based directly on the control system diagram from Figure 7.20 [28]. This approach is preferred because discretizing a continuous-time controller could lead to additional error whereas the designed discrete-time controller can be directly implemented.
The next step is generating software for the mechatronic control system that can be implemented into a microcontroller. As an example, let’s look at a DC-motor speed control system to demonstrate how to use Simulink for a program that can be implemented into the Arduino MKR 1000 Wi-Fi microcontroller. In order to control the DC-motor speed, the Wi-Fi board needs to be properly connected to the carrier board. We can start programming the board using Simulink when the mini-UBS wire is connected to the Wi-Fi board. To control the DC motor with speed feedback, we must install the Simulink Arduino MKR library. For MATLAB 2024b, click the drop list of “Add-Ons” and select “Get Hardware Support Packages.” In the new window, select “Simulink Support Package for Arduino Hardware.” Then install the Simulink library package that includes Arduino MKR 1000 Wi-Fi and its motor carrier board.
When working with any DC motor, we need an external power source to feed the motor driver and power the motor. For the DC-motor speed control system, we can connect a LiPo battery to the MKR motor carrier board (see Figure 7.18). Adding a switch to turn the power on and off is recommended. Once power is connected, we can program in Simulink to regulate the DC-motor speed. Figure 7.21 shows the Simulink program as a block diagram. Now, let’s discuss this Simulink program step-by-step from right to left.
Consider the program for the MKR motor carrier board on the right. A DC motor is connected to it. The armature voltage in the form of a PWM signal is used to drive the motor in two directions, and encoder signals (pulses A and B) are collected for motor speed feedback. To make the closed-loop control system work, we must program the carrier board. From the Motor Drive board in the Simulink library, find the Arduino DC Motor Drive block and the Arduino Motor Encoder block. Configure the carrier board to include the wire connections for both the DC motor and encoder.
For this example, the software configuration is based on the wire connection of the DC motor and encoder shown in Figure 7.18. The DC-motor armature winding is connected to the M3 motor pins, and the motor encoder is connected to the encoder #1 pins. As a result, both the DC-motor drive and motor encoder blocks must be calibrated to reflect these wire connections. The left configuration window in Figure 7.22 is for the DC-motor drive selection, where the motor drive port can be selected through the drop-down list. For the DC-motor wiring shown in Figure 7.18, the motor drive was selected to be M3. The right configuration window shown in Figure 7.22 is for the motor encoder selection, where the encoder port can be selected through the drop-down list. For the DC-motor wiring shown in Figure 7.18, the encoder number was selected to be #1.
The encoder output in Figure 7.21 shows the current digital count updated with a given sample period. Here, the controller update period, \(T_s\), is input as the “sample time” shown in the right window of Figure 7.21. The feedback signal sample period matches the controller update period. In addition, the counter output increases as the motor shaft rotates clockwise and decreases as it rotates anticlockwise. The low-level software of the encoder block combines the two pulse trains (A and B) to generate one speed signal with a rational sign.
The speed control Simulink software shown in the left Simulink block diagram in Figure 7.21 can be divided into three parts. The first is the DC-motor speed calculation. The counter difference signal is an integer (32-bits) and needs to be converted into double (64-bits floating number) to be used in Simulink. After the conversion, the difference is divided by the sample period, \(T_s\) (second), to obtain a signal with a unit of pulse per second. Based upon the discussion in Section 6.2, for the selected motor, each motor output axis rotation leads to 1320 pulses. As a result, we can obtain the signal in pulse per second by dividing the counts by 1320 and then multiplying by 60 to obtain a motor speed signal \({\dot{θ}}_m\) in RPM (rotation per minute).
The second part of the block diagram is the reference speed signal \({\dot{θ}}_{ref}\). Subtracting the low-pass filtered motor axis speed \({\dot{θ}}_m\) from it generates the speed error signal for the PID controller. The low-pass filter (see Section 4.7) has a unit gain and a time constant of 0.2 second. In addition, we can develop certain GUI connections to change the reference signal \({\dot{θ}}_{ref}\) (not shown here). This makes modifying the motor reference speed easy. (See the mini-Segway and three-wheel cart software in Chapters 8 and 9 for detail.)
The third part of the diagram is a continuous-time PID controller. Constant blocks (\(K_p\), \(K_i\), and \(K_d\)) are PID control gains (proportional, integral, and derivative). They can be tuned to achieve the desired performance of closed-loop controlled motor speed based upon the tuning method described in Section 3.4. The integral used in the Simulink model is continuous-time, and the same for the derivative operation. To improve the efficiency of integration and derivative operations, the discrete-time integral and derivative should be implemented. A low-pass filter is used to smooth the error speed signal in the Simulink model. This reduces the noise generated by the derivative operation (see Section 3.4). The DC-motor drive block uses an integer number (PWM duty-cycle number) to generate the armature PWM signal for motor control. The double format of the PID controller output is automatically converted into the integer for the motor drive.
Understand how the software is executed in these target processors is helpful in the long run. Note that the motor drive and encoder counting is executed in the Arduino MKR motor carrier board. The MKR 100 Wi-Fi microcontroller board is executed through the I2C serial communication. The rest of the software is executed in the host computer with the Simulink software running in real-time. As a result, the speed reference signal \({\dot{θ}}_{ref}\) and PID gains (\(K_p\), \(K_i\), and \(K_d\)) can be adjusted in real-time by opening the associated Simulink constant block.
Section Summary
This section addresses the control system architecture for mechatronic systems. It uses an example of a DC-motor speed control, calling on the overall architecture for both hardware and software introduced in Section 7.1. The section presents the hardware of the DC-motor speed control system utilizing the Arduino MKR 1000 Wi-Fi microcontroller. To make this control system work, an additional DC-motor drive board, the Arduino MKR motor carrier board [12], is needed to drive the DC motor and collect the hall-effect speed sensor signals. Note that the Arduino MKR motor carrier board is open source. Next, the section introduces the Simulink motor control software. This software shows how the motor drive and hall-effect sensor input blocks in the Arduino Simulink library can be used to develop closed-loop control software utilizing the PID (proportional-integral- derivative) control [13].
Section Keywords
Arduino MKR motor carrier board: This add-on board is designed to control a variety of motors (servo, DC, and stepper) and to connect other sensors. Compatible with the Arduino MKR family, it provides connections for four servo motors, four DC motors (two high-performance and two standard), two encoder sensors, and four analog sensors.
Arduino Simulink library: This selection of Simulink blocks is specifically designed for interacting with Arduino hardware. These blocks enable configuration and access to Arduino sensors, actuators, and communication interfaces (e.g., I2C, SPI, serial).
Control system architecture: This structure comprises the physical hardware components and the software that organizes and controls them. The hardware components include sensors, microcontrollers, and actuators. The software architecture defines the overall structure.
PID DC-motor speed control: This control utilizes a feedback mechanism based on the difference between a desired motor speed and the actual speed. It continuously adjusts the armature voltage of a DC motor via a PID control signal.
Practice Problems
- What is the number of high-performance DC-motor drives provided by the Arduino MKR motor carrier board? Select the correct answer.
- 2
- 4
- 6
- The Arduino MKR 1000 Wi-Fi board sends the PWM motor control signal to the MKR motor carrier board via which of the following? Select the correct answer.
- I2C
- SPI
- Digital timer/counter channels
- The DC-motor encoder signal was sent to the Arduino MKR 1000 Wi-Fi board by the MKR motor carrier board via which of the following? Select the correct answer.
- I2C
- SPI
- Digital timer/counter channels
- List two approaches from this section used when a closed-loop mechatronic control software is to be implemented into an Arduino MKR microcontroller.
This page titled 7.4: Mechatronic Control System Architecture- Speed Control Example was last modified on Thu, 23 Jul 2026 03:46:29 GMT and is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Guoming Zhu (Co-DREAM OER) .
The book could not be loaded just now.