小车摄像头寻线程序C语言编写Word格式文档下载.docx

上传人:b****6 文档编号:19470086 上传时间:2023-01-06 格式:DOCX 页数:27 大小:19.36KB
下载 相关 举报
小车摄像头寻线程序C语言编写Word格式文档下载.docx_第1页
第1页 / 共27页
小车摄像头寻线程序C语言编写Word格式文档下载.docx_第2页
第2页 / 共27页
小车摄像头寻线程序C语言编写Word格式文档下载.docx_第3页
第3页 / 共27页
小车摄像头寻线程序C语言编写Word格式文档下载.docx_第4页
第4页 / 共27页
小车摄像头寻线程序C语言编写Word格式文档下载.docx_第5页
第5页 / 共27页
点击查看更多>>
下载资源
资源描述

小车摄像头寻线程序C语言编写Word格式文档下载.docx

《小车摄像头寻线程序C语言编写Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《小车摄像头寻线程序C语言编写Word格式文档下载.docx(27页珍藏版)》请在冰豆网上搜索。

小车摄像头寻线程序C语言编写Word格式文档下载.docx

if(i>

150)

FaChe=0;

Work_Mode=0;

//Motor_PWM=1500;

Motor_Base=Speed_Base;

}

voidmain(void)

//uint32count=0;

//uint8j=0,a=0;

//uint16ADValue;

//unsignedcharcross_Recognition=0;

DisableInterrupts;

All_Init();

EnableInterrupts;

enable_irq(87);

//使能A口中断,A24场中断

enable_irq(90);

//使能D口中断,D6,D7

enable_irq(68);

//定时器0

enable_irq(69);

//定时器1

LED_P8x16Str(0,0,"

000"

);

Excursion=0;

Per_E=0;

Last_Per_E=0;

Motor_PWM=0;

Time=0;

Cross_Time=0;

//if(gpio_get(PORTA,14)==1&

gpio_get(PORTA,16)==1)//保守速度

//{

//Speed_Max=135;

//Speed_Min=125;

//straight_Speed=135;

//}

//elseif(gpio_get(PORTA,14)==0&

gpio_get(PORTA,16)==1)//最大速度

//Speed_Max=160;

//Speed_Min=90;

//straight_Speed=140;

gpio_get(PORTA,16)==0)//中档速度

//Speed_Max=150;

//Speed_Min=140;

gpio_get(PORTA,16)==0)

//Speed_Min=110;

//straight_Speed=150;

for(;

;

{

//cross_Recognition=0;

#ifControl_one

if(DMA_Finish_Flag==0)//DMA传输完成

//gpio_ctrl(PORTA,16,1);

//Servo_PWM=5350;

SCI_Finish_Flag=1;

Denoising(uc_FrameBuffer_Even[0]);

//去噪

EdgeDetection(uc_FrameBuffer_Even[0],EdgeData[0]);

//提取边缘

Get_Edge(uc_FrameBuffer_Even[0]);

//求边缘

//SCI();

if(XuXian_Flag==1)

//XuXian_Find(uc_FrameBuffer_Even[0]);

if(White_Row_End!

=IMAGE_ROW-1&

White_Row_End>

10)

Cross_Connect();

Edge_Filtering();

//边缘滤波

Edge_Repair();

Cross

(1);

//if(cross_Recognition!

=1)

//{

Repair_Edge();

//}

New_Control();

//Servo_PWM=5450;

//Servo_PWM=4600;

//Servo_PWM=6300;

if(Work_Mode==0)

//Motor_Control();

Motor_PWM=2000;

//Key();

SCI();

//Project();

//gpio_ctrl(PORTA,16,0);

AT_LED_P8x16Str(30,0,L_Edge_Zero_StartRow1);

AT_LED_P8x16Str(62,0,L_Edge_Zero_End1);

AT_LED_P8x16Str(30,2,R_Edge_Zero_StartRow1);

AT_LED_P8x16Str(62,2,R_Edge_Zero_End1);

AT_LED_P8x16Str(104,2,(L_Edge_Zero_StartRow1+L_Edge_Zero_End1)/2);

AT_LED_P8x16Str(104,4,(R_Edge_Zero_StartRow1+R_Edge_Zero_End1)/2);

AT_LED_P8x16Str_4w_int(0,4,L_Inflexion_Slope_Value);

AT_LED_P8x16Str_4w_int(48,4,Left_Inflexion_Point);

AT_LED_P8x16Str_4w_int(0,6,R_Inflexion_Slope_Value);

AT_LED_P8x16Str_4w_int(48,6,Right_Inflexion_Point);

AT_LED_P8x16Str(104,0,XuXian_Flag);

AT_LED_P8x16Str(104,6,Find_Base_Edge_Flag);

SCI_Finish_Flag=0;

DMA_Finish_Flag=2;

#elifControl_two

if(ImageOverEven==TRUE)

//AT_LED_P8x16Str_4w(48,6,ADValue);

Source_image=uc_FrameBuffer_Even[0];

////gpio_ctrl(PORTA,16,1);

//if(cross_Recognition!

//}

//Cross_Stop();

Motor_Control();

//Motor_PWM=1400;

//Motor_PWM=DJ;

Key();

Start_TwoMiao();

//SCI传输

ImageOverEven=FALSE;

////gpio_ctrl(PORTA,16,0);

elseif(ImageOverOdd==TRUE)

Source_image=uc_FrameBuffer_Odd[0];

Denoising(uc_FrameBuffer_Odd[0]);

EdgeDetection(uc_FrameBuffer_Odd[0],EdgeData[0]);

Get_Edge(uc_FrameBuffer_Odd[0]);

ImageOverOdd=FALSE;

#elifControl_three

//1主程序使用的变量定义

uint32runcount;

//运行计数器

uint16ADValue;

//2关中断

//禁止总中断

//3模块初始化

light_init(Light_Run_PORT,Light_Run1,Light_OFF);

//指示灯初始化

uart_init(UART0,periph_clk_khz,9600);

//串口初始化

//ADC

adc_init(0);

adc_init

(1);

uart_sendstring(UART0,(uint8*)"

WelcometoK60ADCExample\r\n"

uart_sendstring(UART0,(uint8*)"

PreparingforADCoperate!

\r\n"

StartADC0.......\taccuracyis10.\r\n"

StartADC1.......\taccuracyis16.\r\n"

//主循环

while

(1)

//1主循环计数到一定的值,使小灯的亮、暗状态切换

runcount++;

if(runcount>

=10)

light_change(Light_Run_PORT,Light_Run1);

//指示灯的亮、暗状态切换

runcount=0;

//进行一次模块0通道16采样

ADValue=ad_ave(0,ADchannel,10,10);

uart_sendnumber(UART0,ADValue);

//进行一次模块1通道16采样

\t---------------"

ADValue=ad_ave(1,ADchannel,16,10);

#else

#endif

//ControlC文件

unsignedcharConRowSta=40;

unsignedcharConRowEnd=60;

unsignedshortintSpeed=100;

//按键

unsignedcharButton_work_flag=0;

unsignedcharShake_Count=0;

unsignedcharWork_Button=0;

unsignedcharWork_Mode=1;

//保护

unsignedcharProject_Start=0;

unsignedcharStart_Count=0;

//PID

//floatKp=0.555;

//floatKd=0.509;

//floatKp=0.370;

//floatKd=0.120;

//floatKp=0.420;

//floatKd=0.530;

//

floatKp=0.300;

//floatKd=1.900;

floatKd=0.200;

unsignedshortintMotor_P=50;

unsignedcharMotor_I=1;

unsignedcharMotor_D=10;

shortintSpeed_Output=0;

//有关刹车

unsignedshortintSpeed_Base=0;

unsignedshortintDJ=3300;

unsignedshortintSpeed_Max=100;

unsignedshortintSpeed_Min=100;

//Max120Min100稳定十字还有问题Max130Min105稍微有点不稳

unsignedcharstraight_Speed=100;

unsignedcharStaLine_delay=25;

unsignedshortintDuoJi_Goal=5520;

unsignedcharDuoJi_Value_Count=0;

unsignedshortintL_DuoJi_Goal=5520;

signedshortintDuoJi_Add=0;

unsignedshortintChange_error=800;

voidKey(void)

staticsignedcharorder_num=0;

staticunsignedchartemp=0;

if(Work_Mode)

if(Button_work_flag==0)

if(Key_one==0)

Button_work_flag=1;

elseif(Key_two==0)

Button_work_flag=2;

elseif(Key_three==0)

Button_work_flag=3;

elseif(Key_four==0)

Button_work_flag=4;

else

if(Shake_Count>

3)

Shake_Count=0;

if(Button_work_flag==1)

Button_work_flag=0;

//while(!

Key_one);

Work_Button=1;

order_num++;

if(order_num>

100)

order_num=100;

else

Work_Button=0;

elseif(Button_work_flag==2)

if(Key_two==0)

Key_two);

Work_Button=2;

order_num--;

if(order_num<

0)

order_num=0;

elseif(Button_work_flag==3)

if(Key_three==0)

Work_Button=3;

if(order_num%5==0)

FaChe=1;

LED_P8x16Str(80,0,"

Start"

elseif(Button_work_flag==4)

if(Key_four==0)

Work_Button=4;

if(Work_Button!

=0&

Work_Mode!

=0)

if(Work_Button==3||Work_Button==4)

button_debug_data(order_num,Work_Button);

key_display(order_num);

temp++;

if(temp>

8)

key_display(5);

temp=0;

//key_display(5);

voidProject(void)

if(Project_Start)

if(Pulse==0)

Work_Mode=1;

Project_Start=0;

voidbutton_debug_data(charorder,charanniu_number)//赛车数据按钮在线设置函数

{

if(anniu_number==3)//加

switch(order)

//case1:

ConRowSta++;

break;

//case2:

ConRowEnd++;

//case3:

Speed+=10;

//case4:

case6:

Kp+=0.01;

case7:

Kd+=0.01;

case13:

Speed_Base+=50;

case9:

Change_error+=50;

//case9:

Motor_P+=1;

case11:

Motor_I+=1;

case12:

Motor_D+=1;

//case13:

DJ+=100;

case3:

Speed_Max+=5;

case2:

Speed_Min+=5;

case4:

straight_Speed+=5;

case1:

StaLine_delay+=1;

case8:

StaLine_zhi+=1;

default:

elseif(anniu_number==4)//减

ConRowSta--;

ConRowEnd--;

//case3:

Speed-=10;

//case4:

Kp-=0.01;

Kd-=0.01;

Speed_Base-=50;

Change_error-=50;

Motor_P-=1;

Motor_I-=1;

Motor_D-=1;

DJ-=100;

Speed_Max-=5;

Speed_Min-=5;

straight_Speed-=5;

StaLine_delay-=1;

StaLine_zhi-=1;

voidkey_disp

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1