Internet PLC Forum

General => Technical support => Topic started by: ckane on June 18, 2012, 10:57:12 AM

Title: Custom Function
Post by: ckane on June 18, 2012, 10:57:12 AM
I have the following code in a function.

SETLCD 1,1, STR$(CtrPV[1])
if CtrPV[1] = 0 then
   SETLCD 2,2, "Here"
   SETIO stop   
   stepmoveabs 1,0,5  'goto home position
   'CLRIO stop
   call Init  ' initialize all variables
   'CLRIO stop
   return
endif

stepmove 1, C, 4

The problem I am having is the SETIO stop operates the input so the motor stops, but I cannot turn that back off, even with a CLRIO stop.  

I want simulate the momentary action of the pushbutton to turn the motor off.  
Title: Re:Custom Function
Post by: support on June 18, 2012, 11:32:33 AM
Is "STOP" an input that triggers a custom function which run "STEPSTOP"?

If you want to run the custom function that is controlled by the "STOP" signal, simply CALL the custom function. SETIO will turn on the "STOP" I/O bit but until the ladder logic executes the custom function that is controlled by the "STOP" there is no effect on the stepper motor. By running SETIO STOP you are not stopping the motor at all.
Title: Re:Custom Function
Post by: ckane on June 18, 2012, 11:34:01 AM
STOP is an input.  Normally open pushbutton
Title: Re:Custom Function
Post by: ckane on June 18, 2012, 11:34:56 AM
The motr I am turning off is not the stepper motor, it is another motor with a normal start stop function.
Title: Re:Custom Function
Post by: support on June 18, 2012, 12:00:16 PM
What is the label name of the output that controls the motor? You might as well simply turn off the output bit that control the motor?

E.g. CLRIO  MOTOR   ' assuming output that drives motor is called "MOTOR"

When you run SETIO STOP  it won't turn off the 'MOTOR' bit at this point until after current function has ended and the ladder logic resume scanning until the STOP input has been processed.
Title: Re:Custom Function
Post by: ckane on June 18, 2012, 12:33:03 PM
attached is code and ladder
Title: Re:Custom Function
Post by: support on June 18, 2012, 01:50:41 PM
It appears that your STOP input is meant to clear the "Start_Relay" bit and the "Start_Relay" bit is meant to clear the "Blower" output.  So you can run

CLRIO Start_Relay
CLRIO BlowerStart
REFRESH   ' see *note below

*Note: that if your STEPMOVEABS can only run on the condition that the the BlowerStart has been turned OFF, then you should run the REFRESH command once after the CLRIO commands to ensure that the physical output are updated immediately.