8640 views|3 replies

124

Posts

1

Resources
The OP
 

[LSM6DSOX finite state machine routine study 1]--Introduction to finite state machine and routine [Copy link]

 This post was last edited by justd0 on 2020-8-15 20:10

Hello everyone, I am J ustd0 , and I am honored to be invited by @nmg administrator to share with you ST's latest LSM6DSOX six-axis sensor. This sensor not only has a 16g three-axis accelerometer and a 2000dps three-axis angular velocity meter, but also has a built-in finite state machine ( FSM ) and machine learning processing module ( MLC ). You only need to configure it accordingly to directly output the recognition results of specific actions. I believe this sensor will bring you a different experience.

Starting from this post, I will use 9 posts to share my understanding of the finite state machine of LSM6DSOX and the learning and use of official related routines during the competition. I hope to help those who don’t know much about these to better use this ST six-axis sensor ~ ST’s official website actually provides very detailed LSM6DSOX instructions , you can read and refer to them, the official documents are the most authoritative. So, if there are any omissions in the content I share, I also hope that you can correct me.

Okay, let’s get to the point~~~


What is a Finite State Machine (FSM) ?

Explanation given by Wikipedia : A mathematical model of a finite number of states and the transitions and actions between these states.

Use the example state machine diagram of LSM6DSOX to explain, as shown below. Each blue square is a state . The program will run line by line. When certain conditions are met , the corresponding state transfer will be triggered .

According to the above rules, the FSM will first determine whether the "return 1" condition in state 1 is met. If it is met, it will return to the default reset point. If it is not met, it will continue to determine whether the "advance 1" condition is met. If it is still not met, it will return to the reset point. If it is met, it will enter state 2 to perform "command processing". After the processing is completed, it will enter state 3. The judgment method is the same as state 1. (Careful partners can see that the reset point here is no longer the default, yes, because there is a command to change the position of the repeat bit, which will be mentioned later when talking about commands)

What are the characteristics of FSM ?

The official documentation of LSM6DSOX lists the following features:

  • The input can be acceleration, angular velocity, magnetometer ( needs to be expanded ) , and the output of the MLC machine learning module
  • Up to 16 state machine programs can run simultaneously
  • Each state machine program can output multiple states
  • There is a complete set of commands and conditional instructions

Let’s look at each one

First, the input can be acceleration, angular velocity, magnetometer (needs to be expanded), and the output of the MLC machine learning module is as shown in the figure below. The raw data of acceleration, angular velocity, and magnetometer are processed by the signal conditioning module into a half-precision floating point value HFP (float is 32 bits, HFP is 16 bits) of appropriate sensitivity (corresponding to the range), and then directly input into the FSM or processed by the machine learning MLC module and its output is passed to the FSM module, and the FSM outputs the result after processing.

It can be seen that the input sources of FSM are very rich. The specific parameter selected as the input source can be changed through the CMD instruction . The details will be discussed later.

Second, there are up to 16 state machine programs running at the same time. Let's expand the FSM , as shown in the figure below. There are 16 state machine modules in the FSM of LSM6DSOX , and all state machines are independent of each other. Each state machine has its own dedicated memory area , and the maximum space for each program is 256 bytes . Moreover, each state machine runs independently , so each program can output results independently .

The state machine program of LSM6DSOX does not have the power-off preservation feature and needs to be reconfigured every time the power is turned on again .

Third, each state machine program can output multiple states. The output of the state machine program can trigger an internal interrupt through a specific command , thereby transferring the output value to the corresponding FSM_OUTS register. When the external INT1/INT2 interrupt is enabled , the internal interrupt can also be routed to the external interrupt to prompt the external processor to read the FSM_OUTS register state change. The configuration parameter format of the output mask M ask is shown in the figure below. The mask can be used to set different combinations of output states, which will be discussed in detail later.

Mask

+X

-X

+And

-AND

+Z

-WITH

+V

-V

Byte number

7

6

5

4

3

2

1

0

Fourth, there is a complete set of commands and conditional instructions. This command instruction set is mentioned on pages 13-14 of ST Programmable Sensors.pdf . I found a more detailed introduction in the official AN5273 document. FSM has a total of 16 conditional instructions and 35 command instructions, but due to limited space, I will share my understanding and usage examples of each command and conditional instruction function in a post.

After understanding what FSM is and what its characteristics are, you should have a comprehensive understanding of it. But at the same time, you may also have many new questions, such as "How to select these inputs? How to set the output Mak ? How to configure interrupts? What are the instructions? And so on." How should I write a finite state machine program?

In fact, ST has provided us with a lot of application examples. The official example library can be found on

链接已隐藏,如需查看请登录或者注册
. There are 7 examples for LSM6DSOX :

These routines all use FSM to implement the function of motion/action recognition. I believe that by learning and reproducing these routines, you can have a deeper understanding of the FSM of LSM6DSOX and be familiar with future applications.

In the next article, I will explain in detail how to use the FSM programming module and the detailed meaning of the programming instructions to lay a small foundation for example program learning.

This post is the first post about FSM finite state machine learning sharing~

If you have any ideas for sharing or suggestions for improvement, please leave a message. I will adjust the content appropriately based on your opinions.

Latest reply

Learned  Details Published on 2023-9-16 14:19
 
 

3

Posts

0

Resources
2
 
 
 

6593

Posts

0

Resources
3
 

I am looking forward to your understanding and usage examples of each command and conditional instruction function.

 
 
 

24

Posts

0

Resources
4
 
Learned
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

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