激光雷达系统辅助版卡

来源:互联网 发布:腾讯短域名生成 编辑:程序博客网 时间:2024/04/28 22:44

激光雷达系统辅助版卡

周期:2015年11月~2016年2月
开发软件:
程序:MDK4.7.0
图纸:AD14
项目实现功能:
1.辅助提供VLP16型激光雷达测绘所需要的必要数据(GPSPPS等)
2.辅助VLP16提供十轴(包含三轴数字陀螺仪三轴数字加速度计三轴数字磁力计数字压力传感器)数据,辅助激光雷达进行姿态定位。
电源:
12V标准直流电源输入,板卡设有过流、过压、反接保护措施。
板卡外部通讯接口:
串口(UART)*2:232电平
串口(UART)*1:t t l电平
版卡内部接口:
串口(UART)*1:t t l电平
SPI
外接模块:
GPS
软件思路:
1.STM32通过UART口与GPS 模块进行数据通信读取相关数据,数据经芯片处理后整合到陀螺仪数据中由UART口发出,供软件人员使用。
2.STM32通过SPI接口读取十轴陀螺仪数据,经过芯片处理后,与GPS数据整合后由UART口发出,供软件人员使用。
3.GPS数据通过串口发出经232芯片处理后发出,供软件人员使用。
4.GPSPPS引出供软件人员使用
部分程序清单1:

外部中断处理函数:

 void EXTI9_5_IRQHandler(void)//外部中断用于读取PPS {         if(EXTI_GetITStatus(EXTI_Line5) != RESET)         {                 ss++;                 TimingDelay = 0;                 if(ss ==60)//秒清除                 {                         ss = 0;                         mm++;                         if(mm == 60 )//分清除                         {                                 mm = 0;                                 hh++;                         }                 }                 EXTI_ClearITPendingBit(EXTI_Line5);         } }
部分程序清单2:
定时器中断程序

定时器0.1ms进入一次,此定时器为本系统提供精准时间,且时间与GPS获取的精确到秒的时钟进行对时校准

void SysTick_Handler_hook(void) //定时器0.1ms{     if( TimingDelay<9999)        TimingDelay++;     Temp[41] = ((TimingDelay/10%10-'0')&0x0f)*16+((TimingDelay%10-'0')&0x0f);//千分位、0.1ms    Temp[40] =((TimingDelay/1000%10-'0')&0x0f)*16+(0x0F&TimingDelay/100%10-'0');//十分位、百分位    if(TimingDelay == 5000)//秒对时,在每半秒的地方    {        if((ss == ssa)&&(flog_3<3))//秒滤波,连续3次不等在赋值            flog_3++;        if((ss!=ssa)&&(flog_3>0))            flog_3--;        if(flog_3 == 0)            ss = ssa;//秒对时        mm = mma;//分对时        hh = hha;//小时对时    }    Temp[37] = ((hh/10)*16+hh%10);//小时赋值    Temp[38] = ((mm/10)*16+mm%10);//分钟赋值    Temp[39] = ((ss/10)*16+ss%10);//秒赋值    if(usart1_ready_buf_ok>0)                                                           {        usart1_ready_buf_ok--;        if(flog_2 == 2)            usart_send_chars(USART3,&usart1_receive_buf[usart1_tx_count][0],usart1_ready_buf_len[usart1_tx_count]);        if( (usart1_receive_buf[usart1_tx_count ][0]=='O' || usart1_receive_buf[usart1_tx_count ][0]=='o')//功能命令:输出陀螺数据                         &&  (usart1_receive_buf[usart1_tx_count ][1]=='U' || usart1_receive_buf[usart1_tx_count ][1]=='u')        &&  (usart1_receive_buf[usart1_tx_count ][2]=='T' || usart1_receive_buf[usart1_tx_count ][2]=='t')         &&  (usart1_receive_buf[usart1_tx_count ][3]=='P' || usart1_receive_buf[usart1_tx_count ][3]=='p')        &&  (usart1_receive_buf[usart1_tx_count ][4]=='U' || usart1_receive_buf[usart1_tx_count ][4]=='u')        &&  (usart1_receive_buf[usart1_tx_count ][5]=='T' || usart1_receive_buf[usart1_tx_count ][5]=='t'))             {            if(flog_2 == 2)            USART_OUT(USART3,"saveconfig\r\n");            flog_2 = 1;        }           else if( (usart1_receive_buf[usart1_tx_count ][0]=='U' || usart1_receive_buf[usart1_tx_count ][0]=='u')//功能命令:取消输出                &&  (usart1_receive_buf[usart1_tx_count ][1]=='N' || usart1_receive_buf[usart1_tx_count ][1]=='n')                &&  (usart1_receive_buf[usart1_tx_count ][2]=='L' || usart1_receive_buf[usart1_tx_count ][2]=='l')                 &&  (usart1_receive_buf[usart1_tx_count ][3]=='O' || usart1_receive_buf[usart1_tx_count ][3]=='o')                &&  (usart1_receive_buf[usart1_tx_count ][4]=='G' || usart1_receive_buf[usart1_tx_count ][4]=='g'))                     {                    if(flog_2 == 2)                    USART_OUT(USART3,"saveconfig\r\n");                    flog_2 = 0;                }        else if( (usart1_receive_buf[usart1_tx_count ][0]=='L' || usart1_receive_buf[usart1_tx_count ][0]=='l')//功能命令:与GPS com2通讯                &&  (usart1_receive_buf[usart1_tx_count ][1]=='O' || usart1_receive_buf[usart1_tx_count ][1]=='o')                &&  (usart1_receive_buf[usart1_tx_count ][2]=='O' || usart1_receive_buf[usart1_tx_count ][2]=='o')                 &&  (usart1_receive_buf[usart1_tx_count ][3]=='K' || usart1_receive_buf[usart1_tx_count ][3]=='k'))                         {                        flog_2 = 2;                    }                    usart1_ready_buf_len[usart1_tx_count] = 0;        usart1_tx_count++;        if(usart1_tx_count==10)            usart1_tx_count=0;    }} 
串口发送函数
串口发送函数向串口发送数据,其参数为串口号,数据地址,数据长度。
void usart_send_chars(USART_TypeDef* usart,uint8_t* buf,uint8_t len)    //发送字符串函数,参数分别是串口、待发送的缓冲区,发送长度_{    uint8_t i;    for(i = 0; i < len; i++)    {        usart->DR = (*(buf + i) & (uint16_t)0x01FF);        for(ci = 0;ci<100;ci++);        while (USART_GetFlagStatus(usart, USART_FLAG_TC) == RESET);    }    LED1(ON);    LED2(OFF);}
串口接收中断
串口数据接收存入缓冲区内备用,缓冲区自动覆盖。数据接收用定时器进行判断,当0.7ms未收到数据则表示一包数据结束
void usart1_isr(void)                                                                               //串口1中断函数{    if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)                                          //接收字符,并位置加1    {        usart1_receive_buf[usart1_count][usart1_ready_buf_len[usart1_count]++] = (uint8_t)USART_ReceiveData(USART1);            reload_timer(&usart1_timer,7);                                                              //超时设为0.1*7ms = 0.7 ms        start_timer(&usart1_timer);     if(usart1_ready_buf_len[usart1_count] == BUF_SIZE)        {            usart1_count++;            usart1_ready_buf_ok ++;                                                                 //准备缓冲区标志置位_            if(usart1_count==10)            usart1_count=0;            usart1_ready_buf_len[usart1_count]=0;        }    }  if(USART_GetITStatus(USART1, USART_IT_TXE) != RESET)                                              //这段是为了避免STM32 USART 第一个字节发不出去的BUG   {      USART_ITConfig(USART1, USART_IT_TXE, DISABLE);                                                 //禁止发缓冲器空中断_  } }//串口1超时处理函数void usart1_timeover_proc(void)                                                                     //串口1定时器字节超时处理{    usart1_count++;    usart1_ready_buf_ok ++;                                                                         //准备缓冲区标志置位_    if(usart1_count==10)        usart1_count=0;    LED2(ON);}

未完待续

1 0
原创粉丝点击