Prevent Init Button from being pressed twice.

Moderators: TomKerekes, dynomotion

Post Reply
Roamin
Posts: 25
Joined: Tue Dec 13, 2022 10:34 pm

Prevent Init Button from being pressed twice.

Post by Roamin » Tue Jan 10, 2023 3:42 pm

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!

User avatar
TomKerekes
Posts: 2546
Joined: Mon Dec 04, 2017 1:49 am

Re: Prevent Init Button from being pressed twice.

Post by TomKerekes » Tue Jan 10, 2023 6:36 pm

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
Regards,

Tom Kerekes
Dynomotion, Inc.

ajith
Posts: 65
Joined: Sat May 21, 2022 3:57 am
Location: TamilNadu

Re: Prevent Init Button from being pressed twice.

Post by ajith » Sat Jan 14, 2023 5:24 am

Dear sir
I have been also required the same option to prevent the reinitialization.
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.
May i Know the persist Variable that you are mentioning.

User avatar
TomKerekes
Posts: 2546
Joined: Mon Dec 04, 2017 1:49 am

Re: Prevent Init Button from being pressed twice.

Post by TomKerekes » Sat Jan 14, 2023 4:59 pm

Any persist variable you are not using for something else.
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply