Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

My AO triggers were delayed by about 1 ms out of every 1000 ms

Dear Labview Experts,
 
I am an EEG person and am currently trying to build my own stimulation system using Labview.  I have a DAQcard 6062E and Labview 8.0, and I am new in Labview programming. My plan is to play a .wav file continuously through AO channel #0, and at the same time deliver triggers through AO channel #1.  I intertwined the outputs of the two AO channels so that the sound signals and the triggers will always be synchronized.  I do this because my DAQ 6062E card does not do hardware-timed triggering.  The sound signals were sent to a loud speaker, whereas the triggers were sent to a Neuroscan recording system.  The Neuroscan recording system will then be used to record EEGs from a human subject along with the triggers that were sent through my Labview program.
 
My problem is: My triggers recorded by the Neuroscan recording system were delayed by about 1 ms out of every 1000 ms.  I mean I have tested the Neuroscan recording system using their own stimulation system.  When the triggers were sent using Neuroscan's stimulation system, the triggers were correct and precise in time.  However, when the triggers were sent using my Labview program, the triggers were delayed by about 1 ms out of every 1000 ms.  I have also checked the output array of my two AO channels.  They contained exactly the same number of data points as it has in the wave file.  Is it possible that the delay is due to my lousy, immature Labview programming skills?  I mean, it is quite possible, but I simply do not know where the problem is.  If anyone would be generous enough to take a look of my Labview programming codes and to give me comments, I would greatly appreciate it.
 
Sincerely,
 
Fuh
 
P.S. My wave file is generated using MATLAB, at a sampling rate of 44,100 samples/second.  Because the ".wav" file extension is not a valid file extension for attachment on the NI Discussion Forum.  I have changed the file extension of my wave file into ".txt".  If anyone needs to use my wave file to test my Labview program, please be sure to change the file extension bact to ".wav" before using it. 
0 Kudos
Message 1 of 13
(4,125 Views)
Hi Fuh,

A google search for "matlab analog output" might help you with a possible solution.

-Rob
-----
Rob Purser
Manager, Test and Measurement
MathWorks
rob.purser@mathworks.com
0 Kudos
Message 2 of 13
(4,118 Views)

Hi Rob,

Thank you so much for your input.  I googled the "matlab analog output", but I did not use the "analog output" function in Matlab.  I used MATLAB simply to create amplitude-modulated white noise and save it in a wave file.  The wave file should be exactly the same as any "standardized" wave files.   

Also there is another point I probably didn't explain clear enough in my first posting.  When I said my trigger was delayed by about 1 ms out of every 1000 ms, I mean if I use my Labview program to read in a wave file that contains a 1000-ms sound signal (for example, amplitude-modulated white noise),  the intervals between adjacent triggers recorded in the Neuroscan recording system will be 1001 ms.  I mean, if the recording is set to collect 10,000 samples/second, the intervals between adjacent triggers will be 10,011 data points instead of 10,000 data points.  If the recording is set to 20,000 samples/second, the triggers will be evenly spaced by 20,022 data points, instead of 20,000 data points. 

On the other hand, if I use my Labview program to read in a 2000-ms-long wave file and the recording was set to 10,000 samples/second, the intervals between adjacent triggers will be 20,044 data points instead of 20,000 dtat points.  

I mean, the delay seems to be proportional to the lenght of the wave file.   That makes me think: (1) this might due to Labiview programming overhead (due to my immature Labview programming skills), or (2) this might also due to the fact that my Labview stimulation program and the Neuroscan recording system are not using the same clock.  Before I jump into the second conclusion, I would like to be sure that my Labview program is producing any delay, or not.

Hope this would make more sense to the readers.

Sincerely,

Fuh

0 Kudos
Message 3 of 13
(4,110 Views)

Hi Fuh,

I am interested to find out a little more about the issue. Your programming looks to be ok. The data transfer from the to the card from the PC is done through DMA transfers, which means that the data is written to the card in chunks because the on board memery of the card cannot hold all of the data. Do you see a constant error of 1ms per 1 second or does the delay happen periodically at some other interval? Is the Neuroscan stimulation system independant of LabVIEW, the pc, and the DAQ card? What rate is the Neuroscan recording system acquiring data?

Steve B

0 Kudos
Message 4 of 13
(4,100 Views)

Hi Steve,

Thanks a lot for looking at my Labview program. 

I let my Labview program run for a little while and recorded the continuous EEG data (along with the triggers) from the Neuroscan recording system.  I then analyze the recorded data and calculate the data points between adjacent triggers.  It is a constant delay of 1 ms out of every 1000 ms.  I also noted that the delay is not at the beginning, at the end, or at any specific location of the data points.  Instead, the delay is evenly distributed throughout the entire recording data points.  I have done a little experiment.  I modified my Labview stimulation program and add additional triggers at the middle and at the end of the AO channel #1 output.  The delay is found to be evenly distributed throughout the entire recording data points.  That is, for some reason, the 1000 ms stimulation was evenly distributed over a recording period of 1001 ms.  That is, something wrong was happening and delaying the presentation of each data output (either at the stimulation, recording, or somewhere in between).  I simply cannot figure out where...

The Neuroscan stimulation system is completely independent of Labview.  Actually the entire Neuroscan system (both the stimulation and recording systems) is independent of Labview.  Neuroscan is written in Visual C.  Their stimulation system uses a Keithley I/O card (Model KPCI-PIO24 24-ch, PCI Board w/ parallel Digital I/O) running on a DELL computer using Windows XP.  

Signal flow of the Neuroscan recording system can be described as follow.  EEG signals --> headstage preamplifier --> signal box --> USB cable to a DELL computer.   The triggers should be delivered to a trigger port on the back of the signal box (either using Neuroscan stimulation system or through a TTL cable using my Labview program).  When I use my Labview program as the stimulation system, the Neuroscan stimulation system is turned off and completely disconnected from the Neuroscan recording system.  The Neuroscan recording system can record EEGs at different recording rates, from about 500 samples/second up to 20,000 samples/second.  The recording sampling rate I used was 10,000 samples/second.  I have also tried the recording sampling rate of 20,000 samples/second.  Same thing happened -- 1 ms delay out of every 1000 ms, and the delay is evenly distributed throughout the entire recording process. 

Specifications of the Neuroscan stimulation computer is:
NetData (miniature)
            Location: W141A (Lab office)
            CPU: Pentium (R) 4 CPU 3.00 GHz, 3.00 GHz
            RAM: 2 GB
          
Hard Drive: 80 GB, 80 GB

Windows XP + Service Pack 2

 

Neuroscan STIM computer (DELL OPTIPLEX GX620)

            Location: W141 (AEP Lab)

            CPU: Pentium (R) D 2.80 GHz, 2.79 GHz

            RAM: 1 GB

Hard Drive: 150 GB

Windows XP + Service Pack 2

 

By the way, I computer I used for my DAQ6062E (a PCMCIA card) is an ACER laptop. 

Thanks a lot...

Sincerely,

Fuh

0 Kudos
Message 5 of 13
(4,096 Views)

Hi Steve,

Thanks a lot for looking at my Labview program. 

I let my Labview program run for a little while and recorded the continuous EEG data (along with the triggers) from the Neuroscan recording system.  I then analyze the recorded data and calculate the data points between adjacent triggers.  It is a constant delay of 1 ms out of every 1000 ms.  I also noted that the delay is not at the beginning, at the end, or at any specific location of the data points.  Instead, the delay is evenly distributed throughout the entire recording data points.  I have done a little experiment.  I modified my Labview stimulation program and add additional triggers at the middle and at the end of the AO channel #1 output.  The delay is found to be evenly distributed throughout the entire recording data points.  That is, for some reason, the 1000 ms stimulation was evenly distributed over a recording period of 1001 ms.  That is, something wrong was happening and delaying the presentation of each data output (either at the stimulation, recording, or somewhere in between).  I simply cannot figure out where...

The Neuroscan stimulation system is completely independent of Labview.  Actually the entire Neuroscan system (both the stimulation and recording systems) is independent of Labview.  Neuroscan is written in Visual C.  Their stimulation system uses a Keithley I/O card (Model KPCI-PIO24 24-ch, PCI Board w/ parallel Digital I/O) running on a DELL computer using Windows XP.  

Signal flow of the Neuroscan recording system can be described as follow.  EEG signals --> headstage preamplifier --> signal box --> USB cable to a DELL computer.   The triggers should be delivered to a trigger port on the back of the signal box (either using Neuroscan stimulation system or through a TTL cable using my Labview program).  When I use my Labview program as the stimulation system, the Neuroscan stimulation system is turned off and completely disconnected from the Neuroscan recording system.  The Neuroscan recording system can record EEGs at different recording rates, from about 500 samples/second up to 20,000 samples/second.  The recording sampling rate I used was 10,000 samples/second.  I have also tried the recording sampling rate of 20,000 samples/second.  Same thing happened -- 1 ms delay out of every 1000 ms, and the delay is evenly distributed throughout the entire recording process. 

Specifications of the Neuroscan stimulation computer is:
NetData (miniature)
            Location: W141A (Lab office)
            CPU: Pentium (R) 4 CPU 3.00 GHz, 3.00 GHz
            RAM: 2 GB
           
Hard Drive: 80 GB, 80 GB

Windows XP + Service Pack 2

 

Neuroscan STIM computer (DELL OPTIPLEX GX620)

            Location: W141 (AEP Lab)

            CPU: Pentium (R) D 2.80 GHz, 2.79 GHz

            RAM: 1 GB

Hard Drive: 150 GB

Windows XP + Service Pack 2

 

By the way, I computer I used for my DAQ6062E (a PCMCIA card) is an ACER laptop. 

Thanks a lot...

Sincerely,

Fuh

0 Kudos
Message 6 of 13
(4,096 Views)

Oops.  I accidentally pressed some key, and submitted the information twice.  Sorry!

Specifications of the computers should be:

Neuroscan Recording computer:

           NetData (miniature)

            CPU: Pentium (R) 4 CPU 3.00 GHz, 3.00 GHz

            RAM: 2 GB

Hard Drive: 80 GB, 80 GB

Windows XP + Service Pack 2

 

Neuroscan stimulation computer (DELL OPTIPLEX GX620)

            Location: W141 (AEP Lab)

            CPU: Pentium (R) D 2.80 GHz, 2.79 GHz

            RAM: 1 GB

Hard Drive: 150 GB

Windows XP + Service Pack 2

 

0 Kudos
Message 7 of 13
(4,094 Views)

Oops.  I accidentally pressed some key, and submitted the information twice.  Sorry!

Specifications of the computers should be:

Neuroscan Recording computer:

            NetData (miniature)

            CPU: Pentium (R) 4 CPU 3.00 GHz, 3.00 GHz

            RAM: 2 GB

Hard Drive: 80 GB, 80 GB

Windows XP + Service Pack 2

 

Neuroscan stimulation computer (DELL OPTIPLEX GX620)

            Location: W141 (AEP Lab)

            CPU: Pentium (R) D 2.80 GHz, 2.79 GHz

            RAM: 1 GB

Hard Drive: 150 GB

Windows XP + Service Pack 2

 

0 Kudos
Message 8 of 13
(4,094 Views)

Specifications for my Labview stimulation computer is:

******************************************************************************
Acer Aspire 3000
CPU: Mobile AMD Sempron (tm) Processor 3100+ 1.80 GHz
RAM: 512 MB
Windows XP and Service Pack 2
*************************************************************************

For some reason, I kept submitting information twice. 

My apologies about that...

Fuh

0 Kudos
Message 9 of 13
(4,093 Views)
Hello Fuh!

Thanks for your post!

I was looking into your issue as well and I agree with Steve_B that your program looks fine and I do not contribute the problem that you are seeing with your "poor LabVIEW skill", :). What I was able to notice how ever when running a test on a DAQ board of my own I saw that the sample rate was not actually exactly right on 44100 Hz. It was in fact 44095 Hz. This could be the contributing factor of your output getting off by 1ms. The reason is because the divide down ratio of the master time base will not give you the exact integer 44100. So if you use a DAQmx Timing Property node and set it to "Sample Clock Rate". ( You can find this property node in the DAQmx palette) You can see that the value is not in fact 44100. So what I was able to do is run a test with your code on a Digital Sound Analysis (DSA) card that we have here, the PXI-4461, and since the card has an over sample clock and uses a DDS sample generator this causes the frequency to be more exact. So running your same program we were able to get an exact frequency of 44100 for the output of your sound file. So the only way to compensate for your program at this point may be to do some kind of software manipulation or the 4461 may be a way for you to go for your application. Also if you were able to supply an external sample clock of exactally 44100 then that would be a workaround as well.

Let me know if you have any other questions and Good Luck with your application!

Cheers!

Corby_B
http://www.ni.com/support
0 Kudos
Message 10 of 13
(4,065 Views)