Pid help!!!!!

ok i have been working on a pid and i dont know what to put power and velocity to. or if you have totally have a different pid, help

#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, I2C_1, , sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Motor, port1, flywheel1, tmotorVex393TurboSpeed_HBridge, openLoop)
#pragma config(Motor, port3, flywheel2, tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port5, flywheel3, tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port6, flywheel4, tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port7, flywheel5, tmotorVex393TurboSpeed_MC29, openLoop, encoderPort, I2C_1)
#pragma config(Motor, port10, flywheel6, tmotorVex393TurboSpeed_HBridge, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

float kp
float ki
float kd
float current
float circ = 5*3.141592653549;

float power;
float integralActiveZone = ((1*12/circ)*360);
float errorT;
float lastError;
float porportion;
float intergral
float derivative
float velocity
void pre_auton(){
while (true);}
void tick(int tickScale = 1) { //for sanity’s sake: a universal update period
wait1Msec(600 * tickScale);}
task calcRPM() {
int lastValue = 0; //initialize variable lastValue
SensorValue[I2C_1] = 0; //reset from last match
while(true) {
wait1Msec(20); //wait 0.02 sec for encoder to think
power = (SensorValue[I2C_1] - lastValue); //finding encoder change per 20ms

	lastValue = SensorValue[I2C_1];}}

{

float error = ((power*12/circ)*360) = velocity;
if(error <integralActiveZone && error != 0)
{
	errorT += error
}
else{
	errorT = 0;
}
if(errorT > 50/ki){
	errorT = 0;
}
if(error == 0){
	derivative = 0;
}
porportion    =        error            *kp;
intergral     =    		 errorT			      *ki;
derivative		=   (error - lastError)   *kd;

lastError = error;


current = porportion + intergral + derivative;



if(power == 0){
	current = 0
}
if(current < 0){
	current = 0;
}


motor[flywheel1] = motor[flywheel2] = motor[flywheel3] = motor[flywheel4] = motor[flywheel5] = motor[flywheel6] = 0
if (vexRt[Btn5U] == 1){
	motor[flywheel1] = motor[flywheel2] = motor[flywheel3] = motor[flywheel4] = motor[flywheel5] = motor[flywheel6] = current






	}
}

Well a big problem first of all is that you hve the variable velocity in your equation but at no timw do you state what your velocity is you need to take your value form your integrated motor encoders and caculate it to rpms rotations per minute second you are missing a ton of semi colons from when you are defining variables and there are quite a few problems with your PID it self I don’t know why you are setting all your motors to zero near the end of the PID because that is going to be terrible on your motors if you want them to be zero when you are nor holding the button then you need to add an if statement if (vexRTBtn5U ==0) and a ton of other stuff I recomend you look at some other posts on the forum first so you can sort out some of your issues

RobotC has quite a nice velocity calculator built in. If you call


getMotorVelocity(flywheel5);

RobotC will return the RPMs of the motor.

If you add a global for your target velocity, you change this line


float error = ((power*12/circ)*360) = velocity;

to this


float error = getMotorVelocity(flywheel5) - targetVelocity;