Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Loop timer first values not correct

Hello,

 

I'm using NI9223 module on cRIO 9012 controller and cRIO 9118 chassis to acquire a signal. In the attachement you can see my FPGA program to acquire the signal and make some averaging.

 

I have a problem to control the execution of the while loop in the first few itterations, even though I am using the Loop timer VI. For example for the first few acuisiotions the loop time is always smaller than the time that I set. And it seems that even with increasing the loop timer this behaviour stays the same. For example if I take the first sample now, so time is zero, the next sample will be acquired after 25 to 38 ticks, insetad of the 40 ticks that I have specified. Sometimes the same happens with couple of acquisitions more, but sometimes only for the first 2 acqusitions. So the problem seems to be not completely repeatable. Afterwards the acqusitions go on as desired, on every 40 ticks. 

 

So, now, my desired acqusition should be on each microsecond, and istead of that I have acquistion for the first samples on differents times, and the whole acqusition proccess is ruined, because instead of taking the samples on 0,1,2,... micro seconds, I have the samples on 0, 0.95, 1.95, 2.95,... micro seconds. In my application I need to have the samples on equal time distances throuout whole acqusition.

 

Any ideas how can I fix this?

 

Thank you very much.

 

 

Kind regards,

Nikola Todorovski

0 Kudos
Message 1 of 7
(6,401 Views)

Try separating acquisition and signal processing into different loops, and use FIFO to send data. This makes sure that signal processing doesn't ruin signal acquisition timing.

0 Kudos
Message 2 of 7
(6,370 Views)

Dear KateB,

 

because of the requirements of my application I can't separete the acquisition and processing of the data in separate loops, and you can see that I am using FIFO to send the acquired data to my PC already.

 

But, even if I separate then, it will not change anything. The timing of the whole loop including the signal processing is tested and it is less than 40 ticks, so it fulfills the criteria. Also in my application, after this step I only acquire data without any processing, and still the first timing of the loop timer is not correct. The first sample is always taken after around 35 ticks, intead of the set value of 40 ticks, and every additional timing is correct at 40 ticks. I really can't understand what is the problem with the first sample.

 

Cheers,

Nikola

0 Kudos
Message 3 of 7
(6,365 Views)

Hi Nikola,

 

maybe this information ("Loop Timer Details") might be useful: http://zone.ni.com/reference/en-XX/help/371599J-01/lvfpga/loop_timer/

It says that the loop-timer VI only records the current time at the first execution. The wait-functionality starts at the second execution.

 

This might explain your observation with the first loop iteration, as it starts with a wrong time in the first iteration and goes on with correct timing after the second iteration.

 

Have you considered using a timed loop instead?

 

 

Regards,

Michael

__________________________________
Certified LabVIEW Associate Developer
0 Kudos
Message 4 of 7
(6,318 Views)

Hi Michael,

 

thank you for your reply. It seems I didn't understand the explanation of the Loop Timer VI correctly, but now when I read it again it seems that is no way to fix the timing for the first itteration.

 

Now when I am considering to use the SCTL, I have a problem to make the execution of that loop to be on every 40 ticks (1 microsecond). I am trying to derive a clock speed of 1MHz from the 40MHz clock speed of the FPGA. Any ideas how can I control the timed loop to execute on every 1 microsecond?

 

Thank you very much one more time.

 

Regards,

Nikola 

0 Kudos
Message 5 of 7
(6,286 Views)

Hi Nikola,

 

you can have a look at this link to get information on deriving the FPGA clock for a timed loop.

 

 

__________________________________
Certified LabVIEW Associate Developer
0 Kudos
Message 6 of 7
(6,249 Views)

Hi Nikola

the loop timer function executes based on the multiple of clock count.

so suppose when your function first gets the opportunity to execute the milisec timer value is 132 and you have specified the wait of 100ms then the first iteration will execute after 200(next multiple of 100) - 132 = 168 ms.

What you can do to avoid this is   just before the loop use one more loop timer function so that the function in loop will execute at correct time interval.

0 Kudos
Message 7 of 7
(6,236 Views)