This article introduces how to use a PLC (Programmable Logic Controller) to control the myCobot 320 robotic arm. Based on continuous user feedback, there has been significant demand for integrating PLC with the myCobot system. Thus, this article aims to explain the process of achieving this integration.
Knowledge OverviewWhat is PLC?For those familiar with industrial-grade robotic arms, PLCs are likely a familiar concept. PLC stands for Programmable Logic Controller, an industrial digital computer designed specifically for controlling various machinery and production processes in industrial environments. Widely used in automation, PLCs are programmed to execute tasks such as logical control, sequential control, timing, counting, and arithmetic operations.
For a deeper understanding of PLCs, you can watch the following video:
By combining the flexibility of robotic arms with the stability and real-time capabilities of PLCs, tailored solutions can be developed for specific scenarios.
myCobot 320 M5The myCobot 320 is a 6-degree-of-freedom robotic arm available in two versions: one using the M5Stack-Basic as the embedded development board, and another using the Raspberry Pi 4B. Weighing just 3360g, the arm is lightweight and portable, making it convenient to carry. Its end effector can handle a maximum payload of 1000g, sufficient for most experimental scenarios. Additionally, users can attach cameras or actuators (such as grippers or suction pumps) to the end effector, leaving approximately 600g of remaining payload capacity. The arm's maximum working radius is 350mm, enabling flexible movement across various scenarios.
For more detailed information about myCobot 320, refer to the following article.
S7-1200The Siemens S7-1200 PLC is a compact, modular programmable logic controller designed for small to medium-sized automation projects. It offers high reliability, real-time performance, and flexible expandability. Supporting multiple industrial protocols (such as Profinet and Modbus), the S7-1200 includes an Ethernet interface for seamless integration with sensors, actuators, and other devices.
Programmed using the TIA Portal software, it supports ladder diagrams, function block diagrams, and other languages, making development and maintenance straightforward. Widely applied in industrial production, building automation, and mechanical control, it delivers stable and efficient control solutions.
Practical OperationWhen the robotic arm receives IO signals from the PLC, it performs a motion that resets all joints to their zero positions. This action primarily serves to establish communication between the two systems.
Principle Explanation:
1. The robotic arm's output port first sends a signal.
2. Once the PLC detects an input signal, it outputs a signal to power the 24V relay coil.
3. The normally open contact of the relay closes, transmitting a low-level signal to the robotic arm's input port.
4. When the robotic arm detects the input signal, it executes the motion to reset all its joints to their zero positions.
Hardware Connections
Wiring the robotic arm's input to the PLC's output
1. The PLC is a Siemens S7-1200, with an output type of PNP, while the robotic arm's input type is NPN. Therefore, an intermediate relay is required to convert the signals.
2. Connect the power supply to the PLC.
3. Connect the relay coil to the PLC’s common terminal and Q0.0.
4. Connect the normally open contact of the relay to a terminal.
5. Then connect the terminal to the robot’s IN1 input.
Wiring the robotic arm's output to the PLC's input
1. The PLC is a Siemens S7-1200, and its input type supports both PNP and NPN. The robotic arm’s output type is PNP, so the PLC input should use the PNP configuration.
2. Connect 24V to the PLC's input terminal.
3. Connect the robotic arm's GND and OUT1 to the PLC's common terminal and I0.0.
4. Insert the terminal into the robotic arm's output.
Robotic Arm Program
from pymycobot import MyCobot
import time
# Initialize the myCobot on COM port 8
mc = MyCobot("COM8")
# Set the basic output port 1 to low level (0)
mc.set_basic_output(1, 0)
# Infinite loop to monitor input signals
while 1:
# Check the status of input port 1
if mc.get_basic_input(1) == 0:
# If the input is low level (0), send angles to reset all joints to zero
mc.send_angles([0, 0, 0, 0, 0, 0], 50)
break # Exit the loop once the action is executed
else:
pass # Do nothing and continue checking
# Set the basic output port 1 to high level (1)
mc.set_basic_output(1, 1)
Siemens PLCs are renowned for their high stability, real-time capabilities, and resistance to interference, making them specifically designed for industrial environments. They are well-suited for factory automation, harsh environments, and complex workflows involving multiple devices. PLCs support standard industrial communication protocols such as Profinet and Modbus, enabling seamless integration with sensors, actuators, and other devices. This ensures that systems can operate stably over the long term with millisecond-level response times. For scenarios demanding high reliability, such as assembly line control, equipment synchronization, or factories with stringent environmental conditions, PLCs are the optimal choice.
Python, on the other hand, excels in development flexibility and efficiency. With its rich libraries and tools, Python is suitable for algorithm implementation, machine learning, and complex motion control applications. Python is more appropriate for research and experimental scenarios where new ideas can be quickly developed and validated. However, it is relatively weaker in real-time performance and adaptability to harsh environments, as it depends on the underlying hardware and operating system performance.
If the primary requirements are long-term stable operation, real-time control, and industrial environment integration, PLCs are the better choice. If the focus is on rapid development and algorithm flexibility, Python is more suitable. The two can also be combined, with Python handling high-level algorithms and PLCs managing low-level control, providing solutions for a broader range of applications.
Comments