Build in PID controller for Actuator

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Vinh Nguyen
Posts: 21
Joined: Fri Sep 26, 2014 8:53 pm

Build in PID controller for Actuator

Post by Vinh Nguyen » Mon Nov 21, 2016 2:07 pm

Hi,

I am writing a class of controlled motor actuator, which consists of an electrical motor and its PD controller.
The input of class is reference torque and the output is torque of motor.
The equation for controller is:
control signal = Kp * e + Kd * e_dot with e = Torque reference - Torque. I have difficulty calculating the derivative term which is e_dot. I think of calculating by Euler method, such that e_dot = (e_current state - e_previous state)/(time_current_state - time_previous_state). With this method, I need to store the data from previous state, and this seems doable by creating a "global" variable and save data to it, change it at next state. But I got error doing that when trying to modify the variable in other const methods.

Another idea is to create a separated controller class for the motor class. My concern for this is when we run simulation, is it possible to use more than 2 controllers, meaning one controller for motor class and other controller for muscles?

Any suggestions would be great?

Thanks,
Vinh

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Build in PID controller for Actuator

Post by Dimitar Stanev » Tue Nov 22, 2016 1:01 am

Because you have a constant method (computeControls), you can't alter the data members of the class. There is a work around, you can declare the variables that you change as mutable (e.g. mutable Vector previousTorque;).

Just one comment, keep in mind that the integrator does not take consequent steps, e.g. it may be evaluating at ti=0.3 and the next ti+1 = 0.25. This is because internally integrators use error correction and adaptive time stepping techniques. What you can do is to use SimmSpline and to insert the values of the torques for the corresponding time instances. Then you can call calcDerivative(). But again you have to be careful how you handle the points that would be ignored by the integrator (delete them).

Best

POST REPLY