FileDocCategorySizeDatePackage
PIDLoopControler.javaAPI DocAzureus 3.0.3.41083Thu Nov 09 11:01:40 GMT 2006com.aelitis.azureus.core.util.loopcontrol.impl

PIDLoopControler

public class PIDLoopControler extends Object implements com.aelitis.azureus.core.util.loopcontrol.LoopControler

Fields Summary
double
pGain
double
iGain
double
dGain
double
iState
double
iMin
double
iMax
double
dState
Constructors Summary
public PIDLoopControler(double pGain, double iGain, double dGain)

	
	      
		this.pGain = pGain;
		this.iGain = iGain;
		this.dGain = dGain;
	
Methods Summary
public voidreset()

		dState = 0;
		iState = 0;
	
public doubleupdateControler(double error, double position)

		
		//Proportional
		double pTerm = pGain * error;
		
		
		iState += error;
		if(iState > iMax) iState = iMax;
		if(iState < iMin) iState = iMin;
		
		double iTerm = iGain * iState;
		
		double d = dState - position;
		
		double dTerm = dGain * d;
		dState = position;

		double result = pTerm + iTerm - dTerm;
		
		System.out.println("PID p,i,d (" + pGain + "," + iGain + "," + dGain +") : is,ds (" + iState + "," + d + ") p,i,d (" + pTerm + "," + iTerm + "," + dTerm + ") => " + result);
		
		return result;