From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Run one part from code

Hello, 

 

The attached .vi is a part of a code that can be used to make reading from the detector. 

In the original code, I open 4 ports. 3 of them to control the sample position which we put in a movement controller (3-D). The port number 4 for the detector.

Simply, the code used to change the sample position in 3-D and read the detector counts. 

The code works fine. Just I detect the start, step, and the endpoint of (x,y z), set the time, and press start. then the system will change the sample position and read the detector counts for every position.

The problem:

Reading the counts can be done only inside the scanning loops. But, what we should do If we want to run only the detector (the part in the snap(test.ping))!

I mean how can we make a test for the detector counts before run the full scan.

in another way--> how can I start only the part of the detector (see the snap)! 

note:

I delete the not important code part and keep only the part that I want to run. 

You will see many and many loops, sequences, and structures because it already contains terminals in the original code which controls the movement stage. 

If you want to see the whole code I can share it. 

I hope you can get my idea. 

 

 

 

Download All
0 Kudos
Message 1 of 9
(1,923 Views)

I immediately see a major red flag: WAY too many sequence structures.  It looks like you should study up on using a State Machine.


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 2 of 9
(1,884 Views)

In my opinion you should scrap this and start from scratch. Your code is not manageable. Do some LabVIEW tutorials. Learn about data flow. Study state machines as crossrulz suggested. Also, study up on using subvis. You will take less time doing this than you will in trying to do what you want with this mess. You should be able to program this using one loop rather than a series of nested loops and sequence structures.

0 Kudos
Message 3 of 9
(1,858 Views)

@johntrich1971 wrote:

In my opinion you should scrap this and start from scratch. 


I completely agree. While the Mayans were great architects, they were not great "LabVIEW architects" so don't try to adapt their designs.

 

altenbach_1-1596485689777.png

 

 

All you probably need is one loop and one case structure to tie it all together. Start with some simple tutorials and templates.

0 Kudos
Message 4 of 9
(1,826 Views)

Hi,

 

wow, 4 stop buttons to finally stop a VI…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 9
(1,819 Views)

@GerdW wrote:

wow, 4 stop buttons to finally stop a VI…


And since the terminal labels are hidden, we can only guess what belongs to each loop.

 

(... and good luck stopping anything if there is no error in the innermost two loops and an unreasonably large times had been entered)

0 Kudos
Message 6 of 9
(1,811 Views)

I expect that maybe you will miss the idea,

I said in my post that I deleted the residual code, and keep only the important part. 

I attached the whole code, please check it to build the complete idea. 

 

0 Kudos
Message 7 of 9
(1,777 Views)

@BaJa_2020 wrote:

I expect that maybe you will miss the idea,

I said in my post that I deleted the residual code, and keep only the important part. 

I attached the whole code, please check it to build the complete idea. 

 


I still come to the same conclusion (possibly more so): you need to invest in building a proper State Machine.


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 8 of 9
(1,753 Views)

@BaJa_2020 wrote:

I expect that maybe you will miss the idea,

I said in my post that I deleted the residual code, and keep only the important part. 

I attached the whole code, please check it to build the complete idea. 

 


Actually, no, the "residual code" only makes the problem worse, not better. You are wasting your time with this mess.You do not need multiple nested loops and sequence structures.

0 Kudos
Message 9 of 9
(1,725 Views)