From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to make setpoint dynamic for PID control

Solved!
Go to solution
Solution
Accepted by cli21

@cli21 wrote:

How to connect the two PGV?I attached my idea but definitely it's wrong.


You missed the point of how to make a FGV.  A FGV is supposed to be its own VI that has uninitialized shift registers.  Action Engine <- Nugget every LabVIEW developer should read

Though, the way you will be using it here, you might as well just use a global variable.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 11 of 17
(1,562 Views)

Hi,

 

I tried global variable. It works, but I still want to figure out what's the problem with FGV, do you mean I should save the uninitialized shift register as a individual VI, and call out it at different place? 

 

Thanks,

CJ

0 Kudos
Message 12 of 17
(1,553 Views)

cli21 wrote:do you mean I should save the uninitialized shift register as a individual VI, and call out it at different place?

That's how a  FGV works.  You have a non-reentrant VI that has an uninitialized shift register.  By calling it in one place, you can set the value.  By calling the same VI in another place, you can get the value that was set by the other thread.  But if all you are doing is the Get/Set, just use the global.  It is more efficient and does the exact same thing.

 

Now if you go into that Action Engine nugget, you will see some true power of the unitialized shift register.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 13 of 17
(1,549 Views)

Hi,

 

I tried package the PGV as a sub VI, but it doesn't work, "write" is OK, but the read data always be 0, would you please tell me the reason?

 

Thanks,

CJ

Download All
0 Kudos
Message 14 of 17
(1,535 Views)

You are just outputting the data you wrote to the shift register when you are trying to read.  Default value of your control is 0, so you got a 0.

 

Add a boolean input for "Write?"  When that Boolean is TRUE, you write to the shift register.  When it is false, you keep that value that was previously in the shift register.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 15 of 17
(1,530 Views)

Yes, adding a boolean is going to work, but then I have to manually define the boolean to be true or fulse, that's different from what I expected. I hope the program will automatically read the data from the array and transfer to the setpoint, just like what a global variable does. 

 

Also, I am still confused about the data flow, shouldn't the data coming from the array first flow to the register and then flow to setpoint?If it is, why the default value is read?

 

Thanks,

CJ

0 Kudos
Message 16 of 17
(1,521 Views)

The two loops truely act in parallel.  So  there should be nothing connecting the two loops.  So with that, you have to pass data from one loop to another via some construct.  So what happens with a FGV is that only one place can run the VI at a time.  So when your Write calls the VI, you need to set the data point.  When the Read calls the VI, you need to get the data that is put in there.  So what happens when the Write calls the VI and is running it when the Reader suddenly wants to call it?  Since the VI is non-reentrant, the Reader must sit there and wait for the Writer to be done with it.

 

The reason you had the default value on your reader is because you didn't supply a value for an input.  So what does a VI do when a non-required input is not supplied?  It uses the default value for that data type.  For a numeric, it is 0.

 

I highly recommend you try running your code with Highlight Execution turned on.  It slows your code down A LOT, but it shows you how the flow of data works.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 17 of 17
(1,508 Views)