Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing

Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing

1. Determine the Plan and Purpose

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;

Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing

Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing

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.
[Video] 12-Channel Acquisition Effect Demonstration (Arduino UNO)

Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing

2. Known Conditions
Testing Equipment: 8 Arduino Nano with 8-channel 12-bit ADC acquisition
Software Used: LabVIEW
Application Conditions: 8 devices x 8 channels = 64 channels, stress film piezoelectric sensors
Acquisition Rate: Each Arduino acquisition module collects in parallel at 200Hz, requiring 112 channels to synchronize at no less than 100Hz;
Acquisition Range: 0-1V piezoelectric signal
Acquisition Resolution: 12-bit ADC chip, recognizes voltage of 1.22mV, achieved 0.6mV accuracy through software filtering;

3. Core Code of the First Version

Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing

01. In large engineering designs, many general-purpose or specialized programs are often designed, and we need to make them independent for quicker inheritance of similar applications.
02. Establish project management, with the main program responsible for starting auxiliary acquisition processes, using global variables for inter-program communication.
Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing03. 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;

Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing

Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing
05. The Arduino code communicates using the Firmata protocol;

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;

Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing

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.

14. This article is a technical teaching knowledge sharing of Arduino modules, Qiankun Excellent Teaching Base copyright, and does not provide open-source code and upper computer source programs; please purchase Arduino yourself;
4. Optimized Core Code

01. For example, Requirement 2 needs 1200 channels, distributed across different workshops, requiring 6 people to operate manually, increasing costs;

02. The reason for rectification and optimization: According to the above code, (single device has 8 channels) copy and paste the serial port configuration and reading function 150 times, making the program large and easy to lag; for example, one device failure affects the acquisition rate; faulty devices cannot self-repair;

Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing

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;

Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing
Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing

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;

Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing

Comprehensive Guide to 64-Channel 12-Bit Analog Signal Acquisition Testing
13. Use the above code to view global data; due to the lack of synchronization mechanism, there is a phenomenon of data time misalignment; it is recommended to add global markers for acquisition, controlled by external middleware;
14. This operational demonstration video has not been updated for the time being; this article is a technical teaching knowledge sharing of Arduino modules, Qiankun Excellent Teaching Base copyright, and does not provide open-source code and upper computer source programs; please purchase Arduino yourself;

Leave a Comment