LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Data From Multiple For Loops With Shift Registers

Hi there,

 

I'm pretty new to LabView, but Ive been given a project for work, so I'm trying to learn while doing under a time limit.

 

I'm going to have a PID loop where the setpoint will vary based on an Excel spreadsheet file. I've got the spreadsheet into an array, but now the next step is getting a little convoluted.

 

Essentially there needs to be segments of setpoints, where there's a start value, a mid value and an end value. There's a time attached to these as to how long they run. T1 is start value hold time, T2 is start - mid, T3 is mid value hold and T4 is mid to end time. Each of these segments can be repeated a number of times.  Due to all this repeating, I'm getting into a little bit of a For Loop/While Loop nightmare.

 

I've tried to set up a case statement for each of the time segments, so when the file is read in by the VI, it will parse out all the data and work through these cases sequentially until complete, then it will either repeat or move to the next row in the excel file.

 

Finally, here's the problem. I'm trying to have the output of these case statements update live, so whenever it changes, the value gets sent directly to the PID loop. This is not happening now, and I've tried local variables but that isn't doing it either. I think it may not be updating until the while loops finish, but I can't think of a better way to structure this. Is what I'm trying to do possible? Do I need to restructure the whole way I'm doing this?

 

Any help would be appreciated, I've attached the files for you to take a look at.

 

Just ignore the subVI I created, it was just a simple way to clean up my code.

Download All
0 Kudos
Message 1 of 4
(2,464 Views)

Well, you might want to have a look at your "1" case.  There's a possible infinate loop.  I think you want the elaspsed time inside of the while loop and only reset on the first iteration.  I also noticed there's a tunnel overtop of a shift register, making the shift register not used.  I'm guessing the wires to/from the tunnel are supposed to be connected to the shift register.

 

I didn't see you other loop or how you are trying to communicate with it.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 4
(2,462 Views)

Thanks for the pointers, I think I might have been staring at the screen too long. I actually haven't placed my PID loop in there yet, I just have an indicator that I'm passing a local variable to, just so I can see it's getting updated. Is this a valid way of doing this? I haven't quite figured out some of the details on order of execution yet, but it seemed like when the while loop started adding the values in case 2, they weren't updating the indicator. Does that sounds right?

 

Also, I've read a lot about Events and I was wondering if it might be easier (less cumbersome) if I was to place this all in multiple events.

 

Thanks in advance for your help.

0 Kudos
Message 3 of 4
(2,443 Views)

Your indicator labeled "Numeric" will only update once per iteration of the outer while loop.  The outer while loop won't iterate until all the code inside of it completes.

 

As crossrulz pointed out, your inner while loop will only run once, or it will run forever depending on the value coming from the Elapsed Time express VI at the moment the innermost while loop starts.

 

You also need to learn about auto-indexing tunnels.  With your outermost while loop, you can get rid of the array size information going to the N terminal, and the index array inside.  These are just auto-indexing over the rows of the 2-D array.  An auto-indexing tunnel will take care of that for you automatically.

 

There is no need to split the resulting 1-D array 11 times and run it to different Index Arrays to get to each element.  The Index Array function can expand downwards, without wiring up any values to the index terminals, you will automatically get the elements at index 0, 1, 2, 3, .... and so on.

 

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

0 Kudos
Message 4 of 4
(2,441 Views)