LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Voltage Feedback Control

Hello all,

 

I am currently working on a PID controller for two electronic pressure regulators attached to a piston with an LVDT on it. I am using the LVDT to record the velocity of the piston movement and the velocity is my process variable. Then, the control variable, output, is going to be the voltage output to the first pressure regulator. In my VI, I have set the output of the PID VI to the first channel of the DAQ Assist and I have set the second channel to a constant value of 0. My issue is that even though the second channel is set to a constant value of 0, the second channel will still read changing values. Does anyone know why it does this?

 

Thank you,

Shafique

0 Kudos
Message 1 of 8
(1,081 Views)

The only thing I like less than the Dreaded DAQ Assistant is its evil twin, the Dynamic Data Wire.  But I'm just old-fashioned -- when the DDA was first introduced (a decade and a half ago?), I eagerly tried it out.  I never got the hang of the Dynamic Data Wire, chanced upon "Learn 10 Functions in NI-DAQmx and Handle 80 Percent of your Data Acquisition Applications", and threw away the DDA.  Much happier.

 

But as to your question -- what makes you think that Channel 2 has been set to 0?  It certainly isn't that way on your Block Diagram (thanks for saving in LabVIEW 2021, which I am able to open).  If you want it to be zero, zero the wire (or disconnect it).

 

Bob Schor

0 Kudos
Message 2 of 8
(1,028 Views)

Hello Bob,

 

Thank you for your reply. I have zero'd the wire and it is now working as it should. However, I read your comment on the DAQmx functions instead of using the DAQ Assist. I know how to use the DAQmx functions in order to get the same outcome form the DAQ Assist but I found it easier to use the DAQ Assist. Is there an advantage to using the DAQmx functions over the DAQ Assist? 

 

Thank you,

Shafique

0 Kudos
Message 3 of 8
(1,021 Views)

For really simple, "do it quickly and get an answer, because the answer is all that's important", the DDA might be OK.  But if you are developing an application that you want to be stable, understandable by you three months from now and to knowledgable colleagues after 1-3 minutes of "looking at the code", not to mention having all the parameters of the DAQ task (like number of samples, sampling rate, etc.) and the possibility of isolating the Read/Write segment of the acquisition in a Loop (really nice for continuous acquisition) mark some of the advantages of using some of the "lower-level" functions in place of the "one-size-fits-all" DDA will stand you in good stead when you want to use LabVIEW for serious work.

 

Bob Schor

0 Kudos
Message 4 of 8
(1,008 Views)

Hello Bob,

 

You were very helpful this past week and answered my questions very clearly. I was wondering if you could look over my VI code again and see if I have made any errors with the code. I did not use any DAQ Assist blocks and used the functions instead, like you recommended. However, I am getting an error code -50103. Any tips on how to fix that and/or improving my code would be very helpful!

 

Thank you,

Shafique

0 Kudos
Message 5 of 8
(956 Views)

I have attached a updated VI where the code is more simplified and easier to read.

0 Kudos
Message 6 of 8
(931 Views)

What leaps out to me are the three While Loops on the right.

 

You have violated the notion that Data Wires should move from left to right.  In particular, the Stop button to stop the three While Loops is to the right of the While Loops.  This is merely weird, but you bring this wire (or its branch) into the right side of the While loop.  When I learned LabVIEW (many years ago), I was shown wires coming into While Loops through the left side, and leaving the While Loop through the right side.  I assumed that these were "one-way" walls (except, of course, for Queue References which "seemed" to allow data to flow backwards out the "input" side of the While Loop.  But I'd never tested whether this was true for the right-hand edge.

 

Well, I was worrying about the wrong thing.  The walls are not rectifying.  You can stop a While Loop by wiring the Stop Button to the right of the Loop and bringing its output wire "backwards" through the right side of the While Loop.

 

But that won't do anything useful unless you press the Stop Button before the While Loop starts to run!  If you start the program with the Stop button already pressed, then the While Loop will run once and stop (because you "told it to".  But if the Stop Button is not pressed when the While Loop starts, then the While Loop starts running and (by the Laws of Data Flow) doesn't accept any "new" inputs (like you pressing the Stop Button) until the While Loop starts to run, again, which won't happen until the Loop exits (which it cannot, since "False" is wired to the Stop Control).

 

Write your own While Loop with a Stop Button situated to the right of the Loop and bring it in (anywhere, including from the right edge, as you've done).  I put a "Wait (ms)" inside to slow down the loop and wired an indicator to the Index so I could see it "counting", and run this little demo.  Try pressing the Stop button.

 

Bob Schor

0 Kudos
Message 7 of 8
(917 Views)

I am not too sure what you meant by writing my own while loop. I changed the three while loops into one big while loop with the stop button inside the loop. I also added a Wait (ms) inside the loop and wired an indicator. The stop button now works and the while loops ends. However, I am now getting different error codes. I have attached a picture of the errors below along with the updated VI. thank you for all the help!

 

Shafique Noor

Download All
0 Kudos
Message 8 of 8
(885 Views)