print Servo wall velocity

Submitted by Rahul Kumar on Tue, 10/13/2020 - 10:24

Hi
I am using servo wall to maintain constant force on wall. And I have some doubts.

1. The formula referred in documentation for PID controller
output = kp * error + ki * errorsum + kd * errorchange
I want to print or save the output, error, errorsum and errorchange values. How can I do this in LIGGGHTS.

2. Is there any thumb rule for selecting kp, ki, and kd values.

3. How can I change a variable value in every step.

mschramm | Sun, 10/18/2020 - 20:14

Hello,
I do not believe you can print the values that you are looking for directly. You would need to edit the code to do this.
See mesh_module_stress_servo.cpp around line 444 (final_integrate).

For the values kp, ki, and kd, I really only know trial and error. There is literature on how to chose these values.

What variable are you trying to change every step? How do you want this value to change? Is this variable going to be used in a fix? Does that fix allow v_ style variable inputs?

Rahul Kumar | Thu, 10/22/2020 - 05:50

I was trying to change kp value and make is as a function of step.

Will it be help full to change kp every step.

Rahul Kumar | Sun, 10/25/2020 - 11:28

Hi

The formula referred in documentation for PID controller
output = kp * error + ki * errorsum + kd * errorchange

what is the meaning of output?
whether it is force on servo wall or velocity of servo wall

mschramm | Mon, 10/26/2020 - 19:09

Hello,
I did not find that line in the final integration function.... This is the segment of code that I was referring to...

// simple PID-controller
// calc error and sum of the errors
pv_mag_ = vectorDot3D(pv_vec_,axis_);
err_ = (sp_mag_ - pv_mag_);
sum_err_ += err_*dtv_;
// derivative term
// force used instead of the error in order to avoid signal spikes in case of change of the set point
// de()/dt = - dforce()/dt for constant set point
dfdt = -( pv_mag_ - old_pv_mag_)/dtv_;

// vel points opposite to force vector
const double ctrl_op_mag = -ctrl_op_max_ * (err_ * kp_ + sum_err_ * ki_ + dfdt * kd_) * sp_mag_inv_;
vectorScalarMult3D(axis_,ctrl_op_mag,ctrl_op_);

the ctrl_op_ is a velocity term for the mesh.

As for adjusting the parameters. You can use a modify fix command
fix_modify your_servo_fix ctrlParam newKp newKi newKd