
This section covers important and challenging knowledge points, mainly focusing on object-oriented thinking and the construction of multi-task systems.
Specific requirements are as follows:
Requirement 1: A mining company needs to lay 112 stress-strain points on the mountain to prevent mining accidents, using equipment to detect mechanical changes and notify the location in time;
Requirement 2: A laser device needs to batch test 1200 current points for aging detection and record the aging time of defective products;


01: Learn the basic concepts of multi-channel acquisition, advantages and disadvantages; 02: Understand parallel or concurrent thinking, and object-oriented concepts; 03: Modify the test implementation (concurrent thinking) for 8 serial ports to collect in parallel; 04: Close concurrency, transmit concurrent data, organize data, etc.; Keywords: Labview, concurrency, copy shared VI, dynamic events, static events, Arduino, property nodes, method nodes. Note 1: High-definition images can be viewed on mobile WeChat; Note 2: Please refer to books for basic knowledge points.

3. Core Code of the First Version

03. We need to notify the producer, control the producer to start working, and control the producer to stop working, using global event methods to achieve functional control at the bottom layer; When there are many channels, this thinking does not change, we need to add an intermediate layer to organize and forward the data function block, converting discrete channels into a standard format for input.04. This event can be used locally and globally, achieving code reuse; Since this program is designed for compatibility with ART or Advantech high-speed acquisition, multi-channel processing will not lag;


06. Eight Arduinos work together to achieve 8 * 8 = 64 channels of analog signals, 0-5V, 12-bit accuracy, with all channels synchronously acquiring at 200Hz (high configuration theory), actual low configuration computer tests no less than 100Hz;

07. The above image is a code snippet of the producer-consumer model implemented in the main program for acquisition (part).
08. The bottom layer Arduino driver collects data as a [data producer], delivering it to the acquisition queue; here the producer becomes 14 Arduinos, while the consumer remains one;
09. After the main program receives the message, the data is stored as a [data consumer] to process and refine the data.
10. To ensure the balance between Arduino producers and consumers, the priority of the original data conversion and real-time storage is lowered;
11. Here, we share general code that can inherit objects from the data acquisition class;
12. The advantage of introducing global producer-consumer is to reduce the tightness between modules, making it easier to replace or inherit similar classes or functions (method nodes);
13. The main program starts by opening and running the subprogram; if the bottom layer program needs to be operated, a control channel or global variable state machine mode needs to be established.
01. For example, Requirement 2 needs 1200 channels, distributed across different workshops, requiring 6 people to operate manually, increasing costs;

03. Optimization plan: Each Arduino becomes a parallel task (can copy memory VI), generating 14 identical tasks; data is transmitted through global queues or global variables, with intermediate tasks for sequential scheduling and data organization;
04. Implementation method: Start initialization >> parameter allocation >> data transmission >> start parallel VI >> start intermediary;


05. First, initialize the serial port (14 of them), attempt to configure, then close, and then initialize normally to prevent errors from forgetting to close the serial port last time;
06. Enter the second For loop, static VI reference (load into copyable memory VI), then start to transmit data into the designated VI (this is equivalent to opening 14 while loops);
07. Each loop needs to include an internal channel for data transmission, which can be a global variable, object-oriented, or a queue;
08. Executing the second For loop is very fast, equivalent to starting 14 VIs simultaneously; since the VI started from copy memory cannot be viewed, normal operation can be judged through the changes of 14 devices;
09. The concurrent program is running; if not operated, it will run indefinitely;Closing channels also needs to be established;
10. After concurrency, each acquisition operates independently, causing data time to be unsynchronized, resulting in disorder and time difference;
11. Establish simultaneous acquisition markers, and after acquisition, use stacks to transmit data out, trying to avoid using global variable updates for replacement;
12. This code is relatively short, but it allows flexible startup of the number of devices; if the industrial computer has enough memory, it can be expanded sufficiently to fully meet the needs of Requirement 1 and Requirement 2; running 14 concurrent acquisitions, a single channel at 100Hz, the industrial computer’s operating situation can appropriately lower the sampling rate to reduce CPU load;

