Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Binary data/file in DAQmx .NET C# on PCI-6133?

Hi,

 

I'm working on Acquiring data samples on the higher edge of the PCI-6133 from multiple channels (2MS/s). Because of the nature of the project I will have to post process the data later on.

In your opinion, what is the best way of storing the data/saving it during the acquisition stage for post processing it later?

I'm thinking if using the TDMS format for the on-the-fly logging and then open the file and post processing it, the problem is that the file is going to be huge because I need to sample the date for 90 seconds and the fact that it is an ASCII file. How would you approach this problem?

Does the DAQmx has a native binary file handler?

 

Cheers

Maayan

0 Kudos
Message 1 of 10
(4,789 Views)

Hi Maayan,

 

 

The following link talks about all of the examples for NI DAQmx .NET.

http://zone.ni.com/reference/en-XX/help/370473H-01/mstudiowebhelp/html/daqmxexamplesnet2008/

Have you seen the following examples? Is this about what you are looking for?

TdmsAcqVoltageSamples_IntClk_LogOnly

This example demonstrates how to acquire and stream data to a binary file.
Visual C#:
Analog In\Measure Voltage\TdmsAcqVoltageSamples_IntClk_LogOnly\CS
Visual Basic .NET:
Analog In\Measure Voltage\TdmsAcqVoltageSamples_IntClk_LogOnly\VB
TdmsContAcqVoltageSamples_IntClk

This example demonstrates how to acquire a continuous amount while simultaneously streaming that data to a binary file.
Visual C#:
Analog In\Measure Voltage\TdmsContAcqVoltageSamples_IntClk\CS
Visual Basic .NET:
Analog In\Measure Voltage\TdmsContAcqVoltageSamples_IntClk\VB
TdmsContAcqVoltageSamples_IntClk_LogOnly

This example demonstrates how to acquire and stream data to a binary file in a continuous manner.
Visual C#:
Analog In\Measure Voltage\TdmsContAcqVoltageSamples_IntClk_LogOnly\CS
Visual Basic .NET:
Analog In\Measure Voltage\TdmsContAcqVoltageSamples_IntClk_LogOnly\VB
0 Kudos
Message 2 of 10
(4,776 Views)

Hi,

 

Thank you for your response.

I know and played with those TDMS examples and as far as I understand you refer to the TDMS file as a binary file (which is true) - I will rephrase my question. I'm looking for a way to control the size of the file, even by having less resolution regarding the data over the analog inputs/the file structure itself or any other way.

Because I'm sampling 8 digital channels and 7 analog channels the file size if becoming an issue. If the DAQmx could have 2 synchronized tasks with different timing that will be also a possible solution but according to what I’ve read it cannot be done.

I'll look into the resolution properties of the analog signals and see if I can come up with a setting that will decrease the size of the file.

 

Thank you

 

Cheers

Maayan

0 Kudos
Message 3 of 10
(4,769 Views)

Hi,

 

So if you got to the DAQmx .NET help on your computer you can search for the AnalogUnscaledReader Class. You can then read in the unscaled data and write those values to a binary file. However, you will have to scale this data yourself to convert it back to voltages when you read the unscaled data from the file you saved it too.

0 Kudos
Message 4 of 10
(4,752 Views)

Hi,

 

I have the DAQmx .NET help and I just looked into the AnalogUnscaledReader class. It looks like a good place to look for a solution/workaround. I don't mind to sacle it later myself. Can I read multiple unscaled channels like I would usually read multiple analog channels using the AnalogMultiChannelReader and IAsyncResult callbacks? I looked for an example that uses AnalogUnscaledReader and could not find one. Can you point me to it please?

 

Cheers

Maayan

0 Kudos
Message 5 of 10
(4,750 Views)

Hi,

 

The following are the listed Methods for the AnalogUnscaledReader. I found this in the DAQmx .NET Help. The read methods do allow for one or more channels. 

 

AnalogUnscaledReader Methods

 
  Name Description
Public method BeginReadInt16 Begins an asynchronous read of one or more unscaled 16-bit integer samples from one or more AIChannel objects in a task.
Public method BeginReadInt32 Begins an asynchronous read of one or more unscaled 32-bit integer samples from one or more AIChannel objects in a task.
Public method BeginReadUInt16 Begins an asynchronous read of one or more unscaled 16-bit unsigned integer samples from one or more AIChannel objects in a task.
Public method BeginReadUInt32 Begins an asynchronous read of one or more unscaled 32-bit unsigned integer samples from one or more AIChannel objects in a task.
Public method CreateObjRef Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public method EndReadInt16 Handles the end of an asynchronous read initiated with BeginReadInt16 and retrieves the read samples.
Public method EndReadInt32 Handles the end of an asynchronous read initiated with BeginReadInt32 and retrieves the read samples.
Public method EndReadUInt16 Handles the end of an asynchronous read initiated with BeginReadUInt16 and retrieves the read samples.
Public method EndReadUInt32 Handles the end of an asynchronous read initiated with BeginReadUInt32 and retrieves the read samples.
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetLifetimeService Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method InitializeLifetimeService Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected method MemberwiseClone
Overloaded. Creates a shallow copy of the current Object.
Public method ReadInt16 Reads one or more unscaled 16-bit integer samples from one or more AIChannel objects in a task.
Public method ReadInt32 Reads one or more unscaled 32-bit integer samples from one or more AIChannel objects in a task.
Public method ReadUInt16 Reads one or more unscaled 16-bit unsigned integer samples from one or more AIChannel objects in a task.
Public method ReadUInt32 Reads one or more unscaled 32-bit unsigned integer samples from one or more AIChannel objects in a task.
Public method ToString Returns a string representation of the object. (Overrides Object..::.ToString()()().)
0 Kudos
Message 6 of 10
(4,731 Views)

Perefect. Thanks. Missed hte "one or more part", I looked for some kind of "MultiChannel" method.

It looks like it workaround my problem.

 

Cheers

Maayan

0 Kudos
Message 7 of 10
(4,727 Views)

It works well for the "on-the-fly" data of callbacks function but the TDMS file format/resolution is still remains the same. 

I guess I can brew my own format now using the unscaled data but I cannot change the way the TDMS fiel is being written or its resolutions of the analog channels.

0 Kudos
Message 8 of 10
(4,717 Views)
0 Kudos
Message 9 of 10
(4,712 Views)

Yep. This is exactly what I'm working on using the unscaled reader. I was trying to find a way around it - like using the already made TDMS file writers/loggers but in a different resolution so the TDMS file will be smaller.

Tried to avoid it but I see there is no workaround it. It will also will be more tricky regarding the threads and response/call-backs times with the DAQmx.

0 Kudos
Message 10 of 10
(4,637 Views)