08-04-2020 06:23 AM
Hallo,
i have a While loop who checks the TCP ip connection to one of my instruments so i can only start my measurement if all connection are right.
Inside of this While Loop is a sequence with different measurement steps. One of this Measurement steps is a MPPT Tracker.
The MPPT is also a while loop which stops when it reach a stable condition. After the stop the next step in the Sequenze is to switch of the light source.
When i now stop the overall While loop who checks the Tcpip, the programm stops without switch of the light source.
I wannt to stop with one buttom first the MPPT so sequenz can complete an swith of the light. after this the whole programm should disconnect from the instruments.
Does anyone has a clue how i can do this?
Regards
Felix
I was reading that its not good to do a while loop inside a while loop, but im not shure how i can make it better.
08-04-2020 06:31 AM
Use a State Machine. And instead of having loops inside of a state, repeat the state until the right condition has been made.
08-04-2020 08:41 AM - edited 08-04-2020 08:42 AM
To expand a little on what crossrulz said:
One of the reasons why you want to keep repeating a state until the condition to move on is met is because your application only gets to "look" at a control once per spin of the state loop. So if your state has a loop in it, it never gets to see a STOP button being pressed, for instance, until it gets out of that internal loop and comes around again. By that time, maybe your UUT is smoking. 😉 (More realistically, it just means you have wait until the entire test step is done before it exits the application, so maybe you waited half an hour for it to exit and you know the data are meaningless because you forgot to hook up a cable at the beginning of the test.) On the other hand, if you made it loop through the same state until the test was done, the maximum time you would have to wait is one iteration of the test. So if you were testing 60 test points that each took 10 seconds each to test, instead of having to wait ten minutes just to retest the UUT, you press the STOP (or whatever) button and after ten seconds, it exits/returns to the idle state.
08-04-2020 08:55 AM
Thanks for your help.
There is one probleme i dont know to handle with the State maschine.
One of my Measurement steps is measureing 21 diffrent Sprectra. At the moment i have a ENUM going to a case with 21 cases. So i can select with the ENUM 1 of the 21 Spectra and get it shown. For me the benefit is that i dont have to great 21 diffrent Graphs, i can just select the date what goes to the Graph.
When i now use the State Machine and the State where i collecte the Sprectrum date pass, the ENUM for the Spectra doesnt react until i start again the Spectrum State.
Is it possible that i dont have to stay in State where the ENUM is in?
I try to make a small example VI, instead of a Sprectrum there is a simple 1 and 2 Constant
08-04-2020 05:50 PM