LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do i stop a while loop

Maybe I don't quite understand what you mean.

Each single loop iteration gives you an array of 8 sensor outputs. Right? Do you just want seperate indicators (as e.g. in the attached VI for two sensors), or do you want to treat each one individually in the code in a seperate wire thread. I would not recommend that, because it will lead to a lot of duplicate code.

Maybe you can attach the broken VI you're getting above and I will try to better understand exactly what you're trying to do. 🙂
0 Kudos
Message 11 of 21
(1,704 Views)
Hi altenbach,

I would agree that there would be a lot of redundant/duplicate code- but these guys wanted to treat each one individually in the code in a separate wire thread because if you're monitoring up to 8 different manufactured CO detectors they may all have separate set points- however, I'm slowly talking them out of that. ;0 (besides your design looks and runs better than mine).

So, going back to your idea and your 'CO detector#3.vi' say if i was going to use that layout, i see that the 'for loop' in the top left generates a random number and passes it down a bus. And if you look at my code by the fp read.vi, the little blue box with the zero in it accesses the 0th array element for the analog input channel 0 on the FP110A. So what I'm thinking is that i would need to implement your 'for loop' to iterate the array index then have the FP read.vi look at the different channels- does that sound correct? My problem is figuring out how to iterate through the Field Point FPread and FPcreatetag vi's to look at the other 7 channels in some kind of loop. You see my original idea was to just do a single loop like in my original vi (with the added elapsed times like you did for me, then duplicate that 7 more times and viola I'm done. So in light of the aforementioned comment, in the meantime is it difficult to make 8 different for loops if i wanted to treat each channel individually in the code in a separate wire thread? I guess for the time being if i did this that would make them happy and they would soon see that its much better to implement all in one while loop iteration.

Thank you again-

Dan
0 Kudos
Message 12 of 21
(1,700 Views)

@dschuller wrote:
...because if you're monitoring up to 8 different manufactured CO detectors they may all have separate set points...

Actually, you would just make the "set Point" an array of 8 elements, keeping everything else the same. Isn't LabVIEW great! 🙂

Yes, the small FOR loop generates an array of 8 random numbers. I assumed that in your application, your read the 8 sensors in the same fashion and you took element 0 in your original code for sensor #1. Maybe my assumption is wrong and you need to configure 8 different channels in the same fashion but with different "Item Name (Channel number)" input. Sorry, I virtually don't do any hardware stuff, so my experience is very limited here. Maybe somebody else can chip in.


To handle one channel with scalars, you could use something like in the attached VI (Just replace your FPxxx for the "dice and shift register". You can just duplicate it a few times for your purpose.
0 Kudos
Message 13 of 21
(1,686 Views)
Hi altenbach,

I think I have a good solution here.... thanks to you. 🙂 Please see the attached file- I figured out how to capture data from multiple field point channels (here I'm only using 3) and have created a while loop to iterate through the values and all 3 channels work (eventually I want to make it 8 but if I get 3 to work I'm OK it's probably easy to add the rest)... However, here is my new dilemma.

If you look at the attached file, you'll notice that I have 2 while loops- the one with your code and the one with mine. All I believe I need to do is physically 'cut' my 3 channels from my field point loop (thus eliminating my while loop altogether) then make your while loop bigger (taking care to move over the initialize array and tick count on the left side of your loop- i.e. keeping them on the outside) and pasting the 3 channels in your bigger for loop. The problem is that I don't know how to incorporate/connect the 'bundle' in my loop with your 'for loop' which I don't think I need now (maybe a bundle is not the correct function to use anyway- the field point module outputs a double). I tried doing the aforementioned, but with no luck- probably because I don't understand how to link the cluster to the array- or maybe im wrong by using this in the first place. 😞

Can you please help me? This code actually works when I run it 1x but then the values on the input channels aren't continuously changing- i.e. because of the looping problem above.

Also, one more thing- notice how I'm connecting the errors from the 'FP read.vi' into a 'Merge Errors.vi' then to the 'Simple Error Handler.vi'? Well, if I have 8 how do I concatenate all 8 pink error wires together into one Simple Error Handler.vi- the Merge Errors.vi looks like it can take an array but I am having trouble hooking this up too.

Thank you again- looks like if this works then the program is completed.

Daniel
0 Kudos
Message 14 of 21
(1,684 Views)
We must have been working on this at the same time- please take a quick look at my most recent post.... it's (well i think) 😉 problems with arrays, etc.

Thanks!

Dan
0 Kudos
Message 15 of 21
(1,678 Views)
Your values aren't changing because the first loop runs once and never again. The second loop only gets the data from that same run and never calls the hardware again. Your DAQ MUST occur inside the main loop.

Think dataflow! Look at the diagram with execution highlighting enabled, and you'll see the problem immediately.

You could do something similar to the attached. Since I don't have your DAQ subVI, I was not able to connect the error cluster input, but I added an arrow where you need to connect the shift register to the error input of your subVI. You don't need to do fancy merging of errors, simply carry the error cluster via shift registers.
Message 16 of 21
(1,675 Views)
Thank you- I understand what you're referencing in your previous post.

So, if you look at the attached loop (jpeg file) that works (i.e. continuously reads the hardware), all I need to do is take the 'guts' out of the for loop and add this to the >inside< of your while loop. If I do this I dont need the little for loop at the top of your while loop- right? (this what is confusing me).

Therefore, all I need to understand is after pasting the 3 channel inputs/fpread.vis into your while loop is how to combine the 3 numeric FP read.vi outputs together and add them to the orange bus (this is probably simple, but my experience in combining values to create arrays is nil).

The FP read.vi just reads the analog input so perhaps since you dont have the hardware maybe can you do the aforementioned and demonstrate my array/bus proposed connection with 3 random number genererators each in place of the io/channel and FP reads? I think im gonna be OK with the connection of the error busses.

Thank you,

Dan
0 Kudos
Message 17 of 21
(1,658 Views)
I think you can simply do it as I show above in CO_Detection_Monitoring_System_3chanMOD.vi. Just replace the unknown icon with your FP-read.

The little FOR loop contains only your FP-read and will run automatically once for each channel because the input is autoindexing. The output from the loop is also autoindexing, meaning that you automatically get an array with one element from each iteration of the little FOR loop. Three channels--> size-three array.

Does it work?

To build an array from scalars, use the resizeable "Build Array" node, prominently featured in the array palette. 🙂

Message Edited by altenbach on 06-07-2005 07:40 AM

0 Kudos
Message 18 of 21
(1,649 Views)
Good Morning altenbach-

I think I get it now! 😮

Each time the while loop runs its going to run 3 iterations of the for loop. Each iteration of the for loop will perform a single FP_Read.vi (one per channel and the channels are automatically incremented).

So when I get this VI working with 3 channels, in order to add the other 5 channels, all I need to do is right click on the build array and add the 5 inputs. Also, I'll need to change the initialize array on the left of the while loop to have 8 inputs. Most excellent!

Oh- one more thing I was wrestling with, you know how the lines on the plot are color-coded? Well, how can I physically associate the line color with the 'Current Value' boxes on the front panel? I tried to use framed color box and some of the decorations in 'All Controls' but it doesn't look like you can change the color of the objects. I guess I could use labels with text indicating the color, but there has to be a way to draw a line, object or something on the front panel and associate a color with it.

Thank you again altenbach- I've learned so much with your guided assistance. 🙂 🙂 🙂 🙂

Daniel
0 Kudos
Message 19 of 21
(1,636 Views)
If the current values, are an array, you cannot make individual colors because all elements have identical attributes.

You could add a colorbox array next to them. It is easy to get the plot colors in a loop via attribute nodes. You could also make individual indicators and change their background color (shown for the first three channels only). I prefer arrays because you don't need to modify the code if the number of channels changes.

Both possibilities are shown in the attached VI. 🙂
Message 20 of 21
(1,628 Views)