完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
ADXL345各轴加速度值有较大波动
1、如静止不动,其测得的各轴加速度值有近30%-50%的波动 2、芯片转换个位置,静止不动,各轴测的加速度值有十分大的变化,为什么。 难道芯片受重力加速度影响,如何修正这种影响后获取各轴加速度值。比如用于测运动设备的加速度,位置变化影响到测值的! 不明白怎么回事 各位筒子,还有见地,告诉一下子,我的邮件:njnjnjnj2010@yeah.net |
|
相关推荐
1个回答
|
|
我已经帮楼主在我们这边的板子上做了测试,ADXL345+ADuC7026,测试+/-16G,串口使用9600。主要代码如下:
void IRQ_Handler() __irq { if(0 != (IRQSTA & SPM5_IO_BIT)) //External IRQ3 (IRQ3->INT2 pin of ADXL345) { Calculate_Sign = 1; //Set flag xl345Read(6, XL345_DATAX0, buf); //Read DATAX/Y/Z registers DataX_Low = buf[0]; DataX_High = buf[1]; DataX_High &= 0x1F; DataY_Low = buf[2]; DataY_High = buf[3]; DataY_High &= 0x1F; DataZ_Low = buf[4]; DataZ_High = buf[5]; DataZ_High &= 0x1F; } else if(0 != (IRQSTA & UART_BIT)) //UART Interrupt { UartInterrupt = COMIID0 ; if(0x04 == UartInterrupt) //Has Received a Data { UartDataReceived = COMRX; //Get Received Data if(0xAA == UartDataReceived) //Test Communication By Sending Device ID { while(!(0x020==(COMSTA0 & 0x020))){} COMTX = Dev_ID; //COMTX is an 8-bit Transmit Register. } if(0x55 == UartDataReceived) //Start Command { IsStart = 0x01; } if(0xA5 == UartDataReceived) //Stop Command { IsStart = 0x00; } } } } void ADuC7026_Initiate(void) { //Clock Initial POWKEY1 = 0x01; //Start PLL Setting POWCON = 0x00; //Set PLL Active Mode With CD = 0 CPU CLOCK DIVIDER = 41.78MHz POWKEY2 = 0xF4; //Finish PLL Setting GP1CON = 0x00002211; //PIN set up for I2C and UART GP2DAT = GP2DAT | 0x04040000; //Disable LCD; GP0DAT = GP0DAT | 0x02020000; //Disable LED; GP4DAT = GP4DAT | 0x01000000; //Grouding the SDO, I2C address for writing and reading is 0xA6 and 0xA7 //UART Initial,Baud Rate = 9600 COMCON0 = 0x080; COMDIV0 = 0x088; COMDIV1 = 0x000; COMCON0 = 0x007; //I2C Initial I2C1CFG = 0x00000082; // Master Enable & Enable Generation of Master Clock I2C1DIV = 0x3232; // 0x3232 = 400kHz 0xCFCF = 100kHz //Interrupt Set Up FIQEN = SM_MASTER1_BIT; //I2C1 Master Interrupt } //ADXL345 initialization, register configuration void ADXL345_Initiate() { buf[0] = XL345_RATE_50; //Output Data Rate: 50Hz xl345Write(1, XL345_BW_RATE, buf); buf[0] = XL345_FULL_RESOLUTION | XL345_RANGE_16G;//Data Format: +/-16g range, right justified, 256->1g xl345Write(1, XL345_DATA_FORMAT, buf); buf[0] = XL345_DATAREADY; //INT_Enable: Data Ready xl345Write(1, XL345_INT_ENABLE, buf); buf[0] = XL345_DATAREADY; //INT_Map: Data Ready interrupt to the INT2 pin xl345Write(1, XL345_INT_MAP, buf); } void main(void) { ADuC7026_Initiate(); //ADuC7026 Initialization ADXL345_Initiate(); //ADXL345 Initialization IsStart = 0x00; //Variables initialization xl345Read(1,XL345_DEVID,buf); //Get Device ID Dev_ID = buf[0]; COMIEN0 = 0x01; //Enable Receive Buffer Full Interrupt IRQEN = UART_BIT | SPM5_IO_BIT; //Enable UART and IRQ3 Interrupt (IRQ3->INT2 pin of ADXL345) buf[0] = XL345_MEASURE; //Power CTL: Measure mode xl345Write(1, XL345_POWER_CTL, buf); while(1) { if(0x01 == IsStart) // Start { if(1 == Calculate_Sign) { Calculate_Sign = 0; Acceleration[X_CHANNEL] = DataX_High; Acceleration[X_CHANNEL] = (Acceleration[X_CHANNEL]<<8) | DataX_Low; Acceleration[Y_CHANNEL] = DataY_High; Acceleration[Y_CHANNEL] = (Acceleration[Y_CHANNEL]<<8) | DataY_Low; Acceleration[Z_CHANNEL] = DataZ_High; Acceleration[Z_CHANNEL] = (Acceleration[Z_CHANNEL]<<8) | DataZ_Low; //Translate the twos complement to true binary code (256+4096)->1g, (4096-256)->(-1)g for(iTemp=X_CHANNEL;iTemp<=Z_CHANNEL;iTemp++) { if(Acceleration[iTemp] < 4096) { Acceleration[iTemp] = Acceleration[iTemp] + 4096; } else if(Acceleration[iTemp] >= 4096) { Acceleration[iTemp] = Acceleration[iTemp] - 4096; } un.ui = Acceleration[iTemp]; putchar(un.uc[1]);//High Bit putchar(un.uc[0]);//Low bit } } } } } 得到的原始数据如下所示: 其中每两列为一轴的高低8位数据,结果与数据手册指标相符。以下三图分别为静止、沿X、Z轴晃动在PC端通过串口接收与显示的测试结果。 所以如果芯片确定是从正规渠道购买的,芯片本身是没有问题的。请再检查一下软件是否正确或SPI通信是否正常。 |
|
|
|
只有小组成员才能发言,加入小组>>
2261个成员聚集在这个小组
加入小组给ADUM4223 增加信号驱动15V电压就不正常, 波动很大会被烧是什么情况?
1270 浏览 2 评论
ADP5092 SYS端口为2.09V,但是REG_OUT为0是什么原因?
1874 浏览 1 评论
ad7193差分输入ain1与ain2差是正值时,读到电压与实际值误差小,但为负值值,误差就变的很大
4220 浏览 2 评论
8970 浏览 1 评论
3122 浏览 1 评论
ADC3442采集,分析数据出现有规则毛刺,请问是哪方面的问题啊?
1387浏览 3评论
AD7190状态寄存器一直是0x80,连续转换模式下RDY不拉低
1631浏览 2评论
1588浏览 2评论
给ADUM4223 增加信号驱动15V电压就不正常, 波动很大会被烧是什么情况?
1273浏览 2评论
1373浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-10 19:03 , Processed in 0.671001 second(s), Total 44, Slave 39 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号