Cam Follower: Designing Cams Using the Wolfram Language

Introduction

Cams are used in a number of different mechanisms, from valve actuation in internal combustion engines to sewing machines. With the symbolic component creation capabilities in System Modeler, it is easy to design and prototype mechanisms with correct displacements and minimal wear.

Explore the available scenarios by evaluating each cell in order. Evaluation is done by selecting a cell and pressing Shift+Enter.

In order to get the full experience of this example, you need the following:

Wolfram System Modeler; a free trial download is available at www.wolfram.com/system-modeler

The model that came in the same bundle as this notebook

For more information about Wolfram System Modeler, visit www.wolfram.com/system-modeler.

The Model

Cam Designs

The Wolfram Language is used to define the shape of three different cams, one pointy, one with a full-rise harmonic shape and one in between:

camRound=If[Mod[phi[t],2π]>π,1+(((Cos[phi[t]+(( π)/2)])^4)/2),1];
camPointy=If[Mod[phi[t],2π]>((3 π)/2),(4/(3 Cos[phi[t]]-4 Sin[phi[t]])),If[Mod[phi[t],2π]<(π/2),(1/((3/4) Cos[phi[t]]+Sin[phi[t]])),1]];
camHarmonic=If[Mod[phi[t],2 π]>(( π)/2)||Mod[phi[t],2 π]<(π/2),1+0.25` (1-Cos[2 phi[t]]),1];

These shapes can be visualized using the PolarPlot function:

Grid[{
{"Round","Pointy","Harmonic"},
PolarPlot[#,{phi[t],0,2π}]
&/@{camRound,camPointy,camHarmonic}
}
]

Cam Rotation

When the cam is rotated, this will result in the a translational force being applied to the follower. The partial Modelica class PartialElementaryRotationalToTranslational allows rotational movement to be translated to translational:

partialClass="Modelica.Mechanics.Rotational.Interfaces.PartialElementaryRotationalToTranslational";

You need equations that describe the relationship between the translational and rotational movements.
The partial class has two flanges, one for the rotational motion and one for the translational motion. First, create helper variables that can be used to reference these flanges within the model:

helperVariables={
phi[t]==flangeR▴phi[t],
s[t]==flangeT▴s[t]
};

Then, for analysis, you will need variables that describe the derivatives of the motion:

derivativeEqs={
v[t]==s'[t],
a[t]==v'[t],
j[t]==a'[t]
};

Lastly, define a function that describes the relationship among the rotation applied on the cam; the variable s, which is defined by the shape of the cam; and the translational force (Subscript[F, x]) applied to the follower.

forceEq={(Subscript[F, x])[t]==-((tau[t] phi'[t])/(s[t] s'[t]))}/.{(Subscript[F, x])[t]->-flangeT▴f[t],tau->flangeR▴tau,s'->v,phi->flangeR▴phi};

Model Creation

CreateSystemModel[#[[1]],Join[helperVariables,derivativeEqs,forceEq,{#[[2]]}],t,<|"ExtendsModels"-> partialClass,"InitialValues"-> {"phi"-> 0Degree}|>] &/@
{
{"CamFollower.Components.CamRound",s[t]==camRound},
{"CamFollower.Components.CamPointy",s[t]==camPointy},
{"CamFollower.Components.CamHarmonic",s[t]==camHarmonic}
}

With the cam shapes and equations defined, you can create a new model that describes the complete cam follower setup. For this, you will need a rotor that rotates at a constant speed, the cams designed in the previous sections, and a cam follower that is modeled as a spring that is pressed against the cam at one end and fastened to a fixed point at the other:

components={
"rotator"∈"Modelica.Mechanics.Rotational.Sources.ConstantSpeed",
"cam"∈cam,
"follower"∈"Modelica.Mechanics.Translational.Components.Spring",
"fixed"∈"Modelica.Mechanics.Translational.Components.Fixed"};
connections ={"cam.flangeT"\[UndirectedEdge]"follower.flange_a","follower.flange_b"\[UndirectedEdge]"fixed.flange","rotator.flange"\[UndirectedEdge]"cam.flangeR"};

Using the ConnectSystemModelComponents function, you will now connect the components together. You will create three different models, each with a different cam. Again, you can create the three separate setups using a single command:

ConnectSystemModelComponents[
"CamFollower.Examples."<>#<>"Follower",
components/.cam->"CamFollower.Components."<>#,
connections
]&/@
{
"CamRound",
"CamPointy",
"CamHarmonic"
}

Simulation

For simulation, use a fixed speed at 5 rad/s and a spring constant of 2 N/m for the follower:

params={"rotator.w_fixed"-> 5,"follower.c"->2};

Using these values, you can simulate different scenarios using different cams. Then plot the results to see how the follower is translocated during the cam rotation:

ℳ=SystemModelSimulate[#<>"Follower",{0,5},<|"ParameterValues"->params|>]&/@
{
"CamFollower.Examples.CamRound",
"CamFollower.Examples.CamPointy",
"CamFollower.Examples.CamHarmonic"
};
SystemModelPlot[ℳ,"follower.flange_a.s",
PlotLabel->Style["Follower position",Large],
PlotLegends-> {"Round", "Pointy", "Harmonic"}]

Analysis

Follower Jerk

Cam designers want to minimize the jerk (the derivative of the acceleration), in order to minimize the stress and wear on the cam. Directly analyze and visualize the results:

SystemModelPlot[ℳ,"der(cam.a)",
PlotLabel->Style["Follower jerk",Large],
PlotLegends-> {"Round", "Pointy", "Harmonic"},
PlotRange-> All,
AxesLabel-> {"t","m/(s^3)"}]

Animation

Using the graphical constructs in the Wolfram Language, you can create animations from the simulation results to communicate model characteristics.

Define helper functions to retrieve variable values:

ClearAll[followerPos,rot];
followerPos[sim_,t_]:=sim[{"follower.flange_a.s"}][[1]][t];
rot[sim_,t_]:=sim[{"rotator.phi"}][[1]][t]

Define a function for showing the cam and the cam follower at a given point in time:

ClearAll[displayCam];
displayCam[sim_,contour_,dt_]:=Module[{fpos=followerPos[sim,dt]},Show[RegionPlot[Evaluate[Sqrt[x^2+y^2]<(contour/.phi[t]->ArcTan[x,y]+rot[sim,dt])],{x,-2,3},{y,-2.5,2.5},PerformanceGoal->"Quality"],Graphics[{Disk[{0,0},0.1],Rectangle[{fpos+0.2,0.05},{fpos+0.7,-0.05}],Line[{Sequence@@Join@@With[{pos=fpos+0.7},Table[{{x,0.05},{x,-0.05}},{x,pos,2.5,((2.5-pos)/7)}]],{2.5,0}}],{Gray,Disk[{fpos+0.2,0},0.2]},Rectangle[{2.4,-0.1},{2.6,0.1}]}]]]

Using the Animate function, you will get a graphical representation of the cam and follower:

Row[Animate[displayCam[#[[1]],#[[2]],dt],
{dt,0,5},
AnimationRate->0.5,
AnimationRunning->False,
SaveDefinitions->True]&/@
({ℳ,{camRound,camPointy,camHarmonic}}\[Transpose])
]

Model Center

The models created within this notebook are available for further analysis and simulation within the System Modeler Model Center. From there you can explore, manipulate, and simulate the models further. You can open the round cam follower component by running this command:

SystemModeler["CamFollower.Examples.CamRoundFollower"]

Terms and Conditions of Use

This domain example is an informational resource made freely available by Wolfram Research.

Use of This Example

• You may not use this example for any purpose that is unlawful or dangerous.
• You assume total responsibility and risk for your use of this example.
• You may not present this example with any alteration to its trade dress, trademarks, or design.

License

All content in this bundle is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. By accessing the content or using it in any way, you accept and agree to be bound by the terms of this license. If you do not agree to these Terms of Use, you may not use this content. Wolfram Research reserves the right to change, modify, add to, or remove portions of these Terms of Use at any time without notice. Please refer back to www.wolfram.com for the latest Terms of Use.

A summary of the licensing terms can be found at:
http://creativecommons.org/licenses/by-nc-sa/3.0

The full legal code can be found at: 
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode