Build in PID controller for Actuator
Posted: 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
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