LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID

Solved!
Go to solution

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

0 Kudos
Message 1 of 9
(4,670 Views)

Isn't the PID just a functional global?  It's just math.

Your VI is missing VI's.

Richard






0 Kudos
Message 2 of 9
(4,654 Views)

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. 

Message 3 of 9
(4,648 Views)

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

0 Kudos
Message 4 of 9
(4,645 Views)

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

0 Kudos
Message 5 of 9
(4,642 Views)
Solution
Accepted by topic author BLW

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.

Message 6 of 9
(4,619 Views)

This makes a lot of sense Wayne I'll do more research on how to pass between loops and reply maybe tomorrow.  Thanks.

BLW

0 Kudos
Message 7 of 9
(4,616 Views)

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

0 Kudos
Message 8 of 9
(4,560 Views)

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. 

0 Kudos
Message 9 of 9
(4,545 Views)