Work and rest time controller based on single-chip microcomputer

Through a microcontroller-based work and rest time controller, combined with components such as STM32F103 and RF transceiver, the time accuracy, intelligent control and power monitoring of the campus work and rest time control system is solved, and time synchronization and multi-function management of the whole school equipment is realized, and remote settings and power outage memory are supported.

CN120560086APending Publication Date: 2025-08-29HANGZHOU YUHANG NO 1 MIDDLE SCHOOL
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411378971.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-08-29

AI Technical Summary

Technical Problem

The existing campus work and rest time control system has problems such as low time accuracy, insufficient intelligent control, poor power monitoring and inconvenient remote control, and cannot meet the needs of campus intelligent construction.

Method used

The work and rest time controller based on a microcontroller is adopted, including a remote control node and a real-time execution node. STM32F103 is used as the control core, combined with RF transceiver, DS3231 clock chip, nRF24L01P RF chip and MP3 module to realize remote time synchronization, ringtone control, lighting management and power monitoring, and support multi-node remote management.

Benefits of technology

It realizes accurate control of work and rest time on campus, has radio, ringing bells in and out of class, and light control functions, has power outage memory and power prompts, supports wireless remote control settings, can synchronize the time of the entire school equipment, is highly scalable, and has reliable data storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120560086A_ABST
    Figure CN120560086A_ABST
Patent Text Reader

Abstract

The invention discloses a single-chip microcomputer-based work and rest time controller, which comprises a remote control node and a real-time execution node, and is characterized in that the real-time execution node comprises an interface display module and a key module, and the interface display module and the key module form a human-computer interaction interface; communication between the remote control node and the real-time execution node is established through an RF transceiver, the system node adopts STM32F103 as a control core, the remote control node configures time parameters through man-machine interaction interface operation, data are sent to the real-time execution node through a wireless module of the RF transceiver, and the real-time execution node is connected with the system node. And the real-time execution node performs corresponding operation according to the received data so as to realize a remote control function, and the remote control node allows complete remote control of the real-time execution node. Various problems of time precision, intelligent control, electric quantity monitoring and the like of the work and rest time controller can be effectively solved, daily application can be met, and a feasible scheme is provided for intelligence of campuses and various occasions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of single-chip microcomputers, and in particular to a work and rest time controller based on a single-chip microcomputer. Background Art

[0002] Nowadays, the application of electronic technology is ubiquitous, bringing about tremendous innovations in social life and production. Microcontrollers, as a key component of the electronic technology field, have matured into a wide range of electronic products. A work and rest schedule controller is one such microcontroller-based application. This controller design can be widely used in various settings, such as schools, offices, and homes, enabling convenient and controlled work and rest schedules by ringing bells to remind people to work, study, or rest. School bell systems are a primary application context. Schools are inseparable from bells. Teachers and students need a daily routine, whether in primary or secondary schools or universities. Classes, such as those central to campus activities, must begin and end with the bell. Within a campus, there are often different buildings. If the schedules of different buildings are inconsistent, the bell will be played incorrectly, disrupting the normal operation of the entire school.

[0003] With the progress of the times and the development of science and technology, intelligence has become the future development trend. As the forefront of technological development in various disciplines, colleges and universities need to grasp the forefront of science and technology. Therefore, the intelligent construction of schools has become a top priority and an inevitable trend. Therefore, for the long-term development of schools, schools must strengthen the intelligent construction of all aspects of the school. The work and rest time controller provides great convenience for the accurate control of school start and end times and is an important part of realizing the intelligent construction of the campus. Therefore, the design of this work and rest time controller has important practical significance and application value.

[0004] While bell control systems are not complex in design, they place high demands on reliability and real-time performance, and they must also incorporate intelligent control. For various reasons, bell control has received limited attention, leading to the practice of manual bell control on campuses. These unpowered systems lack programming capabilities, making reliability and time accuracy highly challenging. Research on this topic is limited.

[0005] Investigations have revealed a wireless bell system in China that utilizes a Zigbee module. The system's main control chip is the CC2520 from TI, which includes an RF transceiver and an enhanced 8051 microcontroller. The clock control uses a DS1302 chip, enabling relatively accurate timekeeping. However, the system's design is relatively simplistic, simply controlling a relay to turn the bell on and off, without the ability to control music or announcements. Furthermore, it faces distance limitations and is susceptible to interference, making it of limited use.

[0006] Another example is the recent development of a PLC-based campus schedule control system at Yangtze University's School of Electronic Information. This PLC approach ensures accurate time control while also providing flexibility for special circumstances. However, due to its high power consumption, it cannot be powered by batteries. Key parameters require resetting after a power outage, and remote time calibration and adjustment are not possible. This significantly increases costs, making it unsuitable for widespread adoption.

[0007] Overseas, students from the Faculty of Engineering and Information Technology at the International Birch University and the Faculty of Electrical Engineering at the University of Sarajevo jointly developed an embedded system for a school's automatic bell system. The system uses wireless control to establish system connectivity. A computer sends commands to a master node via a serial port, which in turn transmits data to the terminal devices. The terminal nodes, or actuators, can operate as independent devices, without the need for a remote control node. This system has been deployed in local schools and has received positive feedback, making it a valuable reference. However, it also presents some challenges. First, if the distance exceeds the transmission range of the wireless sensor, the computer must be carried to ensure transmission distance, making control more inconvenient. Second, the system only implements point-to-point network node control and does not allow multiple nodes to be managed by a single controller. These issues present significant room for improvement. Summary of the Invention

[0008] In order to solve certain technical problems existing in the prior art, the purpose of this application is to provide a work and rest time controller based on a single-chip microcomputer, which can effectively solve various problems such as time accuracy, intelligent control, power monitoring, etc. of the work and rest time controller, can meet daily applications, and provide a feasible solution for the intelligence of campuses and various occasions.

[0009] In order to solve the above existing technical problems, the purpose of this application is achieved by adopting the following technical solutions:

[0010] A single-chip microcomputer-based work and rest time controller comprises a remote control node and a real-time execution node. The real-time execution node comprises an interface display module and a key module, the interface display module and the key module forming a human-computer interaction interface. Communication between the remote control node and the real-time execution node is established via an RF transceiver. The system node adopts an STM32F103 as a control core. The remote control node configures time parameters via human-computer interaction interface operations and uses a wireless module of the RF transceiver to send data to the real-time execution node. The real-time execution node performs corresponding operations based on the received data, thereby realizing a remote control function. The remote control node allows complete remote control of the real-time execution node.

[0011] Preferably, the remote control node module includes power management, a button module, a wireless communication device, a storage device, a display interface and a controller.

[0012] Preferably, the real-time execution node module consists of eight parts: a controller, a clock chip, a human-machine interface, a storage device, a ringing device, a lighting circuit, a wireless communication device and a power supply.

[0013] Preferably, the clock chip adopts an I2C protocol-based DS3231 external clock chip, and a temperature-compensated crystal oscillator and a crystal are integrated on the clock chip.

[0014] Preferably, the RF transceiver includes an nRF24L01P radio frequency chip and an RFX2401C power amplifier chip, and the RF transceiver has a built-in LNA.

[0015] Preferably, the nRF24L01P radio frequency chip communicates on a channel between 2.4G and 2.5G. The address of each chip is 5 bytes. Each receiving end is set to a different address. The sending end sends data by switching channels and changing addresses. The receiving end will receive the data content of the corresponding channel and address.

[0016] Preferably, the single chip microcomputer in the controller adopts STM32F103C8T6 chip, and the DS3231 clock chip circuit adopts 3V button battery to provide accurate time to the single chip microcomputer, and the single chip microcomputer controls the OLED display module to display accurate and complete time.

[0017] Preferably, the wireless module interface adopts an SPI communication mode, the wireless module is connected to an external single-chip microcomputer, and the external single-chip microcomputer configures internal registers through the SPI interface. The internal registers are divided into control registers and data registers.

[0018] Preferably, the real-time execution node module further includes a storage chip, and the work and rest time controller implements data storage and memory functions through the storage chip.

[0019] Preferably, it further comprises an MP3 module, and the work and rest time controller plays ringtones through the MP3 module.

[0020] Preferably, a lighting circuit is also included.

[0021] Preferably, the interface display module adopts an OLED liquid crystal display screen with a resolution of 128*64, and the internal driver chip is SSD1306.

[0022] Preferably, the working program of the remote control node module includes a main program, a task scheduler and a timer interrupt service function.

[0023] Preferably, the human-computer interaction interface program composed of the interface display module and the button module is in the same task.

[0024] Compared with the prior art, the present invention has the following beneficial effects:

[0025] This controller enables the campus bell system to display the date, day of the week, and clock; it also features functions such as broadcasting, get out of class bells, and lighting control; it has corresponding setting keys to adjust the date, day of the week, and clock, and change the times for broadcasting, get out of class bells, and lighting control; it has a power-off memory function and a low-battery warning function; the setting function is realized by a wireless remote control, and it has a memory function that can save the current setting parameters and set them to different terminals with one click. This allows for time calibration in some way; it can publish a base time to all bell devices in the school to synchronize the ringing time of the bell; it can easily publish the set bell schedule and lighting control time to all devices in the school; it has a data storage function that prevents data from being lost; and it can be expanded to a certain number of bell devices, such as installing bell devices in a new teaching building. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 This is a block diagram of the control network structure of the entire system in the present invention;

[0027] Figure 2 This is a diagram of the remote control node module architecture in the present invention;

[0028] Figure 3 This is a diagram of the real-time execution node architecture of the present invention;

[0029] Figure 4 It is the overall hardware framework of the remote control node in the present invention;

[0030] Figure 5 This is a flowchart of the remote control node working procedure in the present invention;

[0031] Figure 6 Flowchart of the controller node working procedure executed in the present invention;

[0032] Figure 7 This is a flowchart of the remote controller node wireless connection task program in the present invention;

[0033] Figure 8 This is a flowchart of the program for executing the node wireless connection task in real time in the present invention;

[0034] Figure 9 This is a flowchart of the ADC acquisition task program in the present invention;

[0035] Figure 10 This is the overall task flow chart of the interface display module and the button module in the present invention;

[0036] Figure 11 A flowchart showing the processing of the program in the present invention;

[0037] Figure 12 This is a flowchart of the key processing part with the delay debouncing link added in the present invention. DETAILED DESCRIPTION

[0038] Below, the present application is further described in conjunction with the accompanying drawings and specific implementation methods. It should be noted that, under the premise of no conflict, the various embodiments or technical features described below can be arbitrarily combined to form new embodiments.

[0039] In the description of this application, it should be understood that the terms "up", "down", "left", "right", etc. indicate directions or positional relationships based on the directions or positional relationships shown in the accompanying drawings. They are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific direction, be constructed and operated in a specific direction. Therefore, they should not be understood as limitations on this application.

[0040] The terms "first," "second," and the like in this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.

[0041] A single-chip microcomputer-based work and rest time controller comprises a remote control node and a real-time execution node. The real-time execution node comprises an interface display module and a key module, the interface display module and the key module forming a human-computer interaction interface. Communication between the remote control node and the real-time execution node is established via an RF transceiver. The system node adopts an STM32F103 as a control core. The remote control node configures time parameters via human-computer interaction interface operations and uses a wireless module of the RF transceiver to send data to the real-time execution node. The real-time execution node performs corresponding operations based on the received data, thereby realizing a remote control function. The remote control node allows complete remote control of the real-time execution node.

[0042] The work schedule controller consists of two components: a remote control node module and a real-time execution node module. The remote control node's operating program primarily implements clock management, time configuration, display management, communication transmission, data processing, and storage management. The real-time execution node handles communication reception, data processing, storage management, display management, ringtone control, and lighting control. On campus, the real-time execution node is the ringtone playback device, also known as a wireless terminal device. The remote control node is the device that wirelessly controls the ringtone device and can be considered a remote control device, also known as a wireless transmitter. The real-time execution node is a small, compact device whose primary function is to activate the ringtone at the correct time. A human-machine interface consisting of buttons and a display allows users to control the device. The display shows the current time, including year, month, day, and weekday, down to the second. If there is a time discrepancy between the device and the remote control node, the user can synchronize the device through the remote control node. In addition, buttons can be used to adjust the ringtone volume and perform emergency pauses.

[0043] The remote control node allows complete remote control of the real-time execution node, including time synchronization, ringtone data selection, and other related operations. The node also features a user-friendly human-machine interface. The display is the primary means of accessing information and settings, and each button has a distinct function, making operation simple and easy to use. Crucially, the device is portable, allowing for quick configuration.

[0044] The communication between the remote control node and the real-time execution node is established through the RF transceiver. The control network structure diagram of the system is as follows Figure 1 As shown. Figure 1 As can be seen, the control network consists of a remote control node and multiple real-time execution nodes. The remote control node sends data to each real-time execution node via wireless devices based on the configuration. Upon receiving the data, each real-time execution node controls the execution device at a different time point, thus achieving "one-to-many" remote control.

[0045] The above embodiment is further improved as follows: the remote control node module includes a power management, a button module, a wireless communication device, a storage device, a display interface and a controller.

[0046] The remote control node needs to complete multiple operations, including time setting, power monitoring and management, data storage and transmission, etc., all of which are inseparable from the management of the controller. The external module consists of a power supply, a button module, a wireless communication device, a storage device, a display interface and a controller. The operation process is to set different task times through buttons, and the display interface will reflect the setting information to the user. After the user completes the data configuration, the data is saved with one click and the data is packaged into a protocol and sent to the real-time execution node. In addition to this part of the task, the controller also needs to continuously collect the power supply voltage, and obtain the percentage of power through circuit voltage division and software conversion to display on the display interface. If the power is lower than the set value, the light will light up to warn. The remote control node module architecture is as follows Figure 2 shown.

[0047] The above embodiment is further improved as follows: the real-time execution node module is composed of eight parts: a controller, a clock chip, a human-machine interface, a storage device, a ringing device, a lighting circuit, a wireless communication device and a power supply.

[0048] Figure 3 As shown, Figure 3 As shown in the real-time execution node architecture diagram, the controller monitors data sent by the remote control node in real time. Upon receiving a data packet, the software distinguishes the data type and disassembles the packet. Upon completion, the disassembled data is automatically saved to the memory chip to prevent data loss during power outages. When a data packet updates the real-time clock, the internal clock of the clock chip is refreshed to align with the remote control node's clock. When a data packet receives a ringing time packet, the existing data is updated, and the controller rings according to the time of each ringing time. When a data packet receives a lighting time packet, the lighting device turns on and off according to the set time. Furthermore, this real-time execution node also features a clock chip to ensure accurate timekeeping and ringing response, as well as power supply and button control. The buttons are used for functions such as adjusting the ringing music volume and emergency shutdown.

[0049] A further improvement on the above embodiment is that the clock chip adopts an I2C protocol-based DS3231 external clock chip, and the clock chip is integrated with a temperature-compensated crystal oscillator and a crystal.

[0050] In this system, there are multiple methods that can achieve clock control based on the microcontroller, such as delay control, timer control, STM32's built-in RTC peripheral, and external clock chips. However, for places like campuses that require high clock accuracy, the clock control solution needs to be carefully considered.

[0051] Compared with the above methods, delay control is the least accurate way to calculate time, and it greatly occupies system resources and has extremely poor accuracy. Therefore, it is not considered as a solution for this clock control.

[0052] The timer control method shares the same problem as the method using the STM32's built-in RTC peripheral: the accuracy of the external crystal oscillator determines time precision. The higher the external crystal oscillator's precision, the more stable the time control will be; conversely, the lower the crystal oscillator's precision, the greater the time error. Furthermore, the timer interrupt in the timer control method is easily affected by other interrupts, resulting in a certain amount of cumulative error. In summary, both clock control schemes are unsuitable for this research system. Therefore, to prevent abnormal timekeeping during power-up or power-down, the high-precision DS3231 clock chip is used as the clock chip. The DS3231 has two power pins, VCC and VBAT, which connect to the VCC power supply and the backup battery, respectively. Switching between these two power pins is controlled by a temperature-compensated voltage reference (VPF) and a comparator circuit that monitors the VCC level. The chip also has an integrated temperature-compensated crystal oscillator (TCXO) and a 32.768kHz crystal. The integrated crystal oscillator improves the device's long-term accuracy. The RTC maintains information on seconds, minutes, hours, day of the week, date, month, and year, and features automatic adjustment of the end-of-month date and leap year compensation. These functions and features bring great convenience to programmers, eliminating the need for calculations in software programs. A precision, temperature-compensated voltage reference and comparator are used to monitor the VCC status, detect power failures, provide a reset output, and automatically switch to the backup power supply when necessary. The device includes a battery input to maintain accurate timing even when the main power supply is disconnected. The integrated crystal oscillator improves the long-term accuracy of the device. The 32kHz temperature-compensated crystal oscillator can keep the RTC accuracy within ±2 minutes / year.

[0053] The above embodiment is further improved as follows: the RF transceiver includes an nRF24L01P radio frequency chip and an RFX2401C power amplifier chip, and the RF transceiver has a built-in LNA.

[0054] This system uses an RF transceiver, specifically the nRF24L01P radio chip, for information transmission. This RF transceiver enables communication between remote control nodes and real-time execution nodes. Using the low-power, low-cost nRF24L01P chip, the indoor range is approximately 30 meters. Obviously, this distance falls short of the system's requirements. However, using the nRF24L01P RF chip and the RFX2401C power amplifier chip with a built-in LNA significantly improves receiver sensitivity and extends the transmission distance. Ideally, the transmission distance could reach 2,300 meters, making it suitable for large-scale applications like campuses.

[0055] The above embodiment is further improved as follows: the nRF24L01P RF chip communicates on a channel between 2.4G and 2.5G, the address of each chip is 5 bytes, each receiving end is set to a different address, the sending end sends data by switching channels and changing addresses, and the receiving end will receive the data content of the corresponding channel and address.

[0056] However, using the nRF24L01P RF chip presents a significant drawback that limits its use in schools. The nRF24L01P has only six receive channels and can only implement a 6-transmit, 1-receive communication mode; it cannot achieve a 1-transmit, 6-receive mode, or even a 1-transmit, multiple-receive mode. To address this issue, the nRF24L01P is a 2.4GHz frequency band chip that can communicate on channels between 2.4GHz and 2.5GHz, resulting in a total of 125 channels that can be switched. Furthermore, each chip has a 5-byte address, and each receiver can be set to a different address. This way, the transmitter sends data by switching channels and changing addresses, and the receiver receives the data corresponding to the channel and address. This method enables one-to-infinite communication, a broadcast communication method. Imagine a pair of 10 devices communicating with each other, sending and receiving data. The nRF24L01Ps in each of the ten nodes are set to different channels, such as 10, 20, 30, and so on. If the host nRF24L01P wants to obtain data from a particular node, it sets the channel to that node and then sends and receives data to each other. Once this is complete, it can communicate with another node. Because the microcontroller runs quickly, sending and receiving data from all ten nodes can be completed in an instant.

[0057] The above embodiment is further improved as follows: the single chip microcomputer in the controller adopts STM32F103C8T6 chip, the DS3231 clock chip circuit adopts 3V button battery as power supply, provides accurate time to the single chip microcomputer, and the single chip microcomputer controls the OLED display module to display accurate and complete time.

[0058] like Figure 4The overall hardware architecture of the remote control node is shown below. The STM32 microcontroller, based on the ARM Cortex-M3 core, offers breakthrough advantages in low power consumption, low cost, and high performance. The STM32F103C8T6, an enhanced version of the STM32 processor family, boasts extensive internal resources. The DS3231 clock chip, powered solely by a 3V button battery, provides precise time to the microcontroller, which in turn controls the OLED display module to display accurate and complete time. The keypad module and OLED display module combine to implement a human-machine interface. The AT24C08 memory chip enables power-off data storage, preserving important parameters. The wireless module uses the nRF24L01P radio chip to transmit data set by the remote control node to the real-time execution node. The power supply circuit includes a voltage regulator to provide a 3.3V voltage and a voltage divider circuit for voltage acquisition by the microcontroller.

[0059] A further improvement on the above embodiment is that the wireless module interface adopts SPI communication mode, the wireless module is connected to an external single-chip microcomputer, and the external single-chip microcomputer configures internal registers through the SPI interface. The internal registers are divided into control registers and data registers.

[0060] The wireless module interface uses SPI communication and can be driven by any microcontroller. An external microcontroller configures the chip's internal registers via the SPI interface. The internal registers are divided into control registers and data registers. The microcontroller can be used to configure the module in either receive or transmit mode, including the channel, address, number of bytes per transmission, CRC checksum, power, and more. In transmit mode, the microcontroller writes the data to the module, and the module automatically transmits it. In receive mode, the microcontroller monitors its IRQ pin to determine if data has been received. A low IRQ indicates data has been received, and the microcontroller can retrieve the received data through the SPI port.

[0061] A further improvement on the above embodiment is that the real-time execution node module also includes a storage chip, and the work and rest time controller implements data storage and memory functions through the storage chip.

[0062] To store data and provide memory for the work and rest time controller, the AT24C08 memory chip is used. This is a serial interface device, transmitting both address and data information over the same bus. When multiple chips are connected to the serial bus, each must have a unique device address. It offers low power consumption, wide operating voltage range, high erasable and rewritable endurance, fast read / write speeds, strong anti-interference capabilities, and long data retention. The AT24C08 also uses the I2C bus to communicate with the host computer. This I2C data exchange reduces microcontroller pin usage and supports both online and offline programming.

[0063] The above embodiment is further improved to further include an MP3 module, and the work and rest time controller plays ringtones through the MP3 module.

[0064] The ringtone player utilizes a compact micro-integrated MP3 module. It utilizes the MY1690-16S MP3 controller chip and supports both MP3 and WAV decoding. The module supports TF cards up to 32GB; you can also connect an external USB flash drive or USB data cable to a computer to transfer audio files from the SD card. The module also features a built-in 3W power amplifier circuit, capable of directly driving a 3W speaker, making it easy to use.

[0065] The above embodiment is further improved to further include a lighting circuit.

[0066] To achieve lighting control and time setting functions, a lighting circuit was designed for daily routine control. To simplify the system hardware and simulate real-life streetlights, 3W lamp beads were used as the simulation device. The lighting circuit uses the SI2302 NMOS transistor chip. At a 3V gate drive voltage, the on-resistance is only tens of milliohms and the drive current is as high as 3A, easily driving the 3W lamp beads, thereby achieving brighter lighting. The P4 interface in the figure serves as the interface for the 3W lamp beads, and the PWM_IN port is connected to the MCU's PWM output pin. The MCU can adjust the duty cycle to achieve the purpose of adjusting the lamp bead brightness.

[0067] A further improvement on the above embodiment is that the interface display module uses an OLED liquid crystal display with a resolution of 128*64, and the internal driver chip is SSD1306.

[0068] The main function of the schedule controller is to ring the bell on time. The LCD module only assists with manual controller settings and time display. Settings are simple, including date and time, bell time, and lighting duration. Therefore, a 128*64 resolution OLED display was selected, driven by the SSD1306 internal driver chip. This chip has an integrated DC-DC boost, requiring only 3.3V for normal operation and supporting 4-wire SPI communication. OLED_RST is the reset control pin, OLED_DC is the data command control pin, OLED_CLK is the SPI clock control pin, and OLED_SDA is the SPI data input pin.

[0069] A further improvement on the above implementation is that the working program of the remote control node module includes a main program, a task scheduler and a timer interrupt service function.

[0070] The remote control node module's operating program consists of three parts: the main program, the task scheduler, and the timer interrupt service function. After power-on reset, the CPU first initializes the chip internals, including the stack, initializing the Flash memory, updating system variables, and interrupt reset settings. It then initializes external devices, including the LED, OLED, DS3231, buttons, buzzer, wireless module, and ADC. After that, the timer interrupt is initialized, checking the AT24C08 EEPROM memory, reading all settings such as the ringing time and light time, and assigning them to variables. Next, the program enters the FreeRTOS task creation function and begins task scheduling.

[0071] In the task scheduler, the repeatedly executed codes include wireless connection tasks (including operations such as sending data and processing data), ADC acquisition tasks, data storage tasks, and button and display tasks. According to the FreeRTOS real-time operating system, each task can be assigned a certain priority order according to different levels of importance. The CPU is always in a ready state, and the task with the highest priority runs first. Tasks with the same priority are scheduled in a round-robin manner. In this task scheduler, the execution priority order of these tasks is from top to bottom, and low-priority tasks can also be interrupted by high-priority tasks. The wireless connection task needs to complete the sending of update time data packets, ringtone schedule data packets, and lighting control schedule data packets. The ADC acquisition task is used to collect battery power and perform a low-power prompt function to facilitate users to master the controller and prevent problems before they occur. In task scheduling management, the ADC acquisition task is executed approximately once every 1S, which means that the power level changes in real time, and the change time interval is 1 second. Considering that the user can intuitively see the power value, the program will convert the actual voltage value of the digital quantity taken, and convert the voltage value into a relative quantity, and feedback to the user in the form of a percentage. The ADC acquisition task program flow is as follows Figure 9 shown.

[0072] The data storage task is mainly to complete the preservation of ringtone data and lighting data. The button and display tasks are composed of two parts. The button operation is mainly to set the system date and time, ringing time and lighting time on site, and also includes sending data and saving data; the display and buttons complete the interaction of the human-computer interface. The display interface includes the system time interface, function option interface, update time interface, ringtone setting interface and lighting setting interface. The timer interrupt service program is used to turn the buzzer on and off, and is used together with the button. When a button is pressed, the buzzer will sound to prevent the user from making any wrong operations. The working procedure flow of the remote control node is as follows Figure 5 shown.

[0073] The working procedure flow of the real-time execution node module is basically the same as that of the real-time execution node module. Only in the hardware module, the real-time execution node module has a ringtone player and a lighting circuit compared to the remote control node module. This part of the content needs to be added in the software design. First, in the initialization of software and hardware, in addition to the above initialization, the ringtone player needs to be initialized. In addition, the timer PWM needs to be initialized to control the lighting circuit, and the duty cycle can be adjusted arbitrarily to achieve the brightness of the light, which meets the design requirements. In the task scheduler, it is also necessary to add a ringtone playing task and a lighting control task. But the priority can be placed at a lower position. The ringtone playing task needs to play the corresponding ringtone according to the order of sending the schedule; the lighting control task is also turned on and off according to the time data. The working procedure flow of the execution controller node is as follows Figure 6 shown.

[0074] The wireless connection program tasks of the remote controller node are mainly divided into three parts:

[0075] The first part involves sending the update time data packet. Once the update time data is approved, it is sent to the real-time execution node. This data is the current real-time time of the remote controller node, and then the communication data packet is encapsulated in the aforementioned communication data packet format. After encapsulation is complete, the task waits for the wireless module to successfully transmit the data packet. If the data packet is successfully transmitted, a message will be displayed on the display task, indicating the successful transmission.

[0076] The second part is the sending of the ringtone data packet. When the ringtone data packet is allowed to operate, the program will calculate the total number of ringtone data settings, and then send the encapsulated ringtone data in sequence until all the data is sent.

[0077] The third part is the sending of lighting control time data. It also needs to receive permission to send data. The sending process is similar to the sending of update time data packets. For example, the remote controller node wireless connection task program flow is as follows: Figure 7 shown.

[0078] The real-time execution node wireless connection task program flow is opposite to the remote controller node. This node task needs to analyze and decode the received data and then store it in the operation variable. Figure 8 shown.

[0079] A further improvement on the above embodiment is that the human-computer interaction interface program composed of the interface display module and the button module is in the same task.

[0080] The overall task flow of the interface display module and button module is as follows Figure 10 As shown. Figure 10 It can be seen that the task puts the display task handler and the key task handler in the same task. Because after debugging, it was found that if the interface display module and the key module tasks are not in the same task, the switching of the key to the display interface will cause the data at different times to be interspersed, resulting in confusion in the display interface.

[0081] The display part has 7 display interfaces, namely the main interface, menu interface, update time interface, ringtone data configuration interface, light control interface, message box interface and reset interface. The display program processing content is relatively simple, and its program flow is as follows: Figure 11 shown.

[0082] The remote control node of the key processing part has a total of 7 keys, and each key has its own function. The program will perform different operations according to different keys, including interface switching, data modification, data storage, etc. Among them, in order to avoid the value changing too quickly or out of control due to jitter during operation, the program must add a delay de-jitter link, such as Figure 12 This program is actually a millisecond-level delay program, generally controlled to 10ms. After the delay, you need to confirm the button status again before performing the corresponding operation.

[0083] The above-mentioned embodiments are only preferred embodiments of the present application and cannot be used to limit the scope of protection of the present application. Any non-substantial changes and replacements made by technicians in this field based on the present application shall fall within the scope of protection required by the present application.

Claims

1. A work and rest time controller based on a single chip microcomputer, characterized by: The system comprises a remote control node and a real-time execution node. The real-time execution node comprises an interface display module and a button module. The interface display module and the button module constitute a human-computer interaction interface. Communication between the remote control node and the real-time execution node is established through an RF transceiver. The system node adopts STM32F103 as the control core. The remote control node configures time parameters through human-computer interaction interface operations and uses the wireless module of the RF transceiver to send data to the real-time execution node. The real-time execution node performs corresponding operations according to the received data, thereby realizing a remote control function. The remote control node allows complete remote control of the real-time execution node.

2. A single chip microcomputer-based work and rest time controller according to claim 1, characterized in that: The remote control node module includes a power management, a key module, a wireless communication device, a storage device, a display interface and a controller.

3. The single chip microcomputer-based work and rest time controller according to claim 2, characterized in that: The real-time execution node module consists of eight parts: a controller, a clock chip, a human-machine interface, a storage device, a bell device, a lighting circuit, a wireless communication device and a power supply.

4. The single chip microcomputer-based work and rest time controller according to claim 3, characterized in that: The clock chip adopts a DS3231 external clock chip based on the I2C protocol, and a temperature-compensated crystal oscillator and a crystal are integrated on the clock chip.

5. The single chip microcomputer-based work and rest time controller according to claim 1, characterized in that: The RF transceiver includes an nRF24L01P radio frequency chip and an RFX2401C power amplifier chip, and the RF transceiver has a built-in LNA.

6. The single chip microcomputer-based work and rest time controller according to claim 5, characterized in that: The nRF24L01P RF chip communicates on a channel between 2.4G and 2.5G. The address of each chip is 5 bytes. Each receiving end is set to a different address. The sending end sends data by switching channels and changing addresses. The receiving end will receive the data content of the corresponding channel and address.

7. The single chip microcomputer-based work and rest time controller according to claim 3, characterized in that: The single-chip microcomputer in the controller adopts the STM32F103C8T6 chip, and the DS3231 clock chip circuit is powered by a 3V button battery alone to provide accurate time to the single-chip microcomputer, which controls the OLED display module to display accurate and complete time.

8. The single chip microcomputer-based work and rest time controller according to claim 1, characterized in that: The wireless module interface adopts SPI communication mode, the wireless module is connected to an external single-chip microcomputer, and the external single-chip microcomputer configures internal registers through the SPI interface. The internal registers are divided into control registers and data registers.

9. The single chip microcomputer-based work and rest time controller according to claim 1, characterized in that: The real-time execution node module also includes a storage chip, an MP3 module and a lighting circuit. The work and rest time controller realizes the storage data and memory function through the storage chip; the work and rest time controller plays the ringtone through the MP3 module.

10. The single chip microcomputer-based work and rest time controller according to claim 1, characterized in that: The working program of the remote control node module includes a main program, a task scheduler and a timer interrupt service function.