How to write IF statement for a servo positioner in group 2

  • Hello everyone,


    We are trying to move our servo positioner by a certain degrees repeatedly in clockwise direction, trying to put an IF statement in the sub program for the same, saying IF the positioner is in the range say 358deg to 2deg move to position P[2]. What's the correct syntax to write such statement?
    Does any of you have worked with servo positioners? Not sure what system variable is used to refer to current position in group 2 (servo positioner in our case) and how do we know the current position. Any direction in defining a certain position with servo positioner in a subprogram would help. Appreciate your time.


    Thank you,

  • AD
  • If it is just moving by a certain amount every time, regardless of where it is starting, i would use a position register and just add the degree change to the correct axis every iteration, then move to the position register's new location. You can use a single if then else statement to handle axis limits, if you aren't using a continuous rotation axis.

  • Use a position register to store JPOS.
    Then place the value for your positioner in a register.


    1: PR[8:Servo Pos]=JPOS ;
    2: R[9:Servo Pos]=PR[GP2:8,1:Servo Pos]


    Then you can use your IF statement to direct motion for the servo positioner based on the value in the register.
    3: IF R[9:Servo Pos]>358 OR R[9:Servo Pos]<2,JMP LBL[1] ;
    4: PR[GP2:8,1:Servo Pos]=PR[GP2:8,1:Servo Pos]+45 ;
    5:J PR[8:Servo Pos] 100% FINE ;
    6: LBL[1] ;


    In this case if the servo position is "in range" I have added 45 degrees of rotation.
    Now you have to resolve the condition for the servo position being "out of range" for motion perhaps set the position to zero or something, I don't know.


    6: LBL[1] ;
    7: PR[GP2:8,1:Servo Pos]=0 ;
    8:J PR[8:Servo Pos] 100% FINE


    Make sure to have the group mask set to group 2 only.

  • Do you know how to program the positioner to turn clockwise and then change direction for the rest of the cycle ?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now