LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

help with code

Solved!
Go to solution

I am trying to get the code to run after it has completed the movie at the end and display the results on a contour map. The problem is I cant get it to end. It restarts the movie after reaching 4000ms. Should I change the last while loop to a for loop?

0 Kudos
Message 1 of 7
(3,460 Views)
Solution
Accepted by reggie2016

Reggie, my man, your code is off-the-charts linear and unscaleable. Maybe you're okay with this, though.

 

Your last While loop will not stop until you press the Stop button. If you want it to stop once the In Range check shows False, you can add an Or operator in there (with a Not operator too probably) to get your loop to stop.

Reggie voltage input and output 2_BD.png

 

And what's up with your first While loop? You have an Elapsed Time VI that stops the loop, but you use it by checking if Time Target is less than Elapsed Time. Why not just output the Time Has Elapsed boolean for this? You also have the default value set to 1000 seconds, which is a long time... I hope you didn't mean 1000ms.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 7
(3,453 Views)

Yes when I press the stop button though the whole program stops which is not what I want. I need it to move along to the contour map part. Should I put the contour map inside the while loop also.

0 Kudos
Message 3 of 7
(3,443 Views)

See the snippet I put above to make it stop automatically at 4000. You can even remove the Stop button if you don't need it.

 

As you have the contour VI, it just plots the y-size and x-size in the form of an array of the same size as the loop iterations. Is this what you want? You don't want to put it inside the loop because then you would only be plotting single points over and over.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 4 of 7
(3,435 Views)

This is what I want I am working on getting data for the z-axis. This is what i have so far. Thank you for the step above

0 Kudos
Message 5 of 7
(3,421 Views)
Solution
Accepted by reggie2016

No problem. Thanks are best given in the form of Kudos and Marked Solutions (Unofficial Forum Rules and Guidelines). Marked Solutions help others find this post when they have the same issue and Kudos motivate us all to keep coming back to help! Smiley Wink

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 6 of 7
(3,413 Views)

You should probably mark the first post above where I put the snippet as the solution.

 

As far as your general LabVIEW code, you could probably benefit from a little bit of training in best practices. It looks like you have a good start and grasp of how LabVIEW can be used. The state machine architecture would keep you from having such a long stretch of code like you have. Also, the use of subVIs might help.

 

The Simple State Machine template that ships with LabVIEW is really the best way for new developers to get familiar with LabVIEW while utilizing a semi-scalable architecture.

Here's a broad example of how a state machine works:

  • States: Init, Idle, Exit, DoThing1, DoThing2, DoThing3
  • Each state contains code that might take some time. Ideally, not too long because that's how long you code could be unresponsive.
  • The Idle state contains an event structure for all user interaction.
  • The front panel has a button that says "Do Thing 1".
  1. Loop Iteration 0: Application begins, first state is Init. The Init state does some initialization stuff and tells the application to go to the Idle state when finished.
  2. Loop Iteration 1: Application goes to Idle state. It sits there, waiting at the event structure.
  3. Time goes by, then user presses button "Do Thing 1". There is no code, or minimal code, within this event case. The output of this event state tells the application to go to the DoThing1 state.
  4. Loop Iteration 3: Application goes to DoThing1 state. There is code here that does some stuff. The output of DoThing1 state tells the application to go back to the Idle state.
  5. Loop Iteration 4: Application goes to Idle state where it waits at the event structure again.
  • Each of the states can tell the application to go to any state they want. Want to reinitialize? Go to the Init state again. Want to end the program? Go to the Exit state? Want each state to trigger another (like a sequence)? Have DoThing1 output DoThing2, which outputs DoThing3,  which outputs Idle.

 

"Give me six hours to chop down a tree and I will spend the first four sharpening the axe."  - Abraham Lincoln

 

Here are some free training tools primarily focused on LabVIEW and NI hardware to help get started.

NI Learning Center

NI Getting Started

-Hardware Basics

-MyRIO Project Essentials Guide (lots of good simple circuits with links to youtube demonstrations)

-LabVEW Basics

-DAQ Application Tutorials

-cRIO Developer's Guide

Learn NI Training Resource Videos

3 Hour LabVIEW Introduction

6 Hour LabVIEW Introduction
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 7 of 7
(3,403 Views)