Hello Guest it is April 23, 2024, 09:31:46 AM

Author Topic: Where to put cycle/start script?  (Read 627 times)

0 Members and 1 Guest are viewing this topic.

Where to put cycle/start script?
« on: December 09, 2020, 10:54:34 AM »
Hi all,

I added some code to my spindle start button to check a couple of things before being able to manually start the spindle. Basically checking for a door switch to be closed. Code below:

Code: [Select]
local inst = mc.mcGetInstance() --new
if(mc.ISIG_INPUT5) and (state == 1) then -- need to map door switches to input 5...NPN input, so use ground and map input to active LOW
-- if the state is high then throw and error and exit
mc.mcCntlSetLastError(inst, "Error: Make sure doors are closed before attempting to start spindle") -- mew
do return end
else
SpinCW() -- original...this line only
end

I've got it in the the 'Left Up Script' where the factory 'SpinCW()' command is. Unfortunately, the code I added doesn't seem to do anything. I can start the spindle regardless of the state of this switch. Is this the correct location for this script or should it be somewhere else?

Re: Where to put cycle/start script?
« Reply #1 on: December 09, 2020, 10:58:56 AM »
The SpinCW() is a function that lives in the screen load script. 
If you want to add a conditional statement for the spindle, you'll need to add that condition into the spindle function in the screen load script.
Make the changes to the Function in the screen load script and then change your button back to the original code.
You will probably need to add it to the SpinCCW() function as well if your spindle can spin CCW.
Chad Byrd
Re: Where to put cycle/start script?
« Reply #2 on: December 09, 2020, 11:18:38 AM »
Thanks Chad. So, I assume I would do the same for CycleStart()? Basically, I want to prevent cycle start and any manually activated spindle functions if the doors are open. I'll move my code into the functions in the screen load script and go from there. Thanks!
Re: Where to put cycle/start script?
« Reply #3 on: December 09, 2020, 11:23:42 AM »
Yeah.  Just add a condition to your functions.  Be sure to have all your ducks in a row as far as your if...and ends... lined up correctly.
Chad Byrd
Re: Where to put cycle/start script?
« Reply #4 on: December 09, 2020, 12:13:04 PM »
Thanks again, Chad! I got everything working.