Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ public class SensorKionixKXTC92050 extends SensorKionixAccel {
//--------- Sensor specific variables start --------------

public static final double[][] AlignmentMatrixLowNoiseAccelShimmer3 = {{0,-1,0},{-1,0,0},{0,0,-1}};
// Based on a manufacturer stated, typical zero-g offset of 1.65V per axis over an input of 0v to 3v
// [(1.65/3)*4096 = 2252.8]
public static final double[][] OffsetVectorLowNoiseAccelShimmer3 = {{2253},{2253},{2253}};
// Based on a manufacturer stated, typical sensitivity of 660mV/g per axis over an input of 0v to 3v
// [+-2g full-range so 4g (or 39.24 m/s2) over 2.64V -> (2.64/3*4096)/39.24 = 91.85]
public static final double[][] SensitivityMatrixLowNoiseAccel2gShimmer3 = {{92,0,0},{0,92,0},{0,0,92}};
// DEV-1521. The KXTC9-2050's output is ratiometric to its supply: Kionix specifies its zero-g
// offset (1.65 V) and sensitivity (660 mV/g) at Vdd = 3.3 V, with an offset and a sensitivity
// "ratiometric error" (KXTC9-2050 Specifications Rev. 2, Table 1). Every Shimmer3 board that
// carries it (SR31-10, SR47-6, SR48-5, SR49-3) powers it from the same 3.0 V LDO as the MSP430's
// AVCC, the ADC reference, so in ADC counts it reads like the KXRB5-2042 it replaced:
// zero-g 1.5 V -> (1.5/3)*4095 = 2047.5
public static final double[][] OffsetVectorLowNoiseAccelShimmer3 = {{2047},{2047},{2047}};
// 600 mV/g -> (0.6/3)*4095/9.81 = 83.5 per m/s2. 83, as the firmware's own default calibration
// record and the KXRB5-2042's defaults use. The old 2253 and 92 assumed a 3.3 V supply.
public static final double[][] SensitivityMatrixLowNoiseAccel2gShimmer3 = {{83,0,0},{0,83,0},{0,0,83}};

private CalibDetailsKinematic calibDetailsAccelLn2g = new CalibDetailsKinematic(
LN_ACCEL_RANGE_VALUE, LN_ACCEL_RANGE_STRING,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.shimmerresearch.sensors.kionix;

import static org.junit.Assert.*;

import org.junit.Test;

import com.shimmerresearch.driver.calibration.UtilCalibration;

/**
* DEV-1521: the KXTC9-2050's default calibration on a Shimmer3.
* <p>
* Kionix specifies the KXTC9-2050 at Vdd = 3.3 V (zero-g 1.65 V, 660 mV/g) and gives an offset and
* a sensitivity "ratiometric error": its output scales with its supply. Every Shimmer3 board that
* carries it (SR31-10, SR47-6, SR48-5, SR49-3) powers it from the same 3.0 V LDO as the MSP430's
* AVCC, the ADC reference. In ADC counts it therefore reads like the KXRB5-2042 it replaced, and
* its defaults must be that part's: offset 2047, sensitivity 83. The old 2253 and 92 assumed 3.3 V
* and made an uncalibrated new-IMU Shimmer3 read gravity about 17 % high.
*
* @author Mark Nolan
*/
public class API_00051_Kxtc9DefaultCalibrationTest {

private static final double ADC_FULL_SCALE = 4095, ADC_VREF = 3.0, SUPPLY = 3.0, G = 9.81;

@Test
public void defaultsAreTheDatasheetFiguresScaledToTheShimmersThreeVoltSupply() {
double zeroG = 1.65 * SUPPLY / 3.3; // V
double mvPerG = 660 * SUPPLY / 3.3;
double offset = zeroG / ADC_VREF * ADC_FULL_SCALE; // 2047.5
double sensitivity = mvPerG / 1000 / ADC_VREF * ADC_FULL_SCALE / G; // 83.5

for (int axis = 0; axis < 3; axis++) {
assertEquals("offset, axis " + axis, offset, SensorKionixKXTC92050.OffsetVectorLowNoiseAccelShimmer3[axis][0], 1.0);
assertEquals("sensitivity, axis " + axis, sensitivity, SensorKionixKXTC92050.SensitivityMatrixLowNoiseAccel2gShimmer3[axis][axis], 1.0);
}
}

@Test
public void defaultsMatchTheKxrb5s() {
assertArrayEquals(SensorKionixKXRB52042.OffsetVectorLowNoiseAccelShimmer3, SensorKionixKXTC92050.OffsetVectorLowNoiseAccelShimmer3);
assertArrayEquals(SensorKionixKXRB52042.SensitivityMatrixLowNoiseAccel2gShimmer3, SensorKionixKXTC92050.SensitivityMatrixLowNoiseAccel2gShimmer3);
assertArrayEquals(SensorKionixKXRB52042.AlignmentMatrixLowNoiseAccelShimmer3, SensorKionixKXTC92050.AlignmentMatrixLowNoiseAccelShimmer3);
}

/**
* Shimmer3 A615 (SR49-3-1) lying still, 20 Nov 2026: its raw LN accel at rest. On the defaults
* it must read 1 g; on the old 2253 and 92 it read 11.5 m/s2.
*/
@Test
public void aShimmer3AtRestReadsOneG() {
double[] cal = UtilCalibration.calibrateInertialSensorData(new double[] { 1232, 2011, 2125 },
SensorKionixKXTC92050.AlignmentMatrixLowNoiseAccelShimmer3,
SensorKionixKXTC92050.SensitivityMatrixLowNoiseAccel2gShimmer3,
SensorKionixKXTC92050.OffsetVectorLowNoiseAccelShimmer3);
double magnitude = Math.sqrt(cal[0] * cal[0] + cal[1] * cal[1] + cal[2] * cal[2]);
assertEquals(9.81, magnitude, 0.15);
}
}
Loading