mc_control.c File Reference

Go to the source code of this file.

Functions

U16 mc_control_speed_16b (U16 speed_ref, U16 speed_measure)

Variables

S16 speed_error = 0
 Regulation loop error calculation.
S16 speed_integ = 0
 Intermediate integral value.
S16 speed_integral = 0
 Local integral value.
S16 speed_proportional = 0
 Local proportional value.


Function Documentation

U16 mc_control_speed_16b ( U16  speed_ref,
U16  speed_measure 
)

speed controller

Returns:
value of speed (duty cycle on 16 bits) speed_measure has 10 bits resolution

Definition at line 35 of file mc_control.c.

00036 {
00037    U16 result = 0;
00038    S16 increment = 0;
00039 
00040    // Error calculation
00041 //   speed_error = speed_ref - speed_measure/2 ;
00042    speed_error = speed_ref - speed_measure;
00043 
00044    // proportional term calculation : Kp= 7/64=0.1
00045    speed_proportional = speed_error * 4;
00046 
00047    // integral term calculation
00048    speed_integral = speed_integral + speed_error;
00049 
00050    // speed integral saturation
00051    if(speed_integral >  32000) speed_integral =  32000;
00052    if(speed_integral < -32000) speed_integral = -32000;
00053 
00054    speed_integ = (speed_integral - speed_integral/8 + speed_integral/32) / 16 ;
00055 
00056    // amplitude calculation
00057    increment = speed_proportional + speed_integ;
00058 
00059    // saturation of the PI output
00060    if (increment > 0)
00061    {
00062       if  (increment <= (S16)(MAX_AMPLITUDE)) result = (S16)increment ;
00063       else result = MAX_AMPLITUDE ;
00064    }
00065    else result = 0;
00066 
00067    // return Duty Cycle
00068    return result;
00069 }


Variable Documentation

S16 speed_error = 0

Regulation loop error calculation.

Definition at line 22 of file mc_control.c.

Referenced by mc_control_speed_16b().

S16 speed_integ = 0

Intermediate integral value.

Definition at line 24 of file mc_control.c.

Referenced by mc_control_speed_16b().

S16 speed_integral = 0

Local integral value.

Definition at line 23 of file mc_control.c.

Referenced by mc_control_speed_16b().

S16 speed_proportional = 0

Local proportional value.

Definition at line 25 of file mc_control.c.

Referenced by mc_control_speed_16b().


Generated on Tue Sep 16 18:11:23 2008 for Atmel BLDC Sinusoidal on ATAVRMC100 by  doxygen 1.5.3