03-19-2013 12:11 PM
Gurus,
I am trying to use Labview PID control on a piece of hardward. I am using the template single-loop PID. Instead of reading in a voltage, I am reading a value from a serial port. However, I cannot get the serial port read software to work. I have the read section inside the while loop of the PID VI. I have tracked the issue down to a timed loop that counts the number of bytes at the serial port. For some reason, the timed loop is just not triggering
If I have a separate bit of code running to read the serial port that does the same function, everything is fine. I have tried copying the timed loop from one VI to another (renaming it), no joy. Re-written to remove first order idiocy, no joy. Anyone any thoughts?
Attached are the 3 VIs I am using (I have cut it down for simplicity). SNAQ single loop PID.vi is the main, issue is on frame 1 of the 4300 reader.vi. What I don't understand is that if I use the port setup and 4300 reader after a re-boot without opening the SNAQ single loop PID.vi. they work!
thanks in advance
Solved! Go to Solution.
03-20-2013 12:50 PM
Hi,
Please see the attached.
Forgive me, but I neated up your VIs quite a lot to try and understand what was going on, those stacked sequence structures are very difficult to follow!
The only functional change that I've made is to pass the references through the VISA functions. I'm not certain how the VISA resource name reference works, I think either:
1. The reference is simply a pointer to memory that contains the information we've specified about the serial connection.
2. The reference wire actually contains the information about the VISA resource it's referencing.
Previously, you had tapped your reference wire off the same control every time. I've passed the wire through the functions so that if suggestion 2. is true, these settings will be carried through the code.
Give those a go and see if you find anything different.
Is there any reason you're using a timed loop there instead of a normal while loop with timing inside?
Thanks,
03-20-2013 03:49 PM
Thanks for the reply, I will look at the VIs tomorrow for 'tidyness tips'.
After un-installing all earlier versions of Labview, removing the files from the control PC and rewriting with all error outputs wired up, I discovered the problem. You cannot use a timed loop structure inside a time-critical VI. The PID VIs are all time-critical. I lowered the priority to high in VI properties and everything worked. That took all day! I was going to post tomorrow.
I did try your suggestion of wiring the reference through the code yesterday. It doesn't make a difference, although I suspect it is more efficient to program that way.
As for the timed loop....The guts of the VI is many years old. When I upgraded my version of Labview I was trying out the new features. At the time, timed loops was one of them.
Thanks again, I will look at your VIs.
Paul