01-05-2010 08:46 AM
I am using a PCIe-6535 to acquire data from an external device which generates values at irregular intervals. I am using the handshaking mode to achieve this and am programming in C# using Measurement Studio.
I would like to acquire 4 byte integer data rather than the 'DigitalWaveform' data to minimize the processing required to write the data values to file (I may end up with a large throughput of data and so do not want the extra overhead of retrieving my sample values from the waveform class). Is there anyway I can determine the time at which my first data sample was acquired? i.e. Can I obtain a value equivalent to the 'DigitalWaveform.StartTime'? Additionally, can I configure the acquisition so that a digitial output line, e.g. a PFI line, can be set when the first data sample is acquired?
My code looks something like this:
//Create the task
Task inputTask = new Task();
//Specify which channels to read
inputTask.DIChannels.CreateChannel("BTT1/Port0_32","",ChannelLineGrouping.OneChannelForAllLines);
//Continuous acquisition with handshaking
inputTask.Timing.ConfigureHandshaking(SampleQuantityMode.ContinuousSamples, samplesToAcquire);
//Verify
inputTask.Control(TaskAction.Verify);
//data reader
DigitalSingleChannelReader inputReader = new DigitalSingleChannelReader(inputTask.Stream);
//start reader
inputReader.BeginReadMultiSamplePortUInt32(samplesToAcquire, new AsyncCallback(DataReady), inputTask);
Thanks,
CAS
01-15-2010 08:40 AM
CAS
Sorry for the delay in reply, but I wanted to try and answer the couple of questions that you had regarding the PCIe-6535 device. So, the best option for you to get an accurate timestamp for your Digital Data is going to be acquiring a Digital Waveform data type. If you don't acquire a digital waveform there will be no timestamp information sent with the data. With that said, it might be possible to get a timestamp from your Windows OS when the data is returned. As soon as the data was returned you would need to do a system queury for time. This would only give you software timing of when the last sample was returned, and the software timing would only be relatively accurate because of the Windows millisecond clock.
If you wanted to try and use this method it would not be very accurate, but by getting the millisecond clock value you could perform the math to find out when each sample was acquire based off your sample rate. Again, this will not be very accurate, but it depends on how accurate you need your timing information to be. Overall, I would suggest using the Waveform Data type.
As far as outputting a signal when the acquisition starts you can use a DAQmx Export Signal, and then export the Start Trigger of the device to one of the PFI lines. This Start Trigger will then be output to the PFI line as soon as the device begins to aquire samples.
Hope this information helps.
01-15-2010 10:26 AM
CAS,
You should be able to find information on these function from the .NET help. I have attached a couple of links that should show you how to find the Help files if you do have them already. Thanks!
Locations for the NI-DAQmx .NET Help Files
Do I Need Measurement Studio to use NI-DAQmx in .NET?
01-19-2010 07:18 AM - edited 01-19-2010 07:19 AM
Dear Aaron,
Thank you for your reply. I had ruled out capturing the system time when data was returned due to the inaccuracies. I would prefer some hardware based method for that reason. But I really don't want to use the DigitalWaveform due to the large overhead in extracting each data sample as an integer.
The export of the StartTrigger is an option but could you please clarify that this would be set when the first data sample is acquired and not just when I call the 'BeginReadxxxx()' function? I am using the handshaking mode with the external device determining when samples are transferred and so there is potentially an unknown delay between starting the read operation and the first data point being received.
Thanks.
CAS
01-19-2010 09:57 AM
CAS,
The export of the Start Trigger will happen after the BegiRead is called. When the BeginRead is called the 6535 device will be told to begin to acquire samples and export the Start Trigger to a PFI line as well. So these events should execute at the same time.
It is important to note that the DigitalWaveform data type still uses the system clock to get the t0 values for the waveform. In general, there should not be a huge difference between getting the t0 from the digital waveform and calling to the system clock to get a time value when the read is first called. If you would like to know the typical difference you could do a quick test with the digital waveform data type. You could call to the system clock and then compare it against the t0 from the digital waveform.
Overall, how exact do you need the timestamp for the first sample to be?