?? wushua.h
字號(hào):
//**************************************************************************
// 無有刷電機(jī)控制程序頭文件
// BY: Sunny.xu
// Data: 2004.06.19
// Version V1.0
//
//**************************************************************************
//********************************//
// //
// 常量定義區(qū) //
// //
//********************************//
const unsigned char AD_CHNNEL0=0x81;
const unsigned char AD_CHNNEL1=0x89;
const unsigned char AD_CHNNEL2=0x91;
const unsigned char AD_CHNNEL3=0x99;
const unsigned char AD_CHNNEL4=0xA1;
const unsigned char AD_CHNNEL5=0xA9;
const unsigned char PWR_0_LOW =160;
const unsigned char PWR_0_HIGH=162;//162;
const unsigned char PWR_1_LOW =170;//169;
const unsigned char PWR_1_HIGH=170;//171;
const unsigned char PWR_2_LOW =179;//178;
const unsigned char PWR_2_HIGH=179;//180;
const unsigned char PWR_3_LOW =187;//186;
const unsigned char PWR_3_HIGH=187;//188;
const unsigned char START_RUN=80; //馬達(dá)開始轉(zhuǎn)動(dòng)
const unsigned char OVER_LOAD=100; //飛車監(jiān)測上限
const unsigned char KEY_INITIAL=0x10; //按鍵初始化
const unsigned char ALARM_HIGH=30; //報(bào)警響
const unsigned char ALARM_LOW=40; //報(bào)警不響
const unsigned char DS_TIME=100; //進(jìn)入定速的時(shí)間
const unsigned char DS_MODE_TIME=10; //進(jìn)入定速的時(shí)間
const unsigned char PHASE_DATA[7]={0x0B,0x2A,0x89,0x29,0x43,0x4A,0x83};
//********************************//
// //
// 硬件接口位變量定義區(qū) //
// //
//********************************//
//********************************//
/* PORTA bits */
static volatile bit KEY_MODE @ (unsigned)&PORTA*8+5; //模式按鈕 0: 按下
//static volatile bit RA4 @ (unsigned)&PORTA*8+4;
//static volatile bit RA3 @ (unsigned)&PORTA*8+3;
//static volatile bit RA2 @ (unsigned)&PORTA*8+2;
static volatile bit SPEED_DTC @ (unsigned)&PORTA*8+1;
static volatile bit BATT_DTC @ (unsigned)&PORTA*8+0; //電池電壓監(jiān)測 3.15V//3.33V//3.5V//3.65V
/* PORTB bits */
static volatile bit BREAK_IN @ (unsigned)&PORTB*8+7; //剎車信號(hào)輸入端 1:剎車
static volatile bit PHASE_C_IN @ (unsigned)&PORTB*8+6;
static volatile bit PHASE_B_IN @ (unsigned)&PORTB*8+5;
static volatile bit PHASE_A_IN @ (unsigned)&PORTB*8+4;
static volatile bit ZHULI_DTC @ (unsigned)&PORTB*8+3; //助力信號(hào)監(jiān)測輸入端
static volatile bit S_DATA @ (unsigned)&PORTB*8+2; //164 DTAT
static volatile bit S_CLK @ (unsigned)&PORTB*8+1; //164 CLK
static volatile bit CURRENT @ (unsigned)&PORTB*8+0; //電流監(jiān)測輸入端 0:過流狀態(tài)
/* PORTC bits */
static volatile bit PHASE_B_H @ (unsigned)&PORTC*8+7;
static volatile bit PHASE_C_H @ (unsigned)&PORTC*8+6;
static volatile bit PHASE_A_H @ (unsigned)&PORTC*8+5;
static volatile bit UP_SPEED @ (unsigned)&PORTC*8+4; //極限速度 0:80% 1: 100%
static volatile bit PHASE_A_L @ (unsigned)&PORTC*8+3;
static volatile bit MOTOR_CON @ (unsigned)&PORTC*8+2; //電機(jī)控制
static volatile bit PHASE_C_L @ (unsigned)&PORTC*8+1;
static volatile bit PHASE_B_L @ (unsigned)&PORTC*8+0;
//********************************//
// //
// 變量定義區(qū) //
// //
//********************************//
unsigned char Key_Temp0 @ 0x2C;
unsigned char i @ 0x2D;
volatile unsigned int Main_Flag0 @ 0x2E;
static bit WORK_STA @ (unsigned)&Main_Flag0*8+0; //1:已開鎖標(biāo)志
static bit ERR_DISP_OK @ (unsigned)&Main_Flag0*8+1; //1:錯(cuò)誤顯示標(biāo)志
static bit ALL_OFF_1ST @ (unsigned)&Main_Flag0*8+2; //1:消隱
static bit MODE_DOWN @ (unsigned)&Main_Flag0*8+5; //1:模式按鈕按下
static bit PWR_ON @ (unsigned)&Main_Flag0*8+6; //1:上電標(biāo)志位
static bit MS_5_OK @ (unsigned)&Main_Flag0*8+7; //5ms ok
static bit ALL_OFF @ (unsigned)&Main_Flag0*8+8; //1:消隱
static bit TIME_ZHULI_OK @ (unsigned)&Main_Flag0*8+9; //1
static bit PWR_LOW_STA @ (unsigned)&Main_Flag0*8+10; //
static bit CUR_OVER @ (unsigned)&Main_Flag0*8+11;
static bit BREAK_ST @ (unsigned)&Main_Flag0*8+12;
static bit TIME_OVER @ (unsigned)&Main_Flag0*8+13;
static bit WITH_ERR @ (unsigned)&Main_Flag0*8+14;
static bit MS_1_OK @ (unsigned)&Main_Flag0*8+15;
volatile unsigned int Main_Flag @ 0x31;
volatile unsigned char Main_Flag1 @ 0x31;
volatile unsigned char Main_Flag2 @ 0x32;
static bit PWR_LOW @ (unsigned)&Main_Flag*8+0; //1:欠壓狀態(tài)
static bit PWR_LED0 @ (unsigned)&Main_Flag*8+1;
static bit PWR_LED1 @ (unsigned)&Main_Flag*8+2;
static bit PWR_LED2 @ (unsigned)&Main_Flag*8+3;
static bit PWR_LED3 @ (unsigned)&Main_Flag*8+4;
static bit DINGSU @ (unsigned)&Main_Flag*8+5; //1:定速狀態(tài)
static bit DIANDONG @ (unsigned)&Main_Flag*8+6; //1:電動(dòng)狀態(tài)
static bit ZHULI @ (unsigned)&Main_Flag*8+7; //1:助力狀態(tài)
static bit BREAK_EN @ (unsigned)&Main_Flag*8+8; //1:剎車信號(hào)使能 0:不在剎車狀態(tài)
static bit CUR_LIMIT @ (unsigned)&Main_Flag*8+9; //1: 限流狀態(tài) 0: 正常工作狀態(tài)
static bit KEY_PRO_EN @ (unsigned)&Main_Flag*8+10;
static bit KEY_ORDER @ (unsigned)&Main_Flag*8+11;
static bit KEY_UP @ (unsigned)&Main_Flag*8+12; //按鍵抬起標(biāo)志
static bit ERR_SPEED @ (unsigned)&Main_Flag*8+13; //調(diào)速出錯(cuò)
static bit ERR_BREAK @ (unsigned)&Main_Flag*8+14; //剎車出錯(cuò)
static bit ERR_MODE @ (unsigned)&Main_Flag*8+15; //模式按鈕出錯(cuò)
unsigned char Power_Voltage @ 0x33; //電源電壓
unsigned char Speed_Voltage @ 0x34; //速度
unsigned char Speed_Voltage_Old @ 0x35; //速度
unsigned char Pwm_Duty @ 0x36; //PWM
unsigned char Disp_Data @ 0x37; //顯示數(shù)據(jù)
static bit Msb_Disp_Data@ (unsigned)&Disp_Data*8+7;
unsigned char Key_Data0 @ 0x38; //按鍵數(shù)據(jù)0
unsigned char Key_Data1 @ 0x39; //按鍵數(shù)據(jù)1
unsigned char Key_Result @ 0x3A; //最終按鍵數(shù)據(jù)
static bit KEY0 @ (unsigned)&Key_Result*8; //開鎖
static bit KEY1 @ (unsigned)&Key_Result*8+1; //鎖車
static bit KEY2 @ (unsigned)&Key_Result*8+2; //靜音
static bit KEY3 @ (unsigned)&Key_Result*8+3; //尋車
static bit KEY4 @ (unsigned)&Key_Result*8+4; //模式
static bit KEY5 @ (unsigned)&Key_Result*8+5;
static bit KEY6 @ (unsigned)&Key_Result*8+6; //剎車
static bit KEY7 @ (unsigned)&Key_Result*8+7; //限流
volatile unsigned char Time_Base @ 0x3B; //100mS定時(shí)基準(zhǔn)
volatile unsigned char Time_Mode @ 0x3C; //模式按鈕定時(shí)
volatile unsigned char Time_Err_Speed @ 0x3D; //模式按鈕定時(shí)
volatile unsigned char Time_Speed @ 0x3E; //模式按鈕定時(shí)
volatile unsigned char Time_Zhuli @ 0x3F; //
unsigned char Zhuli_Count @ 0x40; //
unsigned char Zhuli_Duty @ 0x41; //
unsigned char AD_Turn @ 0x42; //
unsigned char Disp_Data_Old @ 0x43; //
unsigned char Zhuli_Low @ 0x44; //
unsigned char Zhuli_High @ 0x45; //
unsigned char Pwr_Low_Count @ 0x46; //
unsigned char Pwm_Low @ 0x47; //
unsigned char Pwm_High @ 0x48; //
unsigned char Pwm_Old @ 0x49; //
unsigned char Time_All_Err @ 0x4A; //
unsigned char Pwr_Low_Num @ 0x4B; //
unsigned char Pwr_Up_Num @ 0x4C; //
unsigned char Phase_Dtc @ 0x4E; //
unsigned char Phase_Dtc_Old @ 0x4F; //
unsigned char Phase_Dtc_Led @ 0x50; //
unsigned char Time_Motor_Ph @ 0x51; //
unsigned char Phase_Ch_Count @ 0x52;
unsigned char Phase_Ch_Count1 @ 0x53;
unsigned char Cur_Over_Time @ 0x54;
unsigned char Cur_Over_Count @ 0x55;
unsigned char Time_Break @ 0x56; //
unsigned char DS_Pwm_Duty @ 0x57; //
unsigned char Zhuli_Count1 @ 0x58; //
unsigned char Zhuli_Count2 @ 0x59; //
unsigned char Zhuli_Low_Bak @ 0x5A; //
unsigned char Zhuli_High_Bak @ 0x5B; //
unsigned char Current_High @ 0x5C; //
unsigned char Old_ZL_Duty @ 0x5D; //
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -