Hi Tom,
Before I get back to tuning I was cleaning up some safety logic in our code. I'm looking for a way to have the "Init" button disabled after being pressed once. I tried using a persist variable , but since it's initialized before my routine, pressing Init once more re-initializes that variable and so I cannot use it to prevent a second Init to happen. If Init is pressed a second time, my machine bugs (partly because it re-inits the axes and affects my tachometer logic).
Any clever way to disable a button from being used again? Maybe there's code to send a .c file to another thread and then use the "startthread(n)" function to start that thread?
Thanks for your tips!
Prevent Init Button from being pressed twice.
Moderators: TomKerekes, dynomotion
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Prevent Init Button from being pressed twice.
Hi Roamin,
I would fix whatever the problem is with re-initializing.
I would think there would be cases where you would want to re-initialize. ie after a crash.
You could disable any axis, disable the Tach operation, perform the Init, re-initialize stuff, then resume the Tach Operation.
If you got rid of the 2nd Thread I think this would workout fairly naturally. First disable your Amplifiers (if case they are on), perform the Init, initialize your Tach Code, and begin looping.
But if you still want to disable the Init button, because persist variables are cleared on power up, then you might check if a variable is 0 and if so Initialize. After a successful Initialization set the persist variable to non zero.
HTH
I would fix whatever the problem is with re-initializing.
I would think there would be cases where you would want to re-initialize. ie after a crash.
You could disable any axis, disable the Tach operation, perform the Init, re-initialize stuff, then resume the Tach Operation.
If you got rid of the 2nd Thread I think this would workout fairly naturally. First disable your Amplifiers (if case they are on), perform the Init, initialize your Tach Code, and begin looping.
But if you still want to disable the Init button, because persist variables are cleared on power up, then you might check if a variable is 0 and if so Initialize. After a successful Initialization set the persist variable to non zero.
HTH
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.
Re: Prevent Init Button from being pressed twice.
Dear sir
I have been also required the same option to prevent the reinitialization.
I have been also required the same option to prevent the reinitialization.
May i Know the persist Variable that you are mentioning.But if you still want to disable the Init button, because persist variables are cleared on power up, then you might check if a variable is 0 and if so Initialize. After a successful Initialization set the persist variable to non zero.
- TomKerekes
- Posts: 2676
- Joined: Mon Dec 04, 2017 1:49 am
Re: Prevent Init Button from being pressed twice.
Any persist variable you are not using for something else.
Regards,
Tom Kerekes
Dynomotion, Inc.
Tom Kerekes
Dynomotion, Inc.