LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Shared Variable Not Working

Hi all, I'm currently trying to develop a feedback loop using PID in LabView where I use PWM to control the heating of a resistor, and I'm using a thermocouple to read the temperature. I want to be able to set the temperature and the feedback loop to then determine the PWM needed. So far, I have been able to read temperature and heat the resistor with PWM separately (I am using LINX / arduino for the PWM). I am trying to implement the PID by putting the PID in the PWM loop and then trying to pass the temperature from the temperature loop to the loop with the PID. I thought that I might be able to use shared variables for this purpose, but whenever I try to put a shared variable in the block diagram, it looks like most of the features are disabled. For example, when I right click on the shared variable, most of the options such as the option to change from write to read are all grayed out and disabled. Do I need a specific software add-on to use shared variables? If so, is there another way to do this without shared variables? Thank you
0 Kudos
Message 1 of 4
(2,548 Views)

The direct replacement to a shared variable is a global variable.

 

How fast are you reading the data?  How fast is your PWM loop running?  What I am getting at is that you may be able to put everything inside a single loop.  Then you could just use a wire!


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 2 of 4
(2,530 Views)
That is the obvious solution that I did not think of, thank you! I'm reading the data at around 100 samples per second for this test, and I'm not quite sure how fast the PWM loop is running. Actually, what I ended up doing is using a local variable. I used a converter to convert the array that was coming out of DAQmx to "dynamic data", and then wire that to the local variable. But the single loop seems like a simpler solution. Will using a single loop make the program run more efficiently?
0 Kudos
Message 3 of 4
(2,513 Views)

@ben49 wrote:
Will using a single loop make the program run more efficiently?

That depends on everything that is happening and what rates you need to run at.  In general, a control system is better off as a single loop.

 

Also converting to/from the Dynamic Data is generally a bad idea (I have seen way too many problems due to that data type).


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 4 of 4
(2,476 Views)