Example #1
0
/*
* Initializes a bangbang controller with a sensor
*/
void bangBang_InitController(bangBang *bb, const tSensors sensor, const int highPower, const int lowPower, const int targetVelocity, const float ticksPerRev)
{
	bb->highPower = highPower;
	bb->lowPower = lowPower;

	bb->currentVelocity = 0.0;
	bb->currentPosition = 0;
	bb->prevPosition = 0;
	bb->error = 0;

	bb->dt = 0.0;
	bb->currentTime = 0;
	bb->prevTime = 0;

	bb->sensor = sensor;
	bb->usingIME = false;
	bb->usingVar = false;
	bb->ticksPerRev = ticksPerRev;
	bb->targetVelocity = targetVelocity;

	filter_Init_DEMA(&bb->filter);
	bb->alpha = 0.19;
	bb->beta = 0.0526;

	bb->outVal = 0;
}
Example #2
0
/*
* Initializes a bangbang controller with a float reference
*/
void bangBang_InitController(bangBang *bb, const float *var, const int highPower, const int lowPower, int targetVelocity, float ticksPerRev)
{
	bb->highPower = highPower;
	bb->lowPower = lowPower;

	bb->currentVelocity = 0.0;
	bb->currentPosition = 0;
	bb->prevPosition = 0;
	bb->error = 0;

	bb->dt = 0.0;
	bb->currentTime = 0;
	bb->prevTime = 0;

	bb->var = var;
	bb->usingIME = false;
	bb->usingVar = true;
	bb->ticksPerRev = ticksPerRev;
	bb->targetVelocity = targetVelocity;

	filter_Init_DEMA(&bb->filter, 0.19, 0.0526);

	bb->outVal = 0;
}