LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cursor List only saving last position in for loop

Solved!
Go to solution

Hi, I am new to LabView 2010 and testing out Cursor List to use in a different program to label peaks. My test program though has a problem, only displays the last cursor peak instead of all of them. Basically my program goes simulate signal with Periodic Sinc Pattern, find peaks and peak locations with Peak Detect, and then use a for loop (length of peak locations array long) to update Cursor List repeatedly. I can't figure out why on my graph, only the last point gets displayed though! Any suggestions? Attached is my VI block diagram

 

 

0 Kudos
Message 1 of 6
(2,796 Views)

Hi,

 

I think you must add a shift register to the for loop you are using and pass the peaks into the shift register and then pass it to your indicator. It would have been more useful if you had put your VI in the forum rather than the jpg image.

 

Regards,

 

Nitz

(Kudos are always welcom:))

0 Kudos
Message 2 of 6
(2,787 Views)
Solution
Accepted by topic author cerebral

You have some very weird code constructs, hinting that you are not yet fully understanding dataflow.

 

The dual property node where you first write, then read the cursor list is half-useless. Delete the lower property. You could just branch the wire to the property node and the indicator.

The property node on the left is outside the loop, meaning it gets read exactly once and then never again. All you read at each iteration is the stale value stored in in the tunnel. If you need the updated cursor list, place the property node inside the loop.

 

Your code is way too convoluted. All you probably need is to autoindex on the two orange arrays and the cursor list, built the new cursor list on an autoindexing output tunnel, then write it to the property node.

 

Please attach the actual VI so I we can more easily show you.

Message 3 of 6
(2,781 Views)

There are some other things that are not clear from the picture:

 

You never change the size of the cursor list. Can we assume that you have a sufficient number of cursors, one for each found location?

 

Why in the world would you use a matrix display for a 1D array??

 

Assuming your cursor list starts out big enough, the following should be all you need.

 

(If you have more locations than cursors, you should reshape the cursor list to the number of locations before the loop).

 

(The current code assumes that the cursor list is larger than the number of locations. If the cursor list size is identical to the number of locations, you can just autoindex at the loop boundary and also eliminate the in place element structure.)

 

See if this makes sense...

 

 

0 Kudos
Message 4 of 6
(2,768 Views)

Thanks for the help! Altenbach, I put the cursor list out block inside the loop and it worked. The real VI I am working on really just has a signal coming in from an instrument that gets filtered in place of my simulated signal. I had those outputs put in there in an effort to debug the thing, they are not actually going to be in the code. Thanks for the suggestions in improving my data flow, just started learning LabView a week ago. Right now, I am assuming that I have enough cursors predefined, and I don't think it will be a problem but I will look into defining the number of cursors before the loop. Thanks!

 

0 Kudos
Message 5 of 6
(2,745 Views)

Remember, property nodes are relatively expensive operations (They are synchronous, fully update the front panel with each call and involve thread switching, for example (details)), so their use should be limited.

If you look at my example code, you see that it it sufficient to read the cursor list once, process it in the loop as desired, then write it once after the loop. If you have both property nodes inside the loop, you are reading and updating the list numerous times in very rapid succession, too fast to see, but churning al lot of unecessary electrons in the process. The end result is the same. 🙂

Message 6 of 6
(2,738 Views)