Optimize program

Hello,
I modify this program in "PID Controller". I gave Autotune and commands line is so big. I have question, i can optimize this program about 2kb memory? I don't have idea how can reduce the weight program and give the program to add on.

Quadrocopter.ino (13.6 KB)

Your question is not easy to understand but I think that you are asking how to reduce the size of the program. It is difficult to give advice because you have not provided all of your code, some of which is presumably in separate header or .ino files in the IDE.

int32_t ComputePID(int32_t DTms, int32_t DTinv, int32_t in, int32_t setPoint, int32_t *errorSum, int32_t *errorOld, int32_t Kp, int16_t Ki, int32_t Kd)
{
  


//Define Variables we'll be connecting to
double SetPoint, In, Out;

//Specify the links and initial tuning parameters
PID myPID(&In, &Out, &SetPoint,2,5,1, DIRECT);

void setup();

  //initialize the variables we're linked to
  In= analogRead(0);
  SetPoint = 100;

  //turn the PID on
  myPID.SetMode(AUTOMATIC);

void loop();

  In = analogRead(0);
  myPID.Compute();
  analogWrite(3,Out);
 
}

Strange placement of function prototypes for setup and loop.

UKHeliBob
Here is all files, if you want.
My English is not good, but i have learn it 1 year.

AWOL
Why do you think it strange?

I find other modified program but it's more complicated to edit for me.
And when we can't modify this program i try other :slight_smile:

Quadrocopter.rar (70.2 KB)

AWOL
Why do you think it strange?

Because the IDE already provides prototypes for these functions, and it is not common practice to put prototypes in the middle of other functions

How can I fix this problem? If can call it that.
My programming language is not good.

I didn't say it was a problem, I said it was odd.
I'd delete them; they're pointless.

When we delete it. I can run Auto Tune or deleted this option?

My programming language is not good.

I wonder then if a quadcopter program is what you should be attempting with all the inherent dangers that an out of control quadcopter implies.

Have you any experience of flying and tuning a quadcopter with a commercial flight controller board ? If not and you are determined to use an Arduino then perhaps you should be considering the Ardupilot board.

This is a project to do. I have just programmed, and someone else check it out and will control. I write here but we can me say what is bad and we can i fix this. For me it's a lot because of something you even more know.