A method and apparatus for programming Internet of Things (IoT) modules
By introducing pre-installed firmware and ladder diagram programming into IoT modules, the problem of high development complexity of IoT modules is solved, which simplifies programming, improves efficiency and portability, reduces development difficulty, and is suitable for low-power design of IoT devices.
Patent Information
- Application Number
- CN202510427570.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-07
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2045-04-07
AI Technical Summary
Existing IoT modules suffer from problems such as underutilization of hardware capabilities, high development complexity, and high costs during development, and PLC programming methods have not been effectively applied to IoT modules.
IoT modules with pre-installed firmware can be programmed using ladder logic and PIN functions, shielding MCU differences. Combined with a graphical interface and visual configuration, this simplifies the programming of user programs.
It reduces the programming difficulty of IoT modules, improves development efficiency and program portability, simplifies low-power design, protects intellectual property rights, and reduces the difficulty of device development.
Smart Images

Figure CN120491947B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Internet of Things (IoT) technology, specifically to an IoT module programming method and apparatus. Background Technology
[0002] As a significant transformation in the information technology industry, the Internet of Things (IoT) faces numerous challenges in developing its sensing layer terminals. For example... Figure 1 Currently, there are two main types of IoT modules used as the sensing layer in the Internet of Things (IoT): one type is IoT modules that cannot be further developed, requiring an external MCU and communication via predetermined protocols, such as AT commands. This does not fully utilize the hardware capabilities of the IoT module, and its size and cost are not optimal. The other type is based on SDKs that allow for secondary development of communication modules, primarily developed in C language. This requires highly skilled developers who are familiar with MCU hardware and SDKs, impacting development efficiency. Some designs involving intellectual property cannot be provided via SDKs. PLCs are widely used in industrial control. They include pre-installed firmware and user programs. Specialized pre-installed firmware greatly ensures the stability of the PLC and also effectively protects related intellectual property. Furthermore, the ladder diagram language of PLCs is simple and easy to learn, resulting in high development efficiency and convenient on-site program modification. A PLC is a complete device, including a robust housing and clearly defined and fixed I / O terminals, equivalent to an IoT module. It is large and expensive. If PLC programming methods can be applied to IoT modules while maintaining the compactness and low cost of IoT modules, and allowing for flexible adaptation to external circuits for hardware and software design, in order to quickly develop various IoT products, it will help reduce the difficulty of developing IoT devices, improve development efficiency, protect intellectual property rights, and further promote the popularization of IoT.
[0003] In view of the above, this application is hereby submitted. Summary of the Invention
[0004] The purpose of this invention is to provide an Internet of Things (IoT) module programming method and apparatus to solve the problems mentioned in the background art.
[0005] To address the aforementioned technical problems, this invention provides an IoT module programming method, comprising the following steps:
[0006] The MCU inside the IoT module has pre-installed firmware, which acts as an operating system, allowing users to write user programs according to the needs of the peripheral circuits. The PIN functions of the IoT module are defined independently, with one PIN function list corresponding to one IoT module model. Some PINs have 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 the user program, the pre-installed firmware masks the differences between different MCUs. The user program sets configuration instructions to select the PIN function definition of the IoT module, and the pre-installed firmware initializes the PIN functions of the internal MCU according to the 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, and network protocols, and initializes the internal data structure of the running loop task.
[0008] The user program must define at least one task that executes in a loop;
[0009] User programs are generated using a graphical interface programming method, with ladder diagram programming being the preferred choice. The host computer is equipped with a ladder diagram editor. A ladder diagram program consists of multiple RUNGs in sequence. Each RUNG contains action instruction symbols and the serial and parallel logical relationships between action instructions.
[0010] The configuration instructions are saved in the ladder diagram using ladder diagrams and D and M resources. The pre-installed firmware in the module executes the series of configuration instructions 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. Users can double-click each IO pin to bring up the corresponding configuration options. After configuration, it is saved as an IO configuration file. The IO configuration file is converted into the same ladder diagram configuration instructions by the compiler and executed by the pre-installed firmware in the module.
[0012] Ladder diagram programming's action instructions operate on objects including external inputs X and outputs Y, internal resources M, D, C, T, etc., and also involve dedicated peripheral interfaces.
[0013] Simultaneously, the present invention provides an Internet of Things (IoT) module programming device, comprising:
[0014] Host computer: The host computer runs a 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 includes 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 the MCU PIN function initialization, interface function configuration, interrupt service configuration, network protocol configuration operations, and repeatedly executing the loop task instruction code in the user program. The user program defines at least one loop 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 ladder diagrams or visual module configuration diagrams into instructions that the module can recognize.
[0017] The PIN functions of the IoT module are defined independently, with one PIN function list corresponding to one IoT module model. Some PINs have multiple optional functions, and the PIN pins are divided into GPIO pins and dedicated pins. Different MCU chip models can be used within the same IoT module model. For the user program, the pre-installed firmware masks the differences between different MCUs. The user program sets configuration instructions 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.
[0018] The IoT module uses a low-power MCU and includes a conventional power supply output switch; the external circuit consists of low-power peripheral circuits and conventional power peripheral circuits, and the power supply of the conventional power peripheral circuits is controlled by the conventional power supply output switch inside the IoT module.
[0019] Furthermore, configuring the GPIO pins includes pin function selection, pin speed setting, and pin output control. For example, when configuring the PIN1 pin to control the LED in GPIO output mode, first select the function of PIN1 as output Y1, then select a suitable speed from multiple speed options, and finally control the LED to turn on or off by programming the high and low levels of the PIN1 pin.
[0020] Furthermore, the RUNG serial-parallel relationships in the ladder diagram program are stored using text descriptions. For example, a RUNG ladder diagram with serial-parallel relationships is given, and its serial-parallel text description is in XML format containing action instructions and related parameters. This is then compiled into a user program that can be recognized by the module's pre-installed firmware.
[0021] Furthermore, the action instructions of the ladder diagram programming operate on external inputs X and outputs Y, internal resources M, D, C, T, etc., and also involve dedicated 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, it notifies the PLC that m data points starting at address S are waiting to be sent, and prepares to receive up to n data points stored in the register starting at address D.
[0022] Furthermore, the user program includes the module's IO configuration (single execution), other code for single initialization (such as serial port baud rate, IP address, interrupt service, etc.), and at least one execution loop task.
[0023] Compared with existing IoT module technologies, the advantages of this invention are:
[0024] 1. Lowering the programming threshold: Using ladder diagram graphical programming, there is no need to pay attention to the details of MCU data or C language programming skills, which reduces the programming difficulty of IoT modules and enables more people to participate in development.
[0025] 2. Improved programming efficiency: The PIN function of the IoT module is independent of the specific MCU. The pre-installed firmware hides the details of the MCU 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: Ladder diagram programming operation instructions operate on external inputs X and outputs Y, internal resources M, D, C, T, etc., and also involve dedicated 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 operation instructions, so user programs between different modules have 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 for IoT devices.
[0028] 5. Facilitates program management and maintenance: The user program has a clear structure, divided into IO configuration, single initialization code, and execution loop tasks. The ladder diagram is saved and compiled in RUNG serial-parallel relationship text, which improves the readability and maintainability of the program. Attached Figure Description
[0029] Figure 1 Schematic diagrams of two solutions developed for existing IoT terminals
[0030] Figure 2 This is a schematic diagram of the basic components of the IoT module of the present invention;
[0031] Figure 3 This is a diagram showing the composition of the firmware and user program of the IoT module of the present invention;
[0032] Figure 4 This invention refers to a ladder diagram RUNG with serial-parallel relationships.
[0033] Figure 5 This is a textual description diagram of a RUNG instruction and its serial-parallel relationship in this invention;
[0034] Figure 6 This is a schematic diagram of the low-power module with a conventional power supply output switch in this invention;
[0035] Figure 7 This is a schematic diagram of a ladder diagram program segment in this invention;
[0036] Figure 8 This is a schematic diagram of the chip pin functions in this invention;
[0037] Figure 9 This is a schematic diagram of the pop-up pin function list in this invention;
[0038] Figure 10 This is a schematic diagram of the functions supported by pin 5 in this invention;
[0039] Figure 11 This is a schematic diagram illustrating the configurable functions of GPIO5 in this invention;
[0040] Figure 12 This is a schematic diagram of the RS serial data transmission instruction format in this invention;
[0041] Figure 13 This is an example of a PLC ladder diagram for RS serial data transmission instructions in this invention. Detailed Implementation
[0042] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0043] This invention provides a technical solution: a method and apparatus for programming an Internet of Things (IoT) module. Please refer to [link / reference]. Figure 2-13 .
[0044] I. Preparation of the implementation environment:
[0045] like Figure 2 As shown.
[0046] (I) Hardware aspects:
[0047] 1. IoT Module Selection:
[0048] Select a stable IoT module that meets the requirements of this invention. The module's definition is independent of the specific model of the internal MCU and the characteristics of its pin functions. Some pins should have multiple optional functions and include GPIO pins and dedicated pins. For example, select an IoT module that integrates a low-power MCU, whose GPIO pins can be flexibly configured as input or output modes, and whose dedicated pins cover power supply, clock, reset, UART, I2C, SPI, CAN, Ethernet, ADC, PWM, antenna, etc., to meet the needs of different application scenarios.
[0049] 2. Preparation of peripheral circuits:
[0050] Prepare a series of external circuits for communication and interaction with the IoT module. Specifically, this includes:
[0051] LED: Used to demonstrate the output control function of the GPIO pin. A common LED is selected, whose operating voltage is compatible with the output voltage of the IoT module. Connect the negative terminal of the LED to the pin configured as a GPIO output in the module (e.g., module PIN5) through a current-limiting resistor, and connect the positive terminal 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., PIN6) via a serial communication cable, and connect the sensor's RX pin to the module's UART1_TX pin (e.g., PIN7). Ensure that the sensor and module's ground signals are connected.
[0053] Other equipment: Depending on actual needs, relays, buttons, and other equipment can also be prepared, which are used to control the on / off state of external circuits and to realize input detection functions, respectively.
[0054] (II) Software Aspects:
[0055] 1. Installation of host computer software:
[0056] Install ladder diagram editor software on the host computer (programming computer). You can choose an open-source or closed-source editor depending on the actual situation, but you must ensure that it supports the graphical programming method used in this invention and has the function of creating, editing, and compiling ladder diagram programs. Open-source editors include LDMicro, OpenPLC Editor, etc. Well-known PLC manufacturers generally have their own proprietary editors, such as Mitsubishi's GX Works2 and Delta's WPLSoft. The editor converts ladder diagram operation objects into configuration instructions and task instructions. Operation objects with the same action instructions generally have the same instruction format, thus user programs have strong portability between different modules.
[0057] 2. IoT module firmware installation:
[0058] like Figure 3 The diagram shows the composition of the IoT module firmware and user program. The pre-installed firmware adapts to the internal MCU driver of the IoT module and the configuration and task instructions in the user program. The pre-installed firmware is developed based on a specific MCU SDK, and the corresponding user program hides the MCU details, only presenting the IoT module's functional definitions. The user program can operate on external inputs (X), outputs (Y), internal resources (M, D, C, T, etc.), and also involves dedicated peripheral interfaces such as ADC, DAC, RS232, RS485, Ethernet, CAN, and PWM. Check whether the pre-installed firmware in the IoT module is running normally. The pre-installed firmware is the foundation for parsing and executing the user program; it must ensure that its version is compatible with the current development environment and has complete functionality, capable of correctly parsing and executing the configuration and task instructions in the user program.
[0059] The user program edited and output by the ladder diagram editor software of the host computer completes the MCU PIN function initialization, interface function configuration, interrupt service configuration, and network protocol configuration operations, and repeatedly executes the loop task instruction code in the user program. The user program defines at least one loop 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.
[0060] II. Specific Implementation Steps:
[0061] (a) Module PIN function configuration:
[0062] 1. Select configuration method:
[0063] This embodiment uses ladder diagrams 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 utilizes ladder diagrams and D / M resources, directly saving the configuration instructions to the ladder diagram. The preloaded program in the module executes each configuration instruction stored in the ladder diagram program. This method is applicable to all modules.
[0066] like Figure 7 As shown in the ladder diagram program snippet, the first 3 lines are configuration instructions, and the user program starts from the 4th line.
[0067] Another method uses a visual module configuration diagram. Each module has its own independent visual module configuration diagram, displayed according to the module's I / O plane distribution. Users can double-click each I / O pin to bring up the corresponding configuration options and save it as an I / O configuration file. The I / O configuration file is then converted by the compiler into the same ladder diagram configuration instructions as the first method. The preload program in the module executes the configuration instructions saved in the ladder diagram program line by line.
[0068] Example of configuration steps:
[0069] As shown in the table below, and Figure 8 As shown: A PIN function independent of the MCU model is defined. Some PINs have multiple functions, which are configured by the user program according to the needs of the external circuit.
[0070]
[0071]
[0072] Note: P: Power supply; I: Input; O: Output; T: Can be set to high impedance. Bold text indicates the default function of the pin.
[0073] 1) Click pin 5
[0074] 2) A list of pin functions will pop up; the default option is GPIO5.
[0075] like Figure 9 As shown;
[0076] Click the drop-down arrow to see the functions supported by pin 5, then select the GPIO5 option.
[0077] like Figure 10 As shown;
[0078] 3) Selecting the GPIO5 option will reveal the configurable functions of GPIO5.
[0079] like Figure 11 As shown;
[0080] X5 is the input, and Y5 is the output.
[0081] 4) Continue configuring the functions of other pins, and finally save it as a configuration file after confirming.
[0082] 2. Configure GPIO pins;
[0083] Taking configuring PIN5 as a GPIO output mode to control an LED as an example, the detailed steps are as follows:
[0084] Pin Function Selection: Locate the pin function configuration instruction in the instruction library of the ladder diagram editor, and select PIN5 as output Y5. This can be done by entering the corresponding instruction code in the instruction input box or by selecting the corresponding option in the graphical interface.
[0085] Pin speed setting: From the provided pin speed options (such as 2MHz, 10MHz, 50MHz, etc.), select the appropriate speed based on the LED's response speed and the module's 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 the PIN1 pin.
[0086] Pin Output Control: Write instructions to control the pin output, setting GPIO5 to high or low level to control the LED's on / off state. Add logic judgment instructions and output instructions to the ladder diagram. For example, when a certain condition is met (such as a high-level input signal), set GPIO5 to low level to light up the LED; when the condition is not met, set PIN1 to high level to turn off the LED.
[0087] Similarly, set IO6 to UART1_RX and IO7 to UART1_TX for receiving and transmitting UART1.
[0088] (II) Ladder Diagram Programming:
[0089] 1. Construct a ladder diagram program:
[0090] A ladder diagram program consists of multiple RUNG sequences. In the ladder diagram 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-to-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, and input X3 is high, output Y0 is high.
[0092] Instruction Writing: Based on the above logical relationships, write the corresponding action instructions in the ladder diagram. Specific instructions and serial / parallel text descriptions are as follows: Figure 5 As shown;
[0093] The corresponding instruction set is as follows:
[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 number 1 of the X software element, and 3534 represents the ANI X instruction.
[0104] 30303338 3030 represents the M software element number 0, 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 represents the ORB command.
[0107] 30333434 3033 represents the number 3 of the X software element, and 3434 represents the AND X instruction.
[0108] 30304335 3030 represents the number 0 of the Y software element, and 4335 represents the OUT Y command.
[0109] After the program is downloaded to the module, it is converted into corresponding ASCII 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 pre-installed firmware identifies and executes instructions. For example, the steps for parsing LD X000 are as follows: Starting from the user program, the 16-bit pointer reads the high 8 bits (0x24), which the firmware interprets as the LD X command. Then, it reads the low 8 bits (0x00), which the firmware interprets as the X soft device number being 0. After reading the status of soft device X0 and storing it in the corresponding register, the 16-bit pointer is incremented by 1, and the parsing continues to the next instruction.
[0111] 2. Set the target of the action command:
[0112] Ladder diagram programming's action instructions operate on external inputs X and outputs Y, internal resources M (internal relays), D (internal data registers), C (internal counters), T (internal timers), and also involve dedicated peripheral interfaces.
[0113] Taking communication with a serial temperature and humidity sensor using RS serial data transmission commands as an example:
[0114] RS serial data transmission command format is as follows: Figure 12 As shown:
[0115] The RS instruction is a serial data transmission instruction used to send and receive serial data on expansion boards and special adapters such as UART, RS232, and RS485. When the RS instruction is valid, it notifies the IoT module firmware that m data points starting at address S are ready to be sent, and that it is ready to receive up to n data points, stored in a register starting at address D.
[0116] like Figure 13 As shown;
[0117] X0: RS instruction trigger condition. When X0 is ON, the RS instruction enters a waiting state to send or receive data.
[0118] D0: Start register for sending data.
[0119] K5: Number of data to be sent, indicating that data from 6 registers in the range D0 to D4 is sent each time.
[0120] D10: Start register for receiving data.
[0121] K8: Number of data received, indicating that the data returned by the external device will be stored in 8 registers in the range of D10 to D17.
[0122] Instruction settings: When input X0 is ON, the RS serial data transmission instruction is triggered. D0 is set as the start register for sending data, K5 indicates that data from 5 registers in the range D0 to D4 is sent each time, D10 is set as the start register for receiving data, and K8 indicates that data returned by the external device is stored in 8 registers in the range D10 to D17.
[0123] Data processing: After receiving sensor data, the data is parsed and processed using 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] (III) User Program Composition and Processing:
[0125] 1. Program structure planning:
[0126] The user program includes the module's I / O configuration (one-time execution), other code for one-time initialization (such as serial port baud rate, IP address, interrupt service, etc.), and at least one execution loop task. In the ladder diagram, write it in the following order:
[0127] IO Configuration: At the beginning of the program, write the module's IO configuration instructions to configure the function of each PIN pin, ensuring that the module can correctly identify and process the input and output signals of external devices.
[0128] Single-initialization code: Following the IO configuration section, write the remaining code for single-initialization. This includes setting parameters such as the baud rate and parity for serial communication, configuring the IP address and subnet mask for the network connection, and initializing the interrupt service routine.
[0129] Execute loop tasks: In the main body of the program, define at least one loop task. A loop task can contain multiple RUNGs to implement specific business logic, such as data acquisition, processing, and control.
[0130] 2. Program compilation and saving:
[0131] The ladder diagram is saved as text according to the serial-parallel relationship of each RUNG. Then, the compiler included with the ladder diagram editor is used to compile it into a user program recognizable by the module's pre-installed firmware. During compilation, the compiler performs syntax checks and error messages on the ladder diagram program to ensure its 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 execution:
[0133] 1. Download the user program:
[0134] The compiled user program is downloaded to the IoT module via serial port or USB communication. The specific steps are as follows:
[0135] Connecting devices: Use a serial cable or USB data cable to connect the host computer to the IoT module, ensuring that the communication line is working properly.
[0136] Select the download method: In the ladder diagram editor, select the appropriate download method, such as serial port download or USB download. Based on the selected download method, set the corresponding communication parameters, such as baud rate, data bits, and stop bits.
[0137] Start Download: 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 successful completion.
[0138] 2. Module Operation:
[0139] After receiving the user program, the IoT module begins execution of the pre-installed firmware. 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 user program's requirements, ensuring their normal operation.
[0141] Loop Execution Phase: After initialization, the pre-installed firmware begins to repeatedly execute the loop task instruction code in the user program to control external devices and acquire data. For example, it continuously reads data from temperature and humidity sensors, controls the on / off state of LEDs based on data changes, or uploads the data to a server for analysis and processing.
[0142] (V) Debugging and Optimization:
[0143] 1. Debugging process:
[0144] During module operation, observe the status of the LEDs and whether the sensor data matches expectations. If problems are found, troubleshooting can be done using the following methods:
[0145] View log information: Some IoT modules support log output function. By viewing the log information, you can understand the module's operating status and key information in the program execution process, which helps to locate the problem.
[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's 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 result of each step, and ensure the logical correctness of the program.
[0148] 2. Optimization process:
[0149] Based on the debugging results, optimize the ladder diagram program. For example:
[0150] Algorithm optimization: Optimize data processing algorithms to reduce computation and processing time, and improve program efficiency.
[0151] Resource optimization: Allocate and use internal resources (such as registers, memory, etc.) in a reasonable manner to avoid resource waste and reduce the power consumption of the module.
[0152] Low-power optimization: IoT sensing layer terminals generally require low-power design, which involves low-power MCUs, low-power circuits, and low-power software processes. The MCU typically operates in one or more low-power sleep states, only emerging from sleep mode to run business processing programs when needed. Whether in hardware or software design, even slight oversights can severely exceed low-power performance limits, thus placing higher demands on the design. Figure 6 As shown, the IoT module uses a low-power MCU and includes a conventional power supply output switch. The external circuitry consists of both low-power and conventional power peripheral circuits. The power supply to the conventional power peripheral circuits is controlled by the conventional power supply output switch within the IoT module. Because the IoT module integrates low-power control hardware circuitry and manages the power supply to the conventional power peripheral circuits, the program can be adjusted according to actual conditions, supplying power only when necessary to optimize low-power operation. For example, setting appropriate sleep times and wake-up conditions reduces unnecessary power consumption.
[0153] In summary, the IoT module programming method and apparatus provided by this invention overcome the limitations of traditional IoT module development. By shielding MCU details, implementing no-code ladder diagram programming, enabling multi-functional PIN configuration, and providing specialized firmware functions, it reduces development difficulty and improves development efficiency, while retaining the compact size, low cost, and versatility of IoT modules. This provides new ideas and directions for the development of IoT module technology.
Claims
1. A programming method for an Internet of Things (IoT) module, characterized in that: Includes the following steps: The MCU inside the IoT module has firmware pre-installed. This firmware acts as an operating system, allowing users to write user programs according to the needs of the peripheral circuits. The PIN functions of the IoT module are defined independently, with one PIN function list corresponding to each IoT module model. Some PINs have multiple optional functions, and PIN pins are divided into GPIO pins and dedicated pins. The same IoT module model uses one or more different MCU chip models internally. For the user program, the pre-installed firmware masks the differences between different MCUs. After the pre-installed firmware initializes the PIN functions 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, and network protocols, and initializes the internal data structure of the running loop task. The user program defines at least one running loop task. The user program contains configuration instructions to select the PIN function definition of the IoT module, and the pre-installed firmware initializes the PIN functions of the internal MCU according to these configuration instructions.
2. The IoT module programming method as described in claim 1, characterized in that: User programs are generated using a graphical interface programming method, and ladder diagram programming is used. The host computer is equipped with a ladder diagram editor. A ladder diagram program consists of multiple RUNGs in sequence. Each RUNG contains action instruction symbols and the serial and parallel logical relationships between action instructions. The configuration instructions are saved in the ladder diagram using ladder diagrams and D and M resources. The pre-installed firmware in the module executes the series of configuration instructions saved in the ladder diagram program one by one. D is the internal data register and M is the internal relay.
3. The IoT module programming method as described in claim 2, characterized in that: 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. Users can double-click each IO pin to bring up the corresponding configuration options. After configuration, it is saved as an IO configuration file. The IO configuration file is converted into the same ladder diagram configuration instructions by the compiler and executed by the pre-installed firmware in the module.
4. The IoT module programming method as described in claim 3, characterized in that: Ladder diagram programming operation instructions operate on objects including external inputs X and outputs Y, internal resources M, D, C, and T, and also involve dedicated peripheral interfaces. The same operation instruction operation objects have the same instruction format, where M is an internal relay, D is an internal data register, C is an internal counter, and T is an internal timer.
5. An IoT module programming device, used in the IoT module programming method according to any one of claims 1-4, characterized in that: include: Host computer: The host computer runs a 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 includes 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 the MCU PIN function initialization, interface function configuration, interrupt service configuration, network protocol configuration operations, and repeatedly executing the loop task instruction code in the user program. The user program defines at least one loop task.
6. The IoT module programming device as described in claim 5, characterized in that: The ladder diagram editor of the host computer supports two graphical configuration mechanisms, which convert the configuration information generated by the user through ladder diagrams or visual module configuration diagrams into instructions that the module can recognize.
7. The IoT module programming device as described in claim 5, characterized in that: The IoT module uses a low-power MCU and includes a conventional power supply output switch; the external circuit consists of a low-power peripheral circuit and a conventional power peripheral circuit, and the power supply of the conventional power peripheral circuit is controlled by the conventional power supply output switch inside the IoT module.
Citation Information
Patent Citations
Functional WiFi module based on the Internet of Things
CN105743658A
Multi-mode configurable Internet of Things module
CN114690689A