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

📄 main.lst

📁 该程序是ST7MC驱动三洋压缩机(交流)
💻 LST
📖 第 1 页 / 共 2 页
字号:
  214:  
  215:  /*-----------------------------------------------------------------------------
  216:  ROUTINE Name : SendSystemDataRS232
  217:  
  218:  Description : upload internal data to the PC via RS232 and hyperterminal for 
  219:  debug purposes
  220:  -----------------------------------------------------------------------------*/
  221:  void SendSystemDataRS232(void)
  222:  {

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

  223:  
  224:  	#ifdef CLOSED_LOOP
  225:  
  226:  	  	SCI_PutString("S=");		// Speed Command
  0000 ae01     LD    X,#HIGH("S=")
  0002 a600     LD    A,#"S="
  0004 cd0000   CALL  SCI_PutString
  227:  		PrintUnsignedInt(100 + (ADC_GetRV1()*10));	// Set by RV1 Trimmer
  0007 cd0000   CALL  ADC_GetRV1
  000a 97       LD    X,A
  000b a60a     LD    A,#10
  000d 42       MUL   X,A
  000e ab64     ADD   A,#100
  0010 9097     LD    Y,A
  0012 9f       LD    A,X
  0013 a900     ADC   A,#0
  0015 97       LD    X,A
  0016 909f     LD    A,Y
  0018 cd0000   CALL  PrintUnsignedInt
  228:  //	  	SCI_PutString(" S=");		// Stator frequency
  229:  //		PrintUnsignedInt(MTC_GetStatorFreq());
  230:  //  	SCI_PutString(" R=");		// Rotor frequency
  231:  //		PrintUnsignedInt(MTC_GetRotorFreq());
  232:  //	  	SCI_PutString(" V=");		// Voltage
  233:  //		PrintUnsignedInt(MTC_GetVoltage());
  234:  //		SCI_PutString(" Slp=");		// SlipCmd
  235:  //		PrintUnsignedInt(ACM_GetOptimumSlip( MTC_GetStatorFreq() ));
  236:  		#ifdef PI_PARAM_TUNING
  237:  		  	SCI_PutString(" Ki=");
  238:  			PrintUnsignedInt(Ki);
  239:  	  		SCI_PutString(" Kp=");
  240:  			PrintUnsignedInt(Kp);
  241:  		#endif
  242:  
  243:  	#else	/* OPEN_LOOP */
  244:  	  	SCI_PutString(" Freq=");
  245:  		PrintUnsignedInt(MTC_GetStatorFreq());
  246:  	  	SCI_PutString(" Volt=");
  247:  		PrintUnsignedInt(MTC_GetVoltage());
  248:  //	  	SCI_PutString(" Brake=");
  249:  //		PrintUnsignedInt(ADC_GetRV3());
  250:  
  251:  	#endif
  252:  
  253:  	SCI_PutString("\n\r");	// Go to next line
  001b ae01     LD    X,#HIGH("\012\015")
  001d a600     LD    A,#"\012\015"
  001f cc0000   JP    SCI_PutString
  254:  
  255:  }
  256:  
  257:  /* ####################### CLOSED LOOP OPERATION ######################### */
  258:  /* ####################### CLOSED LOOP OPERATION ######################### */
  259:  /* ####################### CLOSED LOOP OPERATION ######################### */
  260:  /* ####################### CLOSED LOOP OPERATION ######################### */
  261:  /* ####################### CLOSED LOOP OPERATION ######################### */
  262:  #ifdef CLOSED_LOOP
  263:  /*-----------------------------------------------------------------------------
  264:  ROUTINE Name : DoMotorControl
  265:  
  266:  Description : Performs closed loop control of the AC motor: the stator frequency 
  267:  and voltage and updated according to target Speed read on RV1 trimmer.
  268:  -----------------------------------------------------------------------------*/
  269:  void DoMotorControl( void )
  270:  {

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

  271:  		u16 FreqCmd, StatorFreq;
  272:  		u8 SlipCmd;
  273:  
  274:  
  275:  	if (MTC_GetRotorFreq() == 0)
  0000 cd0000   CALL  MTC_GetRotorFreq
  0003 bf00     LD    _spill_0,X
  0005 ba00     OR    A,_spill_0
  0007 2609     JRNE  *11 ;abs = 0012
  276:  	{
  277:  		State = FAULT;
  0009 a606     LD    A,#6
  000b c70001   LD    State:1,A
  000e 4f       CLR   A
  000f c70000   LD    State,A
  278:  	}
  279:  
  280:  	if ( ART_IsRegPeriodElapsed() )
  0012 cd0000   CALL  ART_IsRegPeriodElapsed
  0015 4d       TNZ   A
  0016 276c     JREQ  *110 ;abs = 0084
  281:  	{
  282:  			u8 NewVoltage;
  283:  
  284:  		// Get current Stator frequency
  285:  		StatorFreq  = MTC_GetStatorFreq();
  0018 cd0000   CALL  MTC_GetStatorFreq
  001b b701     LD    StatorFreq:1,A
  001d bf00     LD    StatorFreq,X
  286:  
  287:  		// Read Trimmers
  288:  		FreqCmd = 100 + (ADC_GetRV1()*10);	// Set Speed between 10.0Hz and 266.0Hz
  001f cd0000   CALL  ADC_GetRV1
  0022 97       LD    X,A
  0023 a60a     LD    A,#10
  0025 42       MUL   X,A
  0026 ab64     ADD   A,#100
  0028 b701     LD    FreqCmd:1,A
  002a 9f       LD    A,X
  002b a900     ADC   A,#0
  002d b700     LD    FreqCmd,A
  289:  		#ifdef PI_PARAM_TUNING
  290:  			Ki = ADC_GetRV2();
  291:  			Kp = ADC_GetRV3();
  292:  		#endif
  293:  		
  294:  		SlipCmd = ACM_GetOptimumSlip( StatorFreq );
  002f be00     LD    X,StatorFreq
  0031 b601     LD    A,StatorFreq:1
  0033 cd0000   CALL  ACM_GetOptimumSlip
  0036 b700     LD    SlipCmd,A
  295:  
  296:  		NewVoltage = ACM_SlipRegulation( SlipCmd );
  0038 cd0000   CALL  ACM_SlipRegulation
  003b b700     LD    NewVoltage,A
  297:  
  298:  		if (( (FreqCmd+SlipCmd) > StatorFreq) && (MTC_GetSlip() < ACCEL_SLIP_LIMIT))
  003d ad46     CALLR *72 ;abs = 0085
  003f 2519     JRULT *27 ;abs = 005a
  0041 2604     JRNE  *6 ;abs = 0047
  0043 b301     CP    X,StatorFreq:1
  0045 2313     JRULE *21 ;abs = 005a
  0047 cd0000   CALL  MTC_GetSlip
  004a a300     CP    X,#0
  004c 220c     JRUGT *14 ;abs = 005a
  004e 2604     JRNE  *6 ;abs = 0054
  0050 a164     CP    A,#100
  0052 2406     JRUGE *8 ;abs = 005a
  299:  		{
  300:  			StatorFreq++;
  0054 3c01     INC   StatorFreq:1
  0056 2602     JRNE  *4 ;abs = 005a
  0058 3c00     INC   StatorFreq
  301:  		}
  302:  
  303:  		if (( (FreqCmd+SlipCmd) < StatorFreq) && (MTC_GetSlip() > DECEL_SLIP_LIMIT))
  005a ad29     CALLR *43 ;abs = 0085
  005c 221b     JRUGT *29 ;abs = 0079
  005e 2604     JRNE  *6 ;abs = 0064
  0060 b301     CP    X,StatorFreq:1
  0062 2415     JRUGE *23 ;abs = 0079
  0064 cd0000   CALL  MTC_GetSlip
  0067 a300     CP    X,#0
  0069 250e     JRULT *16 ;abs = 0079
  006b 2604     JRNE  *6 ;abs = 0071
  006d a10a     CP    A,#10
  006f 2308     JRULE *10 ;abs = 0079
  304:  		{
  305:  			StatorFreq--;
  0071 3d01     TNZ   StatorFreq:1
  0073 2602     JRNE  *4 ;abs = 0077
  0075 3a00     DEC   StatorFreq
  0077 3a01     DEC   StatorFreq:1
  306:  		}
  307:  
  308:  		MTC_UpdateSine(NewVoltage, StatorFreq);
  0079 b600     LD    A,NewVoltage
  007b b700     LD    _MTC_UpdateSinep1,A
  007d be00     LD    X,StatorFreq
  007f b601     LD    A,StatorFreq:1
  0081 cd0000   CALL  MTC_UpdateSine
  309:  		
  310:  	}  /* End of if: regulation performed */
  311:  
  312:  }
  0084 81       RET   
  0085 b600     LD    A,SlipCmd
  0087 bb01     ADD   A,FreqCmd:1
  0089 97       LD    X,A
  008a 4f       CLR   A
  008b b900     ADC   A,FreqCmd
  008d b100     CP    A,StatorFreq
  008f 81       RET   
  313:  
  314:  /*-----------------------------------------------------------------------------
  315:  ROUTINE Name : StartMotor
  316:  
  317:  Description : Starts the motor in closed loop: if a minimum speed has not been
  318:  reached after a given period, the start-up is considered as failed.
  319:  -----------------------------------------------------------------------------*/
  320:  SystStatus_t StartMotor( void )
  321:  {

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

  322:  		SystStatus_t NextState;
  323:  
  324:  	switch ( ACM_SoftStart(MIN_START_FREQ) )
  0000 5f       CLR   X
  0001 a664     LD    A,#100
  0003 cd0000   CALL  ACM_SoftStart
  0006 bf00     LD    _spill_1,X
  0008 b700     LD    _spill_3,A
  000a ba00     OR    A,_spill_1
  000c 2724     JREQ  *38 ;abs = 0032
  000e b600     LD    A,_spill_1
  0010 2606     JRNE  *8 ;abs = 0018
  0012 be00     LD    X,_spill_3
  0014 a301     CP    X,#1
  0016 270d     JREQ  *15 ;abs = 0025
  0018 4d       TNZ   A
  0019 261b     JRNE  *29 ;abs = 0036
  001b be00     LD    X,_spill_3
  001d a302     CP    X,#2
  001f 2615     JRNE  *23 ;abs = 0036
  325:  	{
  326:  		case START_FAIL:
  327:  							NextState = STOP;
  0021 a603     LD    A,#3
  328:  							break;
  0023 2013     JRT   *21 ;abs = 0038
  329:  
  330:  		case START_OK:	
  331:  							ACM_InitSlipFreqReg( ACM_GetOptimumSlip( MTC_GetStatorFreq() ) );
  0025 cd0000   CALL  MTC_GetStatorFreq
  0028 cd0000   CALL  ACM_GetOptimumSlip
  002b cd0000   CALL  ACM_InitSlipFreqReg
  332:  							NextState = RUN;
  002e a602     LD    A,#2
  333:  							break;
  0030 2006     JRT   *8 ;abs = 0038
  334:  
  335:  		case START_ONGOING:	
  336:  							NextState = START;
  0032 a601     LD    A,#1
  337:  							break;
  0034 2002     JRT   *4 ;abs = 0038
  338:  
  339:  		default:			NextState = FAULT;
  0036 a606     LD    A,#6
  0038 b701     LD    NextState:1,A
  003a 3f00     CLR   NextState
  340:  							break;
  341:  	}
  342:  
  343:  	return ( NextState );
  003c b601     LD    A,NextState:1
  003e be00     LD    X,NextState
  344:  }
  0040 81       RET   
  345:  #endif
  346:  
  347:  /* ####################### OPEN LOOP OPERATION ######################### */
  348:  /* ####################### OPEN LOOP OPERATION ######################### */
  349:  /* ####################### OPEN LOOP OPERATION ######################### */
  350:  /* ####################### OPEN LOOP OPERATION ######################### */
  351:  /* ####################### OPEN LOOP OPERATION ######################### */
  352:  #ifdef OPEN_LOOP
  353:  /*-----------------------------------------------------------------------------
  354:  ROUTINE Name : DoMotorControl
  355:  
  356:  Description : Performs open loop control of the AC motor: the stator frequency 
  357:  and voltage and updated according to trimmer reading.
  358:  -----------------------------------------------------------------------------*/
  359:  void DoMotorControl( void )
  360:  {
  361:  		u8 NewVoltage, VoltCmd;
  362:  		u16 NewFreq, SlipFreq, FreqCmd;
  363:  
  364:  	// Read Trimmers
  365:  	FreqCmd = 100 + (ADC_GetRV1()*10);
  366:  	VoltCmd = ADC_GetRV2();
  367:  
  368:  	// Get actual values of volt and Freq
  369:  	NewVoltage = MTC_GetVoltage();
  370:  	NewFreq = MTC_GetStatorFreq();
  371:  
  372:  	SlipFreq = MTC_GetSlip();
  373:  
  374:  	if ( ART_Is_TimeInMsElapsed() )
  375:  	{
  376:  			u8 VMax;
  377:  
  378:  		VMax = ACM_VoltageMaxAllowed(NewFreq);
  379:  		if ( VoltCmd > VMax )
  380:  		{
  381:  			VoltCmd = VMax;
  382:  		}
  383:  
  384:  		if ( VoltCmd > NewVoltage ) NewVoltage++;	// Smoothly increase voltage
  385:  		if ( VoltCmd < NewVoltage ) NewVoltage--;	// Smoothly decrease voltage
  386:  
  387:  		if ( FreqCmd > NewFreq ) NewFreq++;		// Smoothly increase frequency
  388:  		// Smoothly decrease frequency unless RotorFreq>=StatorFreq (risk of reactive current)
  389:  		// if no sensor available, RotorFreq will be 0 and SlipFreq=StatorFreq
  390:  		if ( (SlipFreq != 0) && ( FreqCmd < NewFreq ) ) NewFreq--;
  391:  
  392:  	}
  393:  	
  394:  	MTC_UpdateSine(NewVoltage, NewFreq);
  395:  
  396:  }
  397:  
  398:  /*-----------------------------------------------------------------------------
  399:  ROUTINE Name : StartMotor
  400:  
  401:  Description : Starts the motor in open loop: with the stator frequency read 
  402:  on the trimmer, increase the stator voltage from 0 to the limit set by the 
  403:  V/f curve. When Voltage reaches this limit the routine returns TRUE.
  404:  -----------------------------------------------------------------------------*/
  405:  SystStatus_t StartMotor( void )
  406:  {
  407:  		u8 StartVolt, MaxVolt;
  408:  		u16 StartFreq;
  409:  
  410:  	// Read Trimmers
  411:  	StartFreq = 100 + (ADC_GetRV1()*10);
  412:  	StartVolt = ADC_GetRV2();
  413:  
  414:  	// Verify that Start-up voltage is in line with V/f characteristic
  415:  	MaxVolt = ACM_VoltageMaxAllowed(StartFreq);
  416:  	if (StartVolt > MaxVolt)
  417:  	{
  418:  		StartVolt = MaxVolt;
  419:  	}
  420:  	
  421:  	if ( ACM_SoftStartOL(StartVolt) )
  422:  	{
  423:  		return(RUN);
  424:  	}
  425:  	else
  426:  	{
  427:  		return(START);
  428:  	}
  429:  
  430:  }
  431:  #endif	/* OPEN_LOOP */
  432:  /*** (c) 2004  STMicroelectronics **************************** END OF FILE ***/

⌨️ 快捷键说明

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