⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.h

📁 BLDC_SENSORLESS controller using freeescale mcu aw60
💻 H
字号:
/*******************************************************************************
*
* Freescale Semiconductor Inc.
* (c) Copyright 2004-2006 Freescale Semiconductor, Inc.
* (c) Copyright 2001-2004 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
********************************************************************************
*
* $File Name: main.h$
*
* $Date:      Jan-19-2007$
*
* $Version:   0.0.2.0$
*
* Description: Header file for BLDC Sensorless motor control using MC9S08AW60
*
*****************************************************************************/

#ifndef _MAIN_H
#define _MAIN_H


#define PWM_MODULO      626     // PWM frequency set to 16000
                                // 20MHz/2/16kHz = 625
                                // Note: rounded up to be even value

#define PWM_DEAD_TIME   6       // 6 * 2 * 50 ns @ 20MHz

#define AD_DCB_V     0
#define AD_DCB_I     1
#define AD_BEMF_A    6
#define AD_BEMF_B    5
#define AD_BEMF_C    4
#define AD_TEMP      7
#define AD_DISABLE   15

#define DCB_OFFSET   3
#define DCB_CURRENT_OFFSET        512

#define POSITIVE_VOLTAGE          1
#define NEGATIVE_VOLTAGE          0
#define RAISING_EDGE              1
#define FALLING_EDGE              0

#define C_DIRECTION               0
#define CC_DIRECTION              1

#define SPEED_MODE                0
#define TORQUE_MODE               1

#define APP_INIT                  0
#define APP_ALIGNMENT             1
#define APP_START                 2
#define APP_RUN                   3
#define APP_STOP                  4
#define APP_STABILIZATION         5
#define APP_ERROR                 6

#define ALIGNMENT_TIME            100
#define START_ALIGNMENT_VOLTAGE   0
#define ALIGNMENT_VOLTAGE         43
#define ALIGNED_VOLTAGE_INCREMENT (unsigned int)(256*ALIGNMENT_VOLTAGE/ALIGNMENT_TIME)

#define START_PERIOD              6000
#define START_ACCELERATION        243   //0.95 * 256

#define START_SPEED               1610
#define SPEED_RAMP_INCREMENT      50
#define START_TORQUE              10

#define START_CMT_NUMBER          6
#define STABILIZATION_CMT_NUMBER  6

#define DEBOUNCE_VALUE 20

#define MAX_SPEED          12880   // 1200 RPM
#define MIN_SPEED          1610    // 150 RPM
#define SPEED_STEP         1610    // 150 RPM

#define MAX_TORQUE         100      // 2 Amps
#define MIN_TORQUE         10        // 0.2 Amps
#define TORQUE_STEP        5        // 0.1 Amps

typedef void (*tPointerFcn)(void); /* pointer to function */
/* Structure for conroller parameters and integral portion keeping */
typedef struct
{
    unsigned char   ProportionalGain;
    unsigned char   IntegralGain;
    signed int     IntegralPortionK_1;
}sPIparams;
  
typedef union uProcessStatus
  {
  unsigned char  byte;
  struct
    {
    unsigned char AfterAlignment   :1;
    unsigned char AfterCMT         :1;
    unsigned char NewZC            :1;
    unsigned char DisableADC       :1;
    unsigned char EnableZC         :1;
    unsigned char StallCheck       :1;
    unsigned char bit6             :1;
    unsigned char bit7             :1;
    }bit;
  }tProcessStatus;  

typedef union uDriveStatus
  {
  unsigned char  byte;
  struct
    {
    unsigned char StopRun          :1;
    unsigned char SpeedTorque      :1;
    unsigned char Alignment        :1;
    unsigned char Sensorless       :1;
    unsigned char EnablePWM        :1;
    unsigned char CloseLoop        :1;
    unsigned char bit6             :1;
    unsigned char Error            :1;
    }bit;
  }tDriveStatus;

typedef union uDriveDemand
  {
  unsigned char  byte;
  struct
    {
    unsigned char StopRun          :1;
    unsigned char SpeedTorque      :1;
    unsigned char bit2             :1;
    unsigned char bit3             :1;
    unsigned char bit4             :1;
    unsigned char bit5             :1;
    unsigned char bit6             :1;
    unsigned char bit7             :1;
    }bit;
  }tDriveDemand;

typedef union uDebugStatus
  {
  unsigned char  byte;
  struct
    {
    unsigned char EnablePWM        :1;
    unsigned char bit1             :1;
    unsigned char bit2             :1;
    unsigned char bit3             :1;
    unsigned char bit4             :1;
    unsigned char bit5             :1;
    unsigned char bit6             :1;
    unsigned char bit7             :1;
    }bit;
  }tDebugStatus;

typedef union uInterfaceStatus
  {
  unsigned char  byte;
  struct
    {
    unsigned char Switch           :1;
    unsigned char SwitchChange     :1;
    unsigned char Up               :1;
    unsigned char Down             :1;
    unsigned char bit4             :1;
    unsigned char bit5             :1;
    unsigned char bit6             :1;
    unsigned char bit7             :1;
    }bit;
  }tInterfaceStatus;
  
#endif /* _MAIN_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -