LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I reset a formula node input to 0 after I finish the program?

Solved!
Go to solution

Hi  

 

Please refer to this fixed code to answer my questions if possible

 

I fixed the indexing problem, I still don't understand how to improve the array stuff (autoindexing and 2d to 1d array)

 

Thank you!

0 Kudos
Message 11 of 19
(2,312 Views)

@patomated wrote:

Please refer to this fixed code to answer my questions if possible


You did not attach any code, just a picture. Please attach the actual VI.

0 Kudos
Message 12 of 19
(2,266 Views)

Apologies.

Here it is.

0 Kudos
Message 13 of 19
(2,246 Views)
Solution
Accepted by topic author patomated

OK, you are doing way too many redundant things.

  • The entire inner loop is just to get the current x and y, but you already have that!!! Just branch the wire from the x and y controls! Now you don't even need to keep track of the index.
  • The formula node is overkill, just use simple primitives.
  • Since the integration includes 0,0 as first point, you should initialize the graph shift register with that value, not with an empty array.
  • As I said, a 1D complex array would simplify things (x=RE, y=IM). xy graphs can graph 1D complex arrays just fine.
  • As mentioned, you should put the indicators before the event structure. This way they get updated when the program starts, erasing stale data from the previous run.
  • logically arrange the code horizontally. Don't have wires going in all directions and crossing each other.
  • Label the shift registers (I usually show the label of the initializer value).
  • Why is the front panel and diagram maximised to the screen? That is very annoying! Don't do that!

 

Attached is a very simple rewrite, keeping the results the same. Most likely you could simplify it quite a bit more. For example it would make sense to turn the area calculation into a subVI. Make it reentrant and have it keep the previous point internally. You should also add diagram comments to explain what the code segments do.

 

 

Download All
Message 14 of 19
(2,225 Views)

I cannot thank you enough for all the help!

I hadn't realized how I could replace many of the things with simpler code, using shift registers and simple primitives instead of the formula node.

Thanks for all the other points. All are noted! Makes it much neatier and easy to use or modify later. 

I hope I will be better in LabView later on so I could help people on the forum too!

 

0 Kudos
Message 15 of 19
(2,208 Views)

Hi 

 

I've been using the help you've given me to modify the program myself but I've noticed that in your case the initial point of the curve is always 0,0. 

What I want to do is start at any point that I specify and continue with it.

I cant see how to fix this using the complex array since im not familiar with it.

Could you offer me how to proceed with solving this?

I attached the vi of the program I want using your optimized soluions

0 Kudos
Message 16 of 19
(2,171 Views)

To keep it simple, just use a couple of local variables to initialize your first point when the VI starts with whatever values you have in for X and Y.



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 17 of 19
(2,153 Views)

@patomated wrote:

 

I've been using the help you've given me to modify the program myself but I've noticed that in your case the initial point of the curve is always 0,0. 

What I want to do is start at any point that I specify and continue with it.

I cant see how to fix this using the complex array since im not familiar with it.

Could you offer me how to proceed with solving this?

I attached the vi of the program I want using your optimized soluions


Remember that your integration actually includes 0,0 for the area calculation, and that's the only reason I initialized with 0,0. There are many ways around it and the correct solution depends on how you want it to behave. We cannot know that.

 

  • You could just intialize the shift register with an empty complex array, but then you need to make sure that the area is not calculated for the first entered point. This is probably the preferred solution.
  • (If you want to use the values that is contained in the x and y controls when the VI starts, you could use the local varables as shown by tim above or you could initialize with an empty array, but add a timeout event to the same event case. place the timeout in a shift regsiter initialized with zero and fed with a -1 on the right side. Now the event executes once when the pogram starts and then only if new points are added. Personally I don't like these because they mean that controls need to be at specific values before the VI starts.)

And please change the file name when attaching a modified VI! It is confusing if you attach a new VI that has the same file name as an existing VI disucssed earlier.

Message 18 of 19
(2,132 Views)

Here's one way from preventing inclusion of 0,0 in the integration.

 

 

Message 19 of 19
(2,117 Views)