Sign in to follow this  
Followers 0
ravi.joshi53

Using time as a variable in TwinCAT 2 PLC

3 posts in this topic

Hi, I am trying to run the Beckhoff Motor (reference velocity 900mm/s and maximum velocity 810mm/) in a sinusoidal trajectory. Following is the snippet of the PLC code- (* Joint 2 is using the external set point generator functionality *)ExtPosition := theta_max*COS(omega*t); (* t is time in second *)ExtVelocity := -theta_max*omega*SIN(omega*t);ExtAcceleration := -omega*omega*theta_max*COS(omega*t);IF ExtVelocity=0 AND ExtAcceleration=0 THEN ExtDirection := 0; (* stand still *)ELSIF ExtVelocity >= 0 THEN ExtDirection := 1; (* positive motion *)ELSE ExtDirection := -1; (* negative motion *)END_IFt:=t+0.01; (* The task is called at every 10 ms = 0.01sec *)(* feed the dynamic data into the external setpoint generator interface of axis *)MC_ExtSetPointGenFeed( Position := ExtPosition, Velocity := ExtVelocity, Acceleration := ExtAcceleration, Direction := ExtDirection, Axis := Joint_2);The global constants are defined as following- VAR_GLOBAL CONSTANT theta_max: INT := 60; (* in degree *) omega: REAL := 0.62; (* 2PI/Time Period=10sec *)END_VARWhen I set Position Lag Monitoring to TRUE, I get error 17744(0x4550). When Position Lag Monitoring is set to FALSE, the motor moves but not continuous. Also the motion is neither smooth nor instantaneous. I think the way, I am using time variable t is not correct. Somebody please help me to overcome with this problem. Edited by ravi.joshi53

Share this post


Link to post
Share on other sites
Okay, you 177744 is a following error - Meaning your target position is outside the range of the estimated position. First check on you TwinCAT System Manager by clicking on axis to see what size of window is set. Adjusting that window should help a little bit. Also you can set your Jerk (m/s2/s) to have a smoother movement.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0