LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

while loop with shift register

Solved!
Go to solution

I see,

I've implemented an event structure. But clearly I'm not doing it right (I'm not really familiar with it yet) The clipping function doesn't work at all, and when I use a shift register the graph keeps moving when I let it calculate the mean etc. When I don't use shift register the mean function works properly, but then it wouldn't be able to remember the things I clipped (if it works at all).

How can I solve this?

0 Kudos
Message 11 of 20
(2,613 Views)

1. See those output tunnels with the little dot in them?  That indicates they are set to Use Default If Unwired.  Right-click on them and turn that off.  The only exception here is the Stop condition, that one can default to FALSE for you.

 

2. Add a shift register for the Max, Min, Average.  You are going to feed through this value in all cases where you do not update it.

 

3. In your Clipping subVI, you should look into using Array Subset and Replace Array Subset instead of Delete From Array and Insert Into Array.  The Array Subset and Replace Array Subset will avoid memory copies, making things more efficient in both memory and processing.


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 12 of 20
(2,585 Views)

Thanks for your feedback!

I've managed to do what you suggested. Sadly, the graph still moves when I click 'Calculate mean of nr of elements' Do you know how I can stop it from doing that? I've added captures and my new program.

Thank you 🙂

0 Kudos
Message 13 of 20
(2,573 Views)

Hi LvL,

 

Sadly, the graph still moves when I click 'Calculate mean of nr of elements' Do you know how I can stop it from doing that?

You still repeat this averaging operation on already processed data: no wonder it will average more and more…

 

Btw. in the event structure you see a big disadvantage of using very long labels (even with a line break inside): the event case is hard to read! Use shorter control labels and use the control caption in the front panel instead!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 14 of 20
(2,567 Views)

Thanks for the tip on the labels!

I understand the problem, but I really don't know what I have to do to make it work.  I had a program (added it) where it did what I wanted. When I went to value 1 in the 'Calculate mean' it showed the raw data. When I went to 5 it showed the most averaged version of the data. In this program I don't have shift registers. But Crossrulz said I should use shift register In the program with the event structure. I just don't know what's right and what's not anymore.

All I want is to combine the two subVI's in one, working program 😕 

Thanks!

0 Kudos
Message 15 of 20
(2,564 Views)

Update: I've had a small sudden realisation moment!

The mean sub vi is programmed to handle raw data, not data from the graph! 

So this will be my plan: 

First, the data has to go through the mean subvi. After that it goes into the graph for the first time. When the data is clipped, the data from the graph is my new 'raw data' . From this data I need the new high, low, average and mean. This updated data has to go into the same graph again. The cycle has to repeat with every clip that is done. So this means I can not send the edited graph data through the mean subvi again and again, I have to write something that is suited for the graph data, right? 

Any ideas on this?

0 Kudos
Message 16 of 20
(2,554 Views)

I'm really starting to get a bit desperate now... I've tried so much but I have the feeling I'm just going in circles with this problem.... Can someone please give some elaborate tips?

0 Kudos
Message 17 of 20
(2,538 Views)
Solution
Accepted by topic author LvL1995

Hi LvL,

 

take a sheet of paper.

Write your algorithm definition onto that sheet: which data gets processed? Which data needs to be stored within the loop? When should data be processed (all the time or event-based)?

 

Then draw the algorithm on that sheet of paper. (Speak with your collegues about your algorithm to verify it.)

Then (and only then) start to code in LabVIEW!

 

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 18 of 20
(2,534 Views)

Thanks,

Will do that. Maybe start with a clean slate. I'll let you know when I worked it out.

Thanks for all your help so far!

0 Kudos
Message 19 of 20
(2,532 Views)

Hi GerdW,

It helped! Starting over helped me get it done.

I used a sequence structure so the program runs properly. In the first tab, I read the file and I replace all the zero values with NaN values. Then in the second, I split the 2D array into six 1D arrays. For every array, there is a tab in the sequence with a while loop in which the peaks and valleys can be clipped in the graph. Because of the sequence structure, the user has to edit the graph, then click a button before the next graph can be edited. This feature was unintended but my employer actually liked it. After all the graphs are edited, The arrays are bundled and put into a for loop.  The data is put into a new graph. In the for loop the coating offset, the mean and the Max, Min, and Avg are calculated. 

There are still some minor things to work on, but the program does what I want it to do, and that's the most important for me.

Thanks for all your help!

0 Kudos
Message 20 of 20
(2,501 Views)