|
如题,近期在测试ADXL355这个三轴加速度计,使用的是SPI协议,用arduino开发的程序,目前程序输出的值如下
部分代码如下:
void setup() {
Serial.begin(115200);
SPI.begin();
pinMode(CHIP_SELECT_PIN,OUTPUT);
writeRegister(RANGE,RANGE_10G);//使用10G
writeRegister(POWER_CTL,MEASURE_MODE);
delay(100);
}
void loop() {
int axisAddresses[] = {XDATA1, XDATA2, XDATA3, YDATA1, YDATA2, YDATA3, ZDATA1, ZDATA2, ZDATA3};
int axisMeasures[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
int dataSize = 9;
readMultipLEData(axisAddresses, dataSize, axisMeasures);
int xdata = (axisMeasures[0] >> 4) + (axisMeasures[1] << 4) + (axisMeasures[2] << 12);
int ydata = (axisMeasures[3] >> 4) + (axisMeasures[4] << 4) + (axisMeasures[5] << 12);
int zdata = (axisMeasures[6] >> 4) + (axisMeasures[7] << 4) + (axisMeasures[8] << 12);
IF (xdata >= 0x80000) {
xdata = ~xdata + 1;
}
if (ydata >= 0x80000) {
ydata = ~ydata + 1;
}
if (zdata >= 0x80000) {
zdata = ~zdata + 1;
}
Serial.print("X=");
Serial.print(xdata);
Serial.print("\t");
Serial.print("Y=");
Serial.print(ydata);
Serial.print("\t");
Serial.print("Z=");
Serial.print(zdata);
Serial.print("\n");
delay(100);
}
量程暂定为±10g,灵敏度为51200 LSB/g,请问输出的数值应当如何转换成g值呢?
|
|