LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Repeat a portion of code periodically

Hey everyone,

 

I've got a program structure problem that I could use some help with, and am wondering if anyone has some ideas. I  have to make a program in which a portion of the code has to be repeated periodically, the overall program may run for many hours but i need some portion of the code to repeat (for example after every 15 or 20 mins).

 

The program structure involves flat structure with few loops also. 

 

Looking forward for recommendations.

 

Thank You

0 Kudos
Message 1 of 6
(2,345 Views)

Show your code.  Attach your VI.

 

Flat sequences are almost certainly not necessary.  At least one loop is.  Other than that, a case structure and a timing mechanism (such as Elapsed Time express VI) to decide when code needs to be executed versus not.

0 Kudos
Message 2 of 6
(2,344 Views)

Repetition is normal program behavior. I would be more interested in the code that does not repeat (typically, that is only initialization and shutdown code). How can things run for many hours without repeating???

 

Your description is way too vague. (All structures in LabVIEW are "flat" because the diagram is 2D). What are you actually talking about? Flat sequences perhaps? Typically, if sequences are mentioned first, the code is already suspect. 😄 Are the loops parallel or stacked inside each other?

 

All you probably need is a state machine that also keeps timeouts.

How do the various program parts depend on each other? (run in parallel? occasional synchronization? lockstep? Data exchange?)

0 Kudos
Message 3 of 6
(2,314 Views)

In my case I need to measure for few hours and need to create a log file which will monitor and save some machine parameters periodically while the measurement is on going .. 

So my program structure will be .. 
Set the machine temperature .. allow for temperature to stabilize .. initialize the magnet .. set the magnetic field .. measure  the sample and then repeat the sequence again 

My thinking is sequential running as i have to wait for previous step to complete before proceeding to next

Yes data from the previous sequence will be used in the next step

 

0 Kudos
Message 4 of 6
(2,254 Views)

@HamzaZG wrote:

My thinking is sequential running as i have to wait for previous step to complete before proceeding to next


Any loop can only go to the next iteration once every code part in it has completed, so successive iteration are necessarily sequential, even without any sequence structures. Again you probably want a state machine that monitors states and decides when to go to the next state.

 


@HamzaZG wrote:

Yes data from the previous sequence will be used in the next step 


That simply requires a shift register or feedback node.

 

See how far you get and post some code and ask question whenever you get stuck. 😄

0 Kudos
Message 5 of 6
(2,248 Views)

@HamzaZG wrote:

Hey everyone,

 

 I  have to make a program in which a portion of the code has to be repeated periodically, the overall program may run for many hours but i need some portion of the code to repeat (for example after every 15 or 20 mins).

 


Well that is pretty much the definition of a STATE MACHINE 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 6
(2,232 Views)