10-03-2006 04:59 PM
DataPoints = 6250;
%daq cards cannot read more than 7000 samples per iteration,Fs = 6250;
%Sampling Rate (Samples per second)Duration = 20;
%seconds%Devchans + 1 ... is the number of channels for each device
Dev1Chans = 3;
Dev2Chans = 2;
NumDataPoint = Duration*Fs;
%total number of samples to be takenfig1 = init();
%starts figure one%format long
ai1 = analoginput(
'nidaq','dev1'); %add device one (IEPE) as the first analog input dev.ai2 = analoginput(
'nidaq','dev2'); %adds device two (V DIFF) as the second analog input dev. %define the sample rate for each deviceai1.SampleRate = Fs;
ai2.SampleRate = Fs;
%define Channels:addchannel(ai1,0:Dev1Chans);
addchannel(ai2,0:Dev2Chans);
%define number of samples to be takenai1.SamplesPerTrigger = NumDataPoint;
ai2.SamplesPerTrigger = NumDataPoint;
%define AI Objectai = [ai1,ai2];
%define logging mode to be done in memory , can be set to disk if %desiredai.loggingmode =
'memory' ;%'disk'ai1.LogFileName =
'ai1.daq';ai2.LogFileName =
'ai2.daq'; %set trigger manually using start(ai) command:ai.TriggerType =
'manual';start(ai);
%end of initialization code ------------------------------------------------------------
%data acquisition code:
ai1 = ai(1);
ai2 = ai(2);
pause(2);
addreport(hObject,handles,
'Acquiring now......');trigger(ai);
t = clock;
while (strcmp(ai1.running,'On'));pause(1);
[CurrentData] = PickData(SensorNum,DataPoints,ai);
[xx,yy] =size(CurrentData);
DisplayError = DisplayData(SensorNum,CurrentData,DisplayType,hObject,handles,Fs,0);
etime(clock,t);
GG = ai1.samplesacquired/NumDataPoint;
GG= fix(GG*100);
report = [
'Samples Acquired; AI1:' num2str(ai1.samplesacquired) ' AI2:' num2str(ai2.samplesacquired) ' ' num2str(GG) '% Completed' ];addreport(hObject,handles,report);
end;wait(ai,100);
[data1,time1,abstime1,events1] = getdata(ai1);
[data2,time2,abstime2,events2] = getdata(ai2)
%--------------------------------------------------------------------------------------
could you please help me with the problem?
10-04-2006 10:15 AM
Hello High Speed,
The problem that you are encountering is a common problem due to the nature of the all DSA cards, inlcuding the 9233 board that you are using. This board uses a Sigma Delta ADC which automatically filters out higher frequency components but also introduces a certain delay in the signal. This delay is always going to be a certain amount of time. You will have to delete a certain number of samples from the other acquisition in order to synchronize the readings. The number of samples you have to delete depends on your sample rate. The easiest way to figure out how many samples to delete is to just try it out with one signal wired into both inputs. You can refer to these links for more information.
Why Is My Data Delayed When Using A Digital Trigger With My DSA Device?
Synchronization with Dynamic Signal Acquisition (DSA) Products with DAQmx
10-04-2006 04:06 PM
10-05-2006 01:53 PM
Hello High Speed,
I’ve had another idea after you mentioned that the number of samples that you miss varies so much. I went back and looked at your code and from what I can tell it looks like you have software timing. Now is the appropriate time for the Disclaimer: We did not write that code and we do not officially support any of the higher level code that you’re using. It looks to be code from another vendor. We support the board and the drivers that we’ve written, but for official support of that code and exactly what it does you might have to contact the people who wrote it. That being said I have a pretty good guess on what is going on and I’d like to help to the best of my ability.
First, I want to confirm that you are indeed using the USB 9215 and the USB 9233. They are probably each in a separate carrier and each have their own USB cord. The other alternative is that they are both in a USB Compact DAQ chassis. If they are both USB versions, then there is bad news, because there is no way to synchronize these devices besides in software, which has the obvious limitations that you’re running into now. If they are in the Compact DAQ chassis it is possible to synchronize them to within a set number of samples because they share timing and triggering lines. There are still a few difficulties because one is a DSA card and one is a standard AI card, but those difficulties can be overcome as mentioned in the above KBs.
Right now you’re basically doing software timed acquisition. That means that one task is going to start and then the next is going to start. There is no hardware trigger connecting the two cards, and in fact I don’t think the 9233 even supports triggering. There are ways of getting them reasonably close, and it looks like you’ve taken those measures already. Besides making sure to call both start tasks right in a row there is not a lot you can do to increase the timing. Everything is at the mercy of the operating system to execute the actions as quickly as possible one after another. It’s unlikely that they’ll ever start at exactly the same time. If you do need synchronous results then you’ll have to look other hardware. I would recommend cDAQ because you would be able to reuse the modules that you’ve already bought and would only need the chassis. It would also keep the flexibility of USB for you.
If you are in fact using cDAQ and still having difficulties, please let me know. If you are triggering the start of the acquisition with cDAQ there should be a deterministic delay between modules rather than a variable delay between the modules that we are seeing now.
Regards,
10-05-2006 05:37 PM
10-09-2006 08:15 AM
Hello Siamak,
Again I can’t be positive of exactly what the code is doing, but here is my suspicion. I think the timestamping information is coming from the computer and is put into the data after the fact. Basically the timestamp is being inserted by software instead of taking any sort of hardware timestamp. For these cards that you’re using that is basically the only way to get a timestamp like you’re seeing. The boards themselves do not have any sort of atomic clock and are not receiving a GPS signal so they cannot have anything resembling and absolute timestamp.
Since the timestamps are coming from the operating system, it would be easy to see how you could get two identical timestamps because a timestamp is taken once and then applied to both of the sets of samples. Unfortunately this gives us no indication of when either task actually started. Ideally the function calls would be setup in this order. Start task 1, timestamp 1, start task 2, timestamp 2. In that way we could get more accurate and useful timestamps. They still would not be perfect though since we’re relying so heavily on a non-deterministic operating system to perform the actions.
As far as why you could get negative delays. It could be that it does not always start the tasks in the same order each time. Again, this may be something you would have to discuss more with the people who wrote the functions that you are using. This could also be related to using USB for the communication which is also non-deterministic and could take longer sometimes to transmit the information, or longer to communicate with one card than another.
I hope this helps clear up some things.