LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a counter to an existing analog input TDMS file

Hi LVIEWPQ,

 


@LVIEWPQ wrote:
I've tried Bundle, and build array, and there's nothing obvious when searching that converts to waveform? 

Did you look into the waveform functions palette?

There is a function dedicated to build a waveform from its components…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 11 of 17
(580 Views)

@cordm wrote:

snip.png

 

or change the type of DAQmx Read.vi

cordm_1-1691068172967.png

 

 


So how do you do that when the DAQ Read is a counter?

0 Kudos
Message 12 of 17
(574 Views)

Sorry, I forgot about the "counter" part. Forget about the second option in that case.

Message 13 of 17
(565 Views)

RE: combining Counter 1D array data with AI waveform data:

    First let me show you how you *can* do it, then get into a little discussion about whether you *should* do it.  

 

1.  Use the AI waveform as a starting point for making a waveform out of your 1D counter data.  Illustrated here.

 

2.  Change some particular attributes of that waveform to give your counter channel its own name.  Illustrated here.

 

3. Consult the standard set of attribute names used by DAQmx to know what attributes to change.  Table shown here.

 

But *should* you do it?   Well, that probably depends on the nature of your counter task, and whether & how it's sync'ed to your AI task. 

    If the tasks are synced and share a sample clock, it would be appropriate do the steps above and put them in the same TDMS group.

    If not synced but the counter task uses a regular sample clock, it could still be appropriate to put the counter data into a waveform, adjusting t0 and dt as needed.

    If the counter task uses Implicit timing (such as frequency measurement), then you should *NOT* try to put that into a waveform.  What I've done is turn the data into 2 1D array channels -- one for the frequencies, another for the times when those frequency samples were taken, where time relative to task start is just a cumulative sum of (1/freq).

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 14 of 17
(549 Views)

@Kevin_Price wrote:

RE: combining Counter 1D array data with AI waveform data:

    First let me show you how you *can* do it, then get into a little discussion about whether you *should* do it.  

 

1.  Use the AI waveform as a starting point for making a waveform out of your 1D counter data.  Illustrated here.

 

2.  Change some particular attributes of that waveform to give your counter channel its own name.  Illustrated here.

 

3. Consult the standard set of attribute names used by DAQmx to know what attributes to change.  Table shown here.

 

But *should* you do it?   Well, that probably depends on the nature of your counter task, and whether & how it's sync'ed to your AI task. 

    If the tasks are synced and share a sample clock, it would be appropriate do the steps above and put them in the same TDMS group.

    If not synced but the counter task uses a regular sample clock, it could still be appropriate to put the counter data into a waveform, adjusting t0 and dt as needed.

    If the counter task uses Implicit timing (such as frequency measurement), then you should *NOT* try to put that into a waveform.  What I've done is turn the data into 2 1D array channels -- one for the frequencies, another for the times when those frequency samples were taken, where time relative to task start is just a cumulative sum of (1/freq).

 

 

-Kevin P


So in this case I'm running a flow meter which records in Hz then gets converted to to l/min.

What would be the most appropriate way to log the Pressure & Thermocouple channels, and then the flow rate into a single timestamped log file?

0 Kudos
Message 15 of 17
(531 Views)

@LVIEWPQ wrote:

@Kevin_Price wrote:

RE: combining Counter 1D array data with AI waveform data:

    First let me show you how you *can* do it, then get into a little discussion about whether you *should* do it.  

 

1.  Use the AI waveform as a starting point for making a waveform out of your 1D counter data.  Illustrated here.

 

2.  Change some particular attributes of that waveform to give your counter channel its own name.  Illustrated here.

 

3. Consult the standard set of attribute names used by DAQmx to know what attributes to change.  Table shown here.

 

But *should* you do it?   Well, that probably depends on the nature of your counter task, and whether & how it's sync'ed to your AI task. 

    If the tasks are synced and share a sample clock, it would be appropriate do the steps above and put them in the same TDMS group.

    If not synced but the counter task uses a regular sample clock, it could still be appropriate to put the counter data into a waveform, adjusting t0 and dt as needed.

    If the counter task uses Implicit timing (such as frequency measurement), then you should *NOT* try to put that into a waveform.  What I've done is turn the data into 2 1D array channels -- one for the frequencies, another for the times when those frequency samples were taken, where time relative to task start is just a cumulative sum of (1/freq).

 

 

-Kevin P


So in this case I'm running a flow meter which records in Hz then gets converted to to l/min.

What would be the most appropriate way to log the Pressure & Thermocouple channels, and then the flow rate into a single timestamped log file?


First Kevin is on point!  But, since you gave us some additional information about your channels I can jump in and offer some advice.

 

The Timing of each Task becomes important for the exact solution but, let's assume for simplicity that each channel is sampled at regular intervals.   

 

Find the highest sample rate then resample each of the other channels to have the same dT.  There is a function that interpolates the "in-between" reading points using one of several defined interpolation algorithms.   For Pressure, I would chose a sin(x)/dx since that mimics a wave function over time (pressure moves in waves - demonstrate for yourself by dropping a rock in any pond) EDIT: make that any liquid pond, I'm from Minnesota so, try singing into a rotating fan.

 

For Flow Rate or Temperatures chose a linear interpretation but for different reasons:

  • Temperatures change relatively slowly unless there is almost no mass to hold the heat energy.
  • Flow Rate measurement changes are inherently dampened by the centripetal force of the sensor

Which really is the same thing, the changes are averaged out, Temp by the DUT, Flow rate by the sensor.


"Should be" isn't "Is" -Jay
Message 16 of 17
(499 Views)

@JÞB wrote:

@LVIEWPQ wrote:

@Kevin_Price wrote:

RE: combining Counter 1D array data with AI waveform data:

    First let me show you how you *can* do it, then get into a little discussion about whether you *should* do it.  

 

1.  Use the AI waveform as a starting point for making a waveform out of your 1D counter data.  Illustrated here.

 

2.  Change some particular attributes of that waveform to give your counter channel its own name.  Illustrated here.

 

3. Consult the standard set of attribute names used by DAQmx to know what attributes to change.  Table shown here.

 

But *should* you do it?   Well, that probably depends on the nature of your counter task, and whether & how it's sync'ed to your AI task. 

    If the tasks are synced and share a sample clock, it would be appropriate do the steps above and put them in the same TDMS group.

    If not synced but the counter task uses a regular sample clock, it could still be appropriate to put the counter data into a waveform, adjusting t0 and dt as needed.

    If the counter task uses Implicit timing (such as frequency measurement), then you should *NOT* try to put that into a waveform.  What I've done is turn the data into 2 1D array channels -- one for the frequencies, another for the times when those frequency samples were taken, where time relative to task start is just a cumulative sum of (1/freq).

 

 

-Kevin P


So in this case I'm running a flow meter which records in Hz then gets converted to to l/min.

What would be the most appropriate way to log the Pressure & Thermocouple channels, and then the flow rate into a single timestamped log file?


First Kevin is on point!  But, since you gave us some additional information about your channels I can jump in and offer some advice.

 

The Timing of each Task becomes important for the exact solution but, let's assume for simplicity that each channel is sampled at regular intervals.   

 

Find the highest sample rate then resample each of the other channels to have the same dT.  There is a function that interpolates the "in-between" reading points using one of several defined interpolation algorithms.   For Pressure, I would chose a sin(x)/dx since that mimics a wave function over time (pressure moves in waves - demonstrate for yourself by dropping a rock in any pond) EDIT: make that any liquid pond, I'm from Minnesota so, try singing into a rotating fan.

 

For Flow Rate or Temperatures chose a linear interpretation but for different reasons:

  • Temperatures change relatively slowly unless there is almost no mass to hold the heat energy.
  • Flow Rate measurement changes are inherently dampened by the centripetal force of the sensor

Which really is the same thing, the changes are averaged out, Temp by the DUT, Flow rate by the sensor.


 

In terms of sample rate, it's relatively low (1Hz) and consistent across all measurements. So the smoothing isn't necessarily a concern, and this seems to be far beyond what I am trying to achieve. 

My aim is to have a program that will produce 1 data point each second for Pressure, Temperature and coolant flow, with each reading having a timestamp.

It's how to get the readings from the Pressure & Temperature task and the counter task to log to a single file with a timestamp. I'd be quite happy with it in a .csv file, but I just can't seem to get my head around how to log things to a single text file, and the time stamp to work.

0 Kudos
Message 17 of 17
(384 Views)