A control device and control method of embedded PLC based on STM32

By integrating control and communication functions on the STM32 platform, it solves the problems of traditional PLC structure decentralization and technical closure, achieves high openness and flexibility of embedded PLC, reduces costs, and improves real-time operation through cycle scanning function and FreeRTOS ability.

CN114740794BInactive Publication Date: 2024-10-22KUNMING UNIV OF SCI & TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202210240464.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-10
Publication Date
2024-10-22
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional PLC has the problems of dispersed structure, closed technology, poor scalability, poor compatibility and high price, making it difficult to meet the needs of modern industrial control.

Method used

Design an embedded PLC device based on STM32, integrating control and communication on the same hardware platform, using a top-down core circuit board and signal circuit board, through the microprocessor minimum system module, user program storage module, communication The modules, digital input/output modules, analog modules and power modules are connected to each other to achieve higher openness and flexibility, and realize the control function of the PLC through cyclic scanning of the main program and the FreeRTOS real-time operating system.

Benefits of technology

It achieves higher combination flexibility and space usage, reduces the cost of embedded PLC, simplifies code operations, and realizes the practicality of a real-time operating system through the loop scanning function and FreeRTOS.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114740794B_ABST
    Figure CN114740794B_ABST
Patent Text Reader

Abstract

The present invention relates to a control device and control method of an embedded PLC based on STM32, comprising a main control module for interpreting a PLC program transmitted from a host computer and executing corresponding operation instructions; a digital quantity input module for inputting digital quantities of the device; a digital quantity output module for outputting digital quantities of the device; a communication module for communicating between the device and a host computer or other devices; an analog quantity module and a power supply module. The device uses a FreeRTOS real-time operating system to implement the cyclic scanning work of the PLC; uses the internal resources of STM32 to implement the internal soft components, data definition and instruction system of the PLC, implements PID control and self-tuning functions, and realizes the conversion from the PLC programming language to the C language. The conversion from MCU-oriented programming to PLC-oriented programming is completed, and the conversion from C language programming to instruction table language programming is realized, thereby reducing the programming difficulty. The present invention realizes the digital quantity input and output function, analog quantity input and output function, and communication function of the PLC through STM32.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a control device and a control method based on an embedded PLC of STM32, belonging to the field of automatic control. Background Art

[0002] Programmable controller is a general industrial automatic control device developed with microprocessor as the core, integrating computer technology, automatic control technology and communication technology. It has a series of advantages such as high reliability, small size, strong function, simple program design, flexible and universal, easy maintenance, etc. Therefore, it is widely used in metallurgy, energy, chemical industry, transportation, electricity and other fields, and has become one of the three pillars of modern industrial control (PLC, robot and CAD / CAM). However, PLC also has its own shortcomings, such as decentralized structure, closed technology, poor scalability, poor compatibility and high price. With the development of science and technology network and microprocessor, traditional PLC has been increasingly unable to meet the needs of industrial development. Traditional PLC with a glorious past will appear and develop under the impact of social diversification, automation and continuous progress of embedded technology. However, embedded PLC at home and abroad is in the early stage of development, which is one of the breakthroughs for my country to break the foreign monopoly. Therefore, it is of great significance to develop embedded PLC. Summary of the invention

[0003] The purpose of the present invention is to solve one or more of the above-mentioned defects and design an embedded PLC device based on STM32, which integrates control, communication, etc. on the same hardware platform and can run on different hardware by simply modifying the system program. Compared with traditional PLC, it has higher openness, flexibility and lower price.

[0004] The technical scheme adopted by the present invention is: an embedded PLC device based on STM32, comprising a core circuit board and a signal circuit board which are arranged from top to bottom, the signal circuit board is electrically connected to the core circuit board, a microprocessor minimum system module, a user program storage module and a communication module are arranged on the core circuit board, a digital quantity input module, a digital quantity output module, an analog quantity module and a power supply module are arranged on the signal circuit board, the digital quantity input module, the digital quantity output module, the analog quantity module and the communication module are all connected with the microprocessor minimum system module, a PLC control system is embedded in the microprocessor minimum system module, and the PLC control system comprises a cyclic scanning main program.

[0005] Specifically, the microprocessor minimum system module includes a microprocessor STM32 single-chip microcomputer, a crystal oscillator circuit, and a reset circuit, and a PLC control system is embedded in the STM32 single-chip microcomputer.

[0006] Specifically, the user program storage module includes a 24C128EEPROM, and the connection method is that the PB8 pin and the PB9 pin of the STM32 microcontroller are respectively connected to the SCL pin and the SDA pin of the 24C128EEPROM.

[0007] Specifically, the communication module includes an Ethernet communication circuit, an RS485 communication circuit, and a CAN bus communication circuit. The Ethernet communication circuit uses a LAN8720A chip as an Ethernet physical layer transceiver, the RS485 communication circuit uses an SSP3485 chip as a transceiver, and the CAN bus communication circuit uses an HGA1050M / TR chip as a transceiver.

[0008] Specifically, the digital input module includes 8 identical ordinary digital input circuits and 4 identical high-speed digital input circuits. The ordinary digital input circuit includes a PC817 optocoupler U12 as an isolation chip, and the high-speed digital input circuit uses a 6N317 high-speed optocoupler U8 as an isolation circuit.

[0009] Specifically, the digital quantity output module includes 8 identical relay output circuits and 4 identical transistor output circuits.

[0010] The relay output circuit of channel 1 includes: PC817 optocoupler U12, resistor R31, resistor R32, resistor R36, SS8050 transistor Q12, G5NB-1A relay JK8;

[0011] The relay output circuit connection method is as follows:

[0012] Pin 2 of PC817 optocoupler U12 is connected to STM32 microcontroller, pin 1 of PC817 optocoupler U12 is connected to one end of resistor R31, the other end of resistor R31 is connected to the positive electrode of 3.3V power supply, pin 4 of PC817 optocoupler U12 is connected to one end of resistor R32, the other end of resistor R32 is connected to the positive electrode of 3.3V power supply, base b of SS8050 transistor Q12 is connected to pin 3 of PC817 optocoupler U12, emitter e of SS8050 transistor Q12 is grounded, resistor R36 is connected in parallel with base b and emitter e of SS8050 transistor Q12, pin 1 of G5NB-1A relay JK8 is connected to collector c of SS8050 transistor Q12, pin 4 of G5NB-1A relay JK8 is connected to the positive electrode of 5V power supply, pin 2 and pin 3 of G5NB-1A relay JK8 are used as common terminal and output terminal respectively.

[0013] The transistor output circuit of channel 1 includes: 6N137 high-speed optocoupler U8, resistor R24, resistor R20, capacitor C4, resistor R28, 2SA954 transistor Q8, 1N4148 diode D4;

[0014] The transistor output circuit connection circuit is as follows:

[0015] Pin 3 of 6N137 high-speed optocoupler U8 is connected to STM32 microcontroller, pin 2 of 6N137 high-speed optocoupler U8 is connected to one end of resistor R24, the other end of resistor R24 ​​is connected to the positive electrode of 3.3V power supply, pin 5 of 6N137 high-speed optocoupler U8 is grounded, pin 8 of 6N137 high-speed optocoupler U8 is connected to the positive electrode of 5V power supply, pin 7 of 6N137 high-speed optocoupler U8 is connected to one end of resistor R20, the other end of resistor R20 is connected to the positive electrode of 5V power supply, one end of capacitor C4 is connected to 5V The positive pole of the power supply is connected to the ground, and the other end is grounded. Pin 6 of the 6N137 high-speed optocoupler U8 is connected to pin 1 of the 2SA954 transistor Q8. Resistor R28 is connected in parallel with pins 1 and 2 of the 2SA954 transistor Q8. The positive pole of the 1N4148 diode D4 is connected to pin 3 of the 2SA954 transistor Q8, and the negative pole of the 1N4148 diode D4 is connected to pin 2 of the 2SA954 transistor Q8. Pins 2 and 3 of the 2SA954 transistor Q8 are used as the output end and the common end respectively.

[0016] Specifically, the analog quantity module includes an analog quantity input circuit and an analog quantity output circuit, and both circuits use an LM358 operational amplifier.

[0017] Specifically, the power module inputs 24VDC power and outputs 5V and 3.3V voltages to power the core circuit board and the signal circuit board.

[0018] A control method of the embedded PLC device based on STM32, the specific steps of cyclic scanning main program are:

[0019] Step S100: Initialize the system;

[0020] Step S200: Execute the communication task: The STM32 microcontroller obtains the PLC programming instructions of the external user through the communication module, and stores the obtained user instructions in the user program storage module;

[0021] Step S300: Input refresh task: input the data in the digital input module and save it to the input image register of the STM32 microcontroller;

[0022] Step S400: Execute user program task: The STM32 MCU first reads the user instructions in the user program storage module and stores them in the internal logic stack, then combines the data in the digital input module, matches the user instructions through the switch instruction, and then converts the user's PLC programming instructions into C language programs, and then the STM32 MCU executes the corresponding C language programs;

[0023] Step S500: Output refresh program: After the STM32 MCU executes the user instruction, it outputs the status instruction to the output image register in the STM32 MCU, and then the STM32 MCU scans the state of each output relay in the output image register, and outputs the corresponding value to the digital output module according to its state, and finally re-enters step S200, refreshes the task, and executes it in a loop.

[0024] The beneficial effects of the present invention are:

[0025] (1) The present invention is composed of two layers of PCB boards. Compared with the embedded PLC with a whole PCB board commonly seen on the market, it has higher combination flexibility and can effectively save the area occupied by the embedded PLC and increase space utilization.

[0026] (2) The internal soft appliances in the present invention are stored in the bit band area of ​​the chip, and the internal soft appliance registers can be directly read and written through bit band operations, making the code more concise and the operation more convenient.

[0027] (3) The cyclic scanning function of the present invention is realized by the FreeRTOS real-time operating system. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 It is the overall structure diagram of embedded PLC;

[0029] Figure 2 It is a digital quantity input module; (a) is a common digital quantity input circuit diagram, (b) is a high-speed digital quantity input circuit diagram;

[0030] Figure 3 It is a digital output module; (a) is a relay output circuit diagram, (b) is a high-speed transistor output circuit diagram;

[0031] Figure 4 It is an analog module; (a) is an analog input circuit, and (b) is an analog output circuit;

[0032] Figure 5 It is a power module; (a) is a 24V to 5V circuit diagram, (b) is a 5V to 3.3V circuit diagram;

[0033] Figure 6 This is a flow chart of PLC cycle scanning;

[0034] Figure 7 It is the push and pop operation of the logical stack; (a) is the push operation, (b) is the pop operation;

[0035] Figure 8 It is the task flow chart for executing user programs. DETAILED DESCRIPTION

[0036] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0037] Example 1: Figure 1-8 As shown, an embedded PLC device based on STM32 includes a core circuit board and a signal circuit board arranged from top to bottom. The signal circuit board is electrically connected to the core circuit board through a pin header. The core circuit board is provided with a microprocessor minimum system module (i.e. Figure 1 The signal circuit board is provided with a digital input module, a digital output module, an analog module and a power supply module. The digital input module, the digital output module, the analog module and the communication module are all connected to the microprocessor minimum system module. The microprocessor minimum system module is embedded with a PLC control system. The PLC control system includes a cyclic scanning main program.

[0038] Furthermore, the microprocessor minimum system module includes a microprocessor STM32 single-chip microcomputer, a crystal oscillator circuit, and a reset circuit. The STM32 single-chip microcomputer is specifically STM32F407GZT6, and a PLC control system is embedded therein.

[0039] Furthermore, the user program storage module includes a 24C128EEPROM, and the connection mode is that the PB8 pin and the PB9 pin of the STM32 microcontroller are respectively connected to the SCL pin and the SDA pin of the 24C128EEPROM, which is used to store the user program transmitted from the host computer or other devices. The 24C128EEPROM has a storage capacity of 128KB and is used to store PLC user instructions.

[0040] Furthermore, the communication module includes an Ethernet communication circuit, an RS485 communication circuit, and a CAN bus communication circuit. The Ethernet communication circuit uses a LAN8720A chip as an Ethernet physical layer transceiver. The Ethernet communication of the present invention uses the LWIP protocol, which is a small TCP / IP protocol stack. It only requires a dozen KB of RAM and about 40K of ROM to run, and can run in the FreeRTOS operating system. The communication between the PLC and the host computer is realized through Ethernet communication. The RS485 communication circuit uses an SSP3485 chip as a transceiver, with a maximum transmission speed of up to 10Mbps, supporting up to 32 nodes, and the CAN bus communication circuit uses an HGA1050M / TR chip as a transceiver.

[0041] Furthermore, the digital quantity input module includes 8 identical common digital quantity input circuits and 4 identical high-speed digital quantity input circuits, such as Figure 2As shown, Figure (a) is a common digital input circuit, which uses PC817 optocoupler U12 as an isolation chip for photoelectric isolation; Figure (b) is a high-speed digital input, which uses 6N317 high-speed optocoupler U8 high-speed optocoupler for photoelectric isolation.

[0042] Furthermore, the digital output module includes 8 identical relay output circuits and 4 identical high-speed transistor output circuits. Figure 3 As shown, Figure (a) is a relay output circuit diagram, which uses a PC817 optocoupler to drive the relay, can drive a larger load, and can drive both DC loads and AC loads; Figure (b) is a high-speed transistor output circuit diagram, which uses a 6N137 high-speed optocoupler to drive the transistor, and the 1N4184 diode can prevent the transistor from being reversely broken down.

[0043] The relay output circuit of channel 1 includes: PC817 optocoupler U12, resistor R31, resistor R32, resistor R36, SS8050 transistor Q12, G5NB-1A relay JK8;

[0044] The relay output circuit connection method is as follows:

[0045] Pin 2 of PC817 optocoupler U12 is connected to STM32 microcontroller, pin 1 of PC817 optocoupler U12 is connected to one end of resistor R31, the other end of resistor R31 is connected to the positive electrode of 3.3V power supply, pin 4 of PC817 optocoupler U12 is connected to one end of resistor R32, the other end of resistor R32 is connected to the positive electrode of 3.3V power supply, base b of SS8050 transistor Q12 is connected to pin 3 of PC817 optocoupler U12, emitter e of SS8050 transistor Q12 is grounded, resistor R36 is connected in parallel with base b and emitter e of SS8050 transistor Q12, pin 1 of G5NB-1A relay JK8 is connected to collector c of SS8050 transistor Q12, pin 4 of G5NB-1A relay JK8 is connected to the positive electrode of 5V power supply, pin 2 and pin 3 of G5NB-1A relay JK8 are used as common terminal and output terminal respectively.

[0046] The transistor output circuit of channel 1 includes: 6N137 high-speed optocoupler U8, resistor R24, resistor R20, capacitor C4, resistor R28, 2SA954 transistor Q8, 1N4148 diode D4;

[0047] The transistor output circuit connection circuit is as follows:

[0048] Pin 3 of 6N137 high-speed optocoupler U8 is connected to STM32 microcontroller, pin 2 of 6N137 high-speed optocoupler U8 is connected to one end of resistor R24, the other end of resistor R24 ​​is connected to the positive electrode of 3.3V power supply, pin 5 of 6N137 high-speed optocoupler U8 is grounded, pin 8 of 6N137 high-speed optocoupler U8 is connected to the positive electrode of 5V power supply, pin 7 of 6N137 high-speed optocoupler U8 is connected to one end of resistor R20, the other end of resistor R20 is connected to the positive electrode of 5V power supply, one end of capacitor C4 is connected to 5V The positive pole of the power supply is connected to the ground, and the other end is grounded. Pin 6 of the 6N137 high-speed optocoupler U8 is connected to pin 1 of the 2SA954 transistor Q8. Resistor R28 is connected in parallel with pins 1 and 2 of the 2SA954 transistor Q8. The positive pole of the 1N4148 diode D4 is connected to pin 3 of the 2SA954 transistor Q8, and the negative pole of the 1N4148 diode D4 is connected to pin 2 of the 2SA954 transistor Q8. Pins 2 and 3 of the 2SA954 transistor Q8 are used as the output end and the common end respectively.

[0049] Furthermore, the analog module includes an analog input circuit and an analog output circuit, and both circuits use an LM358 operational amplifier. Figure 4 As shown, Figure (a) is the analog input circuit diagram, which can directly perform 0-10V analog input; Figure (b) is the analog output circuit diagram, which can directly perform 0-10V analog output. Analog input and output do not participate in the cycle, and will only be turned on or off when analog control instructions appear in the user program; that is, only when the user needs to perform analog control, the STM32 microcontroller will perform analog input or output through the analog module.

[0050] Furthermore, the power module inputs 24VDC power and outputs 5V and 3.3V voltages to power the core circuit board and the signal circuit board. Figure 5 As shown in the figure, the input 24VDC is powered by the entire PLC system after two voltage drops. The first voltage drop is from 24V to 5V after passing through the LM2596S-5.0 voltage regulator chip, anti-interference and protection measures, as shown in the figure. Figure 5 (a), the second voltage drop is from 5V to 3.3V through the AMS1117-3.3 voltage regulator chip, such as Figure 5 (b).

[0051] A control method of the embedded PLC device based on STM32, the specific steps of cyclic scanning main program are:

[0052] Step S100: Initialize the system, including initializing the PLC input and output interface, initializing the PLC timer, initializing the counter, initializing the Ethernet interface, establishing the task function, etc.;

[0053] Step S200: Execute the communication task: The STM32 microcontroller obtains the PLC programming instructions of the external user through the communication module, and stores the obtained user instructions in the user program storage module;

[0054] Step S300: Input refresh task: input the data in the digital input module and save it to the input image register of the STM32 microcontroller, specifically: the STM32 microcontroller sequentially scans the state of each input terminal of the digital input module, and then stores the state of the input terminal to the input image register, wherein the input image register is stored in the bit band area of ​​the STM32, and the user program can read the state of the input terminal in the input image register through the bit band operation;

[0055] Step S400: Execute user program tasks: Figure 8 The figure shows the task flow chart of executing the user program. After entering the task, the STM32 microcontroller first reads the user instructions in the user program storage module and stores them in the internal logic stack, then combines the data in the digital input module, matches the user instructions through the switch instruction, and then converts the user's PLC programming instructions into C language programs, and then the STM32 microcontroller executes the corresponding C language programs;

[0056] The user program is a digital code that can be recognized by the PLC, corresponding to the operation code and operand written by the host computer or other equipment. Table 1 shows the codes corresponding to some operation codes and operands.

[0057] Table 1: Some opcodes and operands corresponding to the encoding

[0058]

[0059] The logic stack is designed according to the principle of "first in, last out". In this embodiment, the stack depth of the logic stack is 64. Figure 7 , Figure a is the push operation, and Figure b is the pop operation.

[0060] Step S500: Output refresh program: After the STM32 single-chip microcomputer executes the user instruction, it will output the status instruction to the output image register in the STM32 single-chip microcomputer through the bit-band operation (the output image register is stored in the bit-band area of ​​​​the STM32), and then the STM32 single-chip microcomputer scans the state of each output relay in the output image register, and outputs the corresponding value to the digital output module according to its state (the digital output module will output specific control instructions to the specific components connected to it), and finally re-enter step S200, refresh the task, and execute in a loop.

[0061] In the present invention, the cyclic scanning main program is implemented by FreeRTOS real-time operating system. The user's PLC programming instructions include basic instructions, input relay instructions, output relay instructions, intermediate relay instructions, bit logic instructions, timer and counter instructions, data processing instructions, analog quantity processing instructions, etc.

[0062] The present invention uses the FreeRTOS real-time operating system to implement the cyclic scanning work of the PLC; uses the internal resources of the STM32 to implement the internal soft components, data definition and instruction system of the PLC, realizes the PID control and self-tuning functions, and realizes the conversion from the PLC programming language to the C language. The conversion from MCU-oriented programming to PLC-oriented programming is completed, and the conversion from C language programming to instruction table language programming is realized, which reduces the programming difficulty.

[0063] The specific implementation modes of the present invention are described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above implementation modes. Various changes can be made within the knowledge scope of ordinary technicians in this field without departing from the purpose of the present invention.

Claims

1. An embedded PLC device based on STM32, characterized in that: It includes a core circuit board and a signal circuit board arranged from top to bottom, the signal circuit board is electrically connected to the core circuit board, a microprocessor minimum system module, a user program storage module, and a communication module are arranged on the core circuit board, a digital quantity input module, a digital quantity output module, an analog quantity module, and a power supply module are arranged on the signal circuit board, the digital quantity input module, the digital quantity output module, the analog quantity module, and the communication module are all connected to the microprocessor minimum system module, a PLC control system is embedded in the microprocessor minimum system module, and the PLC control system includes a cyclic scanning main program; The microprocessor minimum system module includes a microprocessor STM32 single-chip microcomputer, a crystal oscillator circuit, and a reset circuit, and a PLC control system is embedded in the STM32 single-chip microcomputer; The user program storage module includes a 24C128EEPROM, and the connection method is that the PB8 pin and the PB9 pin of the STM32 microcontroller are respectively connected to the SCL pin and the SDA pin of the 24C128EEPROM; The communication module includes Ethernet communication circuit, RS485 communication circuit and CAN bus communication circuit. The Ethernet communication circuit uses LAN8720A chip as Ethernet physical layer transceiver, the RS485 communication circuit uses SSP3485 chip as transceiver, and the CAN bus communication circuit uses HGA1050M / TR chip as transceiver. The digital quantity input module includes 8 identical common digital quantity input circuits and 4 identical high-speed digital quantity input circuits. The common digital quantity input circuit includes a PC817 optocoupler U12 as an isolation chip, and the high-speed digital quantity input circuit uses a 6N317 high-speed optocoupler U8 as an isolation circuit. The digital output module includes 8 identical relay output circuits and 4 identical transistor output circuits; The relay output circuit of channel 1 includes: PC817 optocoupler U12, resistor R31, resistor R32, resistor R36, SS8050 transistor Q12, G5NB-1A relay JK8; The relay output circuit connection method is as follows: Pin 2 of PC817 optocoupler U12 is connected to STM32 microcontroller, pin 1 of PC817 optocoupler U12 is connected to one end of resistor R31, the other end of resistor R31 is connected to the positive electrode of 3.3V power supply, pin 4 of PC817 optocoupler U12 is connected to one end of resistor R32, the other end of resistor R32 is connected to the positive electrode of 3.3V power supply, base b of SS8050 transistor Q12 is connected to pin 3 of PC817 optocoupler U12, emitter e of SS8050 transistor Q12 is grounded, resistor R36 is connected in parallel with base b and emitter e of SS8050 transistor Q12, pin 1 of G5NB-1A relay JK8 is connected to collector c of SS8050 transistor Q12, pin 4 of G5NB-1A relay JK8 is connected to the positive electrode of 5V power supply, pin 2 and pin 3 of G5NB-1A relay JK8 are used as common terminal and output terminal respectively; The transistor output circuit of channel 1 includes: 6N137 high-speed optocoupler U8, resistor R24, resistor R20, capacitor C4, resistor R28, 2SA954 transistor Q8, 1N4148 diode D4; The transistor output circuit connection circuit is as follows: Pin 3 of 6N137 high-speed optocoupler U8 is connected to STM32 microcontroller, pin 2 of 6N137 high-speed optocoupler U8 is connected to one end of resistor R24, the other end of resistor R24 ​​is connected to the positive electrode of 3.3V power supply, pin 5 of 6N137 high-speed optocoupler U8 is grounded, pin 8 of 6N137 high-speed optocoupler U8 is connected to the positive electrode of 5V power supply, pin 7 of 6N137 high-speed optocoupler U8 is connected to one end of resistor R20, the other end of resistor R20 is connected to the positive electrode of 5V power supply, one end of capacitor C4 is connected to 5V The positive pole of the power supply is connected to the ground at the other end. Pin 6 of the 6N137 high-speed optocoupler U8 is connected to pin 1 of the 2SA954 transistor Q8. The resistor R28 is connected in parallel with pins 1 and 2 of the 2SA954 transistor Q8. The positive pole of the 1N4148 diode D4 is connected to pin 3 of the 2SA954 transistor Q8. The negative pole of the 1N4148 diode D4 is connected to pin 2 of the 2SA954 transistor Q8. Pins 2 and 3 of the 2SA954 transistor Q8 are used as the output terminal and the common terminal respectively. The analog quantity module includes an analog quantity input circuit and an analog quantity output circuit, both circuits use an LM358 operational amplifier; The power module inputs 24VDC power and outputs 5V and 3.3V voltages to power the core circuit board and the signal circuit board.

2. A control method for an embedded PLC device based on STM32 according to claim 1, characterized in that: The specific steps of the cyclic scanning main program are: Step S100: Initialize the system; Step S200: Execute the communication task: The STM32 microcontroller obtains the PLC programming instructions of the external user through the communication module, and stores the obtained user instructions in the user program storage module; Step S300: Input refresh task: input the data in the digital input module and save it to the input image register of the STM32 microcontroller; Step S400: Execute user program task: The STM32 MCU first reads the user instructions in the user program storage module and stores them in the internal logic stack, then combines the data in the digital input module, matches the user instructions through the switch instruction, and then converts the user's PLC programming instructions into C language programs, and then the STM32 MCU executes the corresponding C language programs; Step S500: Output refresh program: After the STM32 MCU executes the user instruction, it outputs the status instruction to the output image register in the STM32 MCU, and then the STM32 MCU scans the state of each output relay in the output image register, and outputs the corresponding value to the digital output module according to its state, and finally re-enters step S200, refreshes the task, and executes it in a loop.

Citation Information

Cited By

  • Embedded PLC control method based on OpenPLC

    CN118348905A