智能车制作
标题:
VisualScope
[打印本页]
作者:
超神吧chen
时间:
2017-3-30 16:37
标题:
VisualScope
各位大神,我想看看小车在跑的过程中他的PWM波的波形,用蓝牙接收并发送到电脑的软件VisualScope上显示。请问有没有完整的代码啊?
作者:
超神吧chen
时间:
2017-4-10 18:02
/*
* Description: 虚拟示波器校验码生成函数
*
* Data: 2014.5.8
* Author: Liu
*/
unsigned short CRC_CHECK(unsigned char *Buf, unsigned char CRC_CNT)
{
unsigned short CRC_Temp;
unsigned char i,j;
CRC_Temp = 0xffff;
for (i=0;i<CRC_CNT; i++){
CRC_Temp ^= Buf[i];
for (j=0;j<8;j++) {
if (CRC_Temp & 0x01)
CRC_Temp = (CRC_Temp >>1 ) ^ 0xa001;
else
CRC_Temp = CRC_Temp >> 1;
}
}
return(CRC_Temp);
}
/*
* Description: 虚拟示波器输出函数
*
* Data: 2014.5.8
* Author: Liu
*/
void VisualScope_Output(float data1 ,float data2 ,float data3 ,float data4)
{
int temp[4] = {0};
unsigned int temp1[4] = {0};
unsigned char databuf[10] = {0};
unsigned char i;
unsigned short CRC16 = 0;
temp[0] = (int)data1;
temp[1] = (int)data2;
temp[2] = (int)data3;
temp[3] = (int)data4;
temp1[0] = (unsigned int)temp[0] ;
temp1[1] = (unsigned int)temp[1];
temp1[2] = (unsigned int)temp[2];
temp1[3] = (unsigned int)temp[3];
for(i=0;i<4;i++)
{
databuf[i*2] = (unsigned char)(temp1[i]%256);
databuf[i*2+1] = (unsigned char)(temp1[i]/256);
}
CRC16 = CRC_CHECK(databuf,8);
databuf[8] = CRC16%256;
databuf[9] = CRC16/256;
for(i=0;i<10;i++)
uart_putchar(UART3,databuf[i]);
}
大神们,请问一下用蓝牙接收了小车发来的数据后,想用程序来接收数据然后用VScope显示出来,我该用那个函数啊?
欢迎光临 智能车制作 (http://111.231.132.190/)
Powered by Discuz! X3.2