Internet of Things module programming method and device

By using pre-installed firmware and ladder diagram programming in IoT modules, the problem of high difficulty and low efficiency in IoT module development is solved, low cost, flexible adaptation and intellectual property protection are achieved, and development efficiency and program portability are improved.

CN120491947AActive Publication Date: 2025-08-15BEIJING XIAOER INTELLIGENT TECHNOLOGY CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510427570.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-07
Publication Date
2025-08-15
Estimated Expiration
2045-04-07

AI Technical Summary

Technical Problem

During the development process, existing IoT modules have problems such as insufficient hardware capabilities, high development difficulty, high cost, low development efficiency and insufficient intellectual property protection.

Method used

The IoT module with pre-installed firmware is independently defined through ladder diagram programming and PIN function, blocking MCU differences, combining a graphical configuration mechanism to realize flexible writing and initialization of user programs, and supports low-power design.

Benefits of technology

It reduces the difficulty of programming IoT modules, improves development efficiency and program portability, simplifies low-power design, and protects intellectual property rights.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120491947A_ABST
    Figure CN120491947A_ABST
Patent Text Reader

Abstract

The invention discloses an Internet of Things module programming method and device, and relates to the technical field of Internet of Things, and the Internet of Things module programming method and device comprise the following functions: firmware is pre-installed in an MCU (Microprogrammed Control Unit) in an Internet of Things module, and the firmware is used as an operating system and allows a user to write a user program according to the need of a peripheral circuit; the PIN function of the Internet of Things module is independently defined, one Internet of Things module model corresponds to one PIN function list, a part of PINs are provided with multiple selectable functions, and PIN pins are divided into GPIO pins and special pins; different MCU chip models can be adopted in the same Internet of Things module model, and for a user program, the pre-installed firmware shields the difference of different MCUs; through MCU detail shielding, code-free ladder diagram programming, PIN multifunctional configuration and specialized firmware functions, the development difficulty is reduced, the development efficiency is improved, the intellectual property of firmware is protected, meanwhile, the compactness, low cost and universality of an Internet of Things module are reserved, and development of the Internet of Things industry is expected to be promoted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of Internet of Things, and in particular to a method and device for programming an Internet of Things module. Background Art

[0002] As an important reform of the information technology industry, the development of the IoT’s perception layer terminals faces many challenges. Figure 1 Currently, there are two main types of IoT modules that serve as the IoT's perception layer: one type is non-developable and requires an external MCU and communication via pre-defined protocols, such as AT commands. This doesn't fully utilize the IoT module's hardware capabilities, and its size and cost are suboptimal. The other type is based on an SDK for developing communication modules, primarily developed in the C language. This requires high developer expertise and requires familiarity with MCU hardware and SDKs, hindering development efficiency. Some designs with intellectual property cannot be provided via SDK. PLCs are widely used in industrial control and include pre-installed firmware and user programs. This specialized pre-installed firmware significantly ensures PLC stability and effectively protects the firmware's intellectual property. Furthermore, the PLC's ladder diagram language is easy to learn, resulting in high development efficiency and convenient on-site program modifications. PLCs are complete devices, including a rugged housing and fixed I / O terminals with clearly defined functions. They are equivalent to IoT modules and are bulky and costly. If PLC programming methods can be applied to IoT modules while keeping them compact and low-cost, and allowing them to flexibly adapt to external circuits for hardware and software design, so as to quickly develop various IoT products, it will help reduce the difficulty of IoT device development, improve development efficiency, protect intellectual property rights, and further promote the popularization of the IoT.

[0003] In view of this, this application is hereby filed. Summary of the Invention

[0004] The purpose of the present invention is to provide an Internet of Things module programming method and device to solve the problems raised in the above background technology.

[0005] To solve the above technical problems, the present invention provides an Internet of Things module programming method, comprising the following steps:

[0006] The MCU inside the IoT module is pre-installed with firmware. This firmware acts as an operating system, allowing users to write user programs based on the needs of peripheral circuits. The PIN functions of the IoT module are independently defined, with each IoT module model corresponding to a PIN function list. Some PINs are set with multiple optional functions, and the PIN pins are divided into GPIO pins and dedicated pins. The same IoT module model can be implemented using one or more different MCU chip models. For user programs, the pre-installed firmware masks the differences between different MCUs. Configuration instructions for selecting the PIN function definition of the IoT module are set in the user program, and the pre-installed firmware initializes the PIN function of the internal MCU according to these configuration instructions.

[0007] After the pre-installed firmware initializes the PIN function of the internal MCU according to the configuration instructions in the user program, the user program initializes and configures the relevant interface functions, interrupt services, network protocols, and initializes the internal data structure of the run cycle task;

[0008] The user program defines at least one execution cycle task;

[0009] User programs are generated using a graphical interface, with ladder diagram programming being preferred. The host computer is equipped with a ladder diagram editor. A ladder diagram program consists of multiple RUNG sequences, each containing action instruction symbols and serial and parallel logical connections between action instructions.

[0010] This is accomplished through ladder diagrams and D and M resources. Configuration instructions are saved in the ladder diagram, and the pre-installed firmware in the module executes the configuration instruction series saved in the ladder diagram program one by one.

[0011] Configuration is performed through a visual module configuration diagram. Each module has an independent visual module configuration diagram, which is displayed according to the module's IO plane distribution. The user double-clicks each IO pin to pop up the corresponding configuration options. After configuration is completed, it is saved as an IO configuration file. The IO configuration file is converted by the compiler into the same ladder diagram configuration instructions and executed by the pre-installed firmware in the module.

[0012] The action instruction operation objects of ladder diagram programming include external input X, output Y, internal resources M, D, C, T, etc., and also involve special peripheral interfaces.

[0013] Simultaneously, the present invention provides an Internet of Things module programming device, which includes:

[0014] Host computer: The host computer runs the ladder diagram editor, which is used by users to perform graphical programming operations and generate user programs containing configuration instructions, initialization instructions, and task instructions;

[0015] IoT module: The IoT module contains pre-installed firmware and user program storage space. The pre-installed firmware is responsible for parsing and executing the configuration instructions in the user program, completing MCU PIN function initialization, interface function configuration, interrupt service configuration, network protocol configuration operations, and repeatedly executing the cyclic task instruction code in the user program. The user program defines at least one execution cyclic task.

[0016] The ladder diagram editor of the host computer supports two graphical configuration mechanisms, which convert the configuration information generated by the user through the ladder diagram or the visual module configuration diagram into instructions that can be recognized by the module.

[0017] The PIN function of the IoT module is independently defined. One IoT module model corresponds to a PIN function list. Some PINs are set with multiple optional functions, and the PIN pins are divided into GPIO pins and dedicated pins. Different MCU chip models can be used to implement the same IoT module model. For user programs, the pre-installed firmware shields the differences between different MCUs. Configuration instructions for selecting the PIN function definition of the IoT module are set in the user program, and the pre-installed firmware initializes the PIN function of the internal MCU according to the configuration instructions.

[0018] The IoT module uses a low-power MCU and includes a regular power supply output switch. The external circuit consists of a low-power peripheral circuit and a regular power supply peripheral circuit. The power supply of the regular power supply peripheral circuit is controlled by the regular power supply output switch inside the IoT module.

[0019] Furthermore, the configuration of the GPIO pin includes pin function selection, pin speed setting, and pin output control. For example, when configuring the PIN1 pin to the GPIO output mode to control the LED light, first select the function of PIN1 as output Y1, then select the appropriate speed from multiple speed options, and finally control the LED light on and off by programming the high and low levels of the PIN1 pin.

[0020] Furthermore, the RUNG serial-parallel relationship in the ladder diagram program is saved using text description. For example, a RUNG ladder diagram with a serial-parallel relationship is given, and its serial-parallel text description is in XML format containing action instructions and related parameters, which is then compiled into a user program that can be recognized by the module pre-installed firmware.

[0021] Furthermore, the action instruction operation objects of the ladder diagram programming include external input X, output Y, internal resources M, D, C, T, etc., and also involve special peripheral interfaces such as ADC, DAC, RS232, RS485, Ethernet, CAN, PWM, etc. Taking the RS serial data transmission instruction as an example, when the RS instruction is valid, the PLC is notified to wait for m data with S as the first address to be sent, and is ready to receive up to n data stored in the register with D as the first address.

[0022] Furthermore, the user program includes the module's IO configuration (single execution), other codes for single initialization (such as serial port baud rate, IP address, interrupt service, etc.), and at least one execution cycle task.

[0023] Compared with the existing Internet of Things module technology, the beneficial effects of the present invention are:

[0024] 1. Lower the programming threshold: Using ladder diagram graphical programming, there is no need to pay attention to the data details of the MCU, and no C language programming skills are required, which reduces the difficulty of IoT module programming and enables more people to participate in development.

[0025] 2. Improve programming efficiency: The PIN function of the IoT module is independent of the specific MCU. The pre-installed firmware shields the MCU details and the differences between different MCUs. The user program interacts with the pre-installed firmware instead of the specific MCU. Combined with the graphical configuration mechanism, the program can be modified on site, improving programming efficiency.

[0026] 3. Improve program portability: The action instruction operation objects of ladder diagram programming include external input X, output Y, internal resources M, D, C, T, etc., and also involve special peripheral interfaces such as ADC, DAC, RS232, RS485, Ethernet, CAN, PWM, etc. This IoT operating system generally has the same instruction format for the same action instruction operation objects, so the user program between different modules has strong portability.

[0027] 4. Simplify low-power design: Integrate low-power control hardware circuits and programs into the module, and implement low-power business processes through ladder diagram programming, reducing the difficulty of low-power design of IoT devices.

[0028] 5. Easy to manage and maintain the program: The user program has a clear structure, which is divided into IO configuration, single initialization code and execution cycle task. The ladder diagram is saved and compiled according to the RUNG serial and parallel relationship text, which improves the readability and maintainability of the program. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 Schematic diagram of two solutions developed for existing IoT terminals

[0030] Figure 2 This is a schematic diagram of the basic components of the Internet of Things module of the present invention;

[0031] Figure 3 This is a diagram showing the composition of the IoT module firmware program and user program of the present invention;

[0032] Figure 4 RUNG is a ladder diagram having a serial-parallel relationship in the present invention;

[0033] Figure 5 A schematic diagram of a text description of a RUNG instruction and its serial-parallel relationship in the present invention;

[0034] Figure 6 This is a schematic diagram of the low-power module with a conventional power supply output switch in the present invention;

[0035] Figure 7 This is a schematic diagram of a ladder diagram program fragment in the present invention;

[0036] Figure 8 This is a schematic diagram of the chip pin functions in the present invention;

[0037] Figure 9 This is a schematic diagram of a pop-up pin function list in the present invention;

[0038] Figure 10 This is a schematic diagram of the functions supported by pin 5 in the present invention;

[0039] Figure 11 This is a schematic diagram of the functions that can be configured for GPIO5 in the present invention;

[0040] Figure 12 This is a schematic diagram of the RS serial data transmission instruction format in the present invention;

[0041] Figure 13 This is an example of the PLC ladder diagram for the RS serial data transmission instruction in the present invention. DETAILED DESCRIPTION

[0042] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0043] The present invention provides a technical solution: a method and device for programming an Internet of Things module, please refer to Figure 2-13 .

[0044] 1. Implementation environment preparation:

[0045] like Figure 2 shown.

[0046] (1) Hardware:

[0047] 1. IoT module selection:

[0048] Select an IoT module with stable performance that meets the requirements of this invention. The definition of this module is independent of the specific internal MCU model and the characteristics of the pin PIN function. Some pins should have multiple optional functions and include GPIO pins and dedicated pins. For example, choose an IoT module with an integrated low-power MCU. Its GPIO pins can be flexibly configured as input or output mode, and dedicated pins include power, clock, reset, UART, I2C, SPI, CAN, Ethernet, ADC, PWM, antenna, etc. to meet the needs of different application scenarios.

[0049] 2. Peripheral circuit preparation:

[0050] Prepare a series of external circuits for communication and interaction with the IoT module. Specifically including:

[0051] LED light: This demonstrates the output control function of the GPIO pins. Use a standard light-emitting diode (LED) with an operating voltage compatible with the IoT module's output voltage. Connect the negative lead of the LED light to the module's GPIO output pin (e.g., module pin 5) through a current-limiting resistor, and the positive lead to a 3.3V power supply.

[0052] Serial port sensors, such as temperature and humidity sensors, are used to collect environmental data. Connect the sensor's TX (transmit) pin to the UART1_RX pin (e.g., PIN 6) via a serial communication cable, and connect the sensor's RX pin to the module's UART1_TX pin (e.g., PIN 7). Ensure the sensor and module ground signals are connected.

[0053] Other equipment: According to actual needs, relays, buttons and other equipment can also be prepared to control the on and off of external circuits and realize input detection functions.

[0054] (2) Software:

[0055] 1. Host computer software installation:

[0056] Install the ladder diagram editor software on the host computer (programming computer). You can choose an open source or closed source editor according to the actual situation, but you must ensure that it supports the graphical programming method adopted by the present invention and has the functions of creating, editing and compiling ladder diagram programs. Open source editors include LDMicro, OpenPLC Editor, etc., and each well-known PLC manufacturer generally has its own private editor, such as Mitsubishi's GX Works2, Delta's WPLSoft, etc. The editor converts the ladder diagram operation objects into configuration instructions and task instructions. The same action instruction operation objects generally have the same instruction format, so the user program has strong portability between different modules.

[0057] 2. IoT module firmware installation:

[0058] like Figure 3 As shown in the diagram of the IoT module firmware and user program composition, the pre-installed firmware adapts the IoT module's internal MCU driver and the configuration and task instructions in the user program. Developed based on a specific MCU SDK, the pre-installed firmware masks MCU details from the corresponding user program, presenting only the IoT module's functional definitions. The user program can operate on external inputs X and Y, internal resources M, D, C, and T, and dedicated peripheral interfaces such as ADC, DAC, RS232, RS485, Ethernet, CAN, and PWM. Check that the pre-installed firmware in the IoT module is functioning properly. The pre-installed firmware is the foundation for parsing and executing the user program. Ensure that its version is compatible with the current development environment and has complete functionality to correctly parse and execute the configuration and task instructions in the user program.

[0059] The ladder diagram editor software of the host computer edits and outputs the user program to complete the MCU PIN function initialization, interface function configuration, interrupt service configuration, and network protocol configuration operations, and repeatedly executes the cyclic task instruction code in the user program. The user program defines at least one execution cyclic task, such as reading sensor data from the serial port and controlling the GPIO output high and low levels based on the data to drive the LED light.

[0060] 2. Specific implementation steps:

[0061] (1) Module PIN function configuration:

[0062] 1. Select the configuration method:

[0063] This embodiment uses ladder diagram and D and M resources to complete the configuration. Open the ladder diagram editor and create a new ladder diagram program file.

[0064] Two graphical configuration mechanisms:

[0065] One method is to use ladder diagrams and D and M resources to directly save the ladder diagram configuration instructions. The pre-loaded program in the module will execute the configuration instructions saved in the ladder diagram program one by one. This is common to all modules.

[0066] like Figure 7 As shown in the ladder diagram program fragment, the first three lines are configuration instructions, and the fourth line onwards is the user program.

[0067] Another method uses a visual module configuration diagram. Each module has a separate visual module configuration diagram that displays the module's IO plane layout. Users double-click each IO pin to pop up the corresponding configuration options, which can then be saved as an IO configuration file. The IO configuration file is converted by a compiler into ladder diagram configuration instructions, similar to the first method. The pre-loaded program in the module executes the configuration instructions saved in the ladder diagram one by one.

[0068] Configuration steps example:

[0069] As shown in the following table, Figure 8 As shown in the figure: a PIN function is defined that is independent of the MCU model. Some PINs have multiple functions, and the user program configures them according to the needs of the peripheral circuit.

[0070]

[0071]

[0072] Note: P: Power; I: Input; O: Output; T: Can be set to high impedance. Pins in bold indicate their default functions.

[0073] 1) Click pin 5

[0074] 2) A list of pin functions pops up, with GPIO5 as the default option.

[0075] like Figure 9 As shown;

[0076] Click the drop-down arrow to display the functions supported by pin 5, and select GPIO5.

[0077] like Figure 10 As shown;

[0078] 3) After selecting the GPIO5 option, the functions that can be configured for GPIO5 will be associated

[0079] like Figure 11 As shown;

[0080] X5 is the input and Y5 is the output.

[0081] 4) Continue to configure the functions of other pins, and finally save them as a configuration file after confirmation.

[0082] 2. Configure GPIO pins;

[0083] Take configuring PIN5 as GPIO output mode to control the LED light as an example. The detailed steps are as follows:

[0084] Pin function selection: Find the pin function configuration instruction in the instruction library of the ladder diagram editor and select the function of PIN5 as output Y5. This can be done by entering the corresponding instruction code in the instruction input box or selecting the corresponding option in the graphical interface.

[0085] Pin Speed Setting: Select the appropriate speed from the various available pin speed options (such as 2MHz, 10MHz, and 50MHz) based on the LED's response speed and module performance requirements. For example, if the LED is only used for simple indication, a lower speed (such as 2MHz) can be selected to reduce power consumption. Add the corresponding speed setting instruction in the ladder diagram and associate it with PIN1.

[0086] Pin output control: Write instructions to control pin outputs. Program GPIO5 to turn the LED on or off by setting it high or low. Add logic and output instructions to the ladder diagram. For example, when a certain condition is met (such as an input signal is high), set GPIO5 to a low level, turning the LED on. When the condition is not met, set PIN1 to a high level, turning the LED off.

[0087] Similarly, set IO6 to UART1_RX and IO7 to UART1_TX for UART1 reception and transmission.

[0088] (2) Ladder diagram programming:

[0089] 1. Build a ladder diagram program:

[0090] A ladder program consists of multiple rungs. In the ladder editor, rungs are created sequentially from left to right and from top to bottom. Figure 4 Here is an example of a RUNG with a serial-parallel relationship:

[0091] Serial-parallel relationship design: Design a complex logic relationship. For example, when input X0 is high and input X1 is low, or internal resource M0 is low and input X2 is high, while input X3 is high, output Y0 is high.

[0092] Instruction writing: According to the above logical relationship, write the corresponding action instructions in the ladder diagram. The specific instructions and serial and parallel text descriptions are as follows Figure 5 As shown;

[0093] The corresponding instruction series is:

[0094] LD X000

[0095] ANI X001

[0096] LDI M0

[0097] AND X002

[0098] ORB

[0099] AND X003

[0100] OUT Y000

[0101] The compiled hexadecimal ASCII code download program:

[0102] 30303234 3030 represents the number 0 of the X software element, and 3234 represents the LD X instruction

[0103] 30313534 3031 represents the X software element number 1, 3534 represents the ANI X instruction

[0104] 30303338 3030 represents the number 0 of the M software element, and 3338 represents the LDI M instruction

[0105] 30323434 3032 represents the number 2 of the X software element, and 3434 represents the AND X instruction

[0106] 46394646 indicates ORB instruction

[0107] 30333434 3033 represents the number 3 of the X software element, and 3434 represents the AND X instruction

[0108] 30304335 3030 indicates the number 0 of the Y software element, and 4335 indicates the OUT Y instruction

[0109] After the program is downloaded to the module, it is converted into the corresponding ASCII code characters and stored in the pre-allocated user program address segment. The converted program is: 0024 0154 0038 0244 F9FF 0344 00C5

[0110] The module's pre-installed firmware recognizes and executes commands. For example, to parse LD X000, the following steps are performed: Starting from the user program, the 16-bit pointer reads the upper 8 bits of data, 0x24, which the firmware interprets as the LD X command. It then reads the lower 8 bits of data, 0x00, which the firmware interprets as the X device number 0. After reading the status of device X0 and storing it in the corresponding register, the 16-bit pointer increments by 1, and parsing continues with the next instruction.

[0111] 2. Set the action instruction operation object:

[0112] The action instruction operation objects of ladder diagram programming include external input X, output Y, internal resources M (internal relay), D (internal data register), C (internal counter), T (internal timer), etc., and also involve special peripheral interfaces.

[0113] Take the RS serial data transmission instruction to communicate with the serial port temperature and humidity sensor as an example:

[0114] The RS serial data transmission instruction format is as follows Figure 12 As shown:

[0115] The RS command is a serial data transmission command used to send and receive serial data with expansion function boards such as UART, RS232, and RS485, as well as special adapters. When the RS command is valid, it notifies the IoT module firmware that m data items, with an address starting with S, are ready to be sent and that it is ready to receive up to n data items, stored in registers with an address starting with D.

[0116] like Figure 13 As shown;

[0117] X0: RS instruction trigger condition. When X0 is ON, the RS instruction enters the waiting state for sending or receiving data.

[0118] D0: Starting register for sending data.

[0119] K5: The number of data to be sent, indicating that the data of 6 registers in the range of D0 to D4 are sent each time.

[0120] D10: Starting register for receiving data.

[0121] K8: The number of received data, indicating that the data returned by the external device is stored in the 8 registers within the range of D10 to D17.

[0122] Instruction settings: When input X0 is ON, the RS serial data transmission instruction is triggered. Set D0 as the starting register for sending data, K5 indicates that the data of the five registers in the range of D0 to D4 will be sent each time, D10 is the starting register for receiving data, and K8 indicates that the data returned by the external device will be stored in the eight registers in the range of D10 to D17.

[0123] Data processing: After receiving sensor data, the data is parsed and processed using the data processing instructions in the ladder diagram. For example, the received temperature and humidity data can be converted and displayed, or corresponding control operations can be performed based on the temperature and humidity data.

[0124] (3) User program composition and processing:

[0125] 1. Program structure planning:

[0126] The user program includes the module's IO configuration (single execution), other single initialization codes (such as serial port baud rate, IP address, interrupt service, etc.), and at least one execution cycle task. In the ladder diagram, write in the following order:

[0127] IO configuration: At the beginning of the program, write the module's IO configuration instructions and configure the functions of each PIN to ensure that the module can correctly identify and process the input and output signals of external devices.

[0128] Single-time initialization code: Following the IO configuration section, write the rest of the single-time initialization code. For example, set the serial communication parameters such as the baud rate and parity bit, configure the network connection information such as the IP address and subnet mask, and initialize the interrupt service routine.

[0129] Execute cyclic tasks: In the main body of the program, define at least one cyclic task. A cyclic task can contain multiple rungs to implement specific business logic, such as data collection, processing, and control.

[0130] 2. Program compilation and saving:

[0131] The ladder diagram is saved as text, showing the serial and parallel relationships of each rung. The compiler included with the ladder diagram editor then compiles it into a user program recognizable by the module's pre-installed firmware. During the compilation process, the compiler performs syntax checking and error notifications on the ladder diagram to ensure program correctness. After successful compilation, the generated user program is saved to the local computer for subsequent download to the IoT module.

[0132] (IV) Program download and operation:

[0133] 1. Download the user program:

[0134] Download the compiled user program to the IoT module via serial port or USB communication. The specific steps are as follows:

[0135] Connect devices: Use a serial cable or USB data cable to connect the host computer and the IoT module to ensure that the communication line is normal.

[0136] Select the download method: In the ladder diagram editor, select the appropriate download method, such as serial port download or USB download. According to the selected download method, set the corresponding communication parameters, such as baud rate, data bits, stop bits, etc.

[0137] Start downloading: Click the Download button to send the user program to the IoT module. During the download process, observe the download progress and status information to ensure that the download process is completed smoothly.

[0138] 2. Module operation:

[0139] After the IoT module receives the user program, the pre-installed firmware begins to execute. The specific operation process is as follows:

[0140] Initialization phase: The pre-installed firmware first parses and executes the configuration instructions in the user program, completing operations such as MCU initialization, interface function configuration, interrupt service configuration, and network protocol configuration. During this phase, the module initializes and configures each hardware module according to the requirements of the user program to ensure its normal operation.

[0141] Loop execution phase: After initialization, the pre-installed firmware begins repeatedly executing the cyclic task instruction code in the user program to control external devices and collect data. For example, it continuously reads data from temperature and humidity sensors, controls the on / off of LED lights based on data changes, or uploads data to a server for analysis and processing.

[0142] (V) Debugging and optimization:

[0143] 1. Debugging process:

[0144] During module operation, observe whether the LED status and sensor data are consistent with expectations. If any problems are found, debug them using the following methods:

[0145] View log information: Some IoT modules support log output. By viewing log information, you can understand the module's operating status and key information during program execution, helping to locate problems.

[0146] Breakpoint debugging: Set breakpoints in the ladder diagram editor to pause program execution, check the values of various variables and registers, analyze the program execution flow, and find possible errors.

[0147] Step-by-step execution: Use the step-by-step execution function of the ladder diagram editor to execute the program code line by line, observe the execution results of each step, and ensure the logical correctness of the program.

[0148] 2. Optimization process:

[0149] According to the debugging results, optimize the ladder diagram program. For example:

[0150] Algorithm optimization: Optimize data processing algorithms to reduce calculation amount and processing time, and improve program operation efficiency.

[0151] Resource optimization: Rationally allocate and use internal resources (such as registers, memory, etc.) to avoid resource waste and reduce module power consumption.

[0152] Low power consumption optimization: IoT perception layer terminals generally require low power consumption design. The entire low power consumption design involves low power MCU, low power circuit, and low power software process. The MCU state is generally in one or more low power sleep states, and only when needed will it come out of the low power sleep state and run the business processing program. Whether it is hardware design or software design, if you are not careful, the low power consumption index may be seriously exceeded, so higher requirements are placed on the design. Figure 6 As shown, the IoT module uses a low-power MCU and includes a regular-power power output switch. The external circuits consist of both low-power and regular-power peripheral circuits. The power supply to the regular-power peripheral circuits is controlled by the regular-power output switch within the IoT module. Because the IoT module integrates low-power control hardware and manages the power supply to the regular-power peripheral circuits, the program can be adjusted based on actual conditions to power the regular-power peripheral circuits only when necessary, optimizing low-power operation. For example, setting appropriate sleep times and wake-up conditions can reduce unnecessary power consumption.

[0153] In summary, the IoT module programming method and device provided by this invention overcome the limitations of traditional IoT module development. By shielding MCU details, code-free ladder diagram programming, multi-functional PIN configuration, and specialized firmware functions, they reduce development difficulty and improve efficiency while maintaining the compactness, low cost, and versatility of IoT modules. This provides new insights and directions for the development of IoT module technology.

Claims

1. A method for programming an Internet of Things module, characterized by: The following steps are involved: The MCU inside the IoT module is pre-installed with firmware, which acts as an operating system and allows users to write user programs according to the needs of peripheral circuits; The PIN function of the IoT module is defined independently. One IoT module model corresponds to a PIN function list. Some PINs are set with multiple optional functions, and the PIN pins are divided into GPIO pins and dedicated pins. The same IoT module model is implemented using one or more different MCU chip models. For user programs, the pre-installed firmware shields the differences between different MCUs. There are configuration instructions in the user program to select the PIN function definition of the IoT module, and the pre-installed firmware initializes the PIN function of the internal MCU according to the configuration instructions.

2. The method for programming an Internet of Things module according to claim 1, wherein: After the pre-installed firmware initializes the PIN function of the internal MCU according to the configuration instructions in the user program, the user program initializes and configures the relevant interface functions, interrupt services, network protocols, and initializes the internal data structure of the run cycle task; The user program defines at least one execution cycle task.

3. The method for programming an Internet of Things module according to any one of claims 1 to 2, wherein: User programs are generated using a graphical interface, with ladder diagram programming being preferred. The host computer is equipped with a ladder diagram editor. A ladder diagram program consists of multiple RUNG sequences, each containing action instruction symbols and serial and parallel logical connections between action instructions. This is accomplished through ladder diagrams and D and M resources. Configuration instructions are saved in the ladder diagram, and the pre-installed firmware in the module executes the configuration instruction series saved in the ladder diagram program one by one.

4. The method for programming an Internet of Things module according to any one of claims 1 to 3, wherein: Configuration is performed through a visual module configuration diagram. Each module has an independent visual module configuration diagram, which is displayed according to the module's IO plane distribution. The user double-clicks each IO pin to pop up the corresponding configuration options. After configuration is completed, it is saved as an IO configuration file. The IO configuration file is converted by the compiler into the same ladder diagram configuration instructions and executed by the pre-installed firmware in the module.

5. The method for programming an Internet of Things module according to claim 4, wherein: The action instruction operation objects of ladder diagram programming include external input X, output Y, internal resources M, D, C, T, and also involve special peripheral interfaces. The same action instruction operation objects have the same instruction format.

6. An Internet of Things module programming device, characterized by: include: Host computer: The host computer runs the ladder diagram editor, which is used by users to perform graphical programming operations and generate user programs containing configuration instructions, initialization instructions, and task instructions; IoT module: The IoT module contains pre-installed firmware and user program storage space. The pre-installed firmware is responsible for parsing and executing the configuration instructions in the user program, completing MCU PIN function initialization, interface function configuration, interrupt service configuration, network protocol configuration operations, and repeatedly executing the cyclic task instruction code in the user program. The user program defines at least one execution cyclic task.

7. The IoT module programming device according to claim 6, wherein: The ladder diagram editor of the host computer supports two graphical configuration mechanisms, which converts the configuration information generated by the user through the ladder diagram or the visual module configuration diagram into instructions that can be recognized by the module.

8. The IoT module programming device according to claim 6, wherein: The Internet of Things module adopts a low-power MCU and includes a normal power consumption power supply output switch; the external circuit is a low-power consumption peripheral circuit and a normal power consumption peripheral circuit, and the power supply of the normal power consumption peripheral circuit is controlled by the normal power consumption power supply output switch inside the Internet of Things module.

Citation Information

Patent Citations

  • Functional WiFi module based on the Internet of Things

    CN105743658A

  • Method and system for downloading and debugging optical module codes

    CN111045930A

  • Multi-mode configurable Internet of Things module

    CN114690689A

  • Fan driving circuit capable of regulating speed automatically and power supplying circuit

    CN201846296U