ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID control loop with data saving

Hello,
 
I am trying to make a simple PID controller for a rather slow process (loop rates < 1000 Hz), so I thought that I would just use a simple Labview VI. This seems to work fine and fast enough, but I would also like to save the input signal and the controller output to a spreadsheet or binary file to be able to analyse the performance of the controller.
 
I tried to add a 'write to spreadsheat' sub VI inside the controller loop to write the successive data values to a file (I used the append option to ensure that the previous values are not overwritten), but this limits the maximum loop rate to about 100 Hz. Does anyone know have a better idea? Maybe a VI alrready exists to do this?
 
Thank's a lot in advance!
 
CU
Peter Mercelis
0 Kudos
Message 1 of 3
(2,995 Views)
I suspect that the speed hit is due to the overhead required by the file maintenance when using the upper level 'write to spreadsheet.vi'.  Since that VI opens, writes and then closes the file on each loop iteration it is not very efficient.  What you need to do is use 'Open File.vi' before your PID loop, then pass in the reference to 'Write File.vi' and write you data on-the-fly with that.  After the loop ends, pass out the reference and close the file with 'Close File.vi'.  That should speed you up considerably.
 
 
LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 2 of 3
(2,991 Views)

Hello,

thanks for your suggestion. The Write with Ref.vi did not work in Labview 6.1, but I could solve the problem in a similar way using other VI's (Open/Create/Replace File VI + Write File (+ string) VI + Close File VI). The loop rate can be up to 10000 Hz now while keeping realtime behavior. That's more than enough for my purpose. Thanks again!

 

CU

Peter

0 Kudos
Message 3 of 3
(2,984 Views)