avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Help, Compiler ignores some part of the function!


From: MuRaT KaRaDeNiZ
Subject: [avr-gcc-list] Help, Compiler ignores some part of the function!
Date: Sat, 3 Dec 2005 00:20:31 +0200

Hello All,

Using WinAVR-20050214, I try to compile the following function, but the section between [BOOKMARK1] and [BOOKMARK2] does not get compiled without any error indication. İ checked the routine in the .lst file, this section is not compiled to assembly. The rest is there. What is wrong?

 

Thanks.

Murat Karadeniz

http://www.onlinefavbar.com/mukas

 

 

 

Note: target CPU is ATMEGA16 and avr-size after compilation gives:

text data bss dec hex filename

11065 78 585 11728 2dd0 main.elf

 

void ProcessPID_Vertical()

{

#define encoder Motor1_Counter

#define PWMchannel 1

#define IntegralActivationLimit 12

static long integral_error = 0;

static long prev_error = 0;

static long prev_prev_error = 0;

long error;

int controller;

 

#ifdef USE_INTERNAL_ENCODER_CONSTS //destinationVertical given in angles at the final moving axis

ErrorVertical = error = ( DestinationVertical / enc1_constant ) - encoder; #endif

#ifndef USE_INTERNAL_ENCODER_CONSTS //destinationVertical given in encoder ticks at the motor encoder for the same final motion

ErrorVertical = error = DestinationVertical - encoder;

#endif

if (error == 0)

controller = 0;

else

{

integral_error += i1*error*10;

if (integral_error > INTEGRAL_LIMIT_V) integral_error = INTEGRAL_LIMIT_V;

if (integral_error < -INTEGRAL_LIMIT_V) integral_error = -INTEGRAL_LIMIT_V;

[BOOKMARK1]

if ((d1*(error -prev_prev_error)/2 < IntegralActivationLimit) && (d1*(error -prev_error)/2 > -IntegralActivationLimit))

{

if ((error < PTERM_AMPLIFICATION_CLOSURE_V) && (error > -PTERM_AMPLIFICATION_CLOSURE_V))

controller = (int) ( p1*error*PTERM_AMPLIFICATION_MAGNITUDE_V + integral_error/10 + d1*(error -prev_prev_error)/2);

else

controller = (int) ( p1*error + integral_error/10 + d1*(error -prev_prev_error)/2);

}

else

{

if ((error < PTERM_AMPLIFICATION_CLOSURE_V) && (error > -PTERM_AMPLIFICATION_CLOSURE_V))

controller = (int) ( p1*error*PTERM_AMPLIFICATION_MAGNITUDE_V + d1*(error -prev_prev_error)/2);

else

controller = (int) ( p1*error + d1*(error -prev_prev_error)/2);

}

[BOOKMARK2]

/*

if ( controller > 0 )

SetDirection2(LEFT);

else

SetDirection2(RIGHT);

*/

if ( controller > SPEED_LIMIT_V ) controller = SPEED_LIMIT_V;

else if ( controller < -SPEED_LIMIT_V ) controller = -SPEED_LIMIT_V;

}

prev_prev_error = prev_error;

prev_error = error;

//WritePWM(PWMchannel, abs(controller));

}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]