📄 bldcadczcdefines.h
字号:
/*************************************************************************
* Freescale Inc.
* (c) Copyright 2005 Freescale, Inc.
* ALL RIGHTS RESERVED.
*************************************************************************/
/*************************************************************************
*
* FILE NAME: bldcadczcdefines.h
*
* Description: Header file for 3-phase sensorless BLDC motor
* with BEMF Zero Crossing using ADC application
*
*************************************************************************/
#ifndef __BLDCADCZCDEFINES_H
#define __BLDCADCZCDEFINES_H
/* DEFINITION_START */
#include "types.h"
/************************************************************************/
/** SYSTEM CONSTANTS DEFINITIONS **/
/************************************************************************/
#define CLOCK 8000000 /* Clock frequency of Relaxation Oscilator */
#define IPBUS_CLOCK_FREQ (CLOCK / (1 << ((C_Cpu_reg_PLLDB & 0x0700) >> 8))) * 24 / 3 / 2
#define CMT_QT_PRESCALER 32 /* Commutation Quad Timer Prescaler
Needs to be set according commutation timer parameters */
/* By selecing the prescaler of commutation timer 32,
we obtain an exact 1 us step for this timer, because the
Anguilla internal oscilator runs at 32 MHz */
/* Fault const declarations */
#define NO_FAULT 0 /* No Fault */
#define DC_OVERVOLTAGE 1 /* DC Overvoltage */
#define DC_UNDERVOLTAGE 2 /* DC Undervoltage */
#define DC_OVERCURRENT 4 /* DC Overcurrent */
/* system maximal register limits and offset */
#define VOLTAGE_OFFSET_SYSU 0x3FFF /* Zero voltage is at 50% duty cycle [system unit] */
#define VOLTAGE_UP_LIMIT_SYSU (16383-64) /* Possibly -128 max. output from PI controller */
#define VOLTAGE_DOWN_LIMIT_SYSU (-16383+64) /* Possibly +128 min. output from PI controller */
#define CURR_DC_BUS_OFFSET_SYS 0x4000 /* DC bus current offset [system unit] (1.65V) */
#define CURR_DC_BUS_UP_LIMIT_SYS 0x3fff /* DC bus current upper limit range [system unit] */
#define OMEGA_INCREMENT_SYSU 2048 /* Speed Increment [system unit] */
#define OMEGA_LIMIT_SYSU (32768-1) /* Speed Limit [system unit] */
#define OMEGA_UP_LIMIT_SYSU OMEGA_LIMIT_SYSU/* Speed Up Limit [system unit] */
#define OMEGA_DOWN_LIMIT_SYSU (-OMEGA_LIMIT_SYSU)/* Speed Down Limit [system unit] */
#define PER_START_TIMEROC_CMT 0x8000 /* Init periode of Commutation Timer */
#define ALIGN_DESVOLTAGE_SYSU 0 /* Alignment Voltage [system unit] at Alignment start */
#define PER_SPEED_SAMPLE_S 0.001 /* Sampling Period of the Speed Controller [s] */
/* Sampling Period of the Speed Controller [system unit] */
#define PER_SPEED_SYS (PER_SPEED_SAMPLE_S / CONTROL_SCAN_PERIOD)
#define CONTROL_SCAN_PERIOD 0.00020 /* Scan period of IsrSpeedCurrentControl [s] */
#define UDCBUS_FILT_INDEX 4
#define IDCBUS_FILT_INDEX 6
#define SPEED_FILT_INDEX 3
#define BUTTON_READ_PRESCALER_SCAN 150 /* Debounce counter value to limit scan rate, during regular scan */
#define BUTTON_READ_PRESCALER_DEBOUNCE 7500 /* Debounce counter value, after button is pressed */
#define RAMP_INCREMENT_UP 32
#define RAMP_INCREMENT_DOWN 32
#define CL_MARKER_HIGH_LIMIT 500
#define CL_MARKER_LOW_LIMIT 0
/************************************************************************/
/** EVM33395 board parameters constants **/
/************************************************************************/
/* EVM motor Application maximum values used for scaling */
#define EVM33395_APP_VOLT_MAX 16.0 /* 16.0 V = 100 % */
#define EVM33395_APP_CURR_MAX 9.6 /* 9.6 A = 100 % */
/* EVM motor DC-bus voltage error limits */
#define EVM33395_DCB_UNDERVOLTAGE 10.0 /* Undervoltage limit [V] */
#define EVM33395_DCB_OVERVOLTAGE 15.0 /* Overvoltage limit [V] */
#define EVM33395_DCB_OVERCURRENT 9.0 /* Overcurrent limit [A] */
/************************************************************************/
/** Micro Power Stage board parameters constants **/
/************************************************************************/
/* HV motor Application maximum values used for scaling */
#define MP_APP_VOLT_MAX 16.3 /* 16.3 V = 100 % */
#define MP_APP_CURR_MAX 8.25 /* 8.25 A = 100 % */
/* EVM motor DC-bus voltage error limits */
#define MP_DCB_UNDERVOLTAGE 10.0 /* Undervoltage limit [V] */
#define MP_DCB_OVERVOLTAGE 15.0 /* Overvoltage limit [V] */
#define MP_DCB_OVERCURRENT 3.0 /* Overcurrent limit [A] */
/************************************************************************/
/** MOTOR A PARAMETERS **/
/** Low Voltage Motor MCG IB23810 **/
/************************************************************************/
/* Alignment duration settings */
#define MOTORA_PER_ALIGNMENT_S 0.5 /* Alignment duration [seconds] */
/* Alignment current settings */
#define MOTORA_CURR_ALIGN_DESIRED_A 1.5 /* Alignment Current Desired [A] */
/* Alignment Current PI regulator constants */
#define MOTORA_CURR_PI_PROPORTIONAL_GAIN 17500 /* Alignment PI Controller Parameters */
#define MOTORA_CURR_PI_PROPORTIONAL_GAIN_SCALE 2
#define MOTORA_CURR_PI_INTEGRAL_GAIN 17500
#define MOTORA_CURR_PI_INTEGRAL_GAIN_SCALE 5
/* Current Limitation PI regulator constants */
#define MOTORA_CURRLIMIT_PI_PROPORTIONAL_GAIN 16384 /* Current Limitation PI Controller Parameters */
#define MOTORA_CURRLIMIT_PI_PROPORTIONAL_GAIN_SCALE 5
#define MOTORA_CURRLIMIT_PI_INTEGRAL_GAIN 16384
#define MOTORA_CURRLIMIT_PI_INTEGRAL_GAIN_SCALE 5
/* Speed PI regulator constants */
#define MOTORA_SPEED_PI_PROPORTIONAL_GAIN 30500 /* Speed PI Controller Parameters */
#define MOTORA_SPEED_PI_PROPORTIONAL_GAIN_SCALE 3
#define MOTORA_SPEED_PI_INTEGRAL_GAIN 19500
#define MOTORA_SPEED_PI_INTEGRAL_GAIN_SCALE 7
/* Speed constants */
#define MOTORA_SPEED_ROTOR_MAX_RPM 2000 /* Maximal rotor speed [rpm] */
#define MOTORA_MOTOR_COMMUTATION_PREV 12 /* Motor Commutations Per mechanical Revolution */
#define MOTORA_OMEGA_MIN_SYSU 3276 /* Angular frequency minimal [system unit] */
#define MOTORA_MAX_ZCROSERR 4 /* Maximal Zero Crossing Errors to stop commutations */
#define MOTORA_MIN_ZCROSOK_START 2 /* Minimal Zero Crossing OK to stop starting */
#define MOTORA_ALIGNMENT_STEP_CMT_ACB 4 /* Alignment commutation step index for direction acb */
#define MOTORA_ALIGNMENT_STEP_CMT_ABC 5 /* Alignment commutation step index for direction abc */
/* Current limit settings */
#define MOTORA_CURR_LIMIT_DESIRED_A 4.0 /* Limitation Current Desired [A] */
#define MOTORA_PER_START_PROCCMT_US 170.0 /* Minimum Toff duration during Start Phase [uS] */
#define MOTORA_PER_CMTSTART_US 3600.0 /* Start Commutation Period [uS] */
#define MOTORA_PER_TOFFSTART_US 7200.0 /* Start Toff Period [uS] */
#define MOTORA_COEF_START_CMT_PRECOMP_FRAC FRAC16(0.5)
#define MOTORA_COEF_START_CMT_PRECOMP_LSHFT 2
#define MOTORA_COEF_START_HLFCMT FRAC16(0.125)
#define MOTORA_COEF_START_TOFF FRAC16(0.250)
#define MOTORA_PER_RUN_PROCCMT_US 170.0 /* Mimimum Toff duration during Run Phase [uS] */
#define MOTORA_COEF_RUN_CMT_PRECOMP_FRAC FRAC16(0.5)
#define MOTORA_COEF_RUN_CMT_PRECOMP_LSHFT 2
#define MOTORA_COEF_RUN_HLFCMT FRAC16(0.50)
#define MOTORA_COEF_RUN_TOFF FRAC16(0.250)
#define MOTORA_PWM_to_ADC_COEF FRAC16(0.5)
/* Values in system units, derived from user definitions */
/* Alignment duration [system units] */
#define MOTORA_PER_ALIGNMENT_SYS ( MOTORA_PER_ALIGNMENT_S / CONTROL_SCAN_PERIOD )
#define MOTORA_CURR_ALIGN_DESIRED_sub CURR_DC_BUS_UP_LIMIT_SYS * MOTORA_CURR_ALIGN_DESIRED_A
#define MOTORA_CURR_LIMIT_DESIRED_sub CURR_DC_BUS_UP_LIMIT_SYS * MOTORA_CURR_LIMIT_DESIRED_A
/* Minimal commutation period in internal scale */
#define MOTORA_PER_CMT_MIN (((( IPBUS_CLOCK_FREQ / MOTORA_SPEED_ROTOR_MAX_RPM ) /\
CMT_QT_PRESCALER ) * 60 ) / MOTORA_MOTOR_COMMUTATION_PREV )
/* CmtProc duration during Start Phase [system unit] */
#define MOTORA_PER_START_PROCCMT ((UWord16) ( MOTORA_PER_START_PROCCMT_US * \
(IPBUS_CLOCK_FREQ / CMT_QT_PRESCALER / 1000000.0)))
/* CmtProc duration during Run Phase [system unit] */
#define MOTORA_PER_RUN_PROCCMT ((UWord16) ( MOTORA_PER_RUN_PROCCMT_US * \
(IPBUS_CLOCK_FREQ / CMT_QT_PRESCALER / 1000000.0)))
/* Start Commutation Period [system unit] */
#define MOTORA_PER_CMTSTART ((UWord16) ( MOTORA_PER_CMTSTART_US * \
(IPBUS_CLOCK_FREQ / CMT_QT_PRESCALER / 1000000.0)))
/* Start Zero Crossing Toff Period [system unit] */
#define MOTORA_PER_TOFFSTART ((UWord16) ( MOTORA_PER_TOFFSTART_US * \
(IPBUS_CLOCK_FREQ / CMT_QT_PRESCALER / 1000000.0)))
/************************************************************************/
/** MOTOR B PARAMETERS **/
/** Low Voltage Motor Pitmann 2311 **/
/************************************************************************/
/* Alignment duration settings */
#define MOTORB_PER_ALIGNMENT_S 0.5 /* Alignment duration [seconds] */
/* Alignment current settings */
#define MOTORB_CURR_ALIGN_DESIRED_A 3.0 /* Alignment Current Desired [A] */
/* Alignment Current PI regulator constants */
#define MOTORB_CURR_PI_PROPORTIONAL_GAIN 17500 /* Alignment PI Controller Parameters */
#define MOTORB_CURR_PI_PROPORTIONAL_GAIN_SCALE 2
#define MOTORB_CURR_PI_INTEGRAL_GAIN 17500
#define MOTORB_CURR_PI_INTEGRAL_GAIN_SCALE 5
/* Current Limitation PI regulator constants */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -