智能车制作
标题:
ccd融合后无法采集到正确数据
[打印本页]
作者:
智能.卓越
时间:
2013-7-9 12:17
标题:
ccd融合后无法采集到正确数据
void main(void) {
unsigned char i;
unsigned char send_data_cnt = 0;
unsigned char *pixel_pt;
inticlock();
AD_init();
SCI_init();
CCD_IO_init();
PIT_init();
inti_Motor0();
inti_Motor1();
inti_Motor2();
inti_Motor3();
Init_TIM();
Init_CD4520();
pixel_pt = Pixel;
for(i = 0;i < 128+10;i++){
*pixel_pt++ = 0;
}
EnableInterrupts;
for(;;)
{
if(TimerFlag20ms == 1){
TimerFlag20ms = 0;
ImageCapture(Pixel);
CalculateIntegrationTime();
if(++send_data_cnt >= 5){
send_data_cnt = 0;
SendImageData(Pixel);
}
}
if(flag == 1){
static unsigned char TimerCnt20ms = 0;
unsigned char integration_point;
unsigned char IntegrationTime;
PITTF_PTF = 1;
TimerCnt20ms++;
integration_point = 20- IntegrationTime;
if(integration_point >= 2){
if(integration_point == TimerCnt20ms)
StartIntegration();
}
if(TimerCnt20ms >= 20){
TimerCnt20ms = 0;
TimerFlag20ms = 1;
}
flag = 0;
}
}
}
//5ms中断
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 66 timer0(void) {
static int i = 0;
static int j = 0;
_asm(MOVB #$01,PITTF); //clear interrupt falg
i++ ;
if(i == 1000){
ADGYRO_GetValue0();
GYRO_ZERO = GYRO_zero;
}
if((i> 1000) && (i < 3000) )
{
ADGYRO_GetValue0();
GYRO_ZERO = ( GYRO_zero + GYRO_ZERO )/2.0;
}
if(i>=3000){
j++;
if(j == 1){
ADGYRO_GetValue1();
ADGYRO_GetValue2();
}
if(j == 2){
AngelCalculate();
}
if(j == 3){
Pluse_Get();
Speed_Calculate();
}
if(j == 4){
//sendInt(GYRO_VAL);
//sendInt(ACC_VAL);
//sendInt(ACC_Angle);
//sendInt(GYRO_Angle);
//sendInt(Car_Angle);
}
if(j == 5){
Angle_Control_Output();
MotorOutControl();
init_ZLSU();
j = 0;
}
flag = 1;
i = 3001;
}
}
#pragma CODE_SEG DEFAULT
这是主函数和中断部分,ccd单独测没问题,加进去主程序后一直没法得到正确的反馈数据,在线调试一直是7~15,AD数值很低,到底是怎么回事求解?
作者:
肥过猪
时间:
2013-7-12 16:54
曝光时间,估计是
欢迎光临 智能车制作 (http://dns.znczz.com/)
Powered by Discuz! X3.2