02-23-2012 02:16 AM
Hello,
There is a problem in my VI. If the upper limit (0.25) of the amplitude is reached, the button "Test starten" is pressed and it should continue to the next frequency. Manually it works, but if it should work automatically, a frequency is skipped.
Does somebody know how to solve this problem? I already have posted my problem in other forums, but nobody could help me. The program is attached. Ask for your help.
Best regards DOM
Hallo,
Ich hab da ein Problem in meinem VI. Wenn das Amplitudenmaximum von 0,25 erreicht ist, wird der Button "Test starten" gedrückt und es sollte zur nächsten Frequenz weitergeschalten werden. Manuell funktioniert das wunderbar, aber wenn es automatisch passiert, wird immer eine Frequenz übersprungen.
Weiß jemand warum das so ist und wie man das korrigieren kann? Hab das schon in anderen Foren gepostet, aber niemand konnte mir helfen. Das Programm befindet sich im Anhang. Bitte um eure Hilfe.
Mfg DOM
02-23-2012 02:48 AM - edited 02-23-2012 02:49 AM
I didn't verify, but from looking at the code I think it's because you have 2 value signaling property nodes on "Test Starten". First you set it to True, then to False. This will trigger the value change event twice. Remove the second property node (setting the value to False). The value will be set to false in the event loop.
02-26-2012 04:51 AM
Thanks for your help, but I already tried this solution once and now a second time and it doesn´t change the function of the program. Still one frequency is skipped.
Do you know another reason?
Best regards DOM
02-27-2012 02:51 AM
Well, the code architecture does not seem the best for what you're trying to accomplish. Did you ever hear about a state machine?
Anyway, you're "Kanäle" array has 2 elements. Since the amplitude is increased both will have a value of 0.25 at some point. So the comparison " =0.25" will result in a TRUE for both elements and thus the event is triggered twice.
A simple fix would be to only trigger the event if the "i" (loop counter) of the for loop is 0.
As mentioned above, a different architecture would also help.
02-27-2012 05:02 AM
When I trigger the event if the loop counter is 0, the amplitude doesn´t increase, because at the beginning the loop counter is 0 and then the case structure is always true. This solutuion doesn´t work. But when i trigger the event when the loop counter is 4 (then the amplitude is 0.25) it also doesn´t work. I think, because the loop counter continues counting and isn´t resetted.
Do you know how I can solve this?
Best regards
DOM
02-27-2012 06:10 AM
I was talking about the counter of the for loop (the inner loop), not the counter of the while loop.
02-29-2012 06:37 AM
I also mean the for loop. Okay, my statement that the counter doesn´t reset was an error by me.
I attached the program again with the changes you talked about. Is it right in this way? But how i said, the program doesn´t work. The amplitude doesn´t increase.
Best regards
DOM
02-29-2012 06:46 AM
Now you deleted the condition amplitude = 0.25.
You should only trigger the Test Starten event when i=0 AND amplitude=0.25.
Again, a better code architecture would help significantly...
03-01-2012 01:59 AM
Thanks for your help. The program works now.
But now when it continues automatically to the next frequency, there is a sound, where no should be.
I searched, but i couldn´t find where it come from. Maybe you know?
Best regards
DOM
03-01-2012 02:24 AM
Do you want to play a sound at amplitude 0.25 or not? The way it is implemented now the first sound at amplitude 0.25 will be quiet (amplitude is overwritten to 0), but the second sound will play.
If you want to play a sound at amp=0.25 then you don't need to set the amplitude to 0 in the case structure. If you don't want to play the sound then you need to set the amplitude to 0 also when i is not 0. But this doesn't seem to make a lot of sense.
Btw, you can give "Kudos" to a good answer. Just click on the + button next to the Kudos number.