Abstract: through the microcontroller embedded real-time operating system RTOS multi-task to achieve solar hot water control system design. Included in the main text-control (main terminal) and data-collection (from the side) of the functional module map and show that the existence of an interpretation of a number of tasks, and gives to achieve the main communication from the definition of the frame structure and the use of I2C Line in the EEPROM memory of the code to read and write data analysis.
With embedded technology development and strengthening of a growing number of SCM in use to achieve the RTOS (real-time operating system a lot of assignments), embedded, multi-task mechanism to improve the efficiency of system operation and reduce the response time used by . As embedded application on the basis of the industrial centre of chip design and application-oriented software development, real-time multi-task operating system embedded into the industrial history of the significance of no less than a third of Machinery Industry view of the contribution of the embedded software And accelerate the standardization of knowledge and innovation is a milestone. RTOS has the following advantages.
① RTOS is a very high reliability and credibility of the real-time kernel, the central controller of time, interruption, input and output, timers, and other resources are packing up, leaving users of a standard application programming interfaces, and in accordance with the mandate of the Priority, a reasonable distribution of the different tasks between the central controller of time.
② RTOS as a software development platform is very desirable, based on the RTOS on the C language program is of great portability. According to expert estimates, RTOS on the outstanding inter-processor platform for transplant procedures, only need to amend the 1% to 5% of the content.
The introduction of ③ RTOS, embedded software development to solve the problem of standardization. With the embedded system software in the proportion rising, more and more applications, the developers, application programming interfaces, file proceedings in the organization and management will become a big issue. RTOS equivalent to the introduction of the introduction of a new management model for the development of units and personnel development is a raise.
The programme from the district and how to better solve the complex life of the residents of the problem with hot water, use of green energy as the main source of solar energy to the floor, integrated control unit, to provide users with hot water. This is not only convenient life, filling out the traditional stand-alone water heaters, the potential safety problems, also facilitates the owners of centralized management and planning.
A system Overview
The solar hot water control system for solar energy, heat outdoors on the roof collector in the water. After warming was heating the water cycle through the valve into the large water storage tanks, and then gravity at small water storage tanks, water tanks in a small supplementary energy to maintain a constant temperature, the device will further boost through the water to individual households. The system in the state of default, automatic control mode to judge the four valves (the main control point) the work of state, may also require staff to manually control. Working through the main terminal to complete the operation of the control panel and the system of interaction. The panel will display real-time display system and the work of the various parameters of data for the reference staff. Water tanks and a high degree of heat required to open the valve when the temperature of 12, and other system parameters, we can control the operation of the control panel box on the set-up and read through the display devices, can also remote monitoring of computer interface settings and view. Taking into account the promotion of the northern region, the system also set the parameters to control the antifreeze recycling antifreeze start and stop cycle. Solar water heating intelligent control system diagram as shown in Figure 1, which is the main control box-control (main terminal), data-acquisition (from the side) at the top of the tank.
Winbond system using the SCM W77E58 production companies as the main terminal and from the side of the microprocessor, since it eliminates redundant clock and storage cycle, faster than the traditional series of 8051 to 1.5 to 3 times faster. SCM used in real-time multi-tasking operating system is RTX51TNY, the operating system by the German company developed Keil, the size of only 800 B, but theoretically support up to 16 missions, tasks and coordination between the rotation mechanism to trigger signal. RTX51TNY operating system to allow the "quasi-parallel," the implementation of several tasks, each a pre-defined task in good time-chip to carry out.
2 architecture
Solar hot water control system posed by the following modules: the main control-processing module (main terminal), data-acquisition module (that is, from the side), and the computer monitor behind the procedures. Among them, from the side also includes ultrasound measuring the water level device module, the device using ultrasonic sound waves reach the surface after the reflection of the simple principle, the use of amplifier circuit, the cost much lower than the market popular input level gauge. Diagram of the structure shown in Figure 2.
2.1 control of the main terminal software and mission analysis
System software from the three main components: the main terminal procedures, from the end use of ultrasound procedures and the procedures for measuring the water level. The main side include in the main terminal control module, its role is to determine the current system work, and through the acquisition of the data processing and analysis of how to get the control system of command. From the end of the process responsible for collecting data and sent to the main process, part of the ultrasound procedures ensure that the water level of the ultrasound test module stability and accuracy. Of these, the main background-processing module control system is a major part of the code occupy most of the volume, the control system from most of the instructions given here, highlighted below this part.
Sketch of the main terminal functional modules as shown in Figure 3.
The main processing logic from seven constitute its main task, the definition of some function as a supplementary. Seven tasks were: ① initialization tasks; ② and serial communication tasks (1 reception from the serial data-collection of data sent back); ③ and serial communication task 2 (2 serial port and is responsible for monitoring the computer exchange of data ); ④ ⑤ were on different display area of control tasks; ⑥ disruption of the hardware processing tasks; ⑦ to return data processing tasks.
Various tasks to achieve the specific functions are as follows:
① initialization tasks: to initialize serial interface, and started the remaining six missions, the final delete their own.
② a serial communication tasks: the main processing logic every certain period of time through a serial port to send queries data acquisition-frame for data, send a certain number do not receive data from the client, through the signal mechanism triggered task, - Communication from the show and the defeat prompted information from the client to return if the correct data, the task of data into the show after show. If found by the CRC check for a number of data from client to return an error, into the task of displaying data show that the error prompted information.
③ 2 serial communication task: to monitor the system's operation because of staff needs through a number of changes to the parameters of real-time understanding of the work of the current system, all these parameters, including the status of the valve, the water level in water tanks, various sensors, such as the current temperature, Therefore, the system uses a serial port to submit data to the computer monitor. Every time the computer monitor will send queries frame, the frame for two, one is for the valve condition and the other for the water level and temperature, host its request filled with the kind of data sent back after the frame.
control display task 1: leadership from top to bottom screen is divided into two lines, one of the region above 1, the following acts of a regional 1 shows that the region responsible for the current system of water tanks, water temperature parameters such as size, per-screen display of a parameter, stay for a period of time after a show, so cycle repeated, the operator can see in this system of values so as to the specific parameters to do To control judgement.
⑤ control display task 2: Regional 2 shows the system is running, the current state of the work of various valves. Set up a system to manual and automatic manipulation of the four valves in two ways, it has used to prompt a distinction. This region is also responsible for showing the wrong information or information that, if the temperature sensor or ultrasound probe returned data is in error, error in the words here are, and that is which part of the problem, in time for staff Maintenance fault line.
⑥ hardware interrupt handling tasks: the console on the surface of the 14 keys to manipulate and control system, every click of a button, the system response to the charge on this task. 16 input from the output of the four keys are encoded encoder, where the 14 kinds of situations into a different procedure of the process.
⑦ to return data processing tasks: one with the serial communication tasks, the system received from the serial port 1 if the data is accurate, then enter this task. The main tasks of the system exist in four movements, namely, water, heating, recycling and backwater, were divided into two working manual and automatic, and computing systems in real-time data to change the decision and how they affect the current system of action.
2.2-data acquisition module map
In the data-collection, the temperature on the roof of the acquisition, including the acquisition collector temperature, the thermostat on the water temperature of the collection, the temperature on the size of the collection boxes on the main network and a certain temperature in the collection. Data acquisition logic of indirect control cycle valves, backwater valves, heating valves, water valves. Data Acquisition side of the functional module map shown in Figure 4 (dotted line on that part of the indirect control valves).
3 communications frame format
Control of the main terminal by the real-time display of data processing and data acquisition-to rely on the acquisition after the return, through communications between the two RS485 interfaces, a frame structure definition of the way to achieve.
In the proceedings, we rely on the distinction between types of frames and judgement, a total of seven representatives of different definition of the meaning of the frame, namely: ① control of the main terminal to send the data-collecting data for frames; ② data acquisition control of the main terminal to terminal The temperature of the water level to send data such as frames; ③ monitor computer-to-send the main control valve for the state frame; ④ control computer to send the main control client enquiries, such as water temperature data frame; ⑤ control of the main terminal to monitor the computer to send the valve The door frame state; ⑥ control of the main terminal to monitor the computer to send the data frame; ⑦ monitor computer-setting parameters inform the main control-frame. If the frame is a frame of the transmission of data, data1 ~ dada7 bytes of the seven large water tanks were filled with water, small water tank water temperature, size me water temperature, water temperature in the roof collector (three collection points) and the collection points The water temperature. If sent as a frame of the current state of the valve frame, with seven bytes in the first four were said to Jin valves, valve back, valves and heating cycle valve is open or closed state. Frame structure of the format shown in Figure 5.
In addition, in accordance with the needs of their own design to increase the type of frame, in order to achieve more complex communication.
4 system, memory EEPROM
As always in control would involve changes to the parameters, in order to make a brown-out system will not affect the operation of parameters that need to reproduce, the system uses I2C bus interface with the EEPROM 2402 chips for data storage and read. Read and write were called the two functions are as follows:
Non-signatories to eepromread (unsigned char the beginbyte) (char
Non-signatories to I signed the non-burned;
EA=0; EA = 0;
i=RW24XX(&result,1,beginbyte,READ_OP,M2402); i = RW24XX (& result, 1, beginbyte, READ_OP, M2402);
EA=1; EA = 1;
return(result); return (result);
I signed the non-burned;
EA=0; EA = 0;
i=RW24XX(&datum,beginbyte,WRITE_OP,M2402); i = RW24XX (& datum, beginbyte, WRITE_OP, M2402);
EA=1; EA = 1;
We can see that the function RW24XX the EEPROM memory chip operations, the main function here is the function included in the definition of parameters:
Point RW24XX (unsigned char * DataBuff, unsigned to ByteQuantity, unsigned int Address, unsigned char the ControlByte, enum eepromtype EepromType char)
One, DataBuff to read and write data input and output buffer zone in the first address, ByteQuantity to read and write data for the number of bytes, the address of the EEPROM chip-chip address, ControlByte is the control byte EEPROM, the specific form of (1) ( 0) (1) (0) (A2) (a) (A0) (R and W), of which R and W = 1, that reading, R and W = 0 to write, A2, 1, A0 EEPROM for the page-election or election address; EepromType for enumeration variables, the need for the M2401 ~ M24256 in one, corresponding to 24 C01 ~ 24C256, the system for the M2402; return value as a function of variables, if returned to a That the operation failed and 0 if successful; ERRORCOUNT to allow the greatest number of times, if there ERRORCOUNT after the failure of the operation, function suspend operations, and return to 1.
Figure 5
In the function, called a number of I2C bus function as follows:
Invalid IICStart (void);
Invalid IICStop (void);
Point IICRecAck (void);
Invalid IICNoAck (void);
Non-signatories to IICReceiveByte (void burned);
Invalid IICSendByte (unsigned char sendbyte);
Closing remarks
The system is simple, easy to operate, with both manual and automatic control mode, has a smart; can control the scene, while remote control; according to the situation at the scene and reasonable control of state regulation. RTX51TNY In addition, the use of RTX51TNY the system to provide real-time operating system features, you can simplify the design process more tasks to meet the multiple tasks of the time of request. Based on real-time multi-task operating system, the task can be broken down Xiu, the task of maintaining the relative independence can effectively improve the program structure to facilitate modular processing, the readability of the procedure, maintainability and portability are Further improved.