2161 views|0 replies

931

Posts

3

Resources
The OP
 

X-NUCLEO-IKS01A3 sensor test based on STM32F401RE development board 5L [Copy link]

 This post was last edited by hujj on 2019-7-23 17:31

After completing the magnetometer test, today I conducted the final test of the LSM6DSO sensor. The test routine for this time was still the 6D direction. The test process was very smooth. As usual, I added the search path, LCD driver and display code, and added some Chinese character fonts as needed. Since I used a 12*14 dot matrix font in the program, I needed to modify it from the 12*12 dot matrix font. This process took some time. The following are photos of the test process:

This is the detection information when laying flat:

The following is a photo of it lying down. I held it up with my hand and took the photo from bottom to top:

This is a photo of the erection:

Here is a picture of him standing upside down:

Here is a photo of the right side:

Finally, here is the photo on the left:

The following is the original code of the relevant functions with LCD display code added:

/**
  * @brief  Send actual 6D orientation to UART
  * @retval None
  */
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_LSM6DSO_0, &xl) != BSP_ERROR_NONE)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "Error getting 6D orientation XL axis from LSM6DSO - 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_LSM6DSO_0, &xh) != BSP_ERROR_NONE)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "Error getting 6D orientation XH axis from LSM6DSO - 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_LSM6DSO_0, &yl) != BSP_ERROR_NONE)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "Error getting 6D orientation YL axis from LSM6DSO - 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_LSM6DSO_0, &yh) != BSP_ERROR_NONE)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "Error getting 6D orientation YH axis from LSM6DSO - 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_LSM6DSO_0, &zl) != BSP_ERROR_NONE)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "Error getting 6D orientation ZL axis from LSM6DSO - 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_LSM6DSO_0, &zh) != BSP_ERROR_NONE)
  {
    (void)snprintf(dataOut, MAX_BUF_SIZE, "Error getting 6D orientation ZH axis from LSM6DSO - 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 == 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 == 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 == 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 == 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 == 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
  {   //LSM6DSO-加速度计中未设置任何6D方向轴。
    (void)snprintf(dataOut, MAX_BUF_SIZE, "None of the 6D orientation axes is set in LSM6DSO - accelerometer.\r\n");
  }

  printf("%s", dataOut);
}




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
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

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