LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

activex - Reg Event Callback - Leds

Solved!
Go to solution

Hey again,

 

I used leds because the events that comes from the equipment are only "void" signals, so there is no data at all. But with that I thought that maybe creating booleans would be a nice way to show me when is triggered.

 

Now I am coupling my two ActiveX programs together, but I am struggling with some basic problem.

 

In my XY program, I have one while loop inside one case structure, and that also is inside in another while loop. I want to create a STOP button that stop the program, WHENEVER is pressed.

 

I connected the STOP button to both stop condition terminals in the while loops, but if I press the STOP button during the process of the inner WHILE structure, it continue to run so I have to wait until it recognizes mi boolean stop button.

 

What am I doing wrong?

0 Kudos
Message 41 of 47
(2,061 Views)

Hello Stavrosyt,

 

I have reviewed the code and understand what is happening to cause this behaviour. The first solution would be to use a local variable, however these are unadvisable to use as they can result in race conditions. For your situation, from a quick glance at the code I believe you would be best suited to use a state machine architecture, you will still achieve the same functionality but with only one while loop and thereby remove the necessity for a local variable. A white paper explaining this can be found in the link below, I hope this answers your question and if you have anymore don't be afraid to ask.

 

http://www.ni.com/white-paper/2926/en/

 

Kind Regards,

Ed

0 Kudos
Message 42 of 47
(2,046 Views)

Stavrosyt wrote:

What am I doing wrong?


You need to understand dataflow. You can't use a STOP button outside a while loop to stop that while loop, because while the loop is running, no data passes through the border of the while loop. Data on a wire only enters a loop when the loop starts, and data exits the loop when the loop terminates. Also, a while loop only iterates once everything inside it has completed, and a control terminal only gets read once per iteration. Your outer while loop waits for the inner while loop to finish, and doesn't re-read the value of the stop button while the inner loop is executing, even if you change the value of the button.

 

As I suggested before, running with execution highlighting will probably make this clearer.

 

If you have the time, I recommend that you start with a much smaller project - without any calls to ActiveX or other external components - to learn more about how LabVIEW works.

Message 43 of 47
(2,021 Views)

Hello all,

 

As I began to build my two programs together, the landscape became more clear.

 

I am using a FOR loop for reading each line of the text file where I have coordinates, on each iteration I extract those coordinates and use them for moving my device (through those SUB-VIs).

 

What I need to the program to hold at the beginning until I press START, and the make only the first FOR iteration. While I have not pressed LASER button, the program should wait (by using Notifier). when I press the LASER button, the FOR loop should make a second iteration and again wait until the LASER button is pressed again.....and it should do the same until the FOR loop is ended.

 

It finishes by findind the end of the file (EOF) or by pressing the STOP button at the time (another Notifier).

 

But somehow the Notifier WHILE loop is not used, can you give me some improvements?

 

and of course, I am using the notifier not in a good way (local variables was what I thought at inserting "element data type", and also STOP latch button can't be used as a local reference.....(produce error)

 

thanks

0 Kudos
Message 44 of 47
(1,992 Views)

Hi Stavrosyt,

 

Okay, i've included quite a few links below which describe basic data flow, event structures, state machines and variables. I think this will be a good starting point for you to get acquinted with an architecture I think will suit your needs.

 

http://www.ni.com/white-paper/2926/en/

http://www.ni.com/white-paper/3331/en/

http://zone.ni.com/reference/en-XX/help/371361M-01/lvconcepts/local_and_global_variables/

https://decibel.ni.com/content/docs/DOC-42804

http://www.ni.com/video/2962/en/

http://www.ni.com/video/1875/en/

http://www.ni.com/white-paper/7537/en/

 

I suggest you read through them before continueing further and possibly even drawing a flow chart of how you would like your program to function, this is good practice with LabVIEW as flow charts can be simple representations of the data flow and therefore a basic structure to the functionality of the program. I suggest you employ an Event Based State Machine from reviewing your program, please do give them a good read and they should provide you with the information you need.

 

Please note that with your current setup of multiple event structures the program cannot function as is desired, you would need to know which event structure is currently polling for an event and trigger the button click events in the order they are waiting on events (which is unknown and indeterministic with your current system), for multiple events you can contain all the events in one event structure which is the general approach and prevents 'hanging' on multiple events at a time. I suggest you employ the methodology outlined in the links above and this is a basic architecture which appears to be what you are looking for.

 

Best regards,

 

Ed

0 Kudos
Message 45 of 47
(1,944 Views)

@edjones93 wrote:

Hi Stavrosyt,

 

Okay, i've included quite a few links below which describe basic data flow, event structures, state machines and variables. I think this will be a good starting point for you to get acquinted with an architecture I think will suit your needs.

 

http://www.ni.com/white-paper/2926/en/

http://www.ni.com/white-paper/3331/en/

http://zone.ni.com/reference/en-XX/help/371361M-01/lvconcepts/local_and_global_variables/

https://decibel.ni.com/content/docs/DOC-42804

http://www.ni.com/video/2962/en/

http://www.ni.com/video/1875/en/

http://www.ni.com/white-paper/7537/en/

 

I suggest you read through them before continueing further and possibly even drawing a flow chart of how you would like your program to function, this is good practice with LabVIEW as flow charts can be simple representations of the data flow and therefore a basic structure to the functionality of the program. I suggest you employ an Event Based State Machine from reviewing your program, please do give them a good read and they should provide you with the information you need.

 

Please note that with your current setup of multiple event structures the program cannot function as is desired, you would need to know which event structure is currently polling for an event and trigger the button click events in the order they are waiting on events (which is unknown and indeterministic with your current system), for multiple events you can contain all the events in one event structure which is the general approach and prevents 'hanging' on multiple events at a time. I suggest you employ the methodology outlined in the links above and this is a basic architecture which appears to be what you are looking for.

 

Best regards,

 

Ed


Hello,

 

I read all those documents, and more.

I build my program using event based state machines, but still, not I face two problems.

One is that obtaining data from one state to another, until reaches a FOR loop, is lost. My sub-VI didn't received a data.

Second, the major problem continues, makng a FOR loop "wait" until a triggered event allows a process to start, and then coming back and continue with another iteration of the FOR loop.

 

FORloopProb-stateMach.png

0 Kudos
Message 46 of 47
(1,891 Views)
Solution
Accepted by topic author Stavrosyt

Thanks all for you help, and the end I simplify the programming by using a queue state machine, but using notifiers instead of queues.

 

It works fine, exepto for some time synchronization problems. In the simulation computers works fine, but somehow the devices needs a little more time when I tried in the connected computer.

That's strange even when my devices starts and ends are triggered by events from them.

 

0 Kudos
Message 47 of 47
(1,856 Views)