Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Python, continually sample two AI modules and apply a timestamp to the readings?

This should meet your requirement.

0 Kudos
Message 11 of 14
(320 Views)

You can also enable TDMS logging, which captures the t0 of the first sample. You can then browse TDMS files or read using npTDMS · PyPI.

Message 12 of 14
(305 Views)

Can you please show to you extract t0 (assuming that's the only one available from the log file?

 

 tdms_file = TdmsFile.read(os.getcwd() + '\data.tdms', raw_timestamps = True)

    for group in tdms_file.groups():
        group_name = group.name
        print(group.properties)
        for channel in group.channels():
            print(channel.properties)

 

The above code gives me this ouptut:

OrderedDict()
OrderedDict([('NI_Scaling_Status', 'unscaled'), ('NI_Number_Of_Scales', 2), ('NI_Scale[1]_Scale_Type', 'Linear'), ('NI_Scale[1]_Linear_Slope', 2.6226045264365987e-09), ('NI_Scale[1]_Linear_Y_Intercept', 0.0), ('NI_Scale[1]_Linear_Input_Source', 0)])
OrderedDict([('NI_Scaling_Status', 'unscaled'), ('NI_Number_Of_Scales', 2), ('NI_Scale[1]_Scale_Type', 'Linear'), ('NI_Scale[1]_Linear_Slope', 2.6226045264365987e-09), ('NI_Scale[1]_Linear_Y_Intercept', 0.0), ('NI_Scale[1]_Linear_Input_Source', 0)])
OrderedDict([('NI_Scaling_Status', 'unscaled'), ('NI_Number_Of_Scales', 2), ('NI_Scale[1]_Scale_Type', 'Linear'), ('NI_Scale[1]_Linear_Slope', 2.6226045264365987e-09), ('NI_Scale[1]_Linear_Y_Intercept', 0.0), ('NI_Scale[1]_Linear_Input_Source', 0)])
OrderedDict([('NI_Scaling_Status', 'unscaled'), ('NI_Number_Of_Scales', 2), ('NI_Scale[1]_Scale_Type', 'Linear'), ('NI_Scale[1]_Linear_Slope', 2.6226045264365987e-09), ('NI_Scale[1]_Linear_Y_Intercept', 0.0), ('NI_Scale[1]_Linear_Input_Source', 0)])
OrderedDict([('NI_Scaling_Status', 'unscaled'), ('NI_Number_Of_Scales', 2), ('NI_Scale[1]_Scale_Type', 'Linear'), ('NI_Scale[1]_Linear_Slope', 2.6226045264365987e-09), ('NI_Scale[1]_Linear_Y_Intercept', 0.0), ('NI_Scale[1]_Linear_Input_Source', 0)])

...

0 Kudos
Message 13 of 14
(272 Views)

The t0 and dt are the metadata of the channel properties. If you open the TDMS file with Excel, you can see t0 & dt and data are on two different worksheets. For more details, NI TDMS File Format - What is a TDMS File?

I have attached an example to read the TDMS file.

 

0 Kudos
Message 14 of 14
(228 Views)