LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI 9403: Ditigal Input/Output slows down timed loop?

Solved!
Go to solution

Hi all,

 

I am using a timed loop to sample from 7 current channels (NI 9023), 3 voltage channels (NI 9025) in 1000 Hz in scan mode and it works fine. However, when I add 8 output channels of Digital Input/Output module from NI 9403 to the timed loop, the sampling frquency can not reach 1000 Hz any more. From the data with timestamp I wroten into file, it looks like I in every ten miliseconds, I missed one milisecond.

 

I would like to ask is there any reason for this to happen? Does the Digital I/O module affect the timed loop?

 

Thank you veyr much in advance.

0 Kudos
Message 1 of 6
(4,012 Views)

The 9403 is a static device.  This meaning you have to tell it to output a voltage by software.  No clock, no high speed timing.  It could be that your code just cannot preform all the functions inside your timed loop in one millisecond.  Maybe it was just under one mS before adding the code for the 9403, but now it is slightly more than 1 mS.  Post your code here, maybe we can try to optimize the code for faster execution.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 6
(4,003 Views)

Hi tbob, thank you for your replying. I did have a lot things inside my timed loop. I am actually working on a data aquisition system that samples from 7 current channels, 3 voltage channels in 100 Hz (normally), and reads 3 different serial devices (from NI 9871) at the same time. And I also read from 8 input channels of the Digital I/O module that shows the power level of power supply for all the equipment. So that I am using scan mode and FPGA in the same project. And also, I calculate the average values of the current and increase the sampling rate to 1000 Hz if they went out of range.

 

The problem I am having now is that, when the sampling rate goes up to 1000Hz, in the text file of data with timestamp, some of the data are missing. And I also attach the text file with current data in 1000 Hz.

 

I attach my project here. I am looking forward for your help.

 

Thank you very very much!! 

0 Kudos
Message 3 of 6
(3,997 Views)
Solution
Accepted by masterwho

I am not familiar with FPGA code so I can't comment there.  However, I noticed that you are calling Write to Text File twice within the timed loop.  Can you just gather data and then write to the files after the time loop?  This would save a lot of time.  For each write, the program has to access the hard drive, find the end of file, append to it and write it back to the hard drive.  Very time consuming, especially as the files grow larger.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 6
(3,994 Views)

Hi tbob,

 

Thank you very much, I will try your suggestion as soon as I am back to my office next Monday. Could I ask you another question about timed loop?

 

As you can see in my host vi, the unit of time source of my timed loop is us (I am using 1MHz absolute time clock as the sorce). However, when the number I connect to the input terminal of dt is 0.01, the sampling rate is 100 Hz, and when the number 0.001, the sampling rate is about 1KHz. Why is this happening? I mean the period number connected to peroid is supposed to has the same unit with the time source, in another word, us. But if I replace 0.01 with 10000, it takes ages for the timed loop to finish one iteration.

 

Many thanks!!  

0 Kudos
Message 5 of 6
(3,956 Views)

Are you using Labview Real Time?  You cannot get 1MHz clock in regular Labview, only in LVRT.  Setting dt to 0.01 will result in a sampling rate to 100Hz.  This is correct, rate in hertz = 1 divided by the period in seconds.  So 1/0.001 = 1000, hence setting dt to 0.001 will give 1KHz sample rate.  If you want higher sample rates, you need LVRT and you need to set dt to smaller than 0.001.  0.000001 will give 1MHz rate.

 

No matter what number is connected to the period, the units are always seconds for time and hertz for frequency.  When you set dt to 10000, it will take 10000 seconds to run one loop.  dt is always in seconds.

- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 6
(3,927 Views)