mc_drv.c File Reference

,v More...

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

Include dependency graph for mc_drv.c:

Go to the source code of this file.

Functions

void init_amplifier_1 (void)
 init Amplifier 1
void mc_ADC_Scheduler (void)
 Launch the sampling procedure to get current value.
void mc_disable_during_inrush (void)
 the purpose of this function is to disable
the overcurrent detection during startup (inrush current)

void mc_duty_cycle (U8 level)
 External interruption Sensor (A) mode toggle.
void mc_estimation_speed (void)
 Timer0 Overflow for speed measurement.
U8 mc_get_hall (void)
 Get the value of hall sensors (1 to 6).
void mc_init_HW (void)
 init HW
void mc_init_timer0 (void)
 Launch the regulation loop (see main.c) .
void mc_init_timer1 (void)
 timer 1 Configuration Use to generate a 250us activation for sampling speed regulation
void mc_inrush_task (void)
 the purpose of this function is to manage the delay
used when the overcurrent detection is disabled

void mc_set_Over_Current (U8 Level)
 Set the Over Current threshold.
void mc_switch_commutation (U8 position)
 Set the Switching Commutation value on outputs according to sensor or estimation position.
void PSC0_Init (unsigned int OCRnRB, unsigned int OCRnSB, unsigned int OCRnRA, unsigned int OCRnSA)
 Initialization of PWM generator PSC0.
void PSC1_Init (unsigned int OCRnRB, unsigned int OCRnSB, unsigned int OCRnRA, unsigned int OCRnSA)
 Initialization of PWM generator PSC1.
void PSC2_Init (unsigned int OCRnRB, unsigned int OCRnSB, unsigned int OCRnRA, unsigned int OCRnSA)
 Initialization of PWM generator PSC2.

Variables

char ADC_State = FREE
U16 average = 0
U8 count = 1
Bool current_EOC = FALSE
Bool g_mc_read_enable = FALSE
Bool g_tick = FALSE
 Use for control the sampling period value.
U16 inrush_delay = 0
Bool inrush_mask_flag = FALSE
U8 ovf_timer = 0
U8 PWMxB
char State = CONV_INIT


Detailed Description

,v

Copyright (c) 2008 Atmel.

Motor Control Driver level :

Definition in file mc_drv.c.


Function Documentation

void init_amplifier_1 ( void   ) 

init Amplifier 1

Precondition:
none
Postcondition:
initialization of hardware

Definition at line 64 of file mc_drv.c.

00065 {
00066 }

void mc_ADC_Scheduler ( void   ) 

Launch the sampling procedure to get current value.

Precondition:
amplifier and IT initialization
Postcondition:
Set the End Of Conversion flag Launch the scheduler for the ADC
Precondition:
none
Postcondition:
Get Channel 6 and 12 results for Potentiometer and current values.

Definition at line 296 of file mc_drv.c.

00297 {
00298 }

void mc_disable_during_inrush ( void   ) 

the purpose of this function is to disable
the overcurrent detection during startup (inrush current)

Definition at line 315 of file mc_drv.c.

Referenced by mci_retry_run(), and mci_run().

00316 {
00317 }

void mc_duty_cycle ( U8  level  ) 

External interruption Sensor (A) mode toggle.

Precondition:
configuration of external interruption (initialization)
Postcondition:
New value in Hall variable External interruption Hall Sensor (B) mode toggle
Precondition:
configuration of external interruption (initialization)
Postcondition:
New value in Hall variable External interruption Hall Sensor (C) mode toggle
Precondition:
configuration of external interruption (initialization)
Postcondition:
New value in Hall variable Set the duty cycle values in the PSC according to the value calculate by the regulation loop

Definition at line 180 of file mc_drv.c.

Referenced by mci_retry_run(), and mci_run().

00181 {
00182 }

void mc_estimation_speed ( void   ) 

Timer0 Overflow for speed measurement.

Precondition:
configuration of timer 0
Postcondition:
generate an overflow when the motor turns too slowly estimation speed
Precondition:
configuration of timer 0
and define or not AVERAGE_SPEED_MEASURE in config_motor.h
Postcondition:
new value for real speed

Definition at line 265 of file mc_drv.c.

00266 {
00267 }

U8 mc_get_hall ( void   ) 

Get the value of hall sensors (1 to 6).

Parameters:
return an unsigned char value of hall sensor
Precondition:
configuration of port PB and PD
Postcondition:
new value of position

Definition at line 119 of file mc_drv.c.

References HALL_SENSOR_VALUE.

Referenced by mci_retry_run(), and mci_run().

00120 {
00121   return HALL_SENSOR_VALUE();
00122 }

void mc_init_HW ( void   ) 

init HW

Precondition:
none
Postcondition:
initialization of hardware

Definition at line 53 of file mc_drv.c.

Referenced by mc_init().

00055 {
00056  
00057 }

void mc_init_timer0 ( void   ) 

Launch the regulation loop (see main.c) .

Precondition:
configuration of timer 1 registers
Postcondition:
g_tick use in main.c for regulation loop Timer 0 Configuration The timer 0 is used to generate an IT when an overflow occurs
Precondition:
None
Postcondition:
Timer0 initialized.

Definition at line 239 of file mc_drv.c.

00240 {
00241 }

void mc_init_timer1 ( void   ) 

timer 1 Configuration Use to generate a 250us activation for sampling speed regulation

Precondition:
None
Postcondition:
An interrupt all 256us

Definition at line 206 of file mc_drv.c.

00207 {
00208 }

void mc_inrush_task ( void   ) 

the purpose of this function is to manage the delay
used when the overcurrent detection is disabled

Definition at line 321 of file mc_drv.c.

00322 { 
00323 }

void mc_set_Over_Current ( U8  Level  ) 

Set the Over Current threshold.

Precondition:
DAC initialization
Postcondition:
the Over Current threshold is set.

Definition at line 309 of file mc_drv.c.

00310 {
00311 }

void mc_switch_commutation ( U8  position  ) 

Set the Switching Commutation value on outputs according to sensor or estimation position.

Parameters:
position (1 to 6) and direction (FORWARD or BACKWARD)

Definition at line 190 of file mc_drv.c.

Referenced by mci_retry_run(), and mci_run().

00191 {
00192 }

void PSC0_Init ( unsigned int  OCRnRB,
unsigned int  OCRnSB,
unsigned int  OCRnRA,
unsigned int  OCRnSA 
)

Initialization of PWM generator PSC0.

Definition at line 77 of file mc_drv.c.

00081 {
00082 }

void PSC1_Init ( unsigned int  OCRnRB,
unsigned int  OCRnSB,
unsigned int  OCRnRA,
unsigned int  OCRnSA 
)

Initialization of PWM generator PSC1.

Definition at line 87 of file mc_drv.c.

00091 {
00092 }

void PSC2_Init ( unsigned int  OCRnRB,
unsigned int  OCRnSB,
unsigned int  OCRnRA,
unsigned int  OCRnSA 
)

Initialization of PWM generator PSC2.

Definition at line 98 of file mc_drv.c.

00102 {
00103 }


Variable Documentation

char ADC_State = FREE

Definition at line 39 of file mc_drv.c.

U16 average = 0

Definition at line 27 of file mc_drv.c.

U8 count = 1

Definition at line 26 of file mc_drv.c.

Bool current_EOC = FALSE

Definition at line 36 of file mc_drv.c.

Definition at line 33 of file mc_drv.c.

Bool g_tick = FALSE

Use for control the sampling period value.

Definition at line 34 of file mc_drv.c.

Definition at line 31 of file mc_drv.c.

Definition at line 30 of file mc_drv.c.

Definition at line 28 of file mc_drv.c.

char State = CONV_INIT

Definition at line 38 of file mc_drv.c.


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