LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event State Machine with Producer/Consumer Loops

Hello everyone, just finished writing my first VI using an event state machine architecture. I have 4 while loops in my VI;

  • DAQ initialization and read, the user can select;
    • To use a voltage DAQ and/either-or a TC DAQ.
    • The sample rate and number of samples per channel. (I would generally run at 100Hz)
  • Data logging, streaming data to TDMS.
  • Data visualization, plot data to charts and XY charts.
  • General loop, get date time, event structures to open folders etc.

I'm using a channel stream writer to stream data from the DAQ read loop to the data logging and viz loops.

 

My question is regarding the timestamps of my save data in the TDMS file, the way I'm adding a timestamp is the following;

  • The user clicks data capture
    • A 1D array of size Samples per channel is created, going from 0 to n*sample rate.
    • A time value of (Samples per channel/Sample rate)*1000 is generated.
  • This time value connects to a Wait Till Next ms Multiple timer.
  • The data capture loop is started, where I pass the Time array through and iterate adding the sample rate to each element.
  • This time stamp array is stream with the waveform data to TDMS.

 

Is my logic of adding the timestamp okay? I don't think it is, because at 1 samples per channel the code runs slower than a timer. Is the way I have setup the loops okay? (I understand that a QMS or similar would more than likely be better). I have attached my VI, removed most of the sub-VIs to show how in principle it works.

0 Kudos
Message 1 of 2
(935 Views)

Hi AdzyA, 

 

I'm not familiar with channel wires so it is a bit difficult for me to follow the code. Would combining the two while loops that contain event structures into one and getting the information between the different events with a shift register work to simplify the architecture? That's how I would normally set up an event driven state machine. 

 

On the timestamp, maybe I'm not understanding your question fully but when you record data in waveform format you don't record timestamps as such, you record t0 which is your starting point and dt which is the time step between data points and is defined by your data rate. If you have multiple channels you are acquiring from it will depend on whether the sampling rate you have defined is per channel or not, i.e whether dt corresponds to one data point or N data points where N is the number of channels you are collecting from. You can do a quick test at a low sampling rate to check what is being recorded into your TDMS file. The conversion from waveform to timestamp + data is straightforward, I've done it before but can't find the function I used - it would be very straightforward to add to a subVI using the d0 and dt values though. Hope this is relevant to your question! 

 

Riley 

0 Kudos
Message 2 of 2
(706 Views)