LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Loop Problem

Solved!
Go to solution

Hi,  I am working to calculate the internal resistance of a motor. My program is communicating via OPC servers to the PLC. 

 

So what I actually need : When the state of the shared variable diresist is equal to 16 26 or 36... the program should run and make the whole sequence. 

 

I tried with an event loop on the state of diresist but the program didnt run normally (you can only command the event structure from the front window) 

 

So I tried with the while loop as in the program attached but I am getting the measurement in loop (he doesnt stop measuring). and if I click on the stop button, the program stops after making the measurement the second time. (Which is not a solution because I need the values and the graph of the first loop)

 

Any ideas please?

0 Kudos
Message 1 of 37
(4,723 Views)

What does "diresist" mean?

 

Your diresist is not a shared variable.  It is a front panel indicator.  Also, since it is an indicator and not a control, there is no way to change it while the program is running.  It is also why the event structure would not act on it.

 

Your stop button gets read once per loop iteration.  It probably gets read very early in the loop iteration since the reading of that terminal is not dependent on anything else.  That is why it appears your loop runs twice when you hit the stop button.  Because it doesn't get read again until the next iteration.

0 Kudos
Message 2 of 37
(4,714 Views)

You CAN trigger an event structure programatically by using the property node value(signaling), just make sure you don't program an endless chain of events. An easier approach would be using a notifier/queue via a producer/consumer loop, where one loop is querying the shared variable at a reasonable rate (maybe 10 times a second, depends on your needs) and sends a notifier or queue element to consumer when it reaches the desired value. Something along the lines of this

 

queue.png

0 Kudos
Message 3 of 37
(4,706 Views)

Hi everbody, thanks for your answer. 

To ravens Fan: diresist is a shared variable used in another loop, the variable is changing and working well. I juste didnt put the loop of the shared variable within this program. Thank you for these informations.. and this is what I was trying to explain in my message.. any solutions to propose?

 

To Daikataro, Thanks for the solution. I will try it. Could you please send me the program? I have the version 2014 of labview.. Please attach it. 

0 Kudos
Message 4 of 37
(4,660 Views)
The code that you are asking to be sent to you is a template that ships with LabVIEW. You already have it.

Perhaps you need to go through a few tutorials?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 37
(4,653 Views)

Dear Mike, 

 

I looked in my exemples and I didnt find it already.. Could you please then give me the name of the template (if you know hat it exist?) 

 

Thank you for your answer

0 Kudos
Message 6 of 37
(4,646 Views)

@marwah1 wrote:

Dear Mike, 

 

I looked in my exemples and I didnt find it already.. Could you please then give me the name of the template (if you know hat it exist?) 

 

Thank you for your answer


Producer/Consumer-> https://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/creating_vis_from_templates/

More details: http://www.ni.com/white-paper/3023/en/

Thanks
uday
0 Kudos
Message 7 of 37
(4,622 Views)

Thanks for the answer.. 

No it's not working actually.. this is how I made and I am not getting any results.. 

Capture.PNG

 

 

0 Kudos
Message 8 of 37
(4,614 Views)

How should we debug a picture? 

 

Do you know how Highlight Execution works and how to use it? 

0 Kudos
Message 9 of 37
(4,610 Views)

Did you go through the link?

-Simply adding queue doesn't solve.

-what's the datatype of queue?

-In first loop,inside true case if you are not doing anything how do you expect something to work?

Thanks
uday
0 Kudos
Message 10 of 37
(4,605 Views)