LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Notifier - for loop

Solved!
Go to solution

Hi Stavros,

 

I am not trying to use long-running loops in event cases

In one of your last posts you presented an event case with a FOR loop inside set to run a thousand times with atleast 1s wait in the loop…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 51 of 60
(1,397 Views)

This is how you could do it with a while loop. 

 

While-loop pause.png

 

And you could replace the Event structure with a case structure as a state mashine. 

I don't think Notifiers are the best for your application right now. 

Message 52 of 60
(1,386 Views)

@dkfire wrote:

This is how you could do it with a while loop. 

 

 

And you could replace the Event structure with a case structure as a state mashine. 

I don't think Notifiers are the best for your application right now. 


Hi dkfire:

 

I think that you just have solve my problem. It was very clever to replace a FOR loop for a WHILE loop that do the same function.

Now I can add to them states machines.

Instead of notifiers, I was using val (signl) from a LED, what do you think could  be enough?

here is my new program state machine:

 

statemachine.png

 

and here is the snippet of my program....

 

readRow-stateMach.png

 

please, any comments on how can I improve my program is welcome,

 

looking forward to hear form anyone.....

0 Kudos
Message 53 of 60
(1,335 Views)

My example was to show you how to turn your for-loop around and use a while loop. 

Now, how to implement that in your program in the correct way, I still need to see a bigger and better picture of your program and its design.

How are you using the coordinate (the array element) outside this loop?

Is there anyone, beside a user, that is controlling/instructing this loop?

 

Remember that value signaling is generating an event for EVERY value you write to it, not just if the value change.

You should not need to place a wait in the case structure, let the Event structure timeout do the wait. Change the timeout value when needed, as I did in my example.

 

If you need a good answer and help to your program, you need to give us all the information, else we can only give standart general answers, that might not help you.

 

0 Kudos
Message 54 of 60
(1,309 Views)
dkfire wrote:

My example was to show you how to turn your for-loop around and use a while loop. 

Now, how to implement that in your program in the correct way, I still need to see a bigger and better picture of your program and its design.

How are you using the coordinate (the array element) outside this loop?

Is there anyone, beside a user, that is controlling/instructing this loop?

The bigger picture is that I have two processes a motor executing and a laser executing.

I use the coordinates to a Sub-VI that executes moves in the motor process, after the moves are finished then an event is triggered (by event reg callback) and the laser process should begin. During this laser process, the motor process should be "on pause" keeping the coordinate unchanged until an event is triggered from the laser process saying that it has finished (also by another event reg callback).

 I am using this callback because the program is based on ControlX communication.

 

So the program is based in UI events (for start and stop button) and reg event (for motor finished and laser finished callback events). In this last ones, I was thinking on using value(signall) for triggering the events, what else can I use instead of it?

 

 

Remember that value signaling is generating an event for EVERY value you write to it, not just if the value change.

You should not need to place a wait in the case structure, let the Event structure timeout do the wait. Change the timeout value when needed, as I did in my example.

 

I know that about value signalling, I used for that purpose, because I don't know what else can I use to let the event structure know that something is triggered (besides buttons and leds).

The problem with the wait case in a case strcutre is that after I will need to have another process running (laser process) and I need to have the motor process in "pause". So using the -1 in the time out doesn't allowed me to enter into my states (case structure). if you know how can be do it, please send me a correction.

 

 

If you need a good answer and help to your program, you need to give us all the information, else we can only give standart general answers, that might not help you.

is there anything else you need to know?

 

 

 

 

 

0 Kudos
Message 55 of 60
(1,277 Views)
Solution
Accepted by Stavrosyt

Put the laser cutting process (as a separate VI) in the same for loop as your laser move process.  Each iteration will take a new set of coords, move the laser to the proper position, and begin cutting.  When that iteration finishes, the next set of coords is taken and the same operations happen, rinse and repeat untill all of the rows in the array are used.  Here is how I might do it.  (Note: I added some additional variables in the cluster on the left to show you how you can use this architecture for easily passing data or parameters thru your program.  )

Example_VI_BD.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 56 of 60
(1,265 Views)

Stavrosyt wrote:

The bigger picture is that I have two processes a motor executing and a laser executing.

I use the coordinates to a Sub-VI that executes moves in the motor process, after the moves are finished then an event is triggered (by event reg callback) and the laser process should begin. During this laser process, the motor process should be "on pause" keeping the coordinate unchanged until an event is triggered from the laser process saying that it has finished (also by another event reg callback).

 I am using this callback because the program is based on ControlX communication.

What is ControlX communication?

I don't know what that is, and not something I see in LabVIEW every day. Do you mean ActiveX function?

To have a process in pause mode, is just a statemashine that is waiting for commands. 

 

So the program is based in UI events (for start and stop button) and reg event (for motor finished and laser finished callback events). In this last ones, I was thinking on using value(signall) for triggering the events, what else can I use instead of it?

 For communication to an Event Structure, you can use value signaling, or maybe better User Events. 

 

 

I know that about value signalling, I used for that purpose, because I don't know what else can I use to let the event structure know that something is triggered (besides buttons and leds).

The problem with the wait case in a case strcutre is that after I will need to have another process running (laser process) and I need to have the motor process in "pause". So using the -1 in the time out doesn't allowed me to enter into my states (case structure). if you know how can be do it, please send me a correction.

It was not the Wait case that I was talking about, but the use of Wait(ms) function inside multiple cases in the case structure.

Take a look at my program again, the VI is included. In that I'm changing the timeout dynamicly.  

 

 

is there anything else you need to know?

I still would like to see how you have design your register call back functions, and how you are using them.  

Why not show the motor process, with the vi's for the motor communication.  

 

 


 

0 Kudos
Message 57 of 60
(1,246 Views)

@aputman wrote:

Put the laser cutting process (as a separate VI) in the same for loop as your laser move process.  Each iteration will take a new set of coords, move the laser to the proper position, and begin cutting.  When that iteration finishes, the next set of coords is taken and the same operations happen, rinse and repeat untill all of the rows in the array are used.  Here is how I might do it.  (Note: I added some additional variables in the cluster on the left to show you how you can use this architecture for easily passing data or parameters thru your program.  )

 


Hi again,

 

can you explain a little about how this process works? because I see the two sending notifiers (one for the initialize and one for start cases), and which of the "start" correspond the state in the event case structure?

 

It looks promising but I need to really understand it.....thanks....

0 Kudos
Message 58 of 60
(1,196 Views)

@dkfire wrote:

What is ControlX communication?

I don't know what that is, and not something I see in LabVIEW every day. Do you mean ActiveX function?

To have a process in pause mode, is just a statemashine that is waiting for commands. 

Yes I meant ActiveX control that differs from ActiveX automation. This activeX does not have anything to do with the pause mode. I will use for sure the state machine for waiting an event, but the ActiveX is just how the machine comunicate with LABVIEW.

  For communication to an Event Structure, you can use value signaling, or maybe better User Events. 

Thanks, but I need to used both in anycase. User events for START and STOP buttons, and value signalling for triggering from reg callback events.

 

 It was not the Wait case that I was talking about, but the use of Wait(ms) function inside multiple cases in the case structure.

Take a look at my program again, the VI is included. In that I'm changing the timeout dynamicly.  

 

Ok, it was really clever the way you use the timeout changing to -1 if you need a pause, but when you build a case structure for the state machine, the enviroment somehow changes. I can't continue using -1 in the event structure, because it would never enter inside the states.

 

I still would like to see how you have design your register call back functions, and how you are using them.  

Why not show the motor process, with the vi's for the motor communication.  

 Sure, I am attaching ansnippet of the Motor events process, that's before I was planning to use the state machine. (which now I realize is definitly important)

  


MotorEvents.png

0 Kudos
Message 59 of 60
(1,187 Views)

You need to run the VI with execution highlighting on.  This will explain everything for you (or should explain it).  After initializing, both loops just sit there waiting for an event to occur or a notification to be received.  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 60 of 60
(1,163 Views)