From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Flat Sequencing

Hi.  I am working on a code that measures the voltage of from a mems mirror using an optical fiber, and I am having problems figuring out why the flat sequencing stuctrue isn't working.  I think that the scanning is stuck in an infinite loop.  I am not very good with labview, and I am not sure this is the right way to have the code structured.  I need the mirror to be scanned to find the highest voltage position, and then I need the mirror to move to that position.  Thanks for your help in advance.

0 Kudos
Message 1 of 12
(3,853 Views)

Flat sequence structure is a throwback that is rarely used and never really needed.  There's probably a better way to do what you want.  

 

I haven't updated to LabVIEW 2014 quite yet so I can't open your file to take a look.  I'm sure you'll get some help soon or you can always do a File > Save for Previous Version and post an older version so more people can view your code and help...

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 2 of 12
(3,847 Views)

I'm seeing all kinds of issues here.

 

1. Combine your two Analog Outputs into a single task.

2. You have a tunnel over the shift register for the inner FOR loop.  You should just be wired to the shift register.

3. The local variables make no sense at all.

4. Not sure what you are trying to do in the second sequence frame.  But you should just use the same task(s) and just remove the sequence structure (use data flow to enforce when it will run).  Stop and clear the task after you are completely done with the task.

5. FOR loop that just runs once?  No need for that.

6. Probably should not use the DAQ Assistant.  Use the actual DAQmx API like you did for that Analog Outputs.

7. You can expand the Index Array.  You also do not need to wire up the index since the default for the first index is 0 and it just adds 1 from there.

8. Feedback nodes at the bottom of the code makes absolutely no sense since you are not inside of a loop.


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
0 Kudos
Message 3 of 12
(3,831 Views)

Hi,

 

OK, so as a first guess I see several things wrong with your code:

 

  1. The top left shift register has a tunnel on it. The shift register is unwired. This should not change the behaviour of your code( DAQmx tasks are references and don't necessarily have to be in shift registers.)
  2. That whole desing looks like you have been using the "run continously" button, which you should never do.
  3. I agree with NIquist: You can completely avoid using flat sequences and you should.
  4. The shift register in the smallest For loop does nothing, as does the for loop (I'm assuming, though, that you want to enter more than 1 at a later point)
  5. I would bet that your middle for loop is also not necessary.

These are just some things you might want to think about, but to your problem: To see if the for loops are in fact infinite, you can check the iterator output and see if it's counting up. From what I see, it should do 21 iterations and be done. That's 21x21 iterations for the middle loop.

 

Other than that I hope you know that there's a boatload of free tutorials out there, which you access to get better acquainted with the old lady we call LabVIEW:

3 Hour Introduction
6 Hour Introduction
LabVEW Basics
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training
Learning NI
Getting Started with NI Products



Remember Cunningham's Law
0 Kudos
Message 4 of 12
(3,820 Views)

I'll hopefully try and explain a little bit more about what I am doing.  The feedback loops at the bottom set up a filter cut-off point.  The high voltage amplifier is then turned on.  The three for loops input voltage data to a mems mirror, where the mirror is scanned by infared light to find the point of highest intensty.  What I am trying to do is take the "Volts X" and "Volts Y" data points (which tell me where the highest voltage occurs) and input them into the high voltage amplifier to move the mems mirror to that specific location.  Once that is finished, I then want to turn off the high voltage amplifier. 

 

I have never used DAQmx in labview before, so I would really appreciate well explained solutions because I don't know how to fix this. 

 

I also think I converted it to the 2013 version of LabVIEW, but I'm not sure.

 

Thanks

0 Kudos
Message 5 of 12
(3,792 Views)

I havent looked at the rest of the code, but your local variables for "volts X" and "Volts Y" will get read immediately at the start of that frame and way before the code in the FOR loop has a chance to write to the respective terminals. All you get in the following frame are the stale values from the previous run. Eliminate the local variable and wire directly from the wire going to the terminals, disable indexing when crossing the loop boundaries. Now you can even delete the flat sequence structure, because execution order is fully determined by dataflow.

0 Kudos
Message 6 of 12
(3,762 Views)

@NIquist wrote:

Flat sequence structure is a throwback that is rarely used and never really needed.


I disagree.  It is true that flat sequence structures are overused, but there are many valid uses for them.  Flat sequences can be essential for coercing the order of execution of nodes that don't contain error terminals.  They just need to be used carefully.  You may be referring to stacked sequence structures, which should never be used under any circumstances.

Message 7 of 12
(3,718 Views)

@CMal wrote:
You may be referring to stacked sequence structures, which should never be used under any circumstances.

No I agree with what NIquist said.  Very rarely do I need an operation to happen in a specific order, that doesn't have error wires for data flow, or a state machine or QMH.

 

Often times the data flow itself is all that is needed.  When are you performing an action, that doesn't generate an output, that another function needs as an input?  Are you writing to globals variables all the time and you want to set it before calling a subVI that uses it?  Well that's poor design anyway.  Allowing the compiler to determine the order of functions is best, when the order doesn't matter.

 

I've probably used the sequence structure less then 5 times in all the real applications I've written.  Sure I've used them in demo software, where I'm trying to measure the time between functions and don't want new values written to controls, and maybe once or twice I used one with just a local variable in it to force data flow, but calling them a throwback, that is rare, and never really needed is an accurate statement.  Even the CLAD had a question like "What should you do with sequence structures" and the answer was "Replace it with a state machine".

0 Kudos
Message 8 of 12
(3,688 Views)

@CMal wrote:

@NIquist wrote:

Flat sequence structure is a throwback that is rarely used and never really needed.


I disagree.  It is true that flat sequence structures are overused, but there are many valid uses for them.  Flat sequences can be essential for coercing the order of execution of nodes that don't contain error terminals.  They just need to be used carefully.  You may be referring to stacked sequence structures, which should never be used under any circumstances.


Actually I was thinking about the stacked structure.  I do rarely use the flat sequence but it's generally for making code more readable (I use the "sub-diagram labels" to title each section), not enforcing dataflow.  For nodes that don't contain error terminals I usually have my own version of them that does have error handling. Smiley Tongue

 

Anyway, this topic has been beaten to death so let's not hijack the OP's thread over it.  

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 9 of 12
(3,631 Views)

Speak of the devil.  I just opened a co-workers project and found one of those valid uses:

Untitled.png

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 10 of 12
(3,601 Views)