Skip to content

A GUI Application for the DC Motor Controller

The graphical user interface (GUI) connects with a DC motors controller and visualizes the current, the speed, and the position of the motor. It can be also used to tune and validate the controller. I have written the application in C++ and used Qt and Qwt libraries.

Introduction — the motor controller device

The application is a user interface for the motors controller for up to four DC motors, that I showed some time ago. The motor controller is equipped with an NXP Kinetis microcontroller and can handle up to four incremental encoders. In addition, it was equipped with four digital inputs (DI) and four digital outputs (DO).

GUI functionalities

Main window

The main window shows the current state of each motor, like the current, the velocity, and the position. It contains four bookmarks with different functionalities: control, settings, regulators, and generator.

Control

  • Allows controlling each motor, for example manually with a keyboard.
  • Is used to change the state of DO.

Settings

  • Allows configuring the encoders resolutions.
  • Contains the configuration related to the robot kinematics – used for odometry calculation purposes.
  • It’s used to set the limits of the motors current, velocity or position.

Regulators

  • Settings of PI (proportional-integral) or PID (proportional-integral-derivative) regulators.
  • The device uses the cascade control approach that consists of three controllers: controller loop, velocity loop, and position loop. Each stage can be configured separately.

Signals generator

  • The signal generator is used to create a reference signal for the motor controllers.
  • It allows to generate a sinusoidal signal, a square signal, a triangle signal, or a step.
  • The amplitude, period and, offset of the signal can be adjusted.

Plotting the current, speed, or position

Almost each process value can be plotted in separate windows. All plots are handled in different threads, so it works quite fast. The Plot button allows opening of multiple, separate windows for plotting. Below are a few examples of plotted signals during the control of the motor.



Four motors positions tracking at once.

How it can be used to better tune the motor controller?

  • The plot can be used to analyze the dynamic response of the controller. Based on the visualized data you can confirm that the set value is achieved and tracked all the time.
  • Furthermore, you can generate the step signal from the signal generator and check if the controller response is correct.
  • Another useful feature is the monitoring of the error between the set value and the process value (actual value). It’s especially useful in the validation of the controller response when the motor has some kind of load attached.

Implementation details

  • As mentioned before, it’s implemented in C++ with Qt and Qwt libs.
  • The GUI uses the same API as the ROS node that also can be used with the motor controller.
  • The application uses multithreading, especially for plots generation.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.