LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reverse 1D Array and insert into array are not compatibles?

Hello guys.

I've got a problem with the Reverse 1D Array.I can´t get the result that the array is reverse.
 

ex1.png  
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

If you have any suggestions for improving the program thank you.

 
 
Thanks 
 
 
 
 

Download All
0 Kudos
Message 1 of 13
(4,509 Views)

The functions that you are using from LabVIEW are definitely working.  I took a quick look at your code, and it seems like your are using the "in range" function a lot.  The limit from the code is between 0 to 18.  If the value is outside that range, you will either get a 0 or 18, depending on what limit you cross.  I run the program, and I got a -1 going into the "in range" function", so the result is 0.  If you insert a 0 into an array, you are going to have an array full of 0s.  If you reverse that array, the reverse version will look the same, since all the elements are 0s.  Is that what you are seeing?

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 2 of 13
(4,503 Views)

@msap wrote:

If you have any suggestions for improving the program thank you.


 

 
 I don't see anything wrong with the insert or reverse functions.
 
General comments:
  1. Important! Try to learn how to crop an image before attaching.
  2. Your subVIs have way too many identical cases. All you need are two cases: (A) default, (B) "1..10".
  3. Why are all your tiny subVIs maximized to the screen for both diagram and front panel?
  4. The On/Off button and case structure makes no sense.
  5. Use "built array" instead of "insert into array".
  6. You have several seemingly dangerous coercions. (e.g. in the subVIs, the DBL turns into an integer at the selector terminal)
  7. You are graphing a variable sized array vs a fixed size array.
  8. Resetting the voltage should be done with a local variable isntead of value property. 
  9. ...
  10. ...
Message Edited by altenbach on 03-10-2010 04:57 PM
0 Kudos
Message 3 of 13
(4,481 Views)

I agree altenbach.

 

But I thought I read somewhere it is better (more efficient) to write a value property than it is to use a local variable.

0 Kudos
Message 4 of 13
(4,472 Views)

battler. wrote: 

But I thought I read somewhere it is better (more efficient) to write a value property than it is to use a local variable.


 

 
 Noooo!!! A value property is synchronous and thus carries literally orders of magnitude more baggage.
0 Kudos
Message 5 of 13
(4,469 Views)

Ok, well what about Reading?

 

I kid you not I have read in the NI documentation that (it believe it's reading) a Property node Value should be used above a Local Variable.

0 Kudos
Message 6 of 13
(4,455 Views)

battler. wrote:

Ok, well what about Reading?

 

I kid you not I have read in the NI documentation that (it believe it's reading) a Property node Value should be used above a Local Variable.


If you can find a link or some sort of reference to where you read that, please post it.

 

I've always heard, and read, and seen with my own eyes that for performance reasons, a local variable should be used in place of value property node.

 

Not that there aren't places where a property node isn't the right thing to use.

1.  You pass it a reference to a control so you can programmatically determine what control you want to change the value of.

2.  You need the reference because you are changing the value in a different VI then where the control is located.

3.  You want to use an error wire to control the order of execution.

4.  You are already changing other properties of the control as well, so changing the value is just one more input that you can add to the list of properties in that particular node.

5.  You want to use Value(signalling) so that you can trigger an event structure.

0 Kudos
Message 7 of 13
(4,446 Views)

Ok, well what about Reading?

 

I kid you not I have read in the NI documentation that (it believe it's reading) a Property node Value should be used above a Local Variable.


I believe that its best to use the local variable to pass the value to a control/indicator (like initializing or something like that) since only the data will be duplicated.

 

However A property node will surely duplicate the entire control/indicator to memory.

 

Or am i wrong?

 

Guru

Regards
Guru (CLA)
0 Kudos
Message 8 of 13
(4,441 Views)

Guruthilak wrote:

I believe that its best to use the local variable to pass the value to a control/indicator (like initializing or something like that) since only the data will be duplicated.

 

However A property node will surely duplicate the entire control/indicator to memory.

 

Or am i wrong?

 

Guru


I'm not sure this is the point. I think the problem is that each property node always goes through the UI thread (thread switching), while a local variable can be updated in any thread.

 

 


Ok, well what about Reading?

 

I kid you not I have read in the NI documentation that (it believe it's reading) a Property node Value should be used above a Local Variable.


 

Property nodes have the advantage that the data flow can be ensured using the error cluster. But this doesn't mean that property nodes should be used instead of locals.

 

0 Kudos
Message 9 of 13
(4,429 Views)

Before the existence of tools such as the performance monitor and I was trying to optimise my code I gained the idea (from the NI documentation) that reading/writing to the Property node Value was more efficient than using a Local Variable.  It is something which has stuck with me for a long while now.

 

I will keep searching through the NI docs I have.  However, I did a Google search ad uncovered this for example:

 

Use property nodes rather than local variables

When you make a local variable you make a local copy of the original variable. When you make a property node you make a reference to the original value.
In the case of single values the use of local variables may still be prefered because of the increase in readability. In the case of larger structures, such as an array, it is worth the effort to make the right property node.

 

http://www.morechemistry.com/labview/topic-optimize-for-speed/optimize.html

0 Kudos
Message 10 of 13
(4,416 Views)