@@ -763,15 +763,14 @@ public enum ExpansionBoardDetectShimmer3
763763 public static readonly double [ , ] OFFSET_VECTOR_MAG_SHIMMER3_LSM303AH = new double [ 3 , 1 ] { { 0 } , { 0 } , { 0 } } ;
764764 public static readonly double [ , ] SENSITIVITY_MATRIX_MAG_50GA_SHIMMER3_LSM303AH = new double [ 3 , 3 ] { { 667 , 0 , 0 } , { 0 , 667 , 0 } , { 0 , 0 , 667 } } ;
765765
766- //public static readonly double[,] ALIGNMENT_MATRIX_MAG_SHIMMER3R_LIS3MDL = new double[3, 3] { { 1, 0, 0 }, { 0, -1, 0 }, { 0, 0, -1 } };
767- public static readonly double [ , ] ALIGNMENT_MATRIX_MAG_SHIMMER3R_LIS3MDL = new double [ 3 , 3 ] { { - 1 , 0 , 0 } , { 0 , 0 , - 1 } , { 0 , - 1 , 0 } } ;
766+ public static readonly double [ , ] ALIGNMENT_MATRIX_MAG_SHIMMER3R_LIS3MDL = new double [ 3 , 3 ] { { 1 , 0 , 0 } , { 0 , - 1 , 0 } , { 0 , 0 , - 1 } } ;
768767 public static readonly double [ , ] OFFSET_VECTOR_MAG_SHIMMER3R_LIS3MDL = new double [ 3 , 1 ] { { 0 } , { 0 } , { 0 } } ;
769768 public static readonly double [ , ] SENSITIVITY_MATRIX_MAG_4GA_SHIMMER3R_LIS3MDL = new double [ 3 , 3 ] { { 6842 , 0 , 0 } , { 0 , 6842 , 0 } , { 0 , 0 , 6842 } } ;
770769 public static readonly double [ , ] SENSITIVITY_MATRIX_MAG_8GA_SHIMMER3R_LIS3MDL = new double [ 3 , 3 ] { { 3421 , 0 , 0 } , { 0 , 3421 , 0 } , { 0 , 0 , 3421 } } ;
771770 public static readonly double [ , ] SENSITIVITY_MATRIX_MAG_12GA_SHIMMER3R_LIS3MDL = new double [ 3 , 3 ] { { 2281 , 0 , 0 } , { 0 , 2281 , 0 } , { 0 , 0 , 2281 } } ;
772771 public static readonly double [ , ] SENSITIVITY_MATRIX_MAG_16GA_SHIMMER3R_LIS3MDL = new double [ 3 , 3 ] { { 1711 , 0 , 0 } , { 0 , 1711 , 0 } , { 0 , 0 , 1711 } } ;
773772
774- public static readonly double [ , ] ALIGNMENT_MATRIX_MAG_SHIMMER3R_LIS2MDL = new double [ 3 , 3 ] { { - 1 , 0 , 0 } , { 0 , - 1 , 0 } , { 0 , 0 , - 1 } } ; //Default Values for Magnetometer Calibration
773+ public static readonly double [ , ] ALIGNMENT_MATRIX_MAG_SHIMMER3R_LIS2MDL = new double [ 3 , 3 ] { { - 1 , 0 , 0 } , { 0 , - 1 , 0 } , { 0 , 0 , - 1 } } ; //Default Values for Magnetometer Calibration
775774 public static readonly double [ , ] OFFSET_VECTOR_MAG_SHIMMER3R_LIS2MDL = new double [ 3 , 1 ] { { 0 } , { 0 } , { 0 } } ;
776775 public static readonly double [ , ] SENSITIVITY_MATRIX_MAG_50GA_SHIMMER3R_LIS2MDL = new double [ 3 , 3 ] { { 667 , 0 , 0 } , { 0 , 667 , 0 } , { 0 , 0 , 667 } } ;
777776
@@ -2266,7 +2265,7 @@ public void InterpretInquiryResponseShimmer3R(List<byte> packet)
22662265
22672266 if ( HardwareVersion == ( int ) ShimmerBluetooth . ShimmerVersion . SHIMMER3R )
22682267 {
2269- if ( magSamplingRate == 0 ) //3200 us the raw ADC value and not in HZ
2268+ if ( magSamplingRate == 0x08 )
22702269 {
22712270 LowPowerMagEnabled = true ;
22722271 }
@@ -2280,10 +2279,9 @@ public void InterpretInquiryResponseShimmer3R(List<byte> packet)
22802279 {
22812280 LowPowerGyroEnabled = true ;
22822281 }
2283-
2284- }
2285-
22862282
2283+ }
2284+
22872285 NumberofChannels = ( int ) packet [ 6 + 3 ] ;
22882286 BufferSize = ( int ) packet [ 7 + 3 ] ;
22892287 ListofSensorChannels . Clear ( ) ;
@@ -2654,7 +2652,7 @@ protected void RetrieveKinematicCalibrationParametersFromPacket(byte[] bufferCal
26542652 OffsetVectorMag = offsetVector ;
26552653 SensitivityMatrixMag = sensitivityMatrix ;
26562654 }
2657- else if ( packetType == ( byte ) PacketTypeShimmer3 . MAG_CALIBRATION_RESPONSE && sensitivityMatrix [ 0 , 0 ] != - 1 && HardwareVersion == ( int ) ShimmerBluetooth . ShimmerVersion . SHIMMER3 )
2655+ else if ( packetType == ( byte ) PacketTypeShimmer3 . MAG_CALIBRATION_RESPONSE && ( sensitivityMatrix [ 0 , 0 ] != - 1 && ! UtilCalibration . AllElementsAre ( sensitivityMatrix , 0 ) ) )
26582656 {
26592657 DefaultMagParams = false ;
26602658 AlignmentMatrixMag = alignmentMatrix ;
@@ -2752,19 +2750,19 @@ protected void RetrieveKinematicCalibrationParametersFromPacket(byte[] bufferCal
27522750
27532751 AlignmentMatrixMag = ALIGNMENT_MATRIX_MAG_SHIMMER3R_LIS3MDL ;
27542752 OffsetVectorMag = OFFSET_VECTOR_MAG_SHIMMER3R_LIS3MDL ;
2755- if ( GetMagRange ( ) == 1 )
2753+ if ( GetMagRange ( ) == 0 )
27562754 {
27572755 SensitivityMatrixMag = SENSITIVITY_MATRIX_MAG_4GA_SHIMMER3R_LIS3MDL ;
27582756 }
2759- else if ( GetMagRange ( ) == 2 )
2757+ else if ( GetMagRange ( ) == 1 )
27602758 {
27612759 SensitivityMatrixMag = SENSITIVITY_MATRIX_MAG_8GA_SHIMMER3R_LIS3MDL ;
27622760 }
2763- else if ( GetMagRange ( ) == 3 )
2761+ else if ( GetMagRange ( ) == 2 )
27642762 {
27652763 SensitivityMatrixMag = SENSITIVITY_MATRIX_MAG_12GA_SHIMMER3R_LIS3MDL ;
27662764 }
2767- else if ( GetMagRange ( ) == 4 )
2765+ else if ( GetMagRange ( ) == 3 )
27682766 {
27692767 SensitivityMatrixMag = SENSITIVITY_MATRIX_MAG_16GA_SHIMMER3R_LIS3MDL ;
27702768 }
@@ -3801,7 +3799,8 @@ protected virtual ObjectCluster BuildMsg(List<byte> packet)
38013799 double datatemp = newPacket [ index ] ;
38023800 if ( HardwareVersion == ( int ) ShimmerBluetooth . ShimmerVersion . SHIMMER3R )
38033801 {
3804- datatemp = CalibrateShimmer3RAdcChannel ( datatemp ) * 1.988 ;
3802+ //datatemp = CalibrateShimmer3RAdcChannel(datatemp) * 1.988;
3803+ datatemp = ( CalibrateU12AdcValue ( datatemp , 0 , 3 , 1 ) * 1.988 ) ;
38053804 }
38063805 else
38073806 {
@@ -6525,30 +6524,42 @@ public void SetLowPowerMag(bool enable)
65256524 {
65266525 if ( ! LowPowerMagEnabled )
65276526 {
6528- if ( SamplingRate >= 100 )
6527+ if ( SamplingRate > 560 )
65296528 {
6530- WriteMagSamplingRate ( 1 ) ;
6529+ WriteMagSamplingRate ( 0x01 ) ; //Low Power Mode (1000Hz)
65316530 }
6532- else if ( SamplingRate >= 50 )
6531+ else if ( SamplingRate > 300 )
65336532 {
6534- WriteMagSamplingRate ( 1 ) ;
6533+ WriteMagSamplingRate ( 0x11 ) ; //Medium (560Hz)
65356534 }
6536- else if ( SamplingRate >= 20 )
6535+ else if ( SamplingRate > 155 )
65376536 {
6538- WriteMagSamplingRate ( 1 ) ;
6537+ WriteMagSamplingRate ( 0x21 ) ; //High (300Hz)
65396538 }
6540- else if ( SamplingRate >= 10 )
6539+ else if ( SamplingRate > 100 )
65416540 {
6542- WriteMagSamplingRate ( 1 ) ;
6541+ WriteMagSamplingRate ( 0x31 ) ; //Ultra High (155Hz)
6542+ }
6543+ else if ( SamplingRate > 50 )
6544+ {
6545+ WriteMagSamplingRate ( 0x31 ) ; //Ultra High (155Hz)
6546+ }
6547+ else if ( SamplingRate > 20 )
6548+ {
6549+ WriteMagSamplingRate ( 0x3E ) ; //Ultra High (80Hz)
6550+ }
6551+ else if ( SamplingRate > 10 )
6552+ {
6553+ WriteMagSamplingRate ( 0x3A ) ; //Ultra High (20Hz)
65436554 }
65446555 else
65456556 {
6546- WriteMagSamplingRate ( 1 ) ;
6557+ WriteMagSamplingRate ( 0x38 ) ; //Ultra High (10Hz)
65476558 }
65486559 }
65496560 else //Low power mag for shimmer3R enabled
65506561 {
6551- WriteMagSamplingRate ( 0x0 ) ;
6562+ WriteMagSamplingRate ( 0x08 ) ;
65526563 }
65536564 }
65546565 else //Shimmer2r
0 commit comments