mc_control.h File Reference


Detailed Description

This file contains the function declarations.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file mc_control.h.

#include "mc_drv.h"

Include dependency graph for mc_control.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void mc_regulation_loop ()
 This function launches speed control or no regulation.
void mc_start_motor ()
 Executes the motor startup sequence.


Function Documentation

void mc_regulation_loop (  ) 

This function launches speed control or no regulation.

Definition at line 243 of file mc_control.c.

References FALSE, mc_set_duty_cycle(), MIN_PWM_COMPARE_VALUE, speedReferenceADC, and speedUpdated.

Referenced by main().

00244 {
00245   // Only update duty cycle if a new speed reference measurement has been made. (Done right after speed measurement is ready)
00246   if (speedUpdated)
00247   {
00248     speedUpdated = FALSE;
00249     // Calculate duty cycle from speed reference value.
00250     mc_set_duty_cycle(MIN_PWM_COMPARE_VALUE+(speedReferenceADC>>3));
00251   }
00252 }

Here is the call graph for this function:

void mc_start_motor (  ) 

Executes the motor startup sequence.

This function locks the motor into a known position and fires off a commutation sequence controlled by the Timer/counter1 overflow interrupt.

Definition at line 143 of file mc_control.c.

References ADMUXTableForward, ADMUXTableReverse, commTableForward, commTableReverse, delay_us(), mc_set_duty_cycle(), nextCommutationStep, SET_TIMER1_INT_ZC_DETECTION, start_delay, STARTUP_NUM_COMMUTATIONS, STARTUP_PWM_COMPARE_VALUE, TC0_WRITE_TCNT0, zcPolarity, zcTableForward, and zcTableReverse.

Referenced by main().

00144 {
00145   U8 i = 0;
00146   U8 j = 0;
00147   U8 end_of_start = 0;
00148   mc_set_duty_cycle(STARTUP_PWM_COMPARE_VALUE) ;
00149   
00150   nextCommutationStep = 0;
00151 
00152   while(end_of_start!=1)
00153   {
00154     switch(nextCommutationStep)
00155     {
00156       case 0:       
00157 #if (DIRECTION_OF_ROTATION == CCW) 
00158         TCCR1E = commTableReverse[0];
00159 #else
00160         TCCR1E = commTableForward[0];
00161 #endif        
00162         if (i < 2) i += 1; 
00163         if ((i == 2)&&(j<STARTUP_NUM_COMMUTATIONS)) { 
00164            j += 1;i=0;
00165         }
00166        if ((i==2)&&(j==STARTUP_NUM_COMMUTATIONS)){
00167           end_of_start = 1;
00168         } 
00169         delay_us(start_delay[j]);  
00170         nextCommutationStep = 1;
00171         break;
00172       case 1: 
00173 #if (DIRECTION_OF_ROTATION == CCW)      
00174         TCCR1E = commTableReverse[1];
00175 #else
00176         TCCR1E = commTableForward[1];
00177 #endif
00178         delay_us(start_delay[j]);  
00179         nextCommutationStep = 2;            
00180         break;
00181       case 2:   
00182 #if (DIRECTION_OF_ROTATION == CCW)      
00183         TCCR1E = commTableReverse[2];
00184 #else
00185         TCCR1E = commTableForward[2];
00186 #endif        
00187         delay_us(start_delay[j]);  
00188         nextCommutationStep = 3;
00189         break;
00190       case 3:
00191 #if (DIRECTION_OF_ROTATION == CCW)      
00192         TCCR1E = commTableReverse[3];
00193 #else
00194         TCCR1E = commTableForward[3];
00195 #endif        
00196         delay_us(start_delay[j]);  
00197         nextCommutationStep = 4;           
00198         break;
00199       case 4:       
00200 #if (DIRECTION_OF_ROTATION == CCW)      
00201         TCCR1E = commTableReverse[4];
00202 #else
00203         TCCR1E = commTableForward[4];
00204 #endif        
00205         delay_us(start_delay[j]);  
00206         nextCommutationStep = 5;          
00207         break;
00208       case 5:  
00209 #if (DIRECTION_OF_ROTATION == CCW)      
00210         TCCR1E = commTableReverse[5];
00211 #else
00212         TCCR1E = commTableForward[5];
00213 #endif        
00214         delay_us(start_delay[j]);  
00215         nextCommutationStep = 0;            
00216         break;
00217     default :
00218       nextCommutationStep = nextCommutationStep;
00219       break;
00220     }
00221   }
00222 
00223   //nextCommutationStep++;
00224   nextCommutationStep = 0;
00225   // Use LSB of nextCommutationStep to determine zero crossing polarity.  
00226 #if (DIRECTION_OF_ROTATION == CCW)  
00227   zcPolarity = zcTableReverse[nextCommutationStep];
00228   ADMUX = ADMUXTableReverse[nextCommutationStep];
00229 #else
00230   zcPolarity = zcTableForward[nextCommutationStep];
00231   ADMUX = ADMUXTableForward[nextCommutationStep];
00232 #endif 
00233   // Switch to sensorless commutation.
00234   TC0_WRITE_TCNT0(0);
00235 
00236   // Enable Timer 1 Interrupt
00237   SET_TIMER1_INT_ZC_DETECTION;
00238 
00239 }

Here is the call graph for this function:


Generated on Mon Dec 1 11:12:21 2008 for AVR498 : Atmel BLDC control on ATAVRMC301 with ATtiny861 by  doxygen 1.5.4