LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Highlight execution succeeded, but normal execution failed

Solved!
Go to solution

Purpose:The main program calls the subvi to realize the following functions: input a column of array, and divide each element in the array by the maximum value of the array, and display the divided results in real time.

 

firstly,I write a subvi:input a column of array,  each element in the array divided by the maximum value of the array, and form a new array.

DK_Zero_4-1642347740769.png

picture1.the subvi panel

DK_Zero_2-1642347208224.png

picture2.the subvi program.

 

then i call this subvi in the main program.

DK_Zero_13-1642350074095.png

picture3. the main program(Add a delay function to observe number changes).

 

thirdly,i run the main program in highlight way. The main program can run normally as well I I can see the number change from 0 to 0.25.

DK_Zero_9-1642348910982.png

 

picture4. Screenshot when the number is 0.625

 

but when i run the main program normally, the result number always stay in the last value.

DK_Zero_10-1642348954027.png

picture5.The number is always kept at 0.25!!!

 

Add probes at positions 24 and 25 for testing.During the first normal operation, there is no data at the probe.

DK_Zero_11-1642349394517.png

picture6.Not performed at probe.

but Click run again. At the moment of running, the array at the probe is passed in, and 0.25 final data is obtained.

DK_Zero_12-1642349624275.png

picture7.Data at probe.(The number is directly displayed as 0.25!!)

 

So how to achieve my goal and what's wrong with me?thank you!

0 Kudos
Message 1 of 11
(1,517 Views)
Solution
Accepted by topic author DK_Zero

Hi DK,

 

there are a lot of images in your message, but no VIs at all!

Mind to attach your code? (We cannot debug/edit/run images with LabVIEW!)

 

What's the point of FOR loop set to iterate just once?

What's the point of FOR loops set to iterate as many times as the array input contains elements? Ever heard of "autoindexing"?

Why are there two uninitialized shift registers??? Is that intended behaviour?

 

That whole "sub VI" can be replaced by this:

 


@DK_Zero wrote:

but when i run the main program normally, the result number always stay in the last value.

picture5.The number is always kept at 0.25!!!

Add probes at positions 24 and 25 for testing.During the first normal operation, there is no data at the probe.


When there is an empty array output then the loop will not iterate. And os it will not update the indicator within that loop…

 

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 11
(1,511 Views)

thank you sir:

the pictuer 1 and 2 is the subvi.

the picture 3 is the main program.

For your first question,In the subvi ,“FOR loop set to iterate just once” is just to set the shift register.

For your second question," FOR loops set to iterate as many times as the array input contains elements"is to traverse the elements in the entire array.I just learned about the automaticindexing you mentioned. It is more concise than my method, but the purpose is the same.I will use this method to improve the program.

Finally, I attach my program.

Thank you for your help sincerely!!!

0 Kudos
Message 3 of 11
(1,502 Views)

Sorry,because of the network problem, I didn't read all your answers just now.

 

There is no choice but to have the problem of uninitialization. Because the FOR loop can only be executed once, If the shift registers is initialized, the value read into the shift register will only be the initialization value.

 

There may be some ambiguity in my explanation,do you understand ?

 

D.K

0 Kudos
Message 4 of 11
(1,490 Views)

Hi DK,

 

the VIs work exactly as you programmed them to work!

Maybe there is a difference between "how you programmed them" and "how you want them to be programmed"…

 


@DK_Zero wrote:

when i run the main program normally, the result number always stay in the last value.


Because that is what you have programmed!

Spoiler
The FOR loop iterates as fast as possible and so you will only see the last element of the array.
Best regards,
GerdW


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

Hi DK,

 


@DK_Zero wrote:

There is no choice but to have the problem of uninitialization. Because the FOR loop can only be executed once, If the shift registers is initialized, the value read into the shift register will only be the initialization value.


As you don't need those FOR loops at all you surely have a choice!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 11
(1,483 Views)
Solution
Accepted by topic author DK_Zero

If you want to divide the input array by the maximum value , then display it element by element every 500ms until all elements are displayed, here's how I would do it.

 

(Note that if you want to delay the output of each element, the wait belongs inside the loop. dataflow principle!)

 

altenbach_0-1642354307448.png

 

(Make sure that the array is not e.g. negative and the max is exactly zero!)

 

I strongly recommend to go over the learning resources listed on the top of the forum. You currently don't really have the skills to go much further by just throwing things on the diagram and randomly connect things according to some misunderstanding of LabVIEW principles. Words like "real time" have a specific meaning and if you consider the behavior correct under execution highlighting, this has nothing to do with real time at all! Unreal! 😄

 

 

 

0 Kudos
Message 7 of 11
(1,477 Views)

thank you sir,

DK_Zero_0-1642354793835.png

Obviously, your method is more concise. I just rely on some obscure methods to realize the function. Thank you very much for your help. Your answer and the answer of the following friend perfectly solved my problem!

 

D.K

0 Kudos
Message 8 of 11
(1,470 Views)

THANK YOU!

You are right,i need add the delay function  inside the loop! Now i have solved my problem.

I think your suggestion is sincere and useful.And I will study labview according to your suggestion.

thank you again!

D.K

0 Kudos
Message 9 of 11
(1,465 Views)

@DK_Zero wrote:

I think your suggestion is sincere and useful.And I will study labview according to your suggestion.

thank you again!


Good luck!

 

As you saw here, some basic LabVIEW knowledge allowed me to write a full solution within seconds and the entire code fits on a postage stamp. Now compare that with the time it took you to write and debug your screenfuls of code. Your code is also full of dangerous boobytraps. For example you need to be very careful with uninitialized shift registers because they retain data between calls and I don't think that's what you want here. For example if you run your code with a certain input, then run it again with new values where the max is smaller, you might end up with the max of the earlier run. To operate on the current data, leave shift registers and feedback nodes out of it entirely!

 

Imagine once you can solve this simple problem within seconds, how much more interesting problems you can solve in the time it took you to write your original problem.  😄

 

Again, good luck and have fun programming!

0 Kudos
Message 10 of 11
(1,449 Views)