📄 main.c
字号:
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
//#include <ansli.lib>
#include <MATH.H> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
/**************************7.10程序使用数组变量*********************/
double err1[12]= {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char err2[20]= {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char err3[20]= {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
//
unsigned char xiapo = 0;
float repair = 0;
unsigned char checkline = 0;
unsigned char same = 0;
unsigned char jiasu = 0;
unsigned char shizi = 0;
unsigned char startline = 0;
unsigned char flag = 0;
int baichi = 0;
double ferr;
float BC = 0;
int TopSpeed = 320;
int LowSpeed = 160;
float SpeedSet=0;
signed int PWM23SET;
signed int PWM67SET;
int boma;
int samecount=0;
unsigned char errNUM = 0;
unsigned char DerrNUM= 0;
unsigned char start = 0;
//
unsigned char Sflag=0;
unsigned char state2=0;
unsigned char state=1;
unsigned char state3=0;
unsigned char lukuang = 0;
word Mdc_count=0; //中断次数
word SetPluse;
unsigned char pulse = 0; //一次检测周期获得的脉冲数
int speed_average; //平均速度
int speed_wink; //瞬时速度
float Ps=1.37;
double err=0; //位置偏移
double derr=0; //位置偏移变化增量
double lasterr=0; //上次位置偏移
double G_pluse; //给定转角对应脉冲
/************************************************************************
计算速度和平均速度
函数名;speed_account
功能:计算小车的瞬时速度和平均速度
输入参数:无
输出参数
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -