用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - c代码库

第七届智能车电磁组直立源代码1

2012-08-27 作者: xiaofei举报

[c]代码库

/** ###################################################################
**     Filename  : SMMNew1.C
**     Project   : SMMNew1
**     Processor : 56F8013VFAE
**     Version   : Driver 01.14
**     Compiler  : Metrowerks DSP C Compiler
**     Date/Time : 2012-2-2, 11:06
**     Abstract  :
**         Main module.
**         This module contains user's application code.
**     Settings  :
**     Contents  :
**         No public methods
**
** ###################################################################*/
/* MODULE SMMNew1 */


/* Including needed modules to compile this module/procedure */
#include <intrinsics_56800e.h>
#include "Cpu.h"
#include "Events.h"
#include "LED.h"
#include "AS1.h"
#include "AD1.h"
#include "PWMC1.h"
#include "COUNTER1.h"
#include "COUNTER2.h"
#include "TI1.h"
#include "IFsh1.h"
/* Including shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"

//------------------------------------------------------------------------------
#include "F8013.h"
#include "CarSub.h"
#include "config.h"
#include "debug.h"



//------------------------------------------------------------------------------
#define LOOP_TIME			250
void main(void)
{
	unsigned int nLoop;
 /* Write your local variable definition here */
	//--------------------------------------------------------------------------
	
	//--------------------------------------------------------------------------
  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

	//--------------------------------------------------------------------------
	//	Initialize MCU and control variables
	F8013Init();                                // Initialize the F8013
	CarSubInit();                               // Initialize the control algrithm//控制算法
	LEDFlashInit();                             // Initialize LED Flash
	DebugInit();                                // Initialize debug global variable
		
	//--------------------------------------------------------------------------
	ArgumentLoad();                             // Load Argument from FLASH //加载参数
	if(g_Argument.nInitFlag != INIT_FLAG_DEFAULT) {
		ArgumentInit();
		ArgumentSave();
		DebugFirstStart();
	}
	
	//--------------------------------------------------------------------------
	nLoop = 0;
	
	//--------------------------------------------------------------------------
//	g_fTestSpeedValue = MOTOR_OUT_MAX / 2;

		
	//--------------------------------------------------------------------------
	for(;;) {
		//----------------------------------------------------------------------
		WaitTime(1);		
		nLoop ++;
		
		//----------------------------------------------------------------------
		if(CAN_RECE) {
			DebugProcess();
		}

		//----------------------------------------------------------------------
		if(VOLTAGE_SET1 > 3000) 		DEBUG_STOP_CONTROL;
		if(VOLTAGE_SET2 > 3000) 		DebugStartControl();
		
		//----------------------------------------------------------------------
		LEDFlash();
		
		//----------------------------------------------------------------------
		if(nLoop >= LOOP_TIME) 
			nLoop = 0;
		else continue;

		//----------------------------------------------------------------------
		if(g_nDebugStopFlag == 0) {
			WaitCarStand();
			CheckCarStand();
		} else {
			CarControlStop();
		}
	

		//----------------------------------------------------------------------
		// Show the AD Result;
		g_fDebugWord[0] = g_fCarAngle * 10.0;
		g_fDebugWord[1] = g_fCarSpeed * 10.0;		
		g_fDebugWord[2] = g_fDirectionControlOut * 100.0;
		g_fDebugWord[3] = g_fSpeedControlOut * 100; 
		g_fDebugWord[4] = VOLTAGE_LEFT;
		g_fDebugWord[5] = VOLTAGE_RIGHT;
		g_fDebugWord[6] = VOLTAGE_GYRO;
		g_fDebugWord[7] = VOLTAGE_GRAVITY;//g_fSpeedControlIntegral * 10000; //VOLTAGE_GRAVITY;
		g_fDebugWord[8] = g_fCarSpeedSet * 10.0;
		
		if(g_nDebugStopFlag == 0) {
			g_fDebugWord[9] = g_fAngleControlOut * 100.0;
			g_fDebugWord[10] = g_fSpeedControlIntegral * 100.0; //VOLTAGE_SET2;
		} else {
			g_fDebugWord[9] = 9999;
			g_fDebugWord[10] = 9999;
		}

		SendDebugWordFloat();
//		GetADAverage(1024);
//		SendDebugWord();				
	
		//----------------------------------------------------------------------
#define SPEED_INC			1
#define SPEED_DEC			2
		if(IF_CAR_CONTROL) {
			if(g_fCarSpeedSet != g_Argument.fCarSpeedSet) {
				if(g_Argument.fCarSpeedSet > g_fCarSpeedSet) {
					g_fCarSpeedSet += SPEED_INC;
					if(g_Argument.fCarSpeedSet < g_fCarSpeedSet)
						g_fCarSpeedSet = g_Argument.fCarSpeedSet;
				} else {
					g_fCarSpeedSet -= SPEED_DEC;
					if(g_Argument.fCarSpeedSet > g_fCarSpeedSet)
						g_fCarSpeedSet = g_Argument.fCarSpeedSet;
				}
			}				
		} else {
			g_fCarSpeedSet = 0;
		}
		//----------------------------------------------------------------------
		
	}

	//--------------------------------------------------------------------------
  /* Write your code here */

  for(;;) {}
}



//------------------------------------------------------------------------------
	
/* END SMMNew1 */
/*
** ###################################################################
**
**     This file was created by Processor Expert 3.00 [04.35]
**     for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/


网友评论    (发表评论)

共1 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...