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

📄 acmotor.lst

📁 该程序是ST7MC驱动三洋压缩机(交流)
💻 LST
字号:
ANSI-C/cC++ Compiler for ST7 V-5.0.7, Aug 21 2001

    1:  /**************** (c) 2004  STMicroelectronics ********************************
    2:       
    3:  PROJECT  : 3-phase AC induction motor drive Software Library
    4:  COMPILER : COSMIC / METROWERKS
    5:  
    6:  MODULE  :  acmotor.c
    7:  VERSION :  1.0.0
    8:  
    9:  CREATION DATE : April 2004
   10:  
   11:  AUTHOR :	V. Onde / Microcontroller Division Applications
   12:  			Consumer & Micro Group
   13:  
   14:  -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
   15:  
   16:  DESCRIPTION :   3-phase AC motor control routines, include Start/Stop 
   17:  					management and PI regulation
   18:                
   19:  -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
   20:  
   21:  MODIFICATIONS :
   22:  
   23:  *******************************************************************************
   24:   THE SOFTWARE INCLUDED IN THIS FILE IS FOR GUIDANCE ONLY. ST MICROELECTRONICS
   25:   SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES
   26:   WITH RESPECT TO ANY CLAIMS ARISING FROM USE OF THIS SOFTWARE.
   27:  ******************************************************************************/
   28:  
   29:  #include "lib.h"		/*General purpose typedefs and macros */
   30:  #include "mtc.h"		/*Public motor control peripheral function prototypes*/
   31:  #include "ACMparam.h"	/*AC Motor Control parameters */
   32:  #include "acmotor.h"	/*Public AC motor control function prototypes */
   33:  #include "pwmart.h"		/*Public general purpose Timebase function prototypes*/
   34:  
   35:  #ifdef PI_PARAM_TUNING
   36:  	u8	Kp, Ki;
   37:  #else
   38:  	static u8	Kp, Ki;
   39:  #endif
   40:  
   41:  static s32 VoltageIntegralTerm;                      
   42:  static s8 Error_slip;
   43:  static s32	DeltaVoltage_slip;
   44:  static s16	Voltage_slip;
   45:  static s32	DeltaVoltage_slip_s32;
   46:  static s32	Voltage_slip_s32;         
   47:  static BOOL MinPiOut;
   48:  static BOOL MaxPiOut;
   49:  
   50:  
   51:  #define	VOLT_INIT	((u8)0)		/* Voltage initialisation at MCU start-up */
   52:  #define	FREQ_INIT	((u16)50)	/* Freq initialisation at MCU start-up */
   53:  
   54:  #define SLEW_LIMIT	((u8)20)	/* Voltage and frequency increment/decrement 
   55:  								rate in ms */
   56:  
   57:  /*-----------------------------------------------------------------------------
   58:  ROUTINE Name : ACM_Init
   59:  
   60:  Description: This function performs the initialisation of ACM module.
   61:               Conditions for proper initialisation of ACM module:
   62:               _ MTC functions called in below described order,
   63:               _ Init Sinewave generation with Voltage = 0 to be sure that duty 
   64:                 cycle on each phase is 50% when starting.
   65:  -----------------------------------------------------------------------------*/
   66:  void ACM_Init(void)
   67:  {

Function: ACM_Init
Source  : ..\..\source\acmotor.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

   68:  
   69:  	MTC_InitPeripheral();			// Initialize peripheral for three phase PWM generation
  0000 cd0000   CALL  MTC_InitPeripheral
   70:  	MTC_InitSineGen();				// Configure SW variables for sinewave generation
  0003 cd0000   CALL  MTC_InitSineGen
   71:  
   72:     MTC_Set_ClockWise_Direction();
  0006 cd0000   CALL  MTC_Set_ClockWise_Direction
   73:  
   74:  	ART_SetSpeedRegPeriod(SAMPLING_TIME);
  0009 a60a     LD    A,#10
  000b cc0000   JP    ART_SetSpeedRegPeriod
   75:  	
   76:  }
   77:  
   78:  
   79:  /*-----------------------------------------------------------------------------
   80:  ROUTINE Name : ACM_VoltageMaxAllowed
   81:  
   82:  Description: This function limits the voltage on motor stator according to
   83:               setpoints given in ACMParam.h. It performs a linear interpolation.
   84:               No error codes are returned if StatorFrequency is outside the 
   85:               frequency domain given in MTCParam.h [VF_LOWFREQ_LIMIT/VF_HIGHFREQ_LIMIT].
   86:  Duration:
   87:  Important caution: when modifying setpoints, user must keep in mind that
   88:              VF_COEFF, VF_OFFSET and local variable Buffer are declared as u16.
   89:              They must therefore be declared as u32 there is chance for overflow to occur.
   90:  -----------------------------------------------------------------------------*/
   91:  u8 ACM_VoltageMaxAllowed(u16 StatorFrequency)
   92:  {

Function: ACM_VoltageMaxAllowed
Source  : ..\..\source\acmotor.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  0000 b701     LD    _ACM_VoltageMaxAllowedp0:1,A
  0002 bf00     LD    _ACM_VoltageMaxAllowedp0,X
   93:           u8  VoltageMax;
   94:  
   95:    if ( StatorFrequency <= VF_LOWFREQ_LIMIT )
  0004 a300     CP    X,#0
  0006 220a     JRUGT *12 ;abs = 0012
  0008 2604     JRNE  *6 ;abs = 000e
  000a a1c8     CP    A,#200
  000c 2204     JRUGT *6 ;abs = 0012
   96:    {
   97:         VoltageMax = V_MIN;
  000e a61e     LD    A,#30
   98:  
   99:    } else if ( StatorFrequency >= VF_HIGHFREQ_LIMIT )
  0010 2025     JRT   *39 ;abs = 0037
  0012 b601     LD    A,_ACM_VoltageMaxAllowedp0:1
  0014 be00     LD    X,_ACM_VoltageMaxAllowedp0
  0016 a303     CP    X,#3
  0018 250a     JRULT *12 ;abs = 0024
  001a 2604     JRNE  *6 ;abs = 0020
  001c a1e8     CP    A,#232
  001e 2504     JRULT *6 ;abs = 0024
  100:           {
  101:                VoltageMax = V_MAX;
  0020 a6ff     LD    A,#255
  102:  
  103:           } else {
  0022 2013     JRT   *21 ;abs = 0037
  104:                         u16 Buffer;
  105:                     Buffer = (u16)(StatorFrequency * VF_COEFF) - VF_OFFSET;
  0024 89       PUSH  X
  0025 88       PUSH  A
  0026 a648     LD    A,#72
  0028 5f       CLR   X
  0029 cd0000   CALL  _IMULU
  002c a040     SUB   A,#64
  002e b701     LD    Buffer:1,A
  0030 9f       LD    A,X
  0031 a238     SBC   A,#56
  0033 b700     LD    Buffer,A
  106:                     VoltageMax = (u8)(V_MIN + (u8)((u16)Buffer / (u16)256));
  0035 ab1e     ADD   A,#30
  0037 b700     LD    VoltageMax,A
  107:              /* 256 factor is included in VF COEFF and VF_OFFSET calculations */
  108:                          /* Aim is to keep calculation accuracy */
  109:                  }
  110:  
  111:    return ( VoltageMax );
  112:  }
  0039 81       RET   
  113:  
  114:  
  115:  /*-----------------------------------------------------------------------------
  116:  ROUTINE Name : ACM_InitSoftStart
  117:  
  118:  Description: This function initializes the soft start procedure: it forces 
  119:  				the voltage to be null, enable the PMW outputs and set-up the 
  120:  				timebases required to smoothly increase voltage and have a start-up
  121:  				time out.
  122:  -----------------------------------------------------------------------------*/
  123:  void ACM_InitSoftStart(u16 StatorFreq)
  124:  {

Function: ACM_InitSoftStart
Source  : ..\..\source\acmotor.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  0000 b701     LD    _ACM_InitSoftStartp0:1,A
  0002 bf00     LD    _ACM_InitSoftStartp0,X
  125:  		u8 VoltageMax = ACM_VoltageMaxAllowed( StatorFreq );
  0004 ad00     CALLR ACM_VoltageMaxAllowed
  0006 b700     LD    VoltageMax,A
  126:  		u16 TimeUnit;
  127:  
  128:  
  129:  	MTC_InitTachoMeasure( );
  0008 cd0000   CALL  MTC_InitTachoMeasure
  130:  	MTC_UpdateSine(0, StatorFreq);
  000b 3f00     CLR   _MTC_UpdateSinep1
  000d be00     LD    X,_ACM_InitSoftStartp0
  000f b601     LD    A,_ACM_InitSoftStartp0:1
  0011 cd0000   CALL  MTC_UpdateSine
  131:  	MTC_EnableMCOutputs();			// PWM is present on MCO outputs
  0014 cd0000   CALL  MTC_EnableMCOutputs
  132:  
  133:  	TimeUnit = START_TIMEOUT / VoltageMax;
  0017 ae07     LD    X,#7
  0019 89       PUSH  X
  001a 5c       INC   X
  001b 89       PUSH  X
  001c b600     LD    A,VoltageMax
  001e 5f       CLR   X
  001f cd0000   CALL  _IDIVU
  0022 b701     LD    TimeUnit:1,A
  0024 bf00     LD    TimeUnit,X
  134:  	if ( TimeUnit == 0 )
  0026 b601     LD    A,TimeUnit:1
  0028 ba00     OR    A,TimeUnit
  002a 2606     JRNE  *8 ;abs = 0032
  135:  	{
  136:  		TimeUnit = 1;   /* Avoid applying full voltage directly */
  002c a601     LD    A,#1
  002e b701     LD    TimeUnit:1,A
  0030 3f00     CLR   TimeUnit
  137:  	}
  138:  	ART_Set_TimeInMs(TimeUnit);		// Set soft start slope
  0032 be00     LD    X,TimeUnit
  0034 b601     LD    A,TimeUnit:1
  0036 cd0000   CALL  ART_Set_TimeInMs
  139:  		
  140:  	ART_SetSequenceDuration(START_TIMEOUT + EXTRA_TIMEOUT);
  0039 ae0a     LD    X,#10
  003b a6f0     LD    A,#240
  003d cc0000   JP    ART_SetSequenceDuration
  141:  
  142:  }
  143:  
  144:  
  145:  /*-----------------------------------------------------------------------------
  146:  ROUTINE Name : ACM_SoftStart
  147:  
  148:  Description: This function provides a soft start which limits the inrush current 
  149:  				in the motor. It also monitors the speed feedback to stop 
  150:  				the voltage increase when a given minimum rotor speed is reached.
  151:  				The function ramps up the stator voltage linearly while the stator 
  152:  				frequency remains constant. The ramp ends when one of the following 
  153:  				conditions occurs:
  154:  				

⌨️ 快捷键说明

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