10-22-2014 02:45 AM
Hi all,
I am using a PID controller to control the position of a linear stage. I have problem understand the frequency of the controller.
The PID module locates in a while loop. Is the frequency of the controller the same with the frequency of the while loop? As the frequency of the while loop is "sampling rate"/"samples to read", I need to decrease the value of "samples to read" and increase the "sampling rate" to acheive high frequency control, right?
Thanks
best
10-22-2014 04:24 PM
Hello iyearning
You are right about how often the DAQ assistant is going to execute. It is going to hold the acquisition until it reaches the number of samples to read you defined. So yes, you get frequency dividing rate/samplesToRead, however you need to add the time required by the processor to execute all your logic. So you need to take into account this delay. You are right when you say you need to decrease the value of samples to read and increase the sampling rate to increase the loop execution frequency (however there are some limits here with the values you can use).
If you want to increase the performance of your code, you can also consider the DAQmx low level VIs.
Regards
Frank R.
10-23-2014 12:16 AM
Dear Frank,
I changed my VI with DAQ low level modules. How could I estimate the time delay for eexecuting the logic? How could I know the controller's frequency?
I want to set exact frequency of the controller, for example 1KHz, what should I do? Would it help if I place a time delay module in the while loop?
Thanks
best
10-23-2014 04:24 PM
Hello iyearning
You can use this method to benchmark loop iteration time:
Benchmark Loop Iteration Time with Tick Count Timer
Regards
Frank R.