mc_interface.c File Reference

#include "config.h"
#include "config_motor.h"
#include "mc_interface.h"
#include "mc_control.h"
#include "mc_drv.h"

Include dependency graph for mc_interface.c:

Go to the source code of this file.

Functions

void mc_motor_init ()
 use to init programm
void mc_ramp_up_init (void)
void mci_backward (void)
void mci_forward (void)
U16 mci_get_measured_current (void)
 Get the current measured in the motor.
U8 mci_get_measured_speed (void)
 Measured of speed.
U8 mci_get_motor_speed (void)
U8 mci_get_potentiometer_value (void)
 Get the potentiometer value.
Bool mci_motor_is_running (void)
 get the motor state
void mci_run (void)
 mci_run starts the motor with predefined parameter
void mci_set_motor_direction (U8 direction)
void mci_set_motor_speed (U8 speed)
void mci_set_speed (U16 speed)
void mci_stop (void)
void mci_store_measured_current (U16 current)
 Set the variable 'mc_measured_current' for initialization.
void mci_store_measured_speed (U8 measured_speed)
 set Measured of speed (for initialization)
void mci_store_potentiometer_value (U8 potentiometer)
 Set the 'mc_potentiometer_value' variable with the potentiometer value.

Variables

U8 mci_cmd_speed = 0
 User Input parameter to set motor speed.
Bool mci_direction = CW
 User Input parameter to set motor direction.
U32 mci_measured_current = 0
 Motor Input parameter to get the motor current.
U8 mci_measured_speed = 0
 Motor Input parameter to get the motor speed.
U8 mci_potentiometer_value = 0
 Motor Input to set the motor speed.
Bool mci_run_stop = STOP
 User Input parameter to launch or stop the motor.


Function Documentation

void mc_motor_init ( void   ) 

use to init programm

Parameters:
@post configuration of hardware and sotware
Precondition:
none

Definition at line 48 of file mc_interface.c.

References mc_init_HW(), mc_init_SW(), mci_stop(), and mci_store_measured_speed().

Referenced by main(), and mci_run().

00049 {
00050   mc_init_HW();
00051   mc_init_SW();
00052 
00053   mci_stop();
00054   mci_store_measured_speed(0);
00055 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mc_ramp_up_init ( void   ) 

Definition at line 35 of file main.c.

References g_speed_monitor_period, HS_001, new_position, ramp_counter, ramp_up, tick_divider_min, and TRUE.

Referenced by main(), and mci_run().

00036 {
00037    ramp_counter = 0;
00038    tick_divider_min = 50;
00039    new_position = HS_001;
00040    ramp_up = TRUE;
00041    g_speed_monitor_period = 0;
00042 }

Here is the caller graph for this function:

void mci_backward ( void   ) 

Definition at line 103 of file mc_interface.c.

References CCW, and mci_direction.

Referenced by ushell_task().

00104 {
00105   mci_direction = CCW;
00106 }

Here is the caller graph for this function:

void mci_forward ( void   ) 

Definition at line 93 of file mc_interface.c.

References CW, and mci_direction.

Referenced by ushell_task().

00094 {
00095   mci_direction = CW;
00096 }

Here is the caller graph for this function:

U16 mci_get_measured_current ( void   ) 

Get the current measured in the motor.

Precondition:
Launch ADC scheduler
Postcondition:
Get ADC Channel 12 result (Current value on 8bits).

Definition at line 144 of file mc_interface.c.

References mci_measured_current.

Referenced by mc_control_current(), and ushell_task().

00145 {
00146 /*  U16 value_to_return;
00147   value_to_return = mci_measured_current>>6;
00148   if (value_to_return > 994)
00149   {
00150     value_to_return = value_to_return - 994;
00151   }
00152   else
00153   {
00154     value_to_return = 994 - value_to_return;
00155   }
00156   return value_to_return;*/
00157   return mci_measured_current;
00158 }

Here is the caller graph for this function:

U8 mci_get_measured_speed ( void   ) 

Measured of speed.

Returns:
return value of speed (8 bits)
Precondition:
none
Postcondition:
none

Definition at line 134 of file mc_interface.c.

References mci_measured_speed.

Referenced by main(), mc_control_speed(), and ushell_task().

00135 {
00136   return mci_measured_speed;
00137 }

Here is the caller graph for this function:

U8 mci_get_motor_speed ( void   ) 

Definition at line 72 of file mc_interface.c.

References mci_cmd_speed.

Referenced by mc_regulation_loop(), and mc_switch_commutation().

00073 {
00074   return mci_cmd_speed;
00075 }

Here is the caller graph for this function:

U8 mci_get_potentiometer_value ( void   ) 

Get the potentiometer value.

Precondition:
Launch ADC scheduler
Postcondition:
Get ADC Channel 6 result (Potentiometer value on 8bits).

Definition at line 175 of file mc_interface.c.

References mci_potentiometer_value.

Referenced by mc_regulation_loop().

00176 {
00177   return mci_potentiometer_value;
00178 }

Here is the caller graph for this function:

Bool mci_motor_is_running ( void   ) 

get the motor state

Parameters:
@pre initialization HW and SW
Postcondition:
We know if the motor is running or not

Definition at line 36 of file mc_interface.c.

References mci_run_stop.

Referenced by mc_switch_commutation().

00037 {
00038   return mci_run_stop;
00039 }

Here is the caller graph for this function:

void mci_run ( void   ) 

mci_run starts the motor with predefined parameter

Parameters:
@pre initialization HW and SW
Postcondition:
New value in Hall variable

Definition at line 196 of file mc_interface.c.

References DUTY_RAMP_UP, mc_motor_init(), mc_ramp_up_init(), mc_regulation_loop(), mc_set_Open_Loop(), mci_run_stop, mci_set_motor_speed(), PSC_Run(), and RUN.

Referenced by ushell_task().

00197 {
00198    mc_motor_init();  // launch initialization of the motor
00199    mci_run_stop = RUN;
00200    mci_set_motor_speed(DUTY_RAMP_UP); /* set a speed for the ramp-up */
00201    mc_set_Open_Loop();      /* set the regulation type */
00202    mc_regulation_loop();    /* execute the regulation one time */
00203    mc_ramp_up_init();
00204    PSC_Run();
00205 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mci_set_motor_direction ( U8  direction  ) 

Definition at line 82 of file mc_interface.c.

References mci_direction.

Referenced by mc_control_position().

00083 {
00084 //  if ((mci_direction == CW) || (mci_direction == CCW)) mci_direction = direction;
00085    mci_direction = direction;
00086 }

Here is the caller graph for this function:

void mci_set_motor_speed ( U8  speed  ) 

Definition at line 62 of file mc_interface.c.

References mci_cmd_speed.

Referenced by main(), mci_run(), and mci_set_speed().

00063 {
00064   mci_cmd_speed = speed;
00065 }

Here is the caller graph for this function:

void mci_set_speed ( U16  speed  ) 

Definition at line 214 of file mc_interface.c.

References mci_set_motor_speed().

Referenced by ushell_task().

00215 {
00216    mci_set_motor_speed((U8)speed);
00217 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mci_stop ( void   ) 

Definition at line 207 of file mc_interface.c.

References mci_run_stop, PSC_Stop(), and STOP.

Referenced by mc_motor_init(), and ushell_task().

00208 {
00209    PSC_Stop();
00210    mci_run_stop  = STOP;
00211 }

Here is the call graph for this function:

Here is the caller graph for this function:

void mci_store_measured_current ( U16  current  ) 

Set the variable 'mc_measured_current' for initialization.

Precondition:
none
Postcondition:
'mc_measured_current' set with the current value

Definition at line 165 of file mc_interface.c.

References mci_measured_current.

Referenced by ADC_EOC().

00166 {
00167   mci_measured_current = ((63*mci_measured_current)+(64*current))>>6;
00168 }

Here is the caller graph for this function:

void mci_store_measured_speed ( U8  measured_speed  ) 

set Measured of speed (for initialization)

Precondition:
none
Postcondition:
mc_measured_speed initialized

Definition at line 123 of file mc_interface.c.

References mci_measured_speed.

Referenced by mc_estimation_speed(), mc_motor_init(), and ovfl_timer().

00124 {
00125   mci_measured_speed = measured_speed;
00126 }

Here is the caller graph for this function:

void mci_store_potentiometer_value ( U8  potentiometer  ) 

Set the 'mc_potentiometer_value' variable with the potentiometer value.

Precondition:
Launch ADC scheduler
Postcondition:
'mc_potentiometer_value' set with the potentiometer value

Definition at line 185 of file mc_interface.c.

References mci_potentiometer_value.

Referenced by ADC_EOC().

00186 {
00187   mci_potentiometer_value = potentiometer;
00188 }

Here is the caller graph for this function:


Variable Documentation

U8 mci_cmd_speed = 0

User Input parameter to set motor speed.

Definition at line 23 of file mc_interface.c.

Referenced by mci_get_motor_speed(), and mci_set_motor_speed().

Bool mci_direction = CW

User Input parameter to set motor direction.

Definition at line 21 of file mc_interface.c.

Referenced by mci_backward(), mci_forward(), mci_set_motor_direction(), and ushell_task().

U32 mci_measured_current = 0

Motor Input parameter to get the motor current.

Definition at line 26 of file mc_interface.c.

Referenced by mci_get_measured_current(), and mci_store_measured_current().

U8 mci_measured_speed = 0

Motor Input parameter to get the motor speed.

Definition at line 25 of file mc_interface.c.

Referenced by mci_get_measured_speed(), and mci_store_measured_speed().

U8 mci_potentiometer_value = 0

Motor Input to set the motor speed.

Definition at line 27 of file mc_interface.c.

Referenced by mci_get_potentiometer_value(), and mci_store_potentiometer_value().

Bool mci_run_stop = STOP

User Input parameter to launch or stop the motor.

Definition at line 22 of file mc_interface.c.

Referenced by main(), mci_motor_is_running(), mci_run(), mci_stop(), and ushell_task().


Generated on Wed Jul 12 16:55:22 2006 for Atmel BLDC Sensorless on ATAVRMC100 by  doxygen 1.4.7