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

📄 fault_diagnose.c

📁 基于摩托罗拉(现在飞思卡尔)系列MC68HC908单片机开发车辆ECU系统!
💻 C
字号:
#include <MC68HC908GR16.h>
#include "type.h"
#include "fault_diagnose.h"
#include "seatmotor.h"

Bool slide_sensor_exist_flag;
Bool back_sensor_exist_flag;
Bool front_sensor_exist_flag;
Bool rear_sensor_exist_flag;

UINT16 SAMPLE_VOLTAGE;

											
Bool motor_circuit_fault(void){
UINT8 error_counter=0,i=0,j=0;						 
if(SAMPLE_VOLTAGE<0xA0) { 		//发现一次采样异常,则再连续采样五次做判决
for(j=0;j<5;j++){
i=0xff;
while(i--);   
if(SAMPLE_VOLTAGE<0xA0){
error_counter++;				
}
} 
}
if(error_counter>=3) return 1; //采样5次,出现3次以上采样电压未到达通路时的正常值,则认为继电器-电机电路发生故障
else return 0;
}


 


void slide_sensor_check(void){
if(!TBCR_TBON){				//定时器未开启
  if(slide_sensor_exist_flag){
slide_sensor_exist_flag=0;         //清除滑动电机的传感器信号存在标志
}else{
TBCR_TBON=1;              //启动定时操作
}			                           

}

}


void back_sensor_check(void){

if(!TBCR_TBON){				//定时器未开启
if(back_sensor_exist_flag){
back_sensor_exist_flag=0;         //清除后背电机的传感器信号存在标志
}else{
TBCR_TBON=1;              //启动定时操作
}			                           
}
}




void front_sensor_check(void){

if(!TBCR_TBON){				//定时器未开启
  if(front_sensor_exist_flag){
front_sensor_exist_flag=0;         //清除前部电机的传感器信号存在标志
}else{
TBCR_TBON=1;              //启动定时操作
}			                           
}
}



void rear_sensor_check(void){
if(!TBCR_TBON){				//定时器未开启
  if(rear_sensor_exist_flag){
rear_sensor_exist_flag=0;         //清除后部电机的传感器信号存在标志
}else{
TBCR_TBON=1;              //启动定时操作
}			                           

}

}


Bool margin_position_reached(void){							//检查电机是否到达边缘位置
UINT8 margin_counter=0,i,j;




if(SAMPLE_VOLTAGE>0x2D0){
  for(j=0;j<10;j++){
  i=0xff;
  while(i--);
  if(SAMPLE_VOLTAGE>0x2D0) margin_counter++;
  }
}
if(margin_counter>=6) return 1;
else return 0;

}

⌨️ 快捷键说明

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