LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sampling time changed in the timed loop

Solved!
Go to solution

Hi everyone,

 

I am using the timed loop to control the DC motor with the PID vi. in the loop and the sampling time is set as 0.01s. However, after I added some other VIs into the loop, for instance, the write to measurement file.vi, to collect the errors between the desired angle and the practical angle of the motor during the time histroty of the motor's motion, it is found that the sampling time changed, not always 0.01s before the vi was added, but 0.01 or 0.02s. the whole program desinged to be fininshed with 7s now it is done at 9.4s, i.e., the time to run the loop is extended.

 

Another thing is, if the sampling time is set as 0.05s, the sampling time is always 0.05s and the time to run the loop is always 7s as predined, no matter the write to measurement file.vi is added into the loop or not.

 

Through this, I think if the complexity in the loop is incresead and the set sampling time is small, then the actual sampling time will be changed because of the computational burden of the things in the timed loop. Is this the reason? If so, are there some methods to solve it ?

 

An important thing is: the collection of the angular error of the motor in the time histrory is quite important, which will be used to demostrate the rightness of the KP, KI and KD parameters.

 

Some friend suggests to use the queue vi, but I am not quite sure how to use them. Can anyone gives some instrctions?  

 

Thansk very much!

 

Cheers

0 Kudos
Message 1 of 6
(2,413 Views)
Solution
Accepted by topic author StanleyC
Cramming functions into a timed loop is like stuffing 5 pounds of you know what into a 3 pound bag. The timed loop is only really practical on an rt system but even then, if the code inside requires more time than the loop period, there is no magic that the loop can do to increase execution time. It will simply report that the loop is late. The solution is to remove functions from inside the loop. The Write to Measurement File is one of the worst if you write to a text file. Look at the producer/consumer design pattern that you have examples of. In there, you will have a normal loop that you will write to a queue and a second loop will process the data on the queue. Use File> Open...
0 Kudos
Message 2 of 6
(2,395 Views)
Solution
Accepted by topic author StanleyC

From the sounds of your controls/measurement and file write are all occurring within the same loop and overrunning your desired capture period. If you want to speed up this loop you can always move the File-write to outside of this loop, this should increase performance significantly as File I/O is often the slowest part of a program. 

 

Otherwise it is possible to move the sampling to a second parallel loop that will record the data and then post it to a queue to be processed in the seperate loop. For more information about Queues, Have a look at the "Queue Basics" and "Queued Message Handler" examples available within LabVIEW.

 

Generally the most effective way of asking for help is to present a simplified version of your VI with an explanation of what you believe is causing the problem, so if you want any more specific help don;t hesitate to ask.

0 Kudos
Message 3 of 6
(2,391 Views)

GOOD WAY! MAKE IT! THX SO MUCH!Smiley Happy

0 Kudos
Message 4 of 6
(2,342 Views)

GOOD WAY! MAKE IT! THX SO MUCH!Smiley Happy

0 Kudos
Message 5 of 6
(2,341 Views)

GOOD WAY! MAKE IT! THX SO MUCH!Smiley Happy

0 Kudos
Message 6 of 6
(2,340 Views)