Python Script(Spindle)

How to write a script to make the spindle rotate forward, reverse and stop according to the signal

  • You can implement the function by modifying the following code

if sensorSignal(Customize the signal name).Value==True:
servo.setJointTarget(0,1400)
servo.setMotionTime( 6.0 )
servo.move()

I want the spindle to keep rotating after receiving the signal, not just for a few seconds.
What do i need to do?

Hi,

Instead of IF, you can use WHILE to have continues rotation.

  rot = 360.0
  t = 1.0
   while sensorSignal(Customize the signal name).Value==True
    servo.setJointTarget(0, rot)
    servo.setMotionTime(t)
    servo.move()
    servo.setJointTarget(0,0)
    servo.moveImmediate()

  • Why stop at this step and not proceed?

You need to have that inside a While True loop. Now the program exits if the signal is False.

initialize...
while True:
    while sensorSignal...
        servo...
    else:
        delay..