|
||
|
****JavaScript based drop down DHTML menu generated by NavStudio. (OpenCube Inc. - http://www.opencube.com)****
|
||
PID Controlled Servo
What is a servo?
A servo is a mechanical device that follows a target position by using a closed loop electronic controller.
Parts of a Servo:
- Motor: Usually a DC motor with a gearbox. The motor is used to provide the mechanical output of the system, and to move the potentiomer to close the loop. For high power servos three-phase motors can be used.
- Potentiometer: For standard industrial applications a simple potentiometer can be used to get the current position of the servo. For high accuracy CNC systems an encoder with high number of pulses will be needed.
- Controller: There are a lot type of servos, the controller can be implemented by an analog circuit, with a PID controller or a more complex controller.
Analog controllers usually are only a "P" controller, they work fine if the system can keep the current position when the motor is off, but they create a "position error" when a fixed strenght is applied to the servo, because the system needs a small error to get the necesary torque to keep its position.
PID controller fix the "position error" with the "I" parameter, and also can increase the response speed for the target changes with the "D" parameter. The controller reads the current position from the potentiometer or encoder, and substracts from the target position and gets the "error" variable. This variable tells the controller how far is from the desired position. By using the "P", "I" and "D" coefficients the controller gets the "control action" to be sent to the motor driver.- Motor Driver: As the motor needs to move in two directions usually a H-driver is used to reverse polarity. A PWM output is used to control the motor power. In addition with large motors a current limitation is needed inside the driver to prevent the MOSFETs/IGBTs to be damaged when starting, changing direction or appliying a load to the motor.
Explanation of parameters:
- Kp, this is the "proportional" coefficient of the controller. The servo can work by using only this value. The "error" variable is multiplied by this value to get the "control action". Small values will cause the system to move slowly to the target position. High values will cause the system to oscillate when reaching the target position. An small value generates high "position error" if not using "Ki".
- Ki, this is the "integrative" coefficient. The controller accumulates the error during its normal performing, and uses this coefficient to get an addition "control action" to be added to the main output. This function causes the system to reach its position even when for small Kp. A high Ki value causes the system to oscillate. A small Ki value causes the system to reach its position slowly (for small Kp) Ki is important to get some output at the motor when the target position is reach and some torque still being needed (for example when a spring present in a throttle body). As the target was reach, error=0, and then the proportional output will 0. If no integrative function is present, the spring force will cause the servo to go back until the equilibrium is reach. But when Ki is used, the system can have some memory to keep certain torque at motor when error=0 (target reach).
- Kd, this is the "derivative" coefficient. The controller calculates the difference between the current error and the previous error to know how the system is performing, and multiplies this value by this coefficient to get an additional "control action" to be added to the previous ones. For example, if target is suddenly increased, this value will be high and will cause a higher response from the system. And also, if the system is reaching quickly the target, this value will reduce the motor torque. Kd has to be a small value to prevent the system act as "nervous" servo.
Digital optimizations:
- Dead Band: As current position of servo and target are acquired by a microcontroller, some unacuracy is present on the readings, and some oscillation is present on them. Thus, a small band is defined to ensure that when servo is very close to the target, the motor will stop. In other case, the motor always will be doing small pulses.
- Motor Offset: motors are not linear, they won't start to move until certain output voltage is reach. Thus a small offset is added to the PID output (when output is different from 0) to ensure the motor will work for every value different to 0. In other case, for low output values some current is wasted on the motor, but the motor doesn't move.
- Integration Limits: in order to prevent the integrative counter to windup and to keep the system stable, the integrative counter is kept inside a limits.
- Derivative Dead Band: to make the system more stable for positions near to the target position, a dead band interval is defined to disconnect the derivative function. Only when sudden changes are applied, the derivative function is used.
Connection of PIC12F675 to the motor driver
Motor driver is not specified, it depends on the application:
Click here to download servo firmware- For small power applications an integrated IC bridge may be very easy to use.
- For Low voltage / Medium Power Mosfet drivers and Mosfets transistors are recommended.
- Fot High Voltage / High Power . Mosfet driver + IGBT transistors are recommended.