s Curve Function Block Using Simple Plc
s Curve Function Block Using Simple Plc
net/publication/361437580
CITATIONS READS
0 482
1 author:
Kamlesh Chaudhari
L.B bohle
31 PUBLICATIONS 10 CITATIONS
SEE PROFILE
All content following this page was uploaded by Kamlesh Chaudhari on 21 June 2022.
Motion control engineers spend hours optimizing tuning parameters for their servo-based motion
controllers. But what if they are using step motors? And what if, no matter how much time they
spend on tuning, they can’t get the performance they want? The answer, for many systems, is to
focus on the motion profile instead. In the past ten years advanced profiling features such as
asymmetric acceleration/deceleration, 7-segment S-curve profiling, change-on-the-fly, and electronic
camming have become widely available, providing engineers with new tools to make machines work
faster and better. This article will take you through the mathematics of motion profiles, discuss which
profiles work best for which applications, and provide insights into how to “tune” your profile for
maximum performance.
In the context of a point-to-point move, a full S-curve consists of 7 distinct phases of motion. Phase 1
starts moving the load from rest at a linearly increasing acceleration until it reaches the maximum
acceleration. In phase II. the profile accelerates at this max. acceleration rate until it must start
decreasing as it approaches the max. velocity. This occurs in phase III when the acceleration linearly
decreases until it reaches zero. In phase IV the velocity is constant until deceleration begins, at which
point the profiles decelerates in a manner symmetric to phases I, II and III.
A trapezoidal profile, on the other hand, has 3 phases. It is a subset of an S-curve profile, having only
the phases corresponding to #2 of the S-curve profile (constant acceleration), #4 (constant velocity),
and #6 (constant deceleration). This reduced number of phases underscores the difference between
these two profiles: The S-curve profile has extra motion phases which transition between periods of
acceleration,
1. PLC Program
Frist calculate Velocity, Acceleration, deceleration Using Below Formula
//Total Time
//Acc Time
//Dec Time
//Distance
Velocity:=Distance/((Tacc/2)+(Tdec/2)+(Ttotal -(Tacc+Tdec)));
Velocity_GVL:=Velocity;
IF Tacc<> 0 THEN
Acceleration:=(Velocity/Tacc)/(1-Jerk_Percent/200);
Acceleration_GVL:=Acceleration;
ELSE
Acceleration:=0;
END_IF;
IF Tdec<>0 THEN
Deceleration:=(Velocity/Tdec)/(1-Jerk_Percent/200);
ELSE
Deceleration:=0;
END_IF;
IF Acceleration<>0 THEN
Acceleration_Dst:=(EXPT(Velocity,2))/(2*Acceleration*(1-Jerk_Percent/200));
ELSE
Acceleration_Dst:=0;
END_IF;
IF Deceleration<>0 THEN
Deceleration_Dst:=(EXPT(Velocity,2))/(2*Deceleration*(1-Jerk_Percent/200));
ELSE
Deceleration_Dst:=0;
END_IF;
Constant_Dst:=(Distance-(Acceleration_Dst+Deceleration_Dst));
Jerk:=(EXPT(Acceleration,2)/Velocity)*((200/Jerk_Percent)-1);
Jerk_GVL:=Jerk;
Jerk_Time:=(Acceleration-0)/Jerk;
Jerk_Time_GVL:=Jerk_Time;
Jerk:=(EXPT(Deceleration,2)/Velocity)*((200/Jerk_Percent)-1);
Jerk_Time:=(Deceleration-0)/Jerk;
ELSE
Jerk:=0;
Jerk_Time:=0;
END_IF;
Movement_Time:=Ttotal;
JRound:=LREAL_TO_REAL(Jerk_Time);
IF (Tacc>Tdec) THEN
IF JRound>=Tdec THEN
Movement_Time_NJ:=Movement_Time+JRound;
ELSE
Movement_Time_NJ:=Movement_Time+(JRound/2);
END_IF;
ELSE
Movement_Time_NJ:=Movement_Time;
END_IF;
rStep:=0.01; //Put here your scanTime, if you wont you can put as input param
CASE mStage OF
0: //Initial Case
OutBusy:=FALSE;
OutDone:=FALSE;
IF xExecute THEN
CalcVelocity(Ttotal:= TTotal,Tacc:=TAcc , Tdec:=TDec , Distance:=
RelativeDist, Jerk_Percent:=JerkPercent ,
Velocity=> mVelOut,
Acceleration=> mAccOut,
Deceleration=> mDecOut,
Jerk=> mOutJerk,
Jerk_Time=> mOutJerkTime ,
Acceleration_Dst=> ,
Deceleration_Dst=> ,
Constant_Dst=> ,
Movement_Time=> );
xkey:=TRUE;
mStage:=1;
END_IF
3. PLC CYCLE TIME Adaption
m_Time_In:=Rounded;
m_nScans:=m_Time_In/ScansSg;
m_IntScans:=LREAL_TO_DINT(m_nScans);
Rounded:=m_IntScans*ScansSg;
4. PART 1 OR PHASE 1 Calculation
1:
OutBusy:=TRUE;
IF xkey THEN
rTime:=rStep;
xkey:=FALSE;
END_IF
CASE (ProfileStage) OF
0: //Acc
IF (rTime < TAcc) THEN //AccStage
OutVel := OutVel + (OutAcc*rStep);
CASE (accStage) OF
0: //Phase 1
IF (rTime < mJerkTimeAcc)THEN
OutAcc := mJerkAcc * rTime;
ELSE
OutAcc := mAccOut;
IF(mJerkTimeAcc * 2.0 = TAcc) THEN
accStage :=2;
rTimeAccConst :=mJerkTimeAcc;
ELSE
accStage:=1;
END_IF;
END_IF;
5. PART 2 OR PHASE 2 Calculation
1: //Phase 2
rTimeAccConst:=TAcc - mJerkTimeAcc;
ScanAdapt(ScansSg:=rTimeAccConst , Rounded:=
rTimeAccConst);
IF (rTime>=rTimeAccConst) THEN
accStage:=2;
END_IF
2: //Phase 3
OutAcc:=mAccOut -mJerkAcc*(rTime -
rTimeAccConst);
END_CASE
ELSE
OutAcc:=0;
//Cnst
ProfileStage := 1;
ELSE
//Dec
ProfileStage := 2;
END_IF
END_IF
2: //Dec
rTimeDec:=rTimeDec + rStep;
ScanAdapt(ScansSg:=rTimeDec , Rounded:= rTimeDec);
OutVel:=OutVel + (OutAcc * rStep);
CASE (decStage) OF
0://Phase 5
IF(rTimeDec <mJerkTimeDec) THEN
OutAcc:= - mJerkDec * rTimeDec;
ELSE
OutAcc:=-mDecOut;
IF(mJerkTimeDec*2.0 = TDec) THEN
decStage:=2;
rTimeAccConst:=mJerkTimeDec;
ELSE
decStage:=1;
END_IF
END_IF
9. PART 6 OR PHASE 6 Calculation
1://Phase 6
rTimeAccConst: =TDec - mJerkTimeDec;
ScanAdapt(ScansSg:=rTimeAccConst , Rounded:=
rTimeAccConst);
OutAcc:=-mDecOut;
IF(rTimeDec>=rTimeAccConst) THEN
decStage:=2;
END_IF
10. PART 7 OR PHASE 7 Calculation
2://Phase 7
OutAcc:=-(mDecOut -mJerkDec *(rTimeDec
-rTimeAccConst));
END_CASE
END_CASE
OutPos:= OutPos +(OutVel*rStep);
11. END OF Calculation
IF rTime> rTend THEN
OutPos:=RelativeDist;
OutVel:=0;
OutAcc:=0;
OutBusy:=FALSE;
OutDone:=TRUE;
mstage:=2;
END_IF;
2:
OutDone:=TRUE;
END_CASE
RESULT3
14. APPLY THIS SOLUTION TO PLC BLOCK
View publication stats