Weighing instrument double-MCU circuit
By adopting a dual-MCU architecture design in the weighing instrument, the master MCU and slave MCU handle EtherCAT communication and data acquisition tasks respectively, which solves the stability problem of traditional single MCU systems in high real-time communication and data acquisition, realizes efficient data transmission and system stability, and improves the system's response speed and fault tolerance.
Patent Information
- Application Number
- CN202423315754.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Utility models(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2034-12-31
AI Technical Summary
Traditional single-MCU systems struggle to guarantee the completeness of data acquisition when handling high real-time communication and data acquisition, leading to signal loss and system instability. This is especially true in weighing instruments, where simultaneous EtherCAT communication and data acquisition can easily result in error accumulation and system shutdown.
The system adopts a dual-MCU architecture, with the master MCU and slave MCU handling EtherCAT communication and data acquisition tasks respectively. Data interaction is coordinated through SPI communication and EtherCAT communication modules to achieve efficient data transmission and processing, reduce resource contention, and improve system stability and response speed.
It improves the system's response speed and stability, enhances the system's fault tolerance, ensures that critical tasks are executed normally under high load, reduces communication latency and resource contention, and improves overall performance and reliability.
Smart Images

Figure CN223692754U_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The utility model relates to double MCU circuit technical field, concretely relates to a weighing instrument double MCU circuit. BACKGROUND
[0002] With the increase of the complexity of electronic equipment, the traditional single MCU system often faces performance bottleneck when processing multiple tasks.
[0003] For the system of high real-time communication, the main station instruction needs to be processed in the first time, such as in the weighing instrument, the pressure signal of the sensor and the EtherCAT bus communication signal need to be processed, the processing frequency of the two is rapid, the sensor signal can reach 8 channels per second 3200 times of data sampling, that is 8*3200 = 25600 times of sampling, and the EtherCAT communication cycle needs to reach 1000 times of sampling per second, each sampling of the two needs to occupy a certain processing time of MCU, which is a very huge task for the MCU with the main frequency of 120MHz, it is difficult to guarantee the completeness of the data acquisition of both sides, and the problem of partial signal loss is inevitable.
[0004] Even if the MCU resources are improved, the EtherCAT communication and data acquisition will inevitably occur at the same time, although there will be no problem under one communication cycle, but through error accumulation after long-time work of the weighing instrument, the communication or data acquisition loss will occur. If the sensor signal is lost, the data processing data is incomplete, the signal filtering processing result is not ideal, and the pressure value will fluctuate, if the EtherCAT bus communication is lost, the bus will be disconnected, the whole machine system will alarm, and even the whole machine system will stop running. CONTENT OF THE UTILITY MODEL
[0005] The utility model solves the technical problem in the foregoing, provides a weighing instrument double MCU circuit, adopts double MCU architecture circuit design, reduces the single MCU resource contention at the same time, and effectively coordinates the execution of multiple tasks to achieve the rapid processing of high real-time operation, improves the response speed and system stability, through these improvements, the system can keep stable operation under high load, meets the high requirements of modern electronic equipment on performance and reliability.
[0006] In order to achieve the above object, the utility model provides the following technical scheme:
[0007] The weighing instrument double MCU circuit includes a main MCU controller, a slave MCU controller and an EtherCAT communication module; the slave MCU controller is connected with the main MCU controller and the EtherCAT communication module through SPI communication; the slave MCU controller is used for reading and analyzing data of the EtherCAT communication module; and the main MCU controller is used for executing the result analyzed by the slave MCU.
[0008] Further, the slave MCU controller adopts a chip U6, preferably an STM32F103CB model; and the main MCU controller adopts a chip U2A, preferably an STM32F103RC model.
[0009] The slave MCU controller and the main MCU controller complete hardware double board communication through 4-wire SPI; the slave MCU controller is connected with the main MCU controller through PA25, PA26, PA27 and PA28 as MASTER SPI NSS end, MASTER SPI SCK end, MASTER SPI MISO end and MASTER SPI MOSI end in sequence, and PA20, PA21, PA22 and PA23 of the main MCU controller, respectively; and the communication protocol logic between the main MCU controller and the slave MCU controller is adopted to realize data mutual transmission of the double MCUs, to ensure correct data sending and receiving, thereby completing communication between the double MCUs.
[0010] Further, the EtherCAT communication module adopts a chip U1, preferably a LAN9252 model; the chip U1 includes a slave MCU interrupt interaction data unit, a storage unit and a double network port communication unit; the slave MCU interrupt interaction data unit is used for data information to be interacted between the slave MCU controller and the EtherCAT communication module; the storage unit is used for obtaining configuration information and other data of the EtherCAT communication module; and the double network port communication unit is used for receiving and transmitting data of the EtherCAT communication module.
[0011] Further, the storage unit adopts a chip U5, preferably an AT24C64 model; one end of a resistor R30 connected with PA1, PA2, PA3 and PA7 of the chip U5 is grounded; one end of a capacitor C39 connected with PA4 of the chip U5 is grounded; one end of a resistor R31 connected with PA43 of the chip U1 is connected with PA6 of the chip U5 as F212C SCL end; one end of a resistor R32 connected with PA42 of the chip U1 is connected with PA5 of the chip U5 as F212C SDA end; and 3V3 power supply is connected with PA8 of the chip U5, the other end of the resistor R31, the other end of the resistor R32 and the other end of the capacitor C39.
[0012] Further, the EtherCAT communication module and the slave MCU controller complete hardware double-board communication through 4-wire SPI, the chip U1 of the EtherCAT communication module is connected with PA17, PA13, PA50 and PA19 of the chip U6 of the slave MCU controller as LAN SPI MOSI end, LAN SPI MISO end, LAN SPI NSS end and LAN SPI SCK end in sequence through PA17, PA13, PA50 and PA19.
[0013] Further, the master MCU controller comprises a master MCU interrupt interaction unit, a slave MCU data analysis unit, a data acquisition unit and other units; the master MCU interrupt interaction unit is used for interacting instructions sent by the slave MCU controller; the slave MCU data analysis unit is used for analyzing SPI data of the slave MCU, performing relevant operations such as clearing, calibration or other commands according to the data analysis result, and finally transmitting the execution result to the slave MCU through the master MCU interrupt interaction unit; and the data acquisition unit is used for acquiring data of the weighing module and obtaining real-time values of the weighing instrument.
[0014] Further, the slave MCU controller comprises a slave MCU data analysis unit, a master MCU data uploading unit, a master-slave MCU data conversion unit and an SPI communication unit; the slave MCU controller interacts with data to be processed and analyzed, the data is analyzed by the slave MCU data analysis unit, the analyzed data is converted into instructions of the SPI double-MCU communication protocol logic by the master-slave MCU data conversion unit, and finally transmitted to the master MCU interrupt interaction unit of the master MCU through the SPI communication unit.
[0015] Compared with the prior art, the utility model has the advantages that:
[0016] 1. Improve system performance, through the design of double-MCU architecture, the system can significantly improve the response speed when processing multiple tasks, reduce the delay of task switching, and thus improve the overall performance;
[0017] 2. Enhance system reliability, redundant design enables the system to operate normally when some components fail, ensuring continuous execution of critical tasks and enhancing the fault tolerance of the system;
[0018] 3. Optimize resource utilization, the division of labor between the master MCU and the slave MCU effectively avoids resource competition, improves the utilization efficiency of resources, and enables the system to remain stable under high load;
[0019] 4. Reduce communication delay, efficient communication mechanism reduces the data transmission delay between the double MCUs, improves the efficiency of data exchange, and ensures the real-time performance of the system;
[0020] 5、Adaptability, the design scheme of the patent can flexibly adapt to the needs of different application scenarios, has good expansibility and adaptability, meets the future technology development; BRIEF DESCRIPTION OF DRAWINGS
[0021] In order to more clearly illustrate the technical scheme in the specific embodiment or prior art of the present application, the drawings needed in the specific embodiment or prior art description will be briefly introduced below. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn according to the actual scale.
[0022] Figure 1 The utility model of weighing instrument double MCU circuit structure schematic diagram is shown in the figure;
[0023] Figure 2 The utility model of weighing instrument main MCU circuit diagram is shown in the figure;
[0024] Figure 3 The utility model of weighing instrument slave MCU circuit diagram is shown in the figure;
[0025] Figure 4 The utility model of weighing instrument EtherCAT communication chip U1 circuit diagram is shown in the figure;
[0026] Figure 5 The utility model of weighing instrument slave MCU controller communication protocol logic diagram is shown in the figure;
[0027] Figure 6 The utility model of weighing instrument main MCU controller communication protocol logic diagram is shown in the figure; DETAILED DESCRIPTION
[0028] The technical scheme in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor belong to the scope of protection of the present application.
[0029] As shown in the drawings 1 to Figure 4 A kind of weighing instrument double MCU circuit, including main MCU controller, slave MCU controller, EtherCAT communication module, as shown in the figure, slave MCU controller is connected with main MCU controller and EtherCAT communication module by SPI communication;The slave MCU controller is used to read and analyze the data of EtherCAT communication module;The main MCU controller is used to execute the result of slave MCU analysis.
[0030] The slave MCU controller adopts a chip U6, and the chip U6 is preferably an STM32F103CB; the main MCU controller adopts a chip U2A, and the chip U2A is preferably an STM32F103RC; the slave MCU controller and the main MCU controller complete hardware double-board communication through a 4-wire SPI; the slave MCU controller is connected with the PA20, the PA21, the PA22 and the PA23 of the main MCU controller in sequence through the PA25, the PA26, the PA27 and the PA28 as the MASTER SPI NSS end, the MASTER SPI SCK end, the MASTER SPI MISO end and the MASTER SPI MOSI end respectively, and the communication protocol logic between the main MCU controller and the slave MCU controller is adopted to realize data mutual transmission of the double MCUs, to ensure correct data sending and receiving, and thus to complete communication between the double MCUs.
[0031] The chip U1 is adopted for the EtherCAT communication module, and the chip U1 is preferably a LAN9252; the chip U1 includes a slave MCU interrupt interactive data unit, a storage unit and a double-network-port communication unit; the slave MCU interrupt interactive data unit is used for data information to be interacted between the slave MCU controller and the EtherCAT communication module; the storage unit is used for the EtherCAT communication module to acquire configuration information and the like; and the double-network-port communication unit is used for the EtherCAT communication module to receive and transmit data.
[0032] The chip U5 is adopted for the storage unit, and the chip U5 is preferably an AT24C64; one end of a resistor R30 is connected with the PA1, the PA2, the PA3 and the PA7 of the chip U5, and the other end of the resistor R30 is grounded; one end of a capacitor C39 is connected with the PA4 of the chip U5 and the ground; one end of a resistor R31 is connected with the PA43 of the chip U1 as the F212C SCL end and the PA6 of the chip U5; one end of a resistor R32 is connected with the PA42 of the chip U1 as the F212C SDA end and the PA5 of the chip U5; and the PA8 of the chip U5, the other end of the resistor R31, the other end of the resistor R32 and the other end of the capacitor C39 are connected with a 3V3 power supply.
[0033] The chip U1 of the EtherCAT communication module and the chip U6 of the slave MCU controller complete hardware double-board communication through a 4-wire SPI; the chip U1 of the EtherCAT communication module is connected with the PA17, the PA16, the PA14 and the PA15 of the chip U6 of the slave MCU controller in sequence through the PA17, the PA13, the PA50 and the PA19 as the LAN SPI MOSI end, the LAN SPI MISO end, the LAN SPI NSS end and the LAN SPI SCK end respectively.
[0034] The main MCU controller includes a main MCU interrupt interaction unit, a slave MCU data analysis unit, a data acquisition unit and other units; the main MCU interrupt interaction unit is used for interacting with the instructions sent by the slave MCU controller; the slave MCU data analysis unit is used for analyzing the SPI data of the slave MCU, performing relevant operations such as clearing, calibration or other commands according to the data analysis result, and finally transmitting the execution result to the slave MCU through the main MCU interrupt interaction unit; the data acquisition unit is used for acquiring the data of the weighing module and obtaining the real-time value of the weighing instrument.
[0035] The slave MCU controller includes a chip U1 data analysis unit, a main MCU data uploading unit, a master-slave MCU data conversion unit and an SPI communication unit. The slave MCU controller interacts with the data to be processed and analyzed, the data is analyzed by the chip U1 data analysis unit, the analyzed data is converted into the instructions of the SPI double MCU communication protocol logic by the master-slave MCU data conversion unit, and finally transmitted to the main MCU interrupt interaction unit of the main MCU through the SPI communication unit.
[0036] By adopting the above technical scheme, the double MCU circuit and the EtherCAT communication module data interaction realize the differentiated processing of high priority functions, reduce the single MCU resource contention at the same time, so as to achieve the rapid processing of high real-time operation, the system can significantly improve the response speed when processing multiple tasks, reduce the delay of task switching, and thus improve the overall performance; the division of labor of the master-slave MCU effectively avoids resource competition and improves the utilization efficiency of resources, so that the system can still maintain stability under high load.
[0037] By designing the communication protocol logic between the main MCU controller and the slave MCU controller, it is ensured that the data can be normally executed. If the data sent by the slave MCU controller to the main MCU controller cannot be normally executed, the slave MCU will be informed through a status code, and at this time the slave MCU will resend the data. Through the flow code, the main MCU controller can also determine whether the instructions sent by the slave MCU controller are the same instructions, so as to determine whether the instructions are normally transmitted. Through the one-answer-one-answer mode, the communication between the double MCUs is completed, the reliability of the system is improved, and the overall efficiency of the system is improved. The following is the control flow of the communication protocol logic between the main MCU controller and the slave MCU controller.
[0038] As shown in Figure 5 The communication protocol logic control flow of the slave MCU controller is as follows:
[0039] Step 1: Start;
[0040] Step 2: SPI master sends a receive callback function;
[0041] Third step: whether the current task queue has a task;
[0042] Yes, continue to execute; No, update the sending buffer;
[0043] Fourth step: whether the m times of ACK data are the same;
[0044] Yes, continue to the next step; No, re-count and return to the second step;
[0045] Fifth step: count + 1;
[0046] Sixth step: whether the same number of times is greater than the set number of repetitions
[0047] Yes, continue to the next step; No, return to the second step;
[0048] Seventh step: save the slave response data;
[0049] Eighth step: check whether the instruction and the current sending instruction are the same;
[0050] Yes, continue to the next step; No, update the sending buffer to the first task;
[0051] Ninth step: detect the task execution state of the response signal (switch for subsequent expansion);
[0052] Tenth step: state display code:
[0053] Instruction error code 0X0500, execution failure code 0X400, and execution success code 0X300
[0054] Enter the next step;
[0055] Eleventh step: instruction queue out;
[0056] Twelfth step: whether the instruction queue has a task;
[0057] Yes, execute the next step; No, update the sending buffer;
[0058] Thirteenth step: update the sending buffer to the first task;
[0059] Fourteenth step: state display code: execution code 0X0200, and others
[0060] Return to the thirteenth step “update the sending buffer to the first task”;
[0061] Fifteenth step: all completed, return to the second step, and loop.
[0062] As shown in the following table, the main MCU controller communication protocol logic control flow is as follows: Figure 6
[0063] First step: start;
[0064] Second step: SPI slave station sends a receiving callback function;
[0065] Third step: judge whether the m times of ACK data are the same;
[0066] Yes, execute the next step; no, re-count, update the current response signal to the sending buffer, and return to the second step;
[0067] Fourth step: count + 1;
[0068] Fifth step: whether the same number of times is greater than the set number of repetitions;
[0069] Yes, execute the next step; no, return to update the current response signal to the sending buffer, and return to the second step;
[0070] Sixth step: receive data, disassemble data, and save order, watercode, data1, and data2;
[0071] Seventh step: whether the current execution task state is a no task state (0X7F000000);
[0072] Yes, enter sub-process 1-judge the content of the received data;
[0073] No, enter sub-process 2-detect whether the current task execution state is in execution 0X0200;
[0074] Sub-process 1 control flow: judge the content of the received data
[0075] “no task 0X7F000000” enters “update the current task state and ACK to no task 0X0100” state;
[0076] “other (non-instruction transmission error)” enters “modify the current task state and ACK to instruction error 0X0500” state,
[0077] “instruction” directly enters “update the current execution task data of sub-process 2”;
[0078] No task and other (non-instruction transmission error) are executed and enter “update the current response signal to the sending buffer” and return to the second step “SPI slave station sends a receiving callback function”;
[0079] Sub-process 2 control flow: detect whether the current task execution state is in execution 0X0200
[0080] Yes, enter the next flow step “judge the current instruction type”; no, return to “update the current response signal to the sending buffer, and return to the second step”;
[0081] Judge the current instruction type: task; no task 0X7F000000; instruction error;
[0082] When the type is task, execute the order "detect if the current execution instruction is the same as the current execution instruction, water code", no, execute the order "detect the current task execution state"; yes, execute the return "update the current response signal to the sending buffer, return to the second step"; when the type is "no task", execute the return instruction "update the current task state and ACK to no task 0x0100", execute the return instruction "update the current response signal to the sending buffer, return to the second step"; when the type is "instruction error", execute the return instruction "update the current task state and ACK to instruction error 0x0500", execute the return instruction "update the current response signal to the sending buffer, return to the second step";
[0083] Detect the current task execution state, which is divided into two states: "other" and "in execution", the downward execution state of "other" is "update the current execution task data", then execute "update the current task state and ACK to in execution 0X0200", then execute "release the semaphore execution task", then execute the return instruction "update the current response signal to the sending buffer, return to the second step"; the downward execution state of "in execution" is "do not update the current task execution data (redundant) update the current task execution state and ACK to in execution 0X0200", and finally return "update the current response signal to the sending buffer, return to the second step".
[0084] Through the above control logic, the system reliability is enhanced, the redundant design makes the system still run normally when part of the components fail, ensures the continuous execution of the key task, and enhances the fault tolerance of the system.
[0085] The above only describes the preferred specific implementation of the present application, but the protection scope of the present application is not limited to this, any skilled person in the art can make equivalent replacement or change according to the technical scheme and the inventive concept of the present application within the technical range disclosed by the present application, which should be covered in the protection scope of the present application.
Claims
1. A weighing instrument dual MCU circuit, characterized by: The main MCU controller, the slave MCU controller and the EtherCAT communication module are included; the slave MCU controller is connected with the main MCU controller and the EtherCAT communication module through SPI communication; the slave MCU controller is used for reading and analyzing data of the EtherCAT communication module; and the main MCU controller is used for executing the result analyzed by the slave MCU.
2. A dual MCU circuit for a weighing instrument as claimed in claim 1, characterized in that: The slave MCU controller adopts chip U6, the model of which is STM32F103CB, and the main MCU controller adopts chip U2A, the model of which is STM32F103RC. The slave MCU controller and the main MCU controller complete hardware double-board communication through 4-wire SPI, the slave MCU controller is connected with the main MCU controller through PA25, PA26, PA27 and PA28 as MASTER SPI NSS end, MASTER SPI SCK end, MASTER SPI MISO end and MASTER SPI MOSI end in turn, and the communication protocol logic between the main MCU controller and the slave MCU controller is adopted to realize data mutual transmission of the double MCUs, to ensure correct data sending and receiving and to complete communication between the double MCUs.
3. A dual MCU circuit for a weighing instrument as recited in claim 1, wherein: The EtherCAT communication module adopts chip U1, the model of which is LAN9252, and chip U1 includes a slave MCU interrupt interaction data unit, a storage unit and a double-network-port communication unit; the slave MCU interrupt interaction data unit is used for data information to be interacted between the slave MCU controller and the EtherCAT communication module; the storage unit is used for obtaining configuration information data for the EtherCAT communication module; and the double-network-port communication unit is used for receiving and transmitting data for the EtherCAT communication module.
4. A dual MCU circuit for a weighing instrument as claimed in claim 3, wherein: The storage unit adopts chip U5, the model of which is AT24C64, and one end of PA1, PA2, PA3 and PA7 of chip U5 is connected with one end of resistor R30, the other end of resistor R30 is grounded; PA4 of chip U5 is connected with one end of capacitor C39 and the ground; PA6 of chip U5 is connected with one end of resistor R31 and PA43 of chip U1 as F212C SCL end; PA5 of chip U5 is connected with one end of resistor R32 and PA42 of chip U1 as F212C SDA end; PA8 of chip U5, the other end of resistor R31, the other end of resistor R32 and the other end of capacitor C39 are connected with 3V3 power supply.
5. A dual MCU circuit for a weighing instrument as recited in claim 1, wherein: The EtherCAT communication module and the slave MCU controller complete hardware double-board communication through 4-wire SPI, and PA17, PA13, PA50 and PA19 of chip U1 of the EtherCAT communication module are connected with PA17, PA16, PA14 and PA15 of chip U6 of the slave MCU controller as LAN SPI MOSI end, LAN SPI MISO end, LAN SPI NSS end and LAN SPI SCK end in turn.
6. A dual MCU circuit for a weighing instrument as recited in claim 1, wherein: The main MCU controller comprises a main MCU interrupt interaction unit, a slave MCU data analysis unit, a data acquisition unit and other units; the main MCU interrupt interaction unit is used for interacting with the instructions sent by the slave MCU controller; the slave MCU data analysis unit is used for analyzing the SPI data of the slave MCU, performing relevant operations such as clearing, calibration or other commands according to the data analysis result, and finally transmitting the execution result to the slave MCU through the main MCU interrupt interaction unit; the data acquisition unit is used for acquiring the data of the weighing module and obtaining the real-time value of the weighing instrument.
7. A dual MCU circuit for a weighing instrument as recited in claim 1, wherein: The slave MCU controller comprises a chip U1 data analysis unit, a main MCU data uploading unit, a master-slave MCU data conversion unit and an SPI communication unit; the slave MCU controller interacts with the data to be processed and analyzed, the data is analyzed by the chip U1 data analysis unit, the analyzed data is converted into the instructions of the SPI double-MCU communication protocol logic by the master-slave MCU data conversion unit, and finally transmitted to the main MCU interrupt interaction unit of the main MCU through the SPI communication unit.