LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event structure and for loop

Solved!
Go to solution

Hi everyone
I have a code consisting of a large while loop inside which, among the various parts of code, I have this event structure.
The first event performs a ramp up for the speed of an electric motor using a for loop.
What I would like to do is use the stop condition of the for loop to trigger a second event of the event structure.
Within this second event I would like to take the last value obtained from the for loop of the up ramp and increase it manually.
My problems are 2:
- use the stop condition of the for loop to trigger the second event (gives me the following error "Wire: is a member of a cycle)
- use the output of the for loop, i.e. the speed, in the other event where I increase it manually (gives me the same error)

Is there a block that allows me to do these two things?

0 Kudos
Message 1 of 3
(330 Views)

Instead of long and ambiguous descriptions, just show us the code. (attach your VI saved for 2020 or below)

 

It sounds like whatever you are trying to do does not need an event structure, a plain state machine is probably all you need.

Event cases should not nave lengthy internal code. Events are primarily designed to handle user interactions, not to control program flow. To maintain data between iterations, we typically use shift registers.

 

Have you done any basic LabVIEW tutorials yet? Do you understand what a "cycle" is and the basic principles of dataflow?

0 Kudos
Message 2 of 3
(324 Views)
Solution
Accepted by topic author zeta1928

I agree that a VI or even an image would help...

 


@zeta1928 wrote:

The first event performs a ramp up for the speed of an electric motor using a for loop.


If you put a for loop in the event structure, the event structure will be stuck in that event until the for loop is finished. Sounds bad...

 

There's no 'block' (LabVIEW has VIs or functions) to solve this. You have to arrange the structures so it works for you. If you want to be ramping and respond to events, you need either two things running in parallel (like a producer consumer).

 

Alternatively you sometimes can make an event loop with a timeout, and handling the ramping outside the event:

wiebeCARYA_0-1720684869370.png

That only works if the handling doesn't take much time. The time it takes, the events won't be handled so it should ideally be <100 ms...

0 Kudos
Message 3 of 3
(246 Views)