Check program for LIS3DH bug fixed rev.
I fixed bugs in my library LIS3DH and updated it as Rev.7. This is a check program for LIS3DH lib.
Followings are PC console output data.
003854,new,[m/s2],-0.1079,+0.1177,+9.3457,[mg], -10, +14, +957 003855,new,[m/s2],-0.0588,+0.0686,+9.3555,[mg], -9, +11, +956 003856,new,[m/s2],-0.0686,+0.0883,+9.3163,[mg], -11, +8, +953 003857,new,[m/s2],-0.0981,+0.1275,+9.3752,[mg], -9, +13, +953 003858,new,[m/s2],-0.0981,+0.0294,+9.3457,[mg], -13, +10, +953
In addition, you can see reg. contents.
LIS3DH ultra low-power high performance 3-axes 'nano' accelerometer STATUS_AUX=0xff OUT_ADC1_L=0x00, OUT_ADC1_H=0x00 OUT_ADC2_L=0x00, OUT_ADC2_H=0x00 OUT_ADC3_L=0x00, OUT_ADC3_H=0x00 INT_COUNTER_REG=0x00 WHO_AM_I=0x33 TEMP_CFG_REG=0x00 CTRL_REG1=0x47, CTRL_REG2=0x00, CTRL_REG3=0x00 CTRL_REG4=0x08, CTRL_REG5=0x00, CTRL_REG6=0x00 REFERENCE=0x00 STATUS_REG=0xff OUT_X_L=0xc0, OUT_X_H=0xff OUT_Y_L=0x10, OUT_Y_H=0x00 OUT_Z_L=0x60, OUT_Z_H=0x3b FIFO_CTRL_REG=0x00, FIFO_SRC_REG=0x20 INT1_CFG=0x00, INT1_SOURCE=0x00, INT1_THS=0x00, INT1_DURATION=0x00 CLICK_CFG=0x00, CLICK_SRC=0x00, CLICK_THS=0x00 TIME_LIMIT=0x00, TIME_LATENCY=0x00, TIME_WINDOW=0x00
Here is meaning of data.
<Setting condition> STATUS_AUX=0xff -> new data are avairable but all data are over-run condition OUT_ADC1_L=0x00, OUT_ADC1_H=0x00 OUT_ADC2_L=0x00, OUT_ADC2_H=0x00 OUT_ADC3_L=0x00, OUT_ADC3_H=0x00 -> all ADC data are Zero INT_COUNTER_REG=0x00 -> ? WHO_AM_I=0x33 -> I'm LIS3DH TEMP_CFG_REG=0x00 -> ADC: disabled, Temperature sensor (T): disabled CTRL_REG1=0x47 -> Data rate selection: 50Hz, Low power mode: disabled, XYZ axes: all enabled CTRL_REG2=0x00 -> High pass filter mode selection: normal, Filtered data selection: internal filter bypassed High pass filter: bypassed CTRL_REG3=0x00 -> All kinds of interrupt: disabled CTRL_REG4=0x08 -> Block data update:continuos update, Big/little endian data selection: Data LSB/lower address Full scale selection. default value: +/-2G, High resolution output mode: disabled CTRL_REG5=0x00 -> FIFO disable CTRL_REG6=0x00 -> ? REFERENCE=0x00 -> Reference value for Interrupt generation=0 STATUS_REG=0xff -> new data are avairable but all data are over-run condition OUT_X_L=0xc0, OUT_X_H=0xff -> 0xffc0 -> -64/16 -> -4 OUT_Y_L=0x10, OUT_Y_H=0x00 -> 0x0010 -> 16/16 -> 1 OUT_Z_L=0x60, OUT_Z_H=0x3b -> 0x3b60 -> 15200/16 ->950 FIFO_CTRL_REG=0x00 -> FIFO mode selection: bypassed FIFO_SRC_REG=0x20 -> FIFO: empty INT1_CFG=0x00, INT1_SOURCE=0x00, INT1_THS=0x00, INT1_DURATION=0x00 -> Interrupt related reg's are not used CLICK_CFG=0x00, CLICK_SRC=0x00, CLICK_THS=0x00 -> Click action: not used TIME_LIMIT=0x00, TIME_LATENCY=0x00, TIME_WINDOW=0x00 -> Click related reg's are nit used
Revision 0:117c3daca107, committed 2015-12-12
- Comitter:
- kenjiArai
- Date:
- Sat Dec 12 06:17:47 2015 +0000
- Commit message:
- Check program for LIS3DH bug fixed rev.
Changed in this revision
diff -r 000000000000 -r 117c3daca107 LIS3DH.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LIS3DH.lib Sat Dec 12 06:17:47 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/kenjiArai/code/LIS3DH/#50ac3372def2
diff -r 000000000000 -r 117c3daca107 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Dec 12 06:17:47 2015 +0000 @@ -0,0 +1,102 @@ +/* + * mbed Application program for the mbed + * LIS3DH ultra low-power high performance 3-axes “nano” accelerometer + * + * Copyright (c) 2014 Kenji Arai / JH1PJL + * http://www.page.sannet.ne.jp/kenjia/index.html + * http://mbed.org/users/kenjiArai/ + * Created: November 29th, 2015 + * Revised: December 12th, 2015 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE + * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +// Include --------------------------------------------------------------------------------------- +#include "mbed.h" +#include "LIS3DH.h" + +// Definition ------------------------------------------------------------------------------------ + +// Object ---------------------------------------------------------------------------------------- +// com +Serial pc(USBTX, USBRX); // Communication with Host +I2C i2c(D14,D15); +// Acc +LIS3DH acc(i2c, LIS3DH_V_CHIP_ADDR, LIS3DH_DR_NR_LP_50HZ, LIS3DH_FS_2G); + +// RAM ------------------------------------------------------------------------------------------- +float fa[3]; // Acc 0:X, 1:Y, 2:Z +uint32_t n; + +// ROM / Constant data --------------------------------------------------------------------------- + +// Function prototypes --------------------------------------------------------------------------- +void display_reg(void); + +//------------------------------------------------------------------------------------------------- +// Control Program +//------------------------------------------------------------------------------------------------- +int main(void) { + n = 1; + while (true) { +#if OLD_REV // defined in LIS3DH.h + acc.read_data(fa); + pc.printf("%06d,old,[m/s2], %+7.4f,%+7.4f,%+7.4f,", n++, fa[0], fa[1], fa[2]); + acc.read_mg_data(fa); + pc.printf("[g],%+7.4f,%+7.4f,%+7.4f \r\n", fa[0], fa[1], fa[2]); +#else + acc.read_data(fa); + pc.printf("%06d,new,[m/s2],%+06.4f,%+06.4f,%+06.4f,", n++, fa[0], fa[1], fa[2]); + acc.read_mg_data(fa); + pc.printf("[mg],%+6.0f,%+6.0f,%+6.0f \r\n", fa[0], fa[1], fa[2]); +#endif + wait(0.5); + if (n%25 == 0){ + display_reg(); + } + } +} + +void display_reg(void){ + pc.printf("LIS3DH ultra low-power high performance 3-axes 'nano' accelerometer\r\n"); + pc.printf(" STATUS_AUX=0x%02x\r\n", acc.read_reg(LIS3DH_STATUS_REG_AUX)); + pc.printf(" OUT_ADC1_L=0x%02x,", acc.read_reg(LIS3DH_OUT_ADC1_L)); + pc.printf(" OUT_ADC1_H=0x%02x\r\n", acc.read_reg(LIS3DH_OUT_ADC1_H)); + pc.printf(" OUT_ADC2_L=0x%02x,", acc.read_reg(LIS3DH_OUT_ADC2_L)); + pc.printf(" OUT_ADC2_H=0x%02x\r\n", acc.read_reg(LIS3DH_OUT_ADC2_H)); + pc.printf(" OUT_ADC3_L=0x%02x,", acc.read_reg(LIS3DH_OUT_ADC3_L)); + pc.printf(" OUT_ADC3_H=0x%02x\r\n", acc.read_reg(LIS3DH_OUT_ADC3_H)); + pc.printf(" INT_COUNTER_REG=0x%02x\r\n", acc.read_reg(LIS3DH_INT_COUNTER_REG)); + pc.printf(" WHO_AM_I=0x%02x\r\n", acc.read_reg(LIS3DH_WHO_AM_I)); + pc.printf(" TEMP_CFG_REG=0x%02x\r\n", acc.read_reg(LIS3DH_TEMP_CFG_REG)); + pc.printf(" CTRL_REG1=0x%02x,", acc.read_reg(LIS3DH_CTRL_REG1)); + pc.printf(" CTRL_REG2=0x%02x,", acc.read_reg(LIS3DH_CTRL_REG2)); + pc.printf(" CTRL_REG3=0x%02x\r\n", acc.read_reg(LIS3DH_CTRL_REG3)); + pc.printf(" CTRL_REG4=0x%02x,", acc.read_reg(LIS3DH_CTRL_REG4)); + pc.printf(" CTRL_REG5=0x%02x,", acc.read_reg(LIS3DH_CTRL_REG5)); + pc.printf(" CTRL_REG6=0x%02x\r\n", acc.read_reg(LIS3DH_CTRL_REG6)); + pc.printf(" REFERENCE=0x%02x\r\n", acc.read_reg(LIS3DH_REFERENCE)); + pc.printf(" STATUS_REG=0x%02x\r\n", acc.read_reg(LIS3DH_STATUS_REG)); + pc.printf(" OUT_X_L=0x%02x,", acc.read_reg(LIS3DH_OUT_X_L)); + pc.printf(" OUT_X_H=0x%02x\r\n", acc.read_reg(LIS3DH_OUT_X_H)); + pc.printf(" OUT_Y_L=0x%02x,", acc.read_reg(LIS3DH_OUT_Y_L)); + pc.printf(" OUT_Y_H=0x%02x\r\n", acc.read_reg(LIS3DH_OUT_Y_H)); + pc.printf(" OUT_Z_L=0x%02x,", acc.read_reg(LIS3DH_OUT_Z_L)); + pc.printf(" OUT_Z_H=0x%02x\r\n", acc.read_reg(LIS3DH_OUT_Z_H)); + pc.printf(" FIFO_CTRL_REG=0x%02x,", acc.read_reg(LIS3DH_FIFO_CTRL_REG)); + pc.printf(" FIFO_SRC_REG=0x%02x\r\n", acc.read_reg(LIS3DH_FIFO_SRC_REG)); + pc.printf(" INT1_CFG=0x%02x,", acc.read_reg(LIS3DH_INT1_CFG)); + pc.printf(" INT1_SOURCE=0x%02x,", acc.read_reg(LIS3DH_INT1_SOURCE)); + pc.printf(" INT1_THS=0x%02x,", acc.read_reg(LIS3DH_INT1_THS)); + pc.printf(" INT1_DURATION=0x%02x\r\n", acc.read_reg(LIS3DH_INT1_DURATION)); + pc.printf(" CLICK_CFG=0x%02x,", acc.read_reg(LIS3DH_CLICK_CFG)); + pc.printf(" CLICK_SRC=0x%02x,", acc.read_reg(LIS3DH_CLICK_SRC)); + pc.printf(" CLICK_THS=0x%02x\r\n", acc.read_reg(LIS3DH_CLICK_THS)); + pc.printf(" TIME_LIMIT=0x%02x,", acc.read_reg(LIS3DH_TIME_LIMIT)); + pc.printf(" TIME_LATENCY=0x%02x,", acc.read_reg(LIS3DH_TIME_LATENCY)); + pc.printf(" TIME_WINDOW=0x%02x\r\n", acc.read_reg(LIS3DH_TIME_WINDOW)); +}
diff -r 000000000000 -r 117c3daca107 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Dec 12 06:17:47 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b \ No newline at end of file