2499 views|3 replies

931

Posts

3

Resources
The OP
 

X-NUCLEO-IKS01A3 sensor test based on STM32F401RE development board 3D acceleration LIS2DW12 sensor test... [Copy link]

 

Today I tested the 3D sensor using the LIS2DW12_6Dorientation example. At first I thought this example was for testing acceleration, but after actual operation I realized it was for testing the sensor placement direction, namely horizontal (ZH), horizontal (ZL), upright (YL), inverted (YH), left side (XL), right side (XH), a total of 6 directions.
I still added the LCD driver, added the include path and other "conventional" practices, and then added the LCD display code in the Send_Orientation() function. The code is as follows:

static void Send_Orientation(void)
{
  uint8_t xl = 0;
  uint8_t xh = 0;
  uint8_t yl = 0;
  uint8_t yh = 0;
  uint8_t zl = 0;
  uint8_t zh = 0;

  if (IKS01A3_MOTION_SENSOR_Get_6D_Orientation_XL(IKS01A3_LIS2DW12_0, &xl) != BSP_ERROR_NONE)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "Error getting 6D orientation XL axis from LIS2DW12 - accelerometer.\r\n");
    printf("%s", dataOut);
    LCD_clear_line(4);
    LCD_clear_line(5);
    LCD_write_BG(0,4,(uint8_t *)"XL 轴数据错误");
	  
    return;
  }
  if (IKS01A3_MOTION_SENSOR_Get_6D_Orientation_XH(IKS01A3_LIS2DW12_0, &xh) != BSP_ERROR_NONE)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "Error getting 6D orientation XH axis from LIS2DW12 - accelerometer.\r\n");
    printf("%s", dataOut);
      LCD_clear_line(4);
      LCD_clear_line(5);
	  LCD_write_BG(0,4,(uint8_t *)"XH 轴数据错误");
    return;
  }
  if (IKS01A3_MOTION_SENSOR_Get_6D_Orientation_YL(IKS01A3_LIS2DW12_0, &yl) != BSP_ERROR_NONE)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "Error getting 6D orientation YL axis from LIS2DW12 - accelerometer.\r\n");
    printf("%s", dataOut);
      LCD_clear_line(4);
      LCD_clear_line(5);
	  LCD_write_BG(0,4,(uint8_t *)"YL 轴数据错误");
    return;
  }
  if (IKS01A3_MOTION_SENSOR_Get_6D_Orientation_YH(IKS01A3_LIS2DW12_0, &yh) != BSP_ERROR_NONE)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "Error getting 6D orientation YH axis from LIS2DW12 - accelerometer.\r\n");
    printf("%s", dataOut);
      LCD_clear_line(4);
      LCD_clear_line(5);
      LCD_write_BG(0,4,(uint8_t *)"YH 轴数据错误");
    return;
  }
  if (IKS01A3_MOTION_SENSOR_Get_6D_Orientation_ZL(IKS01A3_LIS2DW12_0, &zl) != BSP_ERROR_NONE)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "Error getting 6D orientation ZL axis from LIS2DW12 - accelerometer.\r\n");
    printf("%s", dataOut);
      LCD_clear_line(4);
      LCD_clear_line(5);
      LCD_write_BG(0,4,(uint8_t *)"ZL 轴数据错误");
    return;
  }
  if (IKS01A3_MOTION_SENSOR_Get_6D_Orientation_ZH(IKS01A3_LIS2DW12_0, &zh) != BSP_ERROR_NONE)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "Error getting 6D orientation ZH axis from LIS2DW12 - accelerometer.\r\n");
    printf("%s", dataOut);
      LCD_clear_line(4);
      LCD_clear_line(5);
      LCD_write_BG(0,4,(uint8_t *)"ZH 轴数据错误");
    return;
  }

  if (xl == 1U && yl == 0U && zl == 0U && xh == 0U && yh == 0U && zh == 0U)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "\r\n  ________________  " \
                   "\r\n |                | " \
                   "\r\n |  *             | " \
                   "\r\n |                | " \
                   "\r\n |                | " \
                   "\r\n |                | " \
                   "\r\n |                | " \
                   "\r\n |________________| \r\n");

      LCD_clear_line(4);
      LCD_clear_line(5);
	LCD_write_BG(0,4,(uint8_t *)"运动方向: XL");
  }

  else if (xl == 0U && yl == 1U && zl == 0U && xh == 0U && yh == 0U && zh == 0U)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "\r\n  ________________  " \
                   "\r\n |                | " \
                   "\r\n |             *  | " \
                   "\r\n |                | " \
                   "\r\n |                | " \
                   "\r\n |                | " \
                   "\r\n |                | " \
                   "\r\n |________________| \r\n");

      LCD_clear_line(4);
      LCD_clear_line(5);
      LCD_write_BG(0,4,(uint8_t *)"运动方向: YL");
  }

  else if (xl == 0U && yl == 0U && zl == 0U && xh == 0U && yh == 1U && zh == 0U)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "\r\n  ________________  " \
                   "\r\n |                | " \
                   "\r\n |                | " \
                   "\r\n |                | " \
                   "\r\n |                | " \
                   "\r\n |                | " \
                   "\r\n |  *             | " \
                   "\r\n |________________| \r\n");

      LCD_clear_line(4);
      LCD_clear_line(5);
	LCD_write_BG(0,4,(uint8_t *)"运动方向: YH");
  }

  else if (xl == 0U && yl == 0U && zl == 0U && xh == 1U && yh == 0U && zh == 0U)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "\r\n  ________________  " \
                   "\r\n |                | " \
                   "\r\n |                | " \
                   "\r\n |                | " \
                   "\r\n |                | " \
                   "\r\n |                | " \
                   "\r\n |             *  | " \
                   "\r\n |________________| \r\n");

      LCD_clear_line(4);
      LCD_clear_line(5);
	LCD_write_BG(0,4,(uint8_t *)"运动方向: XH");
  }

  else if (xl == 0U && yl == 0U && zl == 0U && xh == 0U && yh == 0U && zh == 1U)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "\r\n  __*_____________  " \
                   "\r\n |________________| \r\n");

      LCD_clear_line(4);
      LCD_clear_line(5);
	LCD_write_BG(0,4,(uint8_t *)"运动方向: ZH");
  }

  else if (xl == 0U && yl == 0U && zl == 1U && xh == 0U && yh == 0U && zh == 0U)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "\r\n  ________________  " \
                   "\r\n |________________| " \
                   "\r\n    *               \r\n");

      LCD_clear_line(4);
      LCD_clear_line(5);
	LCD_write_BG(0,4,(uint8_t *)"运动方向: ZL");
  }

  else
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "None of the 6D orientation axes is set in LIS2DW12 - accelerometer.\r\n");

      LCD_clear_line(4);
      LCD_clear_line(5);
      LCD_write_BG(0,4,(uint8_t *)"无运动");
  }
  printf("%s", dataOut);
}


The test results after compilation and downloading are as follows:

1. Photos taken during testing:

2. Data received by the serial port assistant:

3. Flat (ZH) sensor:

4. Horizontal (ZL) sensor:

5. Upright (YL) sensor:

6. Inverted (YH) sensor:

7. Left side (XL) sensor:

8. Right side stand (XH) sensor:

Note: The "movement direction" shown on the LCD display should actually be the placement direction.


This content is originally created by EEWORLD forum user hujj . If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

This post is from MEMS sensors

Latest reply

This is really simple.   Details Published on 2019-7-20 10:02
 
 

1w

Posts

25

Resources
2
 

The posture is determined by the parameters of the three axes.

This post is from MEMS sensors

Comments

The test and judgment are directly based on the example code (see the code in the post). After calling the IKS01A3_MOTION_SENSOR_Get_6D_Orientation_XL() function, the values of the six variables xl, xh, yl, yh, zl, and zh are directly judged.  Details Published on 2019-7-20 09:34
 
 
 

931

Posts

3

Resources
3
 
dcexpert posted on 2019-7-19 22:06 The posture is determined by the parameters of the three axes.

The test and judgment are directly based on the example code (see the code in the post). After calling the IKS01A3_MOTION_SENSOR_Get_6D_Orientation_XL() function, the values of the six variables xl, xh, yl, yh, zl, and zh are directly judged.

This post is from MEMS sensors

Comments

This is really simple.  Details Published on 2019-7-20 10:02
 
 
 

1w

Posts

25

Resources
4
 
hujj posted on 2019-7-20 09:34 The test and judgment are directly using the example code (see the code in the post), calling IKS01A3_MOTION_SENSOR_Get_6D_Orientation_X ...

This is really simple.

This post is from MEMS sensors
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list