LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple C-series Modules: How to Synchronize Data for Logging?

Hi, all!

I'm developing an application in LabVIEW using the following hardware:

NI 9174 4-slot chassis

NI 9207 analog input module

NI 9422 digital input module

NI 9485 digital output module

At its current state, each IO module has its own parallel-running subVI and the data (channel readings + timestamp) is enqueued (for input modules) to be processed by another VI or dequeued to write the relay state. After processing, I'm passing the data to a logging VI, which formats it and writes to a CSV file. Currently, I'm only logging the analog input data from 9207 module in the format
Time (ms); Ch0; Ch1;Ch2...

I'd like to include both the digital input data and the state of the 9485 relay to the log file, but I'm having trouble coming up with a good way of synchronizing the data. Ideally, I'd like the CSV file format to be

Time (ms); 9207 Ch0; 9207 Ch1; ...; 9422 Ch0; 9422 Ch1; ...; 9485 Ch0; 9485 Ch1.

How to synchronize the data between different IO modules for logging, while maintaining the modularity I have managed so far?

0 Kudos
Message 1 of 2
(199 Views)

Well, it depends.  Doesn't it always?

 

1. One approach might be to switch from csv to a format like TDMS that supports logging different channel data at different sample rates.

 

2. To stick with line-by-line CSV and the implied common sample rate, an approach I've tended to favor is to write each module's most-recently-known value.  The cadence can be set by one of the I/O channels or by some other timing mechanism.

    Each I/O module is a producer, some other code module is a common consumer that receives all the I/O data updates and stores them locally via shift register or similar.  Then whenever the next "logging time" comes, write out a line to CSV containing all the most recently known values for all the I/O data.

 

3. When I/O comes in at different rates, this approach may mean that some channels are lossy and not all samples get saved.  It may mean that some channels are slow and sample values get repeated for many lines in the CSV.  Or it could be both effects.  I typically treat my fastest channel as the event that tells me to log everything b/c I usually prefer redundancy in the slow channels to data loss in the fast ones.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
0 Kudos
Message 2 of 2
(182 Views)