# Spings

Hi,
I am trying to alter a hip model of the hip joint which in driven relative to the pelvis. I want to add some resistance to the motion, by adding a block which is connected to the distal femur by a spring. So, for the femur to contact the block it must overcome the resistance of the spring first. There is a similar situation in the tutorials but the spring is added to the joint. Therefore, I wondered if anyone else has any experience or advice about how to model a connecting between a block and a spring via a spring.
Many Thanks
Pete

Hi Pete,

Basicaly you can use the same method as in the tutorial. The spring added to the joint is a force added to the rotational measure of the joint, the stiffness being controlled by an interpolation function. Just replace the rotational measure by a linear measure bettween the block and femur and adjust the stiffness in the interpol function.

Best regards, Sylvain.

Hi,

Thanks for the reply. Just a quick further question - will a joint need to be modelled between the block and femur? In a ideal situation it would be best to have the femur connected to the block via the spring with no joint present.

Thanks
Pete

Hi Pete,

You don’t need to use a joint. The spring force can be applied to a PLine connecting the block and femur for example. So the force would be function of the PLine length and it will act along the line direction.

Best Regards, Sylvain.

Hi,

Thanks for the advice - the model seems to be working fine. There is just one slight problem - as the force is a function of the Pline, the force is decreasing as the distance between the two segments decreases. Ideally, the spring should increase in force as the PLine distance decreases. I have tried and failed to invert how the Pline is measured - is there another way to do this.

Many Thanks
Pete

Hi Pete,

In this case you need an AnyFunInterpol to control the spring stiffness. In the vector T put the PLine length values and in Data the spring force corresponding to the length. This way you can invert it, make it non linear or whatever you want.
There should be an example in the wiki.

Best regards, Sylvain.

Hi,
I have taken the AnyLinPline and AnyForce data from the kinematics and used it in the AnyFunInterpol function with the following code:-

AnyRefNode &MotionNode = Main.HipJoint.Segs.Femur.MotionNode;
AnyRefNode &ContactNode = Main.HipJoint.Block.BlockSeg.Cylinder1.ContactNode;
};

AnyForce Spring = {
};

AnyFunInterpol InvertSpring = {
Type = Bspline;
// BsplineOrder = 4;
T = {61.5068,61.4848,61.4629,61.4412,61.4197,
61.3983,61.3771,61.3560,61.3351,61.3144,61.2939,61.2735,
61.2532,61.2332,61.2133,61.1935,61.1740,61.1546,61.1354,
61.1163,61.0974,61.0787,61.0601,61.0417,61.0235,61.0054,
60.9875,60.9698,60.9522,60.9348};
Data = {{-30.7534,-30.7424,-30.7315,-30.7206,-30.7098,-30.6991,-30.6885,
-30.6780,-30.6676,-30.6572,-30.6469,-30.6367,-30.6266,-30.6166,
-30.6066,-30.5968,-30.5870,-30.5773,-30.5677,-30.5581,-30.5487,
-30.5393,-30.5300,-30.5208,-30.5117,-30.5027,-30.4937,-30.4849,
-30.4761,-30.4674}};
//FileName = “”;
//FileErrorContinueOnOff = Off;
};

[FONT=Calibri]But, the following error appears - ERROR(OBJ1) : C:\Users\Pete\Desktop\2 flex - Min SPLine\Spring.txt(23) : ‘InvertSpring’ : Parameter values are not monotonically increasing. As the spring will be under compressive deformation, I’m not sure how to use the function with decreasing parameter value. Is the AnyFunInterpol function used correctly?[/FONT]
[FONT=Calibri]Thanks[/FONT]
[FONT=Calibri]Pete [/FONT]

Hi Pete,
the Time vector should constantly increase.
Best regards,
Sebastian