LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop delay

Hi,
 
Can any one tell why the delay is comming when i use a while loop inside two while loops.
Please see the code in the attachment for clarity.
 
Presently i am using NI-PXI 6229 DAQ
0 Kudos
Message 1 of 18
(4,712 Views)
Sorry but you are going to have to be a bit more clear on what the exact problem is. What delay are you talking about? When, how much, etc.
0 Kudos
Message 2 of 18
(4,684 Views)
You also have a few architectural problems:
  • You are not using event structures properly. An event structure is not designed to get stuck inside of a lengthy process. As you have it when you press the Start button you get stuck inside the data acquisition loop and cannot get out until you're done. In fact, the great big "Stop" button won't be read until you've finished the loops.
  • Your loop inside a loop inside a loop (I feel like I'm on a bad RollerCoaster 3 ride) is bound to cause problems.
  • You have a small case structure sitting below the big case structure that looks as if you're trying to update some indicators while the loop is running. This will not work. That case structure must wait until the main loop is done before the Boolean wire has a value. This is a fundamental dataflow paradigm.
  • Your use of the "Value" property node for the Table control is completely unnecessary. Use a wire to connect to the table control's terminal.
  • You are using a while loop and indexing out the rows of the table. Use a for-loop instead and auto-index.
To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.
0 Kudos
Message 3 of 18
(4,660 Views)

Hi,

In the front panel i am using a table control. Table consists of maximum 100 rows each row is having duration, frequency, duty cycle values as shown below.

Duration (msec)   Frequency (hz)  Duty cycle (%)

400                        5000                   10

500                        4000                 

0 Kudos
Message 4 of 18
(4,590 Views)

Hi,

In the front panel i am using a table control. Table consists of maximum 100 rows each row is having duration, frequency, duty cycle values as shown below.

Duration (msec)   Frequency (hz)  Duty cycle (%)

400                        5000                   10

500                        4000                  

0 Kudos
Message 5 of 18
(4,590 Views)

Hi,

In the front panel i am using a table control. Table consists of maximum 100 rows each row is having duration, frequency, duty cycle values as shown below.

Duration (msec)   Frequency (hz)  Duty cycle (%)

400                        5000                   10

500                        4000                   10

............................................. upto 100 rows.

While running my code i am observing a delay between 1st row and 2nd row.

I am checking my code with NI PXI-6229 Multi function DAQ and from the counter output pin i am connecting the positive and negative terminals to the buzzer circuitry.

I want to solve that delay when the control is switching form 1st row to the 2nd

 

0 Kudos
Message 6 of 18
(4,588 Views)

Hi,

For more clarity see the attached Query.vi

0 Kudos
Message 7 of 18
(4,587 Views)

The reason for the lockup is due to your code.  You have not fully grasped the use of an Event Structure.  To learn more about LabVIEW, I suggest you try looking at some of these tutorials.

There are ways of having a single loop that contains the Event Structure, but that would require a very lenghty discussion.  You should change your architecture to a Producer Consumer loops where the Event Structure is your Producer loop and feeds a state machine which is your consumer / communication loop.  The basic reason for that is that you have nested loops within an Event Case.  That's a big "no... no"..  Because as you try & try to stop the operation, unless all the triggers align, it will start a new iteration and reset the triggers, over & over again, which will lock up your PC.  I do realize that you are ORing all those booleans..  But your Event Case wants to process the stop event which will start the whole process again...  You could try removing it from your event case..

Also, you do not need a Case Statement wrapping your code. 

R

0 Kudos
Message 8 of 18
(4,558 Views)

see image...



Message Edited by JoeLabView on 07-24-2008 09:44 AM
0 Kudos
Message 9 of 18
(4,557 Views)
Hi Joe,
 
I have purposefully placed two buttons in single event i.e start, stop.
I have clearly ensured that the delay is not with these two buttons in the event structure.
I think it is beacuse of DAQmx Clear Task.
Since it is in the while loop pointed in the figure the delay is happening.
To reduce delay i have to reframe the start event structure and trying for the same.
 
 
0 Kudos
Message 10 of 18
(4,528 Views)