How to Equip an Arduino Opta DC Motor Controller with HMI

Sep 02, 2024

How to Equip an Arduino Opta DC Motor Controller with HMI

The Arduino Opta micro programmable logic controller (PLC) provides a unique entry point into the automation field. Automation fields like smart homes, process controls, and robotics are project areas that can be explored with the Arduino Opta. The Arduino Opta, with its small size of 88.8 mm x 70 mm x 56.8 mm, makes it convenient to fit industrial panels. Like other PLCs, the Arduino Opta has mechanical provisions on the back, allowing it to mount easily inside a control panel or board using DIN rails. In this Maker.io project, you will build a DC motor controller with a pushbutton switch and an M5Stack Core. The M5Stack Core will work as a programmable human machine interface (HMI), thus extending the control capabilities of the Arduino Opta with the DC motor.

Arduino Opta electrical specifications overview

The Arduino Opta is a powerful micro-PLC capable of managing a variety of digital, analog, and electromechanical devices and automation systems. The Arduino Opta uses an ST STM32H747XI processor. The STM32H747XI dual-core processor allows fast computation speeds for industrial or process control applications. The Opta has 2 MB of flash memory and 1 MB of programmable memory RAM. Further, the Arduino Opta can process analog and digital input data. The micro-PLC has eight analog/digital inputs and four electromechanical relays (EMRs). For the project build, one digital input and one EMR will be used to operate a DC motor. Lastly, the power supply voltage has a range of 12 – 24 V DC. For the project, a 12 V DC at 1 A can be used to power the Arduino Opta.

Related:What Is OpenPLC?

STM32H747XI processor block diagram. IMAGE COURTESY OF ST

Arduino Opta micro-PLC pinout. IMAGE COURTESY OF ARDUINO

The Arduino Opta has three versions of PLCs. The three versions consist of the Lite, the RS485, and connectivity units. The connectivity units are Bluetooth, Wi-Fi, and Ethernet. The connectivity allows various communication approaches to control the Opta and the attached I/O devices connected to the PLC. The Opta Lite will be used in the DC motor controller project.

The Arduino Opta DC motor controller with an HMI: The concept

The Arduino Opta DC motor controller with an HMI concept consists of several components properly connected to operate a DC motor. The system concept uses two separate controllers: the Arduino Opta PLC to receive input control signals and to operate the DC motor, and the M5Stack Core that provides the input control signal to command the Arduino Opta PLC to operate the DC motor. Each programmable device's control software is independent, creating a distributed control platform. The interface method for allowing the M5Stack Core and the Arduino Opta PLC to operate together is a physical hardware connection. The bill of materials (BOM) for the Arduino Opta DC motor controller with an HMI project can be obtained from DigiKey

Related:AI Allows Modeling PLC Programs at the Component Level

The Arduino Opta DC motor controller with an HMI system block diagram concept.  DR. DON WILCHER

Programming the M5Stack Core

The M5Stack Core is an ESP32 microcontroller-based device. It has three programmable pushbuttons; two red, green, and blue (RGB) LED bars; a mini audio speaker; and a thin film transistor (TFT LCD). The M5Stack Core has three programmable ports capable of interfacing with various electrical and electronic modules. The ports are labeled A, B, and C. Port A is I2C capable. Port B supports digital general input/output electrical connectivity. Port C provides UART communication. 

The M5Stack Core’s Port A will provide the input control signal to the Arduino Opta using a UiFlow Blockly code program to operate an electromechanical relay’s (EMR) single-pole-single throw (SPST) contact. The EMR’s SPST contact will provide a 12 V DC control signal to the Arduino Opta’s I1 input terminal. An M5Stack 2Channel Relay will connect to Port A to provide the switching control signal to initiate the Arduino Opta  PLC ladder diagram (LD) program. The UiFlow Blockly code software is used to program the M5Stack Core. The UiFlow software can be downloaded from the following site here.

UiFlow Software. IMAGE COURTESY OF M5STACK

Connect the M5Stack Core to an available USB port on your laptop computer or desktop personal computer (PC) using a USB C cable. Once the software has been installed on your laptop computer or desktop PC, the UiFlow Blockly code IDE can open it. Select the COM port where your M5Stack Core is connected. If the COM port is unknown, the device manager will locate it. Silicon Labs CP210x will be the communication port software driver installed on your laptop computer or desktop PC. Click the OK button to open the UiFlow Blockly Code IDE.

Device manager identifying the M5Stack Core COM port.  DR. DON WILCHER

Selecting the COM port for the M5Stack Core.  DR. DON WILCHER

With the UiFlow Blockly Code software open, you may begin selecting the blocks to build the Jog Switch UI. On the left side of the UiFlow IDE, select and drag the Label tag to the virtual M5Stack Core TFT LCD screen. Center the label tag and click it with the left mouse button. A user interface (UI) box will be displayed next to the virtual M5Stack Core. In the text box, type Jog Switch. Click the font drop down box arrow and select DejaVuSans 40. The M5Stack Core will display the new text on the virtual M5Stack Core TFT LCD.

The M5Stack Core UI – Jog Switch text.  DR. DON WILCHER

Repeat the Jog Switch text steps to add the START text to the M5Stack Core TFT LCD.

The M5Stack Core UI – START text.  DR. DON WILCHER

The final step to programming the M5Stack Core is to build the Blockly code blocks. For M5Stack 2 Channel Relay to operate, its unit needs to be added to the IDE environment. With the mouse, click the + sign underneath the Units label. A window will appear on the screen. Scroll, find, and select the 2-Relay Unit. Click the OK button to place the 2-Relay Unit onto the IDE.

2-Relay Unit added to the UiFlow Blockly Code IDE.  DR. DON WILCHER

Next, Button A_was pressed and relay2_0 control blocks will be added to the UiFlow Blockly code IDE. The Button A_was pressed code block is in the Events bin. The relay2_0 control block will be found in the Units bin. Build the code provided in the diagram and set the operation parameters as shown. With the Blockly code built, click the RUN button on the IDE to program the M5Stack Core. The Jog Switch and START text will be displayed on the M5Stack Core TFT LCD. 

The M5Stack Core Blockly Code program. DR. DON WILCHER

Wiring the Arduino Opta DC motor controller system

Wiring the DC motor controller system is quite easy to do. With the project BOM components available, use the electronic circuit schematic diagram to wire the Arduino DC motor controller system. Use appropriate size gauge wires for electrically connecting the components appropriately. The M5Stack 2Relay Module is shown as a 2 Channel SPST relay. The 2Relay Module will be attached to the M5Stack Core module using a mini-4-wire jumper harness. The 2Relay module will be attached to Port A of the M5Stack Core using the mini-4 wire jumper harness.

Arduino Opta DC motor with M5Stack HMI controller electronic circuit schematic diagram.  DR. DON WILCHER

Upon completion of the electrical wiring, the Arduino Opta DC motor controller with HMI system should look like the image shown below.

The assembled Arduino Opta DC motor with M5Stack HMI controller.  DR. DON WILCHER

Programming the Arduino Opta micro-PLC

The Arduino Opta micro-PLC can be programmed using a ladder diagram (LD). The LD is one of the five programming languages specified in the International Electrotechnical Commission (IEC) 61131-3 specification. The Arduino Opta can also be programmed using a sketch. The sketch, a C++ programming language used within the Arduino microcontroller-based platform ecosystem, is the common approach that makers, educators, students, and engineers use. The traditional Arduino IDE can be used to program the Opta or the PLC IDE. The Arduino IDE will be used to program the Opta PLC for this project.

The code for the Arduino Opta micro-PLC is a basic sketch that allows the industrial controller to operate an EMR. The EMR will turn ON or OFF the DC motor upon receiving an input control signal from the I1 terminal of the Arduino Opta. With the M5Stack Core’s EMR or pushbutton switch contacts wired to the +12 V DC rail, this control signal is read by the Arduino Opta code to command the DC motor. 

Arduino Opta DC motor controller C++ code.  DR. DON WILCHER

With the C++ code uploaded to the Arduino Opta PLC, pressing pushbutton switch will turn on the DC motor. The M5Stack Core will allow the DC motor to jog or run for 5 seconds with every press of its UI based START button. A video clip showing the completed project in operation may be watched here and below.

Congratulations on successfully building the Arduino Opta DC motor controller with HMI. As a design challenge, modify the M5Stack Block code to provide an OFF-control function for the DC motor. Explore controller the Opta’s other EMRs and LEDs, by modifying the C++ code. Further, try programming the Opta using the Arduino PLC IDE to operate the DC motor. Happy PLC programming!