LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Two While Loops the problem?

Hello,

Since the first time I used this turned out so well and helpful, here I am again with another project and question.

 

I have a program that was written by someone else. Simply put, the user could modify an electronic load's Current range, Current rating, and Pulse times (on & off). So, the program could pulse a specific load on and off.

My job was to expand this so while the load is pulsing on & off, I would communicate with an Agilent to collect a laundry's list of measurements and data into an array.

 

It all sounded so easy. To keep from damaging the existing program, I simply added to it with additional flat sequences, and a second while loop within one sequence (see cropped image of 2 while loops).

My problem is that when I go to run the program, it seems to get "caught up" on the second sequence. I saw the load switch on, but it did not swtch off. Also, my Agilent got an ERROR with it and turned off all of my channels. I can only assume the issue lies in trying to run two while loops within one flat sequence, even though local variables are being used to tie the two stops together. But I'm not 100% sure they're the problem here.

 

Sorry to have rambled. Any help here is greatly appreciated.

Thank you!

0 Kudos
Message 1 of 2
(2,576 Views)

It is really hard to tell what is going on from a picture.  Here are some observations:

 

1.  Parallel loops are not a problem in themselves.  Since each of your loops has a wait function, they will share CPU resources.

2.  You could have some long wait times which would make the system appear to be unresponsive. What are the values of ON time and Off time when you have the problem?

3.  Sequence structures are rarely a good way to program with LabVIEW.  Use dataflow to control sequencing when needed.

4.  Local variables are not needed.  Use wires and shift registers.  To pass data between parallel loops use queues or an Action Engine.

5.  Cut-Off Voltage and Pack Voltage are compared in each loop.  No need to do it twice. Do the comparison in the lower loop and send the boolean result (stop or continue) via a queue or notifier to the upper loop.

6.  Look at examples of state machines as a better program architecture.

 

Lynn 

0 Kudos
Message 2 of 2
(2,560 Views)