LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timing a case structure inside a producer loop

Hi,

 

I want to activate a case structure inside a while loop for a pre-defined time (the 'True' case runs for a specified time). As soon as the time elapses, it returns to 'False' until it is reactivated by the next Boolean input. The Boolean is defined in a way that it is 'True' only spontaneously much like an impulse train.

 

Here is what you'll find in the attached VI: Two parallel while loops. A signal from one loop initiates a process in the producer loop via a channel wire. How can I use that spontaneous signal to display the data in the producer loop for, say, 5 seconds?  

 

Thanks,

lza

 

0 Kudos
Message 1 of 8
(394 Views)
  • Is the sequence array supposed to be empty? (why not make typical values the default so we don't need to guess.)
  • No modern programmer uses stacked sequences.
  • You have two case structures, which one is supposed to be timed?
  • Why are there so many local variables?
  • Why is the diagram and front panel maximized to the screen?
  • Why are you counting in orange instead of blue?
  • Where do you define the loop time of the producer?
  • Why is the sequence loop greedy if "enable" is false? (spins as fast as the hardware allows) 
  • There are race conditions, for example there is no guarantee that enable is set to TRUE before the terminal inside the loop is read.

Can you take a step back and explain the desired functionality more generally.

0 Kudos
Message 2 of 8
(364 Views)

@altenbach:

Is the sequence array supposed to be empty? (why not make typical values the default so we don't need to guess.)
Please see the updated VI.

No modern programmer uses stacked sequences.
You're probably alluding to the use of a state machine. I will replace the stacked sequence in subsequent iterations.

You have two case structures, which one is supposed to be timed?
The producer loop continuously generates an array of data using a FOR loop. We only need to process the 'current' data based on meeting some conditions. These conditions are dictated by the sequence loop and user inputs during the execution are not required (a stacked sequence was used to place various wait periods and controls in there). Once a signal is received by the producer, it starts processing data for the next 5-10 seconds. This is repeated at the next signal. The producer should produce continuously. We only use a segment of it whenever required (determined by the sequence loop). The timing control can be positioned in either of the two loops as long as the objective is achieved.

Why are there so many local variables?
I think these would go away once a state machine is used for the sequence loop. Right now, I am using them to have status indications on the front screen.

Why is the diagram and front panel maximized to the screen?

I hope the updated one is not maximized.

Why are you counting in orange instead of blue?
Counting in blue now.

Where do you define the loop time of the producer?
Defined now as 200ms.

Why is the sequence loop greedy if "enable" is false? (spins as fast as the hardware allows)
Updated.

There are race conditions, for example there is no guarantee that enable is set to TRUE before the terminal inside the loop is read.
How do I do this?

 

I will integrate this information into my overall goal of acquiring AI/CI signals, and saving the data extracted in segments to separate files.

 

Thanks,

lza

0 Kudos
Message 3 of 8
(344 Views)

It is still not clear at all how this should function. How long is a "certain time" and is that shorter than the rate of new data on the channel wire?

I am not sure why you do the "changed?" test when you put data on the channel because that value is never the same anyway.

0 Kudos
Message 4 of 8
(324 Views)

All I am trying to do is control when the data in the producer loop becomes useful and needs to be extracted/processed.

 

On the sequence side I will have something like this: wait 15 seconds--> perform some tasks --> wait 30 seconds --> we are ready to save the producer data now, send the 'signal' to the producer through the channel wire (it is this 'signal' that I use the 'changed' test for) --> let the producer save data for 10 seconds without sending it more signals --> repeat. 

 

Thanks,

lza

0 Kudos
Message 5 of 8
(316 Views)

So you have data being produced on the PRODUCER, when the Data is ready, it triggers the CONSUMER TO process the data.

Could you do this with state machine ? 

 

 

0 Kudos
Message 6 of 8
(263 Views)

@LVNinja:

The 'consumer' loop is not yet in the picture. There are two loops: sequence and producer (each handling separate hardware).

Data is generated inside the producer. Which of this data do I want to send to the consumer (to be added as a separate while loop) is what the sequence loop sends the signal for. I hope that explains what I am trying to do.

 

lza

0 Kudos
Message 7 of 8
(259 Views)

Here is my first shot at a state machine for the producer loop. Please let me know what improvements are required for it to function properly.

 

Now the question about how to control the number of samples to process: from what I have seen so far, the wait time for  'Channel ON' case and the loop time for the 'producer' loop determines the sample count to be processed. Is that right? 

 

lza

Download All
0 Kudos
Message 8 of 8
(232 Views)