aoi_camm - connect with earthlink, the award …philipp/application technique aoi... · web viewthe...

23
Application Technique Studio 5000 Add-On Instructions Add-On Instruction: CAM MultiSelect - AOI_CAMM (Rev 3) OVERVIEW This Add-On Instruction generates a CAM Profile with multiple motion segments where each motion segment is specified by a selectable number of CAM Points.. Each motion segment has its own selectable calculated motion profile type. The types include Linear and Cubic which are native to the CAM Profile as well as 5th Order Polynomial, 7th Order Polynomial, 9th Order Polynomial, Simple Harmonic, and Epicyclical. The final result of AOI_CAMM is all of the information needed to feed an MCCP instruction so your MCCP instruction can be executed at the time of your choosing. BENEFITS Quickly generate complex motion profiles given application constraints avoiding or minimizing acceleration and jerk. BACKGROUND The CAM data type consists of .Slave and .Master point pairs, as well as an interpolation .Type (0 = linear, 1 = cubic) as its three data Members. A CAM profile is represented by an array of CAM elements. Data can be entered directly into the Cam Editor or written there programmatically.

Upload: dangthuy

Post on 29-May-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

Application Technique

Studio 5000 Add-On Instructions

Add-On Instruction: CAM MultiSelect - AOI_CAMM (Rev 3)

OVERVIEW

This Add-On Instruction generates a CAM Profile with multiple motion segments where each motion segment is specified by a selectable number of CAM Points.. Each motion segment has its own selectable calculated motion profile type. The types include Linear and Cubic which are native to the CAM Profile as well as 5th Order Polynomial, 7th Order Polynomial, 9th Order Polynomial, Simple Harmonic, and Epicyclical. The final result of AOI_CAMM is all of the information needed to feed an MCCP instruction so your MCCP instruction can be executed at the time of your choosing.

BENEFITS

Quickly generate complex motion profiles given application constraints avoiding or minimizing acceleration and jerk.

BACKGROUND

The CAM data type consists of .Slave and .Master point pairs, as well as an interpolation .Type (0 = linear, 1 = cubic) as its three data Members. A CAM profile is represented by an array of CAM elements. Data can be entered directly into the Cam Editor or written there programmatically.

Page 2: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

Motion Calculate Cam Profile (MCCP) instruction uses Start Slope and End Slope operands to facilitate a smooth entry into and exit from a cubic cam profile. The Start Slope and End Slope parameters determine the initial rate of change of the slave relative to the master. These values are used in the cubic spline calculations performed on the CAM array. These two values can be set in the Cam Editor. Cam_Profile data type cannot be written to programmatically, the MCCP must be used.

DESCRIPTION

The CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile made up of motion segments that are defined by Via Point information in a data structure similar in nature to the CAM data type. AOI_CAMM builds a CAM[] array from the data available in Via_Point[] array. The Via_Point structure is a User-Defined data type consisting of eleven data members.

A Via_Point is similar to a CAM point in that it consists of .Slave_Position and .Master_Position point pairs, as well as an interpolation .SegmentType. Via_Point also includes .Slave_Velocity which is similar to the start slope operand in the MCCP instruction. What makes Via_Point different is that the .Slave_Velocity (change in slave position per change in master position) can be constrained or defined for each segment's start and end when using 5th order, 7th order, 9th order or Epicyclical segment types.

Similarly to attain even smoother motions .Slave_Acceleration (change in slave velocity per change in master position) can be constrained or defined for each segment's start and end when using 5th order, 7th order or 9th order types. .Slave_Jerk (change in slave acceleration per change in master position) can be constrained or defined for each segment's start and end when using 7th order or 9th. .Slave_Snap (change in slave jerk per change in master position) can be constrained or defined for each segment's start and end when using 9th order polynomial interpolation type. Crackle and Pop are not used but their place is reserved for 11th order and 13th order respectively if later implemented.

Page 3: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

What's different about Via_Point data structure is that it also includes members- .Steps and .Cycles

AOI_CAMM builds a CAM[] array from the data available in Via_Point[] array. There is a CAM entry for every Via_Point entry. There are additional CAM entries in the CAM[] array corresponding to the number of step specified in each Via_Point[].Steps entry. .Steps determines the number of CAM segments for its Via_Point segment. .Cycles is the number of periods generated by an Epicyclical segment and is only relevant to Epicyclical segment type.

When AOI_CAMM is used in a program its instruction must be uniquely identified, a CAM array, Via_Point array, Length, Start_Slope, and End_Slope tags must be included as operands to the instruction. The CAM array, Length, Start_Slope, and End_Slope will be overwritten by the AOI. The Via_Point array is unchanged by this AOI.

Operand Type Format DescriptionAOI_CAMM CAM MultiSelect Tag AOI to generate complex cams with multiple interpolated segments.My_CAM CAM Array Tag name of the cam array used as the resultant of the AOI_CAMM instruction. Ellipsis

launches Cam Profile Editor.

Interpolation_ViaPoint Via_Point Array Tag name of the Via_Point array used as input to the AOI_CAMM instruction.Length INT Immediate

or Tag This value is calculated by the AOI to be later used in the Length operand of a MCCP instruction. It is the number of CAM elements populated in the My_CAM Array by this AOI.

Start_Slope REAL Immediate or Tag This value is calculated by the AOI to be later used in the StartSlope operand of a MCCP

instruction. This is the boundary condition for the initial slope of the profile.

End_Slope REAL Immediate or Tag

This value is calculated by the AOI to be later used in the EndSlope operand of a MCCP instruction. This is the boundary condition for the ending slope of the profile.

Page 4: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

Here is a table representing the Via_Point data structure and the corresponding CAM generated by AOI_CAMM.

" x " in the Via_Point table means that AOI_CAMM is not using the members per the selection of SegmentType.

You can see what happens when the number of steps is increased from 1 to 7. Six CAM points are added to the CAM profile. Linear and Cubic segment types are native to CAM data type and its functionality remains unchanged. For detailed information regarding Linear and Cubic Types consult Studio 5000 instruction documentation.

When .SegmentType = 0 and .Steps > 1 then the AOI will calculate and populate .Slave_Velocity in the data table overwriting anything that was there.

Via_Point[ ] 0 1 2

.Master_Position 0 180 360

.Slave_Position 0 180 360

.Slave_Velocity x x x

.Slave_Acceleration x x x

.Slave_Jerk x x x

.Slave_Snap x x x

.Slave_Crackle x x x

.Slave_Pop x x x

.Cycles x x x

.SegmentType 0 0 0

.Steps 1 1 x

Via_Point[ ] 0 1 2

.Master_Position 0 180 360

.Slave_Position 0 180 360

.Slave_Velocity 1 x x

.Slave_Acceleration x x x

.Slave_Jerk x x x

.Slave_Snap x x x

.Slave_Crackle x x x

.Slave_Pop x x x

.Cycles x x x

.SegmentType 0 0 0

.Steps 7 1 x

Page 5: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

Via_Points[ ] 0 1 2 3 4 5

.Master_Position 0 4.5 16.5 21 27 33

.Slave_Position 0 3 15 18 9 0

.Slave_Velocity 0 1 1 0 -2.3 0

.Slave_Acceleration 0.4 0 0 -0.4 0 0.4

.Slave_Jerk x x x x x x

.Slave_Snap x x x x x x

.Slave_Crackle x x x x x x

.Slave_Pop x x x x x x

.Cycle x x x x x x

.SegmentsType 3 0 3 3 3 1

.Steps 5 1 5 5 5 x

MOTION PROFILES

The motion profiles beyond Linear and Cubic that supported by this AOI_CAMM instruction are described below.

5th Order Polynomial

The 5th order polynomial position profile satisfies the fundamental law of cam design which states that the velocity and acceleration profiles must be continuous at the boundaries of the position profile. It is desirable that acceleration is minimized over each segment and overall. With 5th order Jerk is not continuous at the boundaries of the motion profile which may result in some mechanical vibration or bump.

Here is an example profile is a reciprocating machine where the slave accelerates to match the speed of the master, holds that speed for a duration then decelerates to a stop, reverses direction, returns to the start and repeats the cycle. .Slave_Acceleration values are chosen to minimize acceleration over the segment and the rest of the profile, as well as to minimize jerk.

Application example:Master Cycle = 33"Max positive travel of the Slave = 18"Distance Slave needs to match speed with the Master = 12".Distance the slave has to accelerate and decelerate is 3" = (18-12)/2 = SfMaster travel during acceleration is 1.5*3" = 4.5" = Mf Likewise for deceleration.Smooth initial slave acceleration is calculated SQRT( (1/Mf)^2 + (1/Sf)^2) = 0.4-0.4 is used for the deceleration. 0.4 is used at the end so that the acceleration is continuous for the next cycle.

Page 6: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

Via_Points[ ] 0 1 2 3 4 5

.Master_Position 0 4.5 16.5 21 27 33

.Slave_Position 0 3 15 18 9 0

.Slave_Velocity 0 1 1 0 -2.3 0

.Slave_Acceleration 0.40 0 0 -0.40 0 0.40

.Slave_Jerk -0.09 0 0 -0.18 0 -0.09

.Slave_Snap x x x x x x

.Slave_Crackle x x x x x x

.Slave_Pop x x x x x x

.Cycle x x x x x x

.SegmentsType 4 0 4 4 4 1

.Steps 7 1 7 7 7 x

7th Order Polynomial

The 7th order polynomial position profile satisfies the condition that velocity, acceleration, and jerk profiles are continuous at the boundaries. Snap, the derivative of Jerk is not continuous.

Here is the same example profile is a typical reciprocating machine where the slave accelerates to match the speed of the master, holds that speed for a duration then decelerate to a stop, reverses direction, returns to the start and repeats the cycle. .Slave_Acceleration and .Slave_Jerk values are chosen to minimize acceleration over the segment and the rest of the profile as well as to minimize jerk.

Application Example: Same as 5th order with Initial Jerk is calculated to be -2.75*Sf/Mf^3 = -0.09 Final Jerk matches initial Jerk. Jerk in the middle is double = -0.18

Page 7: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

Via_Points[ ] 0 1 2

.Master_Position 0 180 360

.Slave_Position 0 41 0

.Slave_Velocity 0 0 0

.Slave_Acceleration 0.00583 -0.00583 0.00583

.Slave_Jerk -0.00000703 0.00000703 -0.00000703

.Slave_Snap 0 0 0

.Slave_Crackle x x x

.Slave_Pop x x x

.Cycle x x x

.SegmentsType 4 4 1

.Steps 11 11 x

9th Order Polynomial

The 9th order polynomial position profile satisfies the condition that velocity, acceleration, jerk and snap profiles are continuous at the boundaries. Crackle, the derivative of Snap is not continuous.

Here is an example profile is a simple reciprocating machine where the slave simply moves back and forth 41 units. .Slave_Acceleration and .Slave_Jerk values are chosen to minimize acceleration over the segment and the rest of the profile as well as to minimize jerk. .Slave_Snap values can also be determined or simply set to zero.

Page 8: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

Simple Harmonic Motion

The Simple Harmonic Motion (SHM) also called Sine velocity profile is an alternative to improve the motion smoothness of a mechanical load. Although, acceleration and jerk are smooth throughout the move, jerk is infinite at the beginning and end of the move which may result is undesirable mechanical load performance and vibration. However, the peak velocity and peak acceleration are lower than the other profiles shown here.

Here is the same example profile of the simple reciprocating machine where the slave simply moves back and forth 41 units. Only the .Master_Position and .Slave_Position data members alter the profile. When compared to the 9th order above, the SHM has higher acceleration and lower velocity.

.Cycle data member for this segment type is necessary for SHM as explained in the next example, Elliptical Motion. SHM is a special case of Elliptical Motion where the .Cycle data member is set to 0.

Elliptical Motion

The Elliptical Motion is a general solution where Simple Harmonic Motion (SHM) is a special case where .Cycle data member is set to 0. The .Cycle data member represents the percent difference between the square of height of the ellipse and the square of its width (major and minor axes). If the height and width are the same then the percent difference is 0 and that is Simple Harmonic. Proper proportions in the ratio between major and minor axes produce cams of acceptable performance at moderate speeds similar to those of the simple harmonic motion curve. The cam appears to have acceleration discontinuity at the beginning and end of the motion however since the two end points have the same value, during continuous motion of the master the slave acceleration it is continuous at the boundaries.

.Cycle data member should be less than 1 and greater than -1.

Page 9: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

Via_Points[ ] 0 1 2

.Master_Position 0 180 360

.Slave_Position 0 41 0

.Slave_Velocity x x x

.Slave_Acceleration x x x

.Slave_Jerk x x x

.Slave_Snap x x x

.Slave_Crackle x x x

.Slave_Pop x x x

.Cycle -0.3 -0.3 x

.SegmentsType 5 5 1

.Steps 11 11 x

Elliptical and Simple Harmonic MotionSince acceleration does not return to zero, this profile can be coupled with itself in an immediate return application.

.Cycle = 0.3

.Cycle = 0

.Cycle = -0.3

Via_Points[ ] 0 1 2

.Master_Position 0 180 360

.Slave_Position 0 41 0

.Slave_Velocity x x x

.Slave_Acceleration x x x

.Slave_Jerk x x x

.Slave_Snap x x x

.Slave_Crackle x x x

.Slave_Pop x x x

.Cycle 0 0 x

.SegmentsType 5 5 1

.Steps 11 11 x

Via_Points[ ] 0 1 2

.Master_Position 0 180 360

.Slave_Position 0 41 0

.Slave_Velocity x x x

.Slave_Acceleration x x x

.Slave_Jerk x x x

.Slave_Snap x x x

.Slave_Crackle x x x

.Slave_Pop x x x

.Cycle 0.3 0.3 x

.SegmentsType 5 5 1

.Steps 11 11 x

Page 10: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

Epicyclical Motion

The Epicyclical Motion profile is the only profile in the group that uses the .Cycles data member. It also uses .Slave_Velocity but none of the other profile modifiers. When .Cycles = 1 this profile is the same as Cycloidal. It is a sine acceleration profile. Since acceleration returns to zero, this profile is best coupled with a dwell, not with itself in an immediate return application. When .SegmentType = 6 and .Cycles = 0 then the AOI will change the 0 to a 1 in the data table.

When .Cycles > 1 the motion repeats that many times over the Via_Point segment.

Velocity can also be adjusted. In this case be sure to set the start slope and end slope MCCP to .Slave_Velocity

Via_Point[ ] 0 1

.Master_Position 0 1

.Slave_Position 0 1

.Slave_Velocity 0 0

.Slave_Acceleration x x

.Slave_Jerk x x

.Slave_Snap x x

.Slave_Crackle x x

.Slave_Pop x x

.Cycles 1 x

.SegmentType 6 x

.Steps 20 x

Via_Point[ ] 0 1

.Master_Position 0 1

.Slave_Position 0 1

.Slave_Velocity 0 0

.Slave_Acceleration x x

.Slave_Jerk x x

.Slave_Snap x x

.Slave_Crackle x x

.Slave_Pop x x

.Cycles 3 x

.SegmentType 6 x

.Steps 20 x

Via_Point[ ] 0 1

.Master_Position 0 1

.Slave_Position 0 1

.Slave_Velocity 0.25 0.25

.Slave_Acceleration x x

.Slave_Jerk x x

.Slave_Snap x x

.Slave_Crackle x x

.Slave_Pop x x

.Cycles 3 x

.SegmentType 6 x

.Steps 20 x

Page 11: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

Via_Points[ ] 0 1

.Master_Position 0 1

.Slave_Position 0 1

.Slave_Velocity x x

.Slave_Acceleration x x

.Slave_Jerk x x

.Slave_Snap x x

.Slave_Crackle x x

.Slave_Pop x x

.Cycle x x

.SegmentsType 7 x

.Steps 20 x

Since Velocity can be adjusted for Epicyclical, the segment can be placed in the middle of the profile. In this example there are four cycles interpolated into matching linear speed segments. In this case be sure to set the start slope and end slope MCCP to .Slave_Velocity

Double Harmonic

The Double Harmonic is best high-speed curve, from the standpoint of slow starting and stopping action and no abrupt change in acceleration. This asymmetrical curve is composed of the difference between two harmonic motions, one being one-quarter of the amplitude and twice the frequency of the other. It has the advantages of the simple harmonic curve with almost complete elimination of the high shock and vibration at the beginning of the stroke. The rate of acceleration change at the beginning of the stroke is small, giving smooth action at the point. Since acceleration begins with zero, this profile is best coupled with a dwell or with another index, not with itself in an immediate return or reciprocating application.

Via_Point[ ] 0 1 2 3

.Master_Position 0 10 90 100

.Slave_Position 0 2 58 60

.Slave_Velocity 0.2 0.2 0.2 0.2

.Slave_Acceleration x x x x

.Slave_Jerk x x x x

.Slave_Snap x x x x

.Slave_Crackle x x x x

.Slave_Pop x x x x

.Cycles x 4 x x

.SegmentType 0 6 0 0

.Steps 1 20 1 x

Page 12: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

Via_Points[ ] 0 1

.Master_Position 0 1

.Slave_Position 0 1

.Slave_Velocity x x

.Slave_Acceleration x x

.Slave_Jerk x x

.Slave_Snap x x

.Slave_Crackle x x

.Slave_Pop x x

.Cycle x x

.SegmentsType 9 x

.Steps 20 x

Via_Points[ ] 0 1

.Master_Position 0 1

.Slave_Position 0 1

.Slave_Velocity x x

.Slave_Acceleration x x

.Slave_Jerk x x

.Slave_Snap x x

.Slave_Crackle x x

.Slave_Pop x x

.Cycle x x

.SegmentsType 8 x

.Steps 20 x

Modified Sine

The modified sine curve is a combination of quarter sine wave curves. In terms of its torsional action, the change from positive to negative torque occurs in over 40 percent of the travel time. This attribute makes this curve attractive as a choice in applications with high load inertias such as moving large masses in indexing applications. Since acceleration begins with zero, this profile is best coupled with a dwell or with another index, not with itself in an immediate return or reciprocating application.

Modified Trapezoid

Cuts a sine wave into three pieces and recombines them with a square wave. Modified Trapezoid is piecewise continuous. Since acceleration begins with zero, this profile is best coupled with a dwell or with another index, not with itself in an immediate return or reciprocating application.

Page 13: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

The final result of AOI_CAMM is all of the information needed to feed an MCCP instruction so your MCCP instruction can be executed at the time of your choosing.

Additional Notes

The Cubic profile in the CAM data type is a recursive algorithm that considers all of the consecutive Cubic profile segments. For the advanced profiles Cubic Type is selected for the cam segments. The more Steps requested in the Via_Point segment the closer cubic spline approximates the higher order method. This is why, in the above examples, I chose to use 5 points for the 5th order interpolation, 7 points for the 7th order etc. Modified Sine and Modified Trapezoid divides the curve into 8 parts so more than 8 points should be used in those segments.

For more information on Cam Design and differences between the different profile types consult the following:

Cam Design Handbook - H. Rothbart (2004)

AOI_MACM Rockwell Sample Code website developed by Aderiano da Silva

Cam Design – Clyde H. Moon (1961)

Page 14: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

// This AOI uses Linear, Cubic, 5th, 7th, or 9th order polynomial interpolation // as well as Elliptical which Simple Harmonic is a special case, // Epicyclic which Cycloidal is a special case, // Double Harmonic, Modified Sine, or Modified Trapezoid,// to calculate slave positions as a function of equally spaced master positions.// This AOI allows user to select the number of interpolation positions between via points.// The result of this AOI is a CAM, its Length, Start Slope and End Slope ready to be used as inputs to a MCCP instruction.//// Copyright Timothy Philipp 2016

SIZE(My_CAM,0,Cam_Size);

// Count the number of interpolation segments in data arraySIZE(Interpolation_ViaPoint,0,Index);Last_Segment:=1;FOR Segment := 1 TO (Index-1) BY 1 DO

IF Interpolation_ViaPoint[Segment].Master_Position > 0 THENLast_Segment := Segment;

END_IF;END_FOR;

// Calculate Step i.e. the master position increment to fill up the cam tableMaster_Cycle := Interpolation_ViaPoint[Last_Segment].Master_Position;Slave_Cycle := Interpolation_ViaPoint[Last_Segment].Slave_Position;

Index := 0;FOR Segment := 1 TO Last_Segment BY 1 DO

i:= Segment-1;f := Segment;

Mi := Interpolation_ViaPoint[i].Master_Position;Mf := Interpolation_ViaPoint[f].Master_Position;Si := Interpolation_ViaPoint[i].Slave_Position;Vi := Interpolation_ViaPoint[i].Slave_Velocity;Ai := Interpolation_ViaPoint[i].Slave_Acceleration;Ji := Interpolation_ViaPoint[i].Slave_Jerk;ni := Interpolation_ViaPoint[i].Slave_Snap;Sf := Interpolation_ViaPoint[f].Slave_Position;Vf := Interpolation_ViaPoint[f].Slave_Velocity;Af := Interpolation_ViaPoint[f].Slave_Acceleration;Jf := Interpolation_ViaPoint[f].Slave_Jerk;nf := Interpolation_ViaPoint[f].Slave_Snap;

CASE Interpolation_ViaPoint[i].SegmentType OF// Linear0: a0 := Si;IF Interpolation_ViaPoint[i].Steps > 1 THEN // Override User Velocity Entry

Vi := (Sf-Si)/(Mf-Mi);Interpolation_ViaPoint[i].Slave_Velocity := Vi;

END_IF;a1 := Vi;a2 := 0;a3 := 0;a4 := 0;a5 := 0;a6 := 0;a7 := 0;a8 := 0;a9 := 0;SegmentType := 0; //Linear

// Cubic1: a0 := Si;a1 := Vi;a2 := 0;a3 := 0;a4 := 0;a5 := 0;a6 := 0;a7 := 0;a8 := 0;a9 := 0;SegmentType := 1; //Cubic

// 5th 0rder2: a0 := Si;a1 := Vi;a2 := Ai/2;a3 := (20.0 * (Sf - Si) - (8.0 * Vf + 12.0 * Vi) * (Mf - Mi) - (3.0 * Ai - Af) * (Mf - Mi) ** 2.0) / (2.0 * (Mf -

Mi) ** 3.0);a4 := (30.0 * (Si - Sf) + (14.0 * Vf + 16.0 * Vi) * (Mf - Mi) + (3.0 * Ai - 2.0 * Af) * (Mf - Mi) ** 2.0) / (2.0 *

(Mf - Mi) ** 4.0);a5 := (12.0 * (Sf - Si) - 6.0 * (Vf + Vi) * (Mf - Mi) - (Ai - Af) * (Mf - Mi) ** 2.0) / (2.0 * (Mf - Mi) ** 5.0);a6 := 0;a7 := 0;a8 := 0;a9 := 0;SegmentType := 1; //Cubic

// 7th 0rder3: a0 := Si;a1 := Vi;a2 := Ai/2;a3 := Ji/6;M := Mf-Mi;

Page 15: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

K0 := Sf - a0 - a1*M - a2*M**2 - a3*M**3 ;K1 := Vf - a1 - 2*a2*M - 3*a3*M**2;K2 := Af - 2*a2 - 6*a3*M;K3 := Jf -6*a3;a4 := 35*K0/M**4 - 15*K1/M**3 + (5*K2/2)/M**2 - (K3/6)/M;a5 := -84*K0/M**5 + 39*K1/M**4 - 7*K2/M**3 + (K3/2)/M**2 ;a6 := 70*K0/M**6 - 34*K1/M**5 + (13*K2/2)/M**4 - (K3/2)/M**3;a7 := -20*K0/M**7 + 10*K1/M**6 - 2*K2/M**5 + (1/6)*K3/M**4;a8 := 0;a9 := 0;SegmentType := 1; //Cubic// 9th 0rder4:a0 := Si;a1 := Vi;a2 := Ai/2;a3 := Ji/6;a4 := ni/24; M := Mf-Mi;K0 := Sf - a0 - a1*M - a2*M**2 - a3*M**3 - a4*M**4 ;K1 := Vf - a1 - 2*a2*M - 3*a3*M**2 - 4*a4*M**3;K2 := Af - 2*a2 - 6*a3*M - 12*a4*M**2;K3 := Jf - 6*a3 - 24*a4*M ;K4 := nf - 24*a4 ;a5 := 126*K0/M**5 -56*K1/M**4 +(21*K2/2)/M**3 - K3/M**2 +(K4/24)/M ;a6 := -420*K0/M**6 +196*K1/M**5 -(77*K2/2)/M**4 +(23*K3/6)/M**3 -(K4/6)/M**2;a7 := 540*K0/M**7 -260*K1/M**6 +53*K2/M**5 -(11*K3/2)/M**4 +(K4/4)/M**3;a8 := -315*K0/M**8 +155*K1/M**7 -(65*K2/2)/M**6 +(7*K3/2)/M**5 -(K4/6)/M**4;a9 := 70*K0/M**9 -35*K1/M**8 +(15*K2/2)/M**7 -(5*K3/6)/M**6 +(K4/24)/M**5;SegmentType := 1; //Cubic

// Simple Harmonic and Elliptical when Cycles <> 05:a0 := 0;a1 := 0;a2 := 0;a3 := 0;a4 := 0;a5 := 0;a6 := 0;a7 := 0;a8 := 0;a9 := 0;IF Interpolation_ViaPoint[i].Cycles >= 1 THEN

Interpolation_ViaPoint[i].Cycles := 0.9990;END_IF;Cycles := Interpolation_ViaPoint[i].Cycles;SegmentType := 1; //Cubic

// Epicylic6:a0 := 0;a1 := 0;a2 := 0;a3 := 0;a4 := 0;a5 := 0;a6 := 0;a7 := 0;a8 := 0;a9 := 0;Cycles := Interpolation_ViaPoint[i].Cycles;IF Cycles <= 0 THEN // Avoid Divide by Zero

Cycles :=1;Interpolation_ViaPoint[i].Cycles := Cycles;

END_IF;SegmentType := 1; //Cubic

// Double Harmonic, Modified Sine, Modified Trapezoid7,8,9:a0 := 0;a1 := 0;a2 := 0;a3 := 0;a4 := 0;a5 := 0;a6 := 0;a7 := 0;a8 := 0;a9 := 0;SegmentType := 1; //Cubic

ELSE// Default to Linear

a0 := Si;a1 := Vi;a2 := 0;a3 := 0;a4 := 0;a5 := 0;a6 := 0;a7 := 0;a8 := 0;a9 := 0;SegmentType := 0; //LinearInterpolation_ViaPoint[i].SegmentType := SegmentType;

END_CASE;

IF Interpolation_ViaPoint[i].Steps < 1 THEN // Check for Divide by 0 and no negative numbersInterpolation_ViaPoint[i].Steps := 1;

END_IF;

Step:=(Mf - Mi)/Interpolation_ViaPoint[i].Steps;

Page 16: AOI_CAMM - Connect with EarthLink, the award …philipp/Application Technique AOI... · Web viewThe CAM MultiSelect Add-On Instruction AOI_CAMM automatically generates a motion profile

MP := Mi; SP := Si;

WHILE MP < (Mf-0.001*Step) DO // Sometimes there is round off

CASE Interpolation_ViaPoint[i].SegmentType OF 0,1,2,3,4: // Interpolating Polynomial

SP := a0 + a1*(MP-Mi) + a2*(MP-Mi)** 2.0 + a3*(MP-Mi)**3.0 + a4*(MP-Mi)**4.0 + a5*(MP-Mi)**5.0 + a6*(MP-Mi)**6.0 + a7*(MP-Mi)**7.0 + a8*(MP-Mi)**8.0 + a9*(MP-Mi)**9.0 ;

5: // Elliptical and Simple Harmonic Equation (SHM when Cycles = 0)SP := (Sf+Si)/2 - (Sf-Si)/2*Cos(3.14159265*(MP-Mi)/(Mf-Mi))/(1-Cycles*(sin(3.14159265*(MP-Mi)/(Mf-Mi)))**2)**0.5;

6: // Epicyclic SP := Si+(Sf-Si)/(Mf-Mi)*((MP-Mi)-(1-Vi*(Mf-Mi)/(Sf-Si))/(2*3.14159265*Cycles/(Mf-Mi))*sin(2*3.14159265*Cycles/(Mf-Mi)*(MP-Mi)));

7: // Double HarmonicSP := Si+((Sf-Si)/2)*(1 - Cos(3.14159265*(MP-Mi)/(Mf-Mi))- 0.25 *(1 - Cos(2*3.14159265*(MP-Mi)/(Mf-Mi))));

8: // Modified SineIF (MP-Mi)<=(Mf-Mi)/8 THEN

SP := Si+(Sf-Si)*(0.43990085*(MP-Mi)/(Mf-Mi) - 0.0350062*Sin(4*3.14159265*(MP-Mi)/(Mf-Mi)));END_IF;IF (MP-Mi)>(Mf-Mi)/8 AND (MP-Mi)<= (7*(Mf-Mi)/8) THEN

SP := Si+(Sf-Si)*(0.28004957+0.43990085*(MP-Mi)/(Mf-Mi) -0.31505577*Cos(4*3.14159265*(MP-Mi)/(Mf-Mi)/3-3.14159265/6));

END_IF;IF (MP-Mi)>(7*(Mf-Mi)/8) THEN

SP := Si+(Sf-Si)*(0.56009915 + 0.43990085*(MP-Mi)/(Mf-Mi) -0.0350062*SIN(2*3.14159265*(2*(MP-Mi)/(Mf-Mi)-1)));END_IF;

9: // Modified TrapezoidIF (MP-Mi)<=(Mf-Mi)/8 THEN

SP := Si+ 0.09724613*(Sf-Si)*(4*(MP-Mi)/(Mf-Mi) - Sin(4*3.14159265*(MP-Mi)/(Mf-Mi))/3.14159265);END_IF;IF (MP-Mi)>(Mf-Mi)/8 AND (MP-Mi)<= 3*(Mf-Mi)/8 THEN

SP := Si+ (Sf-Si)*(2.444016188*((MP-Mi)/(Mf-Mi))**2 - 0.22203094*(MP-Mi)/(Mf-Mi) + 0.00723406);END_IF;IF (MP-Mi)>3*(Mf-Mi)/8 AND (MP-Mi)<= 5*(Mf-Mi)/8 THEN

SP := Si+ (Sf-Si)*(1.6110155*(MP-Mi)/(Mf-Mi) + 0.0309544*Sin(4*3.14159265*(MP-Mi)/(Mf-Mi))- 0.3055077);END_IF;IF (MP-Mi)>5*(Mf-Mi)/8 AND (MP-Mi)<= 7*(Mf-Mi)/8 THEN

SP := Si+ (Sf-Si)*(4.6660917*(MP-Mi)/(Mf-Mi)-2.44406188*((MP-Mi)/(Mf-Mi))**2 -1.2292650);END_IF;IF (MP-Mi)>(7*(Mf-Mi)/8) THEN

SP := Si+ (Sf-Si)*(0.6110155 + 0.3889845*(MP-Mi)/(Mf-Mi) - 0.0309544*SIN(4*3.14159265*(MP-Mi)/(Mf-Mi)));END_IF;

END_CASE;

//Populate CAMMy_CAM[Index].Master := MP;My_CAM[Index].Slave := SP;My_CAM[Index].SegmentType := SegmentType;

// Increment to next positionMP := MP+Step;Index := Index + 1;

END_WHILE;

END_FOR;

// First and Last CAM entry forced to avoid negative numbers and round off errors on the cam boundariesMy_CAM[Index].Master := Master_Cycle;My_CAM[Index].Slave := Slave_Cycle;My_CAM[0].Slave := Interpolation_ViaPoint[0].Slave_Position;

IF Interpolation_ViaPoint[f].SegmentType < 1 THENMy_CAM[Index].SegmentType := 0; //Linear

ELSEMy_CAM[Index].SegmentType := 1; //Cubic

END_IF;

Index := Index + 1;

Length := Index; // Set for MCCP instruction

WHILE Index < Cam_Size DO // Zero out the rest of the CAMMy_CAM[Index].Master :=0.0;My_CAM[Index].Slave := 0.0;My_CAM[Index].SegmentType := 0;Index := Index +1;

END_WHILE;

Start_Slope := Interpolation_ViaPoint[0].Slave_Velocity; // Set for MCCP instructionEnd_Slope := Interpolation_ViaPoint[Last_Segment].Slave_Velocity; // Set for MCCP instruction

// END OF PROGRAM