Thank you for your replies,
I rewrote the code. Could you tell me how to do the state transitions? (and whether my code looks right or not?) The program gives an error when it completes the for loop. I want it to go to "1" (heat up) when it is done with the for loop.
And when heating up is completed, that's thermostat is set to be on for a certain amount of time, it should go to state "2". After state "2" is done, that's stability is checked and temperature is stable, it should go to state "0" and collect data again. (but with a different file name)
state_machine.vi