LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

increment and reset to zero until next change

Hello , 

I got stuck in a phase  of my programm, i record on an Excel file data frim my instruments  continously and  i test if my voltage is in the range  [6V +-10%], i take these values at an interval chosen , otherwise i test for  5 iterations using a shift regsiter to be  sure  taht is not a bug for  measurement error , i should  not  not normaly save  until the value  is  out of range until  at  the next change  , let me explain , i want to reset my variable to zero after 5 iterations and that it does not increase , so as not loop a gain as long as the  value  is  out  of range 

can someone help me thanks  

i put my VI ans some pictures

I will put my Vi and a screen 

Ayoubas01_0-1646661840316.pngAyoubas01_1-1646661888107.pngAyoubas01_2-1646661913171.png

 

   

 

0 Kudos
Message 1 of 4
(936 Views)

Hi Ayoubas,

 


@Ayoubas01 wrote:

I got stuck in a phase  of my programm, i record on an Excel file data frim my instruments  continously


Well, I got stuck too. Your VI needs to be cleaned up before you/we can do any debugging!

 

What is the purpose of that part of your code:

What is the expected result?

Why do you need to convert a boolean array to a DDT wire using an ExpressVI?

Do you want to test for the very first iteration of the outer while loop? (Then why don't you compare "i > 0"???)

 

  • Why do you need 3 input tunnels to the case structure in the center for the very same value?
  • Why do you need to convert the measurement sample inside that case structure in each case into an array, again using an ExpressVI? Why do you need to convert to an array even though that array only contains one element and even though you don't need an array to create your CSV file!?
  • Why do you write "Excel file" when you create ordinary CSV/spreadsheet files?
  • Why do you need InsertIntoArray when you want to build an array? (There's a function called BuildArray…)
  • The whole large case structure in the upper right can be replaced by a Select node and a NOT…
  • Why do you initialise in the while loop (inside another case structure), but not before the loop?
  • Why are there no comments in your code? Why don't you use subdiagram labels for comments?

Please cleanup the VI before trying to improve/debug it…

 


@Ayoubas01 wrote:

let me explain , i want to reset my variable to zero after 5 iterations and that it does not increase


Which "variable" do you want to "reset to zero"?

Do you want to set back to zero after each 5 iterations (without any other condition)? Then simply use Quotient&Remainder on the "i" of the while loop…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(903 Views)

 thank you for taking the time to answer me, for the first iteration of the loop it is to save the first value and not wait for the end of the counter between samples
converting the data to be boleens or not allows me to connect the condition structure afterwards so as not to see the problem of different types of data that's why, if so, what should I do? and why isn't it fair?
About my question how can I take only the first 5 stored data and reset my counter (shift register) to zero without going back to increment until the next change in the range I hope I was clear in the question

0 Kudos
Message 3 of 4
(888 Views)

@Ayoubas01 wrote:

About my question how can I take only the first 5 stored data and reset my counter (shift register) to zero without going back to increment until the next change in the range I hope I was clear in the question


I agree with Gerd that your code is extremely convoluted and most likely wrong in many places. All you probably need is a simple state machine containing 20% of your current code to do everything better. There shouldn't be any dynamic data at all! We are missing subVIs (not clear why you need to get the current VI name twice and repeat that with each iteration. I seriously doubt it will ever change during run so that belongs before the loop. You can branch the wire to all locations where it is needed. What is the desired loop rate? (Seems to be near infinite under error conditions and slaved to the dll call if there is no error. Don't you want a defined rate?)

 

If your "counter" is that orange shift register, why is it not blue??? Do you know about datatypes? If you can do a conditional +1, it should not be hard to conditionally set it to zero somewhere. What have you tried? I don't see any place where you have "stored data"? Do you mean after 5 rows have been written to the file? Something else?

 

Nobody here will be doing any useless detective work trying to figure out the purpose of all your cases and structures. Can you add descriptive diagram comments?

 

Maybe take a step back and describe what the program is supposed to do from a user perspective.

0 Kudos
Message 4 of 4
(872 Views)