02-18-2014 12:02 PM
Hey
I've attached my code that I'm going to use with thermocouples. What I'm trying to do is: when I hit start button the code should run for a minute then stop for 5 minutes and then start again, this process should be repeated twice . Could you please suggest the appropriate way to do it.
Regards
Rajab
Solved! Go to Solution.
02-18-2014 12:17 PM
A simple state machine is all you need. The program itself should always be running.
02-18-2014 12:22 PM
elapsed timer can be a help....
02-19-2014 09:18 AM
Hi altenbach
Thanks a lot for your help, I've tried the state machine, I’ve created 5 case structures as following: start for 1 min, stop 5 min, start again for 1 min, stop 5 min, restart again 1 min and finally stop. I’ve tried the code and it didn’t work. Could you please have a look at the attached code and let me if I need to change something. I think I’ve not used the elapsed time function properly.
Best Regards
Rajab
02-19-2014 10:11 AM - edited 02-19-2014 10:22 AM
@Rajab84 wrote:
Hi @altenbach
Thanks a lot for your help, I've tried the state machine, I’ve created 5 case structures as following: start for 1 min, stop 5 min, start again for 1 min, stop 5 min, restart again 1 min and finally stop. I’ve tried the code and it didn’t work. Could you please have a look at the attached code and let me if I need to change something. I think I’ve not used the elapsed time function properly.
Best Regards
Rajab
you really dont need to repeat cases (2x)...using a shift register will reset your timer function once the timer has reached it's set limit. the "bool crossing" is used to tell me when the "5 min" case is done and increments the cycle count....ofcoarse, change the "seconds" constant to your desired time on the elapsed timer of this example
and you could "or" the stop to the "compare = 2" or change the select "wait" to "exit" with a constant connected to the stop
02-19-2014 11:30 AM
Hey apok
I really appreciate your help, please forgive my ignorance I just want to ask how can I connect my code with the one you've attached?? Is it going to be within my main while loop or the other way around?.
Sorry I've not done any programming before
thanks a lot
Rajab
02-19-2014 11:49 AM - edited 02-19-2014 11:50 AM
@Rajab84 wrote:
Hey @apok
I really appreciate your help, please forgive my ignorance
I just want to ask how can I connect my code with the one you've attached?? Is it going to be within my main while loop or the other way around?.
Sorry I've not done any programming before
thanks a lot
Rajab
the example code given should be your main code, place the data acquisitions within the case statements...