08-19-2009 01:03 PM
Hello,
I added the PID control to my VI and the entire locks up. I'm new to programming with Lab VIEW. Please take a look at the posted VI and let me know what I have done wrong.
Thank you,
BLW
Solved! Go to Solution.
08-19-2009 01:41 PM
Isn't the PID just a functional global? It's just math.
Your VI is missing VI's.
08-19-2009 01:50 PM
BLW,
You have several fatal problems with your vi. One of the worst being that you are trying to run more than one DAQmx AO task at the same time. Start by combining the three AO's into the same task. Wire up the error cluster so you can see any errors generated when your code runs. Your analog read is setup for waveform data which you promptly convert to DBL. Why not just read DBL's to begin? Next, the current method you are using to pass the process variable value between the two loops will not work.
08-19-2009 01:52 PM
Yeah well, I guess that's another thing I suck at. How do I bundle the vi's to attach it as a whole. The previous owner of this project has everything jumble up and hard to find.
Yeah, I know it should be "just math" but apparently it's not working that way. I have taken over this VI for another individual and I understand there are other issues.
Here's another VI I just threw together and I'm not able to get the proper values on the output side. It's was giving negative values and then I added an output control and changed to Kp to a negative value. No avail, still not working properly.
BLW
08-19-2009 01:55 PM
Oh ok, Wayne. That's very helpful. Thank you. How might I transfer the process variable and why won't it work this way?
Thanks,
BLW
08-19-2009 02:20 PM
BLW,
Found this 'Data sent into the While Loop is sent only on the first iteration, and data sent out of the while loop is sent only after the last iteration. ' in this tutorial .
Best way to pass data between loops is open for discussion. I suppose it depends a lot on the platform it will be running on and how time critical your process is. I don't recomend local variables. I suspect a lot of people would use a queue. In this case because you have a single variable and a single writer you might be able to use a single global variable. All my stuff runs on cFP so I tend to use FIFO's.
I'm sure that some of the other forum users will add their thoughts on this as well.
08-19-2009 02:24 PM
This makes a lot of sense Wayne I'll do more research on how to pass between loops and reply maybe tomorrow. Thanks.
BLW
08-20-2009 09:44 AM
Hi Wayne,
I passed the variable to the other loop with a local variable and evything works correctly now.
I do hope you can expound on your point about combining the AO tasks. In other protocols we will require different levels of gas at different time points for each gas (for control subjects the will reamin constant ie. the "air" terminal). Would it still be possible to combine the tasks and operate them with one PID?
Thanks,
BLW
08-20-2009 11:04 AM
BLW,
Glad it works. Please look into alternatives for the local variable.
The idea is to combine multiple analog ouputs into the same task. In your case it sounds like you will have all the AO channels in a single task. You end up writing a 1D array of DBLs where each element of the array is written to its corresponding output.