取消
顯示結果 
搜尋替代 
您的意思是: 

sampling time changed in the timed loop

已解決!
前往解決方案

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 積分
1 條訊息(共 6 條)
3,198 檢視
解決方案
由主題作者所接受 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 積分
2 條訊息(共 6 條)
3,180 檢視
解決方案
由主題作者所接受 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 積分
3 條訊息(共 6 條)
3,176 檢視

GOOD WAY! MAKE IT! THX SO MUCH!高興表情

0 積分
4 條訊息(共 6 條)
3,127 檢視

GOOD WAY! MAKE IT! THX SO MUCH!高興表情

0 積分
5 條訊息(共 6 條)
3,126 檢視

GOOD WAY! MAKE IT! THX SO MUCH!高興表情

0 積分
6 條訊息(共 6 條)
3,125 檢視