CN114115024A - STM 32-based intelligent building controller and control method thereof - Google Patents

STM 32-based intelligent building controller and control method thereof Download PDF

Info

Publication number
CN114115024A
CN114115024A CN202111402089.0A CN202111402089A CN114115024A CN 114115024 A CN114115024 A CN 114115024A CN 202111402089 A CN202111402089 A CN 202111402089A CN 114115024 A CN114115024 A CN 114115024A
Authority
CN
China
Prior art keywords
circuit
output
controller
stm32
main control
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111402089.0A
Other languages
Chinese (zh)
Inventor
董提育
郑鸿
柳雅玲
颜德倩
武永华
郑调汪
陈伟鹏
陈祥奇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zokinre Xiamen Environment Technology Co ltd
Original Assignee
Zokinre Xiamen Environment Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zokinre Xiamen Environment Technology Co ltd filed Critical Zokinre Xiamen Environment Technology Co ltd
Priority to CN202111402089.0A priority Critical patent/CN114115024A/en
Publication of CN114115024A publication Critical patent/CN114115024A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/04Programme control other than numerical control, i.e. in sequence controllers or logic controllers
    • G05B19/042Programme control other than numerical control, i.e. in sequence controllers or logic controllers using digital processors
    • G05B19/0423Input/output
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B2219/00Program-control systems
    • G05B2219/20Pc systems
    • G05B2219/25Pc structure of the system
    • G05B2219/25257Microcontroller

Abstract

The invention relates to an intelligent building controller based on STM32 and a control method thereof. The STM32 intelligent control system comprises an STM32 main control circuit, a power supply circuit connected with the STM32 main control circuit, an RS485 communication circuit, a platinum resistor temperature acquisition circuit, an analog direct-current voltage and current signal input and output circuit, a digital state quantity input and output circuit, an HMI serial port screen display circuit and an alarm circuit. The invention can complete the collection and output of 0-10V direct current voltage and 4-20mA current, and adopts the measures of filtering and optical coupling isolation in the digital state quantity input and output circuit, thereby enhancing the reliability of the circuit, and meanwhile, the invention can communicate with an upper computer through an RS485 communication circuit.

Description

STM 32-based intelligent building controller and control method thereof
Technical Field
The invention relates to an intelligent building controller based on STM32 and a control method thereof.
Background
The intelligent building controller is a ddc (direct Digital control) controller in the field of automation control, and is an english abbreviation of a direct Digital controller. The DDC controller can convert input signals of air pressure, temperature, humidity, liquid level, state and the like in an intelligent building system into digital signals which can be recognized by the system, and outputs analog signals or digital signals to control an external device through a corresponding control algorithm so as to finish actions such as motor start-stop control, water valve switch control, electric or pneumatic control valve control and the like.
With the development of modern electronic technology, the design of the DDC controller is becoming mature. Compared with the traditional DDC (direct digital control) controller, the DDC controller in the market is more intelligent, has stronger expansibility and more energy conservation, and has higher operation speed. Therefore, it quickly replaced the original DDC controller. Some large-scale technology companies employ higher performance processors to achieve greater control capability, but are too costly to be applied in large-scale building control systems and other fields. The processor with high processing speed and high performance is introduced, better control performance can be obtained, and more comfortable experience can be brought to a user if the touch screen is used for man-machine interaction. Therefore, the DDC controller is developing in combination with embedded technology to become the mainstream of the current market.
The innovation of DDC controller technology has prompted the development of intelligent building automation systems. As a core main control device in an intelligent building automatic control system, the DDC controller has high response speed and rich expansion functions, the correction capability is very high, and one terminal can obtain all information of a building system. DDC controller's control mode is also very various, can realize complicacy and accurate control according to building system's situation, like in the common building temperature control system of industrial field, through control algorithm, can make the ambient temperature of building keep at the default, improves user's comfort level.
Through the DDC controller of distributed combination, the intelligent building control system can finish the accurate control of the whole building system. The controlled equipment is integrated into a system, and the whole system is monitored by compiling a monitoring program and a control algorithm, so that each equipment can be accurately controlled. Generally speaking, a reasonably effective building automatic control system can save energy consumption by 15 to 25 percent. Therefore, the DDC controller with the complete design has higher energy utilization rate and control capability. The DDC controller is usually connected to various sensor devices and actuators as a core of a control system, and acquires relevant information collected by the devices. Meanwhile, the DDC controller can be connected with a plurality of terminals to complete information sharing. Therefore, the merits of the controller design directly affect the efficiency of the overall building control system.
The DDC controller usually uses a powerful microprocessor as a master controller, transmits external information collected by each sensing device in the autonomous system to a CPU for specific operation, and then controls an execution device to complete corresponding actions. One of the main characteristics of the DDC controller is that each link from the acquisition of external information to the output signal of the controlled device is designed and implemented in a digital control manner, and functions such as precise control, alarm management, control, monitoring and the like can be implemented. Therefore, it can simultaneously fulfill the control requirements of different devices. Therefore, DDC controllers have a large development space in the field of industrial automation.
The origin of DDC controllers dates back to the last 70 th century. At that time, a better digital control method gradually started to replace an analog control method, and the technology of the controller was also gradually scaled up to be applied to the industrial field. In the early 80 s, the self-control technology began to be widely applied in various fields, some western developed countries began to attach importance to the wide market prospect of the DDC controller, and the DDC controller began to enter the high-speed development stage and gradually introduced into the chinese market in the later stage. By the early 90 s, the design of DDC controllers has tended to be perfected with continued optimization of technology. DDC controllers have been widely used in some large residential buildings to date.
Disclosure of Invention
The invention aims to provide an STM 32-based intelligent building controller and a control method thereof, which can finish the acquisition and output of 0-10V direct current voltage and 4-20mA current, adopt filtering and optical coupling isolation measures in a digital state quantity input and output circuit, enhance the reliability of the circuit, and simultaneously can communicate with an upper computer through an RS485 communication circuit.
In order to achieve the purpose, the technical scheme of the invention is as follows: the utility model provides an intelligence building controller based on STM32, including STM32 main control circuit and with the power supply circuit who is used for whole controller power supply of this STM32 main control circuit connection, an RS485 communication circuit for realizing controller serial port communication, a platinum resistance temperature acquisition circuit for gathering ambient temperature, an analog direct current voltage current signal input/output circuit for carrying out analog signal input/output, a digital state quantity input/output circuit for carrying out digital signal input/output, an HMI serial ports screen display circuit for realizing information display, alarm circuit.
In one embodiment of the invention, the STM32 master circuit comprises an STM32 single chip circuit and peripheral circuits connected with the same.
In an embodiment of the present invention, the peripheral circuit includes a clock circuit and a reset circuit.
In an embodiment of the invention, the power circuit adopts an ST L7812 chip, a TI LM2596-5.0 chip and an LM1117-3.3 chip as 12V, 5V and 3.3V power outputs of the whole controller respectively.
In an embodiment of the invention, the analog dc voltage/current signal input/output circuit includes a 0-10V dc voltage input/output unit and a 4-20mA current input/output unit.
In an embodiment of the present invention, the digital state quantity input/output circuit includes an I/O port state quantity input/output unit subjected to isolation protection.
In an embodiment of the present invention, the platinum resistor temperature acquisition circuit employs a platinum thermistor PT 100.
In an embodiment of the present invention, the RS485 communication circuit employs a MAX485 chip.
The invention also provides a control method based on the STM 32-based intelligent building controller, which is realized as follows:
the STM32 main control circuit adopts a FreeRTOS operating system which allows a plurality of tasks to run, adopts a task type process mode, adopts a task type round-searching software structure and adopts a query type method for each software module to execute respectively; the functions of the software modules are as follows:
(1) direct-current voltage input and output:
the direct current voltage input program is completed based on an analog/digital converter of a single chip microcomputer of an STM32 main control circuit, an actual voltage formula is fitted by calculating the ratio of an external input direct current voltage to the voltage at the port of the single chip microcomputer of the STM32 main control circuit and combining actually measured data, and an initialization program code corresponding to an A/D converter is designed according to an analog/digital converter timing diagram built in the single chip microcomputer of the STM32 main control circuit;
the direct current voltage output program is realized based on a digital/analog converter built in a singlechip of an STM32 main control circuit, the direct current voltage output by the converter is amplified by 3.2 times through an adder circuit of an operational amplifier, so that the output voltage reaches the industrial standard, an actually output voltage formula is fitted according to a circuit design thought by combining with an actually measured error, and an initialization program code corresponding to the A/D converter is designed according to a time sequence diagram of the digital/analog converter built in the singlechip;
(2) RS485 and upper computer communication:
three command types are set, and the interactive communication between the upper computer and the single chip microcomputer of the STM32 main control circuit is realized:
1) and (3) data acquisition of the controller: the upper computer sends the acquisition type and the acquisition channel data to the single chip microcomputer of the STM32 main control circuit, and the single chip microcomputer of the STM32 main control circuit sends the acquisition information of the corresponding controller to the upper computer through a serial port after receiving an upper computer command;
2) reporting collected data: after the upper computer sends a controller data acquisition command, the single chip microcomputer of the STM32 main control circuit returns an acquisition type, an acquisition channel and acquired data to the upper computer;
3) and (3) outputting data of the controller: the upper computer sends the output type, the output channel and the output data to the single chip microcomputer of the STM32 main control circuit, and after the single chip microcomputer of the STM32 main control circuit receives the command of the upper computer, the corresponding output operation is finished by the control system through analyzing the command.
In one embodiment of the invention, a BootLoader upgrading mode adopted by a FreeRTOS operating system comprises an IAP BootLoader _ ITCM and an IAP BootLoader _ FLASH; IAP Bootloader _ ITCM engineering code, which is stored in 0 address, with size 0x 1000; the IAP Bootloader _ FLASH engineering code is stored in an internal FLASH and an external FLASH by a distributed loading file (scf), and the code comprises the following components:
internal flash: 0x8000000-0x8001FFF, size 0x2000
External flash: 0x9000000-0x900 FFFFFFF, size 0x 100000.
Compared with the prior art, the invention has the following beneficial effects:
(1) the power supply circuit adopts the +24V voltage input of the industry common standard and is provided with a +24V power adapter;
(2) the direct current voltage and current input and output circuit is mainly considered from the directions of the analog/digital conversion circuit and the digital/analog conversion circuit to finish the acquisition and output of 0-10V direct current voltage and 4-20mA current;
(3) the digital input and output circuit is designed mainly based on the I/O port of the STM32 singlechip, and meanwhile, filtering and optical coupling isolation measures are adopted, so that the reliability of the circuit is enhanced;
(4) the communication circuit part completes the design of an RS-485 communication circuit and communicates with an upper computer;
(5) the display part is designed to display and control various signal changes (such as water level, temperature, humidity, pressure and the like) by using an HMI serial port screen. The user may control the device acquisition and input devices via STM32 single chip.
Drawings
FIG. 1 is a block diagram of the general design of an intelligent building controller based on STM 32.
Fig. 2 is a schematic diagram of the power supply circuit of the present invention.
Fig. 3 is a schematic diagram of the reset circuit of the present invention.
Fig. 4 is a schematic diagram of the clock circuit of the present invention.
Fig. 5 is a schematic diagram of the controller master control circuit of the present invention.
Fig. 6 is a schematic diagram of an analog dc voltage input unit circuit according to the present invention.
Fig. 7 is a schematic diagram of an analog dc voltage output circuit of the present invention.
Fig. 8 is a schematic diagram of a state quantity input-output circuit of the present invention.
Fig. 9 is a schematic diagram of a current-to-voltage circuit of the present invention.
Fig. 10 is a voltage-to-current circuit schematic of the present invention.
Fig. 11 is a graph of the resistance of the platinum thermistor PT100 against ambient temperature.
FIG. 12 is a graph of output current value versus ambient temperature for an integrated temperature transmitter module.
Fig. 13 is a schematic diagram of the RS485 interface circuit of the present invention.
FIG. 14 is a schematic diagram of an HMI serial port screen interface circuit of the present invention.
FIG. 15 is a FreeRTOS operating system initialization flow diagram.
FIG. 16 is a diagram of tasks performed by the FreeRTOS operating system.
FIG. 17 is an HMI screen display view, (a) function home page view; (b) to test the functional diagram.
Detailed Description
The technical scheme of the invention is specifically explained below with reference to the accompanying drawings.
As shown in figure 1, the intelligent building controller based on STM32, namely a DDC controller, adopts an STM32 single chip microcomputer as a main control circuit, and is provided with unit modules such as a power supply circuit, an RS485 communication circuit, a platinum resistor temperature acquisition circuit, an analog direct-current voltage and current signal input and output circuit, a digital state quantity input and output circuit, an HMI serial port screen display circuit, an alarm circuit and the like according to design requirements to form a basic DDC controller. The overall design block diagram of the system is shown in fig. 1.
First, the circuit modules constituting the system will be described in detail below.
1. Power supply circuit design
For an ideal DDC controller, the design of the power supply circuit is very important, and the stability of the power supply circuit affects the operation performance of the whole controller. In this system, the STM32 singlechip adopts +5V supply voltage, and direct current voltage current input output circuit needs +12V mains voltage, and HMI serial ports screen display circuit and RS485 communication circuit all use +5V power, and digital state quantity input output circuit based on the opto-coupler isolation all adopts +3.3V power supply.
Considering that signal interference exists in the actual application environment of the controller, misoperation of the system can be caused, abnormal work is generated, and even potential safety hazard is brought. The power input and output loop of the invention adopts electrolytic capacitors and bypass ceramic capacitors for filtering.
According to the power supply demand analysis of the invention, in order to ensure the safe operation of the system in practical application and control the stability of the controller, the power supply circuit needs to have larger power output. The present invention uses the ST L7812 chip as the +12V power output of the system, taking into account the current required by the individual circuit cells. In order to obtain higher conversion efficiency and long-time stable work, the TI LM2596-5.0 chip is used as the +5V power supply output of the system, and is a 3A current output step-down switch type integrated voltage stabilizing chip [ [ i ] ]. For +3.3V power output, the LM1117-3.3 chip is adopted in the invention, and 800mA current can be output, thereby meeting the requirements of a controller circuit. Based on the above analysis, a schematic diagram of the power circuit design is shown in fig. 2.
2. STM32 peripheral circuit of single chip microcomputer
2.1 single chip microcomputer STM32
The main control circuit of the invention adopts an STM32 singlechip, and the singlechip chip contains 3 analog/digital converters and 2 digital/analog converters to meet the design requirements of analog input and output of the controller. Meanwhile, 3 serial transceiving modules are provided, and the requirements of transceiving interfaces of an HMI serial port screen display circuit and an RS485 communication circuit are met sufficiently. The STM32F103 single chip microcomputer series has clock frequency as high as 72MHz, can obtain very high running speed and meet the performance requirement of the design in an actual building control system.
2.2 reset circuit and clock circuit
A schematic diagram of the controller reset circuit of the present invention is shown in fig. 3. A schematic diagram of the controller reset circuit of the present invention is shown in fig. 4.
3. Controller main control circuit
The invention uses the STM32 singlechip minimum system board as the main control circuit. According to the data manual of the single chip microcomputer and the basic control principle of the controller, an interface circuit for realizing a controller system is designed. The functions of the system are designed in blocks, and the specific interface distribution design is as follows: the pin VCC5.0 and GND are connected with a +5V power supply circuit; the pins PC14-15, OSCIN and OSCOUT are connected with a clock circuit; the pin RESET is connected with a RESET circuit; the pins PB10-11 and PD7 are connected with an RS485 circuit; the pin PF3-5 is connected with a state quantity input circuit; the pin PE0-1 is connected with a state quantity output circuit; pins PA1, PB1 and PA6-7 are connected with a direct-current voltage current input circuit; the pin PA4-5 is connected with a direct-current voltage and current output circuit; the pin PA9-10 is connected with an HMI serial port screen display circuit. Pin PB0 connects buzzer warning circuit. The main circuit diagram of the controller is shown in FIG. 5:
4. each unit circuit of controller
The signal types received by the controller system are classified, and the signal types can be generally divided into two types, namely a direct current voltage signal and a switch state quantity signal. Accordingly, the system is divided into an analog signal input-output circuit and a digital signal input-output circuit. Generally, the input analog signals of the intelligent building system are: air pressure, temperature, humidity, liquid level, etc. The output analog signal is: an electrically or pneumatically controlled valve. The input digital signals are: fan on-off state, motor on-off state, liquid level on-off state, light on-off state, etc. The output digital signal is: motor start-stop control, water valve switch control, fan switch control and the like.
Therefore, in consideration of common analog signals and digital signals in the industrial field, the system adopts an input and output unit with 0-10V direct current voltage and 4-20mA current and an I/O port state quantity input and output unit subjected to isolation protection so as to meet the requirements of a working environment.
4.1 analog DC voltage input/output circuit
The working principle of the direct-current voltage input unit is as follows: analog signals acquired in an actual application environment are converted into digital signals readable by an STM32 singlechip through a filtering and analog/digital conversion circuit, and operation control processing is performed in the digital signals. The main functions of the direct-current voltage output unit are as follows: the operation result in the STM32 single chip microcomputer is output in the type of analog signal through the process of digital/analog conversion to control the connecting device.
The direct current voltage input unit of the controller realizes the process of converting analog quantity into digital quantity through the analog/digital converter, and then the converted data is further operated and processed in the MCU. In the invention, an analog/digital converter built in the singlechip STM32 is adopted.
The circuit schematic diagram of the dc voltage input unit of the present invention is shown in fig. 6.
In a direct current voltage input unit circuit, capacitors C1 and C2 mainly perform a filtering link, resistors R1 and R2, R3 and R4 divide the voltage of input signals, and the direct current signals of 0-10V collected by an analog input unit are converted into a voltage range which can be converted by an STM32 single chip microcomputer. A chip is internally provided with a 16-channel gradual approximation type analog/digital converter, and the conversion time can reach 1.17 us. Therefore, the system requirements are met;
in the controller system, the direct current voltage output unit circuit converts the result of the operation in the CPU of the single chip microcomputer into an analog signal output by the output port of the controller through a digital/analog converter.
The direct-current voltage output unit circuit adopts a digital/analog conversion module built in an STM32 singlechip, can be configured into a 12-bit digital-analog conversion mode, and has a built-in analog output of 2 channels. The STM32 singlechip has the input reference voltage VREF +, who independently draws, connects +3.3V voltage in order to output more accurate analog output signal.
The output voltage range of the digital-to-analog converter of the STM32 single chip microcomputer is 0-3.3V, in order to enable the output analog voltage signal to be 0-10V voltage of the industrial standard, a first-stage in-phase adder circuit consisting of operational amplifiers is connected to the output port of the digital-to-analog converter to amplify the voltage signal, and in order to ensure the driving capability of an analog output unit circuit to a relay, a first-stage current amplification circuit is formed at the tail end of a triode to enhance the output current of the circuit. In the circuit, Vout = VIN (1+ R6/R5); the schematic diagram of the DC voltage output circuit is shown in FIG. 7.
4.2 State quantity input/output circuit
In practical application of the building intelligent controller, besides collecting analog signals and outputting the analog signals, digital signals are required to be input and output to complete control, such as controlling the start and stop of a motor, a fan switch, the brightness of an illuminating lamp, a relay switch and the like. In consideration of signal interference in an actual working environment, the digital input and output circuit adopts an optical coupling isolation mode, so that the influence of input digital signals on the controller is prevented, and the reliability and the anti-interference capability of the controller are enhanced.
When the input port of the state quantity input unit circuit collects logic level 1, the optical coupler isolator is in a closed state, and +3.3V voltage, namely logic level 1, is input into the I/O port of the STM32 singlechip; when the input port of the circuit collects a logic level '0', the optical coupler isolator is in an open state, and an I/O port of an STM32 singlechip is connected with the ground, namely the logic level '0';
the state quantity output unit circuit mainly has the functions of outputting stable and accurate logic level '1' or '0' digital signals and controlling the actions of equipment devices such as motors, fans and the like connected externally.
The state quantity input and output unit circuit comprises filtering capacitors C4 and C10 for carrying out a filtering link, current limiting resistors R7 and R13 enable the optocoupler TLP521 to be conducted under appropriate current, and the optocoupler TLP521 carries out a circuit optocoupler isolation link. A schematic diagram of the state quantity input/output circuit is shown in fig. 8.
4.3 Current Collection and output Circuit
The magnitude of the analog current input signal received by the building intelligent controller is typically 4-20 mA. The circuit converts the current into a voltage unit circuit, and converts an input analog current signal into an analog voltage range which can be distinguished by an STM32 singlechip analog/digital converter. The input current analog signal forms a loop through a sampling resistor R40, R42 and GND with the resistance value of 160 ohms. When a 4-20mA current signal flows through the sampling resistor and then passes through a current limiting resistor R39 and R41 with the resistance value of 1K ohm and a capacitor C23 and C24, the input voltage range acquired by the STM32 singlechip analog/digital converter is as follows: 160x (4-20 mA) = 0.64-3.2V. A schematic diagram of the current-to-voltage circuit is shown in fig. 9.
In an actual working environment, the anti-interference capability of current transmission is excellent, and errors generated by 4-20mA current transmission are small, so that a current output unit circuit in a 4-20mA standard range is designed for the controller. The design idea is that an STM32 single chip microcomputer outputs 0-3.3V voltage through a digital/analog converter, outputs 0-10V controllable voltage through an adder circuit consisting of an LM2902 operational amplifier, and finally outputs standard 4-20mA current through a high-precision voltage-to-current module. A voltage-to-current circuit schematic is shown in fig. 10.
As shown in fig. 10, the upper and lower potentials of the reference resistor R35 with a resistance value of 100 ohms are V1 and V2, respectively, and it is easy to know from analysis that: v1= VIN +2VR, V2=2x (VIN + VR). Therefore, the output current
Figure DEST_PATH_IMAGE001
. In the circuit, the output end of the LM324 operational amplifier is connected with a first-stage triode circuit, so that the output current of the circuit is increased.
4.4 platinum resistance temperature acquisition circuit
In practical platinum thermal resistor application, the current temperature value is usually calculated according to the substitute quantity converted by the platinum resistor temperature acquisition circuit. PT10, PT100 and PT1000 are generally commercially available, and they differ from each other in that the resistance span of the platinum thermistor varies for every 1 c rise in temperature. The resistance of the platinum thermistor PT100 is compared with the ambient temperature as shown in fig. 11.
The temperature acquisition unit of the invention adopts a platinum thermal resistor PT 100. Considering that the distance between the temperature acquisition place and the central control point may be very large in practical application, the invention adopts a three-wire connection method, thereby effectively eliminating external interference during long-distance transmission and greatly improving the accuracy of temperature measurement.
The temperature acquisition circuit of the controller adopts an integrated temperature transmitter module, converts the temperature value of the application environment into 4-20mA current of an industrial standard, then is connected to the current acquisition circuit, and calculates the current environment temperature information according to a corresponding conversion formula. The comparison graph of the output current value of the integrated temperature transmitter module and the ambient temperature is shown in fig. 12.
4.5 RS485 communication circuit
RS485 serial port communication is a common communication mode in the industrial field nowadays. RS485 is a bus structure, and when the potential difference between the line A and the line B is plus (2-6V) or minus (2-6V), the bus structure represents a logic signal. In the design of the controller, the selected RS485 serial interface chip is MAX 485. In the chip, RO pins and DI pins are respectively connected to PB10-11 pins of an STM32 singlechip through optical coupling isolation, so that the STM32 singlechip can transmit data with an RS485 bus through a serial port;
Figure 906597DEST_PATH_IMAGE002
the STM32 single chip microcomputer is connected with a DE pin and connected with a PD7 pin of an STM32 single chip microcomputer through optical coupling isolation to realize input and output enabling of an RS485 bus structure, so that the STM32 single chip microcomputer can perform data transmission with a bus through an A interface and a B interface; GND is grounded; the A end is connected to the A end of the RS485 interface, and the B end is connected to the B end of the RS485 interface. VCC is connected to +5V voltage. Meanwhile, the invention also uses the optical coupler isolator TLP521 to optically couple and isolate the input and the output, so as to enhance the stability of the unit circuit, and the schematic diagram of the RS485 interface circuit is shown in FIG. 13.
4.6 HMI serial port screen display circuit
The invention adopts the HMI serial port screen as the display circuit of the controller. As the name suggests, the serial port screen is a liquid crystal display screen which can be controlled through a serial port. Through the interactive communication with the HMI serial port screen, the controller can modify the variable parameters of the serial port screen to complete different functions. An HMI serial port screen interface circuit schematic is shown in fig. 14.
Second, the controller software control will be described in detail below.
1. Main program flow chart and key point software design
The STM32 single chip microcomputer software is designed by adopting a FreeRTOS operating system which is an RTOS-type embedded real-time operating system. Real-time operating system initialization process see fig. 15.
The FreeRTOS operating system allows a plurality of tasks to run, adopts a task type process mode, adopts a task type round-searching software structure, and adopts a query type method for each software module to respectively execute. As shown in fig. 16, the present system includes the following 7 tasks.
(1.1) Bootloader upgrade design
The boot loader upgrading process is totally divided into 2 parts of boot, and is different from the traditional boot loader. Are respectively
A first part: IAP Bootloader _ ITCM
A second part: IAP Bootloader _ FLASH
The single-chip microcomputer bootloader code storage area distribution:
IAP Bootloader _ ITCM engineering code is stored in 0 address, and the size is 0x 1000.
The IAP Bootloader _ FLASH engineering code is stored in an internal FLASH and an external FLASH by a distributed loading file (scf), and the code comprises the following components:
internal flash: 0x8000000-0x8001FFF, size 0x2000,
external flash: 0x9000000-0x900 FFFFFFF, size 0x 100000.
The storage area distribution of the application program of the single chip microcomputer is as follows:
the internal and external flash are configured by the scf, which are:
initiating an internal flash: 0x8002000
Initiating an external flash: 0X90100000
(1)IAP Bootloader_ITCM
The part is a core logic code for realizing bootloader upgrading, and the user program is transported to a corresponding flash address. The main functions are as follows:
1. and reading the stored ER _ m _ stmflash application program file data in the w25qxx memory, and writing the data into the 0x8002000 address of the internal flash through the IAP.
2. And reading the stored ER _ m _ qspliflash application program file data in the w25qxx memory, and writing the data into the 0X90100000 address of the external qspi flash through the IAP.
3. And jumping to the address 0x8002000 to run the upgraded user program.
Note that: the bin file compiled by the code needs to convert the bin file into an array according to a provided tool of 'array and bin file conversion', and the array is put into an IAP Bootloader _ FLASH project of the second part.
(2)IAP Bootloader_FLASH
The part is bootloader burning engineering codes and is used for making bootloader guidance to start real upgrading codes: IAP Bootloader _ ITCM.
The main functions are as follows:
1. detecting whether a USB flash disk is inserted
a) If time out, it represents that U disk is not inserted
I. Jump directly to the 0x8002000 address to run the user application.
b) If the USB flash disk is detected within the set time
I. Executing the reading of the U disk program, and writing the read ER _ m _ stmflash and ER _ m _ qspliflash application program files into a w25qxx spi flash memory;
II. And copying a bin array generated by the IAP Bootloader _ ITCM to the address 0.
III, jumping to the address 0, and executing an IAP Bootloader _ ITCM program.
(1.2) read protection design
The stm32H7 has a read out protection (RDP) mechanism inside, which acts on the whole Flash storage area to prevent illegal access to Flash.
By setting the read protection of Flash, other users cannot read the Flash in any one of the following ways:
1. through a debugger (JTAG or SWD);
2. a program started and executed from the RAM;
if the user releases the reading protection by using the tool manually, the chip can automatically empty the codes on the flash.
(1.3) DC Voltage input/output Programming
(1.3.1) DC Voltage input Programming
The controller direct-current voltage input program is completed based on an analog/digital converter of an STM32 single chip microcomputer. According to the actual circuit design, the ratio of the external input direct current voltage to the voltage at the port of the STM32 single chip microcomputer is calculated, and then an actual voltage formula is fitted by combining actually measured data. And designing an initialization program code corresponding to the A/D conversion module according to an analog/digital converter timing diagram built in the STM32 singlechip.
(1.3.2) DC Voltage output Programming
The DC voltage output program of the controller is realized based on a digital/analog converter built in the singlechip. The DC voltage output by the converter is amplified by 3.2 times through an adder circuit of an operational amplifier, so that the output voltage reaches the industrial standard. The actually output voltage formula can be fitted according to the circuit design idea and by combining the actually measured error. And designing an initialization program code corresponding to the A/D conversion module according to a timing diagram of a digital/analog converter built in the single chip microcomputer.
(1.4) communication protocol between RS485 and upper computer
(1.4.1) communication method
The STM32 singlechip communicates with the virtual serial port tool at the PC end of the upper computer through an RS485 communication circuit. The baud rate of both sides communication is 9600, no parity is set, 8 bit data bit, 1 bit stop bit.
(1.4.2) communication protocol
The communication protocol sets three command types to realize the interactive communication between the upper computer and the STM32 single chip microcomputer. The data format of the communication protocol is shown in table 1:
TABLE 1 communication protocol data format
Figure DEST_PATH_IMAGE003
1) And (3) data acquisition of the controller: the PC end sends the acquisition type and the acquisition channel data to the STM32 single chip microcomputer, and the single chip microcomputer sends corresponding controller acquisition information to the upper computer through the serial port after receiving the upper computer command.
2) Reporting collected data: and after the PC terminal sends a controller data acquisition command, the STM32 singlechip returns an acquisition type, an acquisition channel and acquired data to the PC terminal.
3) And (3) outputting data of the controller: the PC end sends the output type, the output channel and the output data to the STM32 single chip microcomputer, and after the single chip microcomputer receives the command of the upper computer, the corresponding output operation is completed by the control system through analyzing the command.
(1.5) control algorithm programming
Application of PID algorithm
The fundamental purpose of the control algorithm is to output a specific value more accurately, so that the real-time output value of the DDC controller is completely consistent with the set value or the operation result of an operator. The external information collected by the external sensor equipment of the DDC controller is transmitted into the STM32 single chip microcomputer, is compared, analyzed, processed and predicted with the set value or the operation result of an operator in the CPU, and the output value is modified in real time by utilizing some control algorithms to stabilize the output signal at an ideal value.
The invention mainly combines and applies proportional, integral and differential algorithms, namely PID algorithm, to strengthen the control ability of DDC controller to the device. In practical applications, three algorithms are usually combined to achieve a stronger control capability of the control system, which is called a PID algorithm.
(1.6) display software of HMI serial port screen
The invention adopts the HMI serial port screen of 2.4 inches to complete the display and function selection work, and can easily realize the display of various characters, pictures and waveforms by utilizing the strong control function. The user can select functions of the HMI serial port screen to complete simple configuration actions of the controller, such as selecting functional modules of AI, AO, DI, DO, Temp and the like, and respectively complete acquisition of input direct current voltage and current, acquisition of output direct current voltage and current control equipment, acquisition of input state quantity, acquisition of output state quantity control equipment and acquisition of temperature of the platinum thermistor PT 100. Meanwhile, the display part of the HMI serial port screen also provides a test for part of logic function structures. Selecting the "Cell" function, 12 different logic functions can be tested. The HMI screen display diagram is shown in fig. 17.
The above are preferred embodiments of the present invention, and all changes made according to the technical scheme of the present invention that produce functional effects do not exceed the scope of the technical scheme of the present invention belong to the protection scope of the present invention.

Claims (10)

1. The utility model provides an intelligence building controller based on STM32, a serial communication port, a power supply circuit for whole controller power supply that is used for including STM32 main control circuit and is connected with this STM32 main control circuit, an RS485 communication circuit for realizing controller serial communication, a platinum resistance temperature acquisition circuit for gathering ambient temperature, an analog direct current voltage current signal input/output circuit for carrying out analog signal input/output, a digital state quantity input/output circuit for carrying out digital signal input/output, an HMI serial screen display circuit for realizing information display, alarm circuit.
2. The intelligent building controller of claim 1 based on STM32, wherein the STM32 main control circuit comprises STM32 single chip circuit and peripheral circuit connected with it.
3. The STM 32-based intelligent building controller of claim 2, wherein the peripheral circuits comprise clock circuits, reset circuits.
4. The STM 32-based intelligent building controller according to claim 1, wherein the power supply circuit adopts an ST L7812 chip, a TI LM2596-5.0 chip and an LM1117-3.3 chip as 12V, 5V and 3.3V power supply outputs of the whole controller respectively.
5. The STM 32-based intelligent building controller of claim 1, wherein the analog dc voltage-to-current signal input-output circuit comprises a 0-10V dc voltage input-output unit and a 4-20mA current input-output unit.
6. The STM 32-based intelligent building controller of claim 1, wherein the digital state quantity input and output circuit comprises an isolation protected I/O port state quantity input and output unit.
7. The STM 32-based intelligent building controller of claim 1, wherein the platinum resistance temperature acquisition circuit employs a platinum thermistor PT 100.
8. An intelligent construction controller based on STM32 according to claim 1, wherein the RS485 communication circuit uses MAX485 chip.
9. A control method based on the STM 32-based intelligent building controller of any one of claims 1-8, characterized by comprising the following steps:
the STM32 main control circuit adopts a FreeRTOS operating system which allows a plurality of tasks to run, adopts a task type process mode, adopts a task type round-searching software structure and adopts a query type method for each software module to execute respectively; the functions of the software modules are as follows:
(1) direct-current voltage input and output:
the direct current voltage input program is completed based on an analog/digital converter of a single chip microcomputer of an STM32 main control circuit, an actual voltage formula is fitted by calculating the ratio of an external input direct current voltage to the voltage at the port of the single chip microcomputer of the STM32 main control circuit and combining actually measured data, and an initialization program code corresponding to an A/D converter is designed according to an analog/digital converter timing diagram built in the single chip microcomputer of the STM32 main control circuit;
the direct current voltage output program is realized based on a digital/analog converter built in a singlechip of an STM32 main control circuit, the direct current voltage output by the converter is amplified by 3.2 times through an adder circuit of an operational amplifier, so that the output voltage reaches the industrial standard, an actually output voltage formula is fitted according to a circuit design thought by combining with an actually measured error, and an initialization program code corresponding to the A/D converter is designed according to a time sequence diagram of the digital/analog converter built in the singlechip;
(2) RS485 and upper computer communication:
three command types are set, and the interactive communication between the upper computer and the single chip microcomputer of the STM32 main control circuit is realized:
1) and (3) data acquisition of the controller: the upper computer sends the acquisition type and the acquisition channel data to the single chip microcomputer of the STM32 main control circuit, and the single chip microcomputer of the STM32 main control circuit sends the acquisition information of the corresponding controller to the upper computer through a serial port after receiving an upper computer command;
2) reporting collected data: after the upper computer sends a controller data acquisition command, the single chip microcomputer of the STM32 main control circuit returns an acquisition type, an acquisition channel and acquired data to the upper computer;
3) and (3) outputting data of the controller: the upper computer sends the output type, the output channel and the output data to the single chip microcomputer of the STM32 main control circuit, and after the single chip microcomputer of the STM32 main control circuit receives the command of the upper computer, the corresponding output operation is finished by the control system through analyzing the command.
10. The STM 32-based control method of the intelligent building controller according to claim 1, wherein a BootLoader upgrade mode adopted by a FreeRTOS operating system comprises IAP BootLoader _ ITCM and IAP BootLoader _ FLASH; IAP Bootloader _ ITCM engineering code, which is stored in 0 address, with size 0x 1000; the IAP Bootloader _ FLASH engineering code is stored in an internal FLASH and an external FLASH by a distributed loading file (scf), and the code comprises the following components:
internal flash: 0x8000000-0x8001FFF, size 0x2000
External flash: 0x9000000-0x900 FFFFFFF, size 0x 100000.
CN202111402089.0A 2021-11-24 2021-11-24 STM 32-based intelligent building controller and control method thereof Pending CN114115024A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111402089.0A CN114115024A (en) 2021-11-24 2021-11-24 STM 32-based intelligent building controller and control method thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111402089.0A CN114115024A (en) 2021-11-24 2021-11-24 STM 32-based intelligent building controller and control method thereof

Publications (1)

Publication Number Publication Date
CN114115024A true CN114115024A (en) 2022-03-01

Family

ID=80371676

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111402089.0A Pending CN114115024A (en) 2021-11-24 2021-11-24 STM 32-based intelligent building controller and control method thereof

Country Status (1)

Country Link
CN (1) CN114115024A (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN201335953Y (en) * 2009-01-20 2009-10-28 江苏联宏自动化系统工程有限公司 General-purpose input/output device
CN112114850A (en) * 2020-07-15 2020-12-22 北京航空航天大学杭州创新研究院 STM32 single chip microcomputer on-chip and off-chip FLASH program decentralized loading method based on serial port

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN201335953Y (en) * 2009-01-20 2009-10-28 江苏联宏自动化系统工程有限公司 General-purpose input/output device
CN112114850A (en) * 2020-07-15 2020-12-22 北京航空航天大学杭州创新研究院 STM32 single chip microcomputer on-chip and off-chip FLASH program decentralized loading method based on serial port

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
高瑞;祝德忠;齐利晓;: "基于STM32的智能建筑现场控制器的设计", 工业控制计算机, no. 10, pages 453 - 273 *

Similar Documents

Publication Publication Date Title
CN100470207C (en) Low-power consumption two-wire system vortex flowmeter
CN102175445B (en) Simulation test device for hydroturbine speed-regulating system
CN104965009A (en) Hydrogen concentration detector
CN103699029B (en) A kind of energy consumption data acquisition terminal
CN103822667A (en) Temperature-humidity acquisition system based on Bluetooth technology
CN203705992U (en) Temperature control device
CN101873349B (en) The multinode real-time power consumption monitoring system in the environment of wireless sensor network
CN103049984B (en) Combustible gas alarm instrument based on Wireless HART communication technology
CN101846117B (en) Hydraulic cylinder performance test device
CN203414433U (en) Temperature and humidity detection system for drying process
CN101739048A (en) Automatic controller for room temperature humidity
CN103439370B (en) The temperature/humiditydetection detection system of drying course
CN114115024A (en) STM 32-based intelligent building controller and control method thereof
Guo et al. Design for indoor environment monitoring system based on embedded system and multi-sensor data fusion algorithm
CN2811962Y (en) Synchronous motor state detector based on Profibus-DP field bus
CN216486060U (en) Intelligent building controller based on STM32
CN216285589U (en) Signal acquisition equipment and detection system of air conditioner electric control board
CN201796256U (en) Intelligent poultry house environment controller
CN202189453U (en) Device used for remotely sensing and monitoring physical quantity of self-organized network with low power consumption
CN211180625U (en) Intermediate device connected between temperature and humidity sensor and equipment
CN203133603U (en) A building structure health monitoring system
CN104965548A (en) Clean room temperature and humidity measuring and controlling device
CN204650327U (en) A kind of toilet temperature and humidity filed device
CN206223718U (en) Gas sensor drive circuit with humidity compensation function
CN201867633U (en) Outdoor analog acquisition module used in low temperature environment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination