03-07-2022 08:07 AM
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
03-07-2022 09:10 AM - edited 03-07-2022 09:17 AM
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"???)
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…
03-07-2022 09:53 AM
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
03-07-2022 10:44 AM - edited 03-07-2022 10:53 AM
@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.