mc_interface.c File Reference

#include "config.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

U8 mc_get_motor_direction (void)
U8 mc_get_motor_speed (void)
U8 mc_get_potentiometer_value (void)
 Get the potentiometer value.
void mc_init ()
 use to init programm
Bool mc_motor_is_running (void)
 get the motor state
void mc_set_motor_measured_speed (U8 measured_speed)
 set Measured of speed (for initialization)
void mc_set_potentiometer_value (U8 potentiometer)
 Set the 'mc_potentiometer_value' variable with the potentiometer value.
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.
void mci_retry_run (void)
 mci_retry_run retry to run if speed is null
void mci_run (void)
 mci_run run the motor with parameter
void mci_set_motor_speed (U8 speed)
void mci_set_speed (U16 speed)
void mci_stop (void)
 mci_stop stop the motor And reset the speed measured value.
void mci_store_measured_current (U16 current)
 Set the variable 'mc_measured_current' for initialization.

Variables

U8 mc_cmd_speed = 0
 User Input parameter to set motor speed.
U8 mc_measured_speed = 0
 Motor Input parameter to get the motor speed.
U8 mc_potentiometer_value = 0
 Motor Input to set the 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.
Bool mci_run_stop = FALSE
 User Input parameter to launch or stop the motor.


Function Documentation

U8 mc_get_motor_direction ( void   ) 

Definition at line 150 of file mc_interface.c.

References mci_direction.

00151 {
00152   return mci_direction;
00153 }

U8 mc_get_motor_speed ( void   ) 

Definition at line 120 of file mc_interface.c.

References mc_cmd_speed.

Referenced by mc_regulation_loop().

00121 {
00122   return mc_cmd_speed;
00123 }

U8 mc_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 201 of file mc_interface.c.

References mc_potentiometer_value.

Referenced by mc_regulation_loop().

00202 {
00203   return mc_potentiometer_value;
00204 }

void mc_init ( void   ) 

use to init programm

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

Definition at line 94 of file mc_interface.c.

References mc_init_HW(), mc_set_motor_measured_speed(), mci_forward(), mci_set_motor_speed(), and mci_stop().

00095 {
00096   mc_init_HW();
00097   Enable_interrupt();
00098 
00099   mci_stop();
00100   mci_forward();
00101   mci_set_motor_speed(0);
00102   mc_set_motor_measured_speed(0);
00103 }

Here is the call graph for this function:

Bool mc_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 72 of file mc_interface.c.

References mci_run_stop.

00073 {
00074   return mci_run_stop;
00075 }

void mc_set_motor_measured_speed ( U8  measured_speed  ) 

set Measured of speed (for initialization)

Precondition:
none
Postcondition:
mc_measured_speed initialized

Definition at line 160 of file mc_interface.c.

References mc_measured_speed.

Referenced by mc_init().

00161 {
00162   mc_measured_speed = measured_speed;
00163 }

void mc_set_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 211 of file mc_interface.c.

References mc_potentiometer_value.

00212 {
00213   mc_potentiometer_value = potentiometer;
00214 }

void mci_backward ( void   ) 

Definition at line 140 of file mc_interface.c.

References CCW, and mci_direction.

00141 {
00142   mci_direction = CCW;
00143 }

void mci_forward ( void   ) 

Definition at line 130 of file mc_interface.c.

References CW, and mci_direction.

Referenced by mc_init().

00131 {
00132   mci_direction = CW;
00133 }

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 181 of file mc_interface.c.

References mci_measured_current.

Referenced by mc_control_current().

00182 {
00183   return mci_measured_current/64;
00184 }

U8 mci_get_measured_speed ( void   ) 

Measured of speed.

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

Definition at line 171 of file mc_interface.c.

References mc_measured_speed.

Referenced by mc_control_speed().

00172 {
00173   return mc_measured_speed;
00174 }

void mci_retry_run ( void   ) 

mci_retry_run retry to run if speed is null

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

Definition at line 57 of file mc_interface.c.

References mc_disable_during_inrush(), mc_duty_cycle(), mc_get_Duty_Cycle(), mc_get_hall(), mc_regulation_loop(), mc_switch_commutation(), mci_run_stop, and TRUE.

00058 {
00059   mci_run_stop = TRUE;
00060   mc_regulation_loop();
00061   mc_duty_cycle(mc_get_Duty_Cycle());
00062   mc_switch_commutation(mc_get_hall());
00063   mc_disable_during_inrush(); /* disable overcurrent during inrush */
00064 }

Here is the call graph for this function:

void mci_run ( void   ) 

mci_run run the motor with parameter

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

Definition at line 34 of file mc_interface.c.

References mc_disable_during_inrush(), mc_duty_cycle(), mc_get_Duty_Cycle(), mc_get_hall(), mc_regulation_loop(), mc_switch_commutation(), mci_run_stop, and TRUE.

00035 {
00036   /* TL: TO BE MODIFIED 
00037   if (!(PCTL2 & (1<<PRUN2))) // if there is an overcurrent 
00038   {
00039     PSC0_Init(255,0,1,0);
00040     PSC1_Init(255,0,1,0);
00041     PSC2_Init(255,0,1,0);
00042   }
00043   */
00044   mci_run_stop = TRUE;
00045   mc_regulation_loop();
00046   mc_duty_cycle(mc_get_Duty_Cycle());
00047   mc_switch_commutation(mc_get_hall());
00048   mc_disable_during_inrush(); /* disable overcurrent during inrush */
00049 }

Here is the call graph for this function:

void mci_set_motor_speed ( U8  speed  ) 

Definition at line 110 of file mc_interface.c.

References mc_cmd_speed.

Referenced by mc_init(), and mci_set_speed().

00111 {
00112   mc_cmd_speed = speed;
00113 }

void mci_set_speed ( U16  speed  ) 

Definition at line 216 of file mc_interface.c.

References mci_set_motor_speed().

00217 {
00218    mci_set_motor_speed((U8)speed);
00219 }

Here is the call graph for this function:

void mci_stop ( void   ) 

mci_stop stop the motor And reset the speed measured value.

Precondition:
motor run (mci_run executed)
Postcondition:
motor stop

Definition at line 83 of file mc_interface.c.

References FALSE, and mci_run_stop.

Referenced by mc_init().

00084 {
00085   mci_run_stop=FALSE;
00086 }

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 191 of file mc_interface.c.

References mci_measured_current.

00192 {
00193   mci_measured_current = ((63*mci_measured_current)+(64*current))>>6;
00194 }


Variable Documentation

User Input parameter to set motor speed.

Definition at line 22 of file mc_interface.c.

Referenced by mc_get_motor_speed(), and mci_set_motor_speed().

Motor Input parameter to get the motor speed.

Definition at line 24 of file mc_interface.c.

Referenced by mc_set_motor_measured_speed(), and mci_get_measured_speed().

Motor Input to set the motor speed.

Definition at line 26 of file mc_interface.c.

Referenced by mc_get_potentiometer_value(), and mc_set_potentiometer_value().

User Input parameter to set motor direction.

Definition at line 20 of file mc_interface.c.

Referenced by mc_get_motor_direction(), mci_backward(), and mci_forward().

Motor Input parameter to get the motor current.

Definition at line 25 of file mc_interface.c.

Referenced by mci_get_measured_current(), and mci_store_measured_current().

Bool mci_run_stop = FALSE

User Input parameter to launch or stop the motor.

Definition at line 21 of file mc_interface.c.

Referenced by mc_motor_is_running(), mci_retry_run(), mci_run(), and mci_stop().


Generated on Wed Oct 22 16:03:26 2008 for AVR496 : Atmel BLDC control on ATAVRMC301 with ATtiny861 by  doxygen 1.5.7.1