Data acquisition based on LIS25BA bone vibration sensor of NUCLEO-767ZI
[Copy link]
This post was last edited by sylar^z on 2019-9-9 08:06
The active ST bone vibration sensor board, first post a picture. The board can be connected by directly soldering a 2.54 double-row pin.
The working voltage of the LIS25BA sensor is 1.8V (1.71V-1.99V), and the board I have is 3.3V. To connect the sensor, I need a 3.3V-1.8V level conversion board. So I bought a TXS0108 conversion board on Taobao to solve this problem.
In addition, the boards I had either didn't have a SAI interface or it was difficult to bring out the interface. Fortunately, EE could borrow a development board, so I connected a NUCLEO-767ZI board. Thanks to @ nmg . After the hardware was done, it looked like the picture below.
The control communication of LIS25BA is I2C protocol, which can support up to 400K rate. There are not many registers on the sensor, and only two registers need to be configured to complete the setting of LIS25BA.
TMD controls the sensor. Enable TMD function, set sampling rate, etc.
LIS25BA controls the sensor. Set PD to 0 to enable the sensor
The data acquisition of LIS25BA is TMD interface, and the master controller needs to provide sampling clock. The signal lines are MCLK, WCLK, BCLK, and SD on the sensor. MCLK is the sensor data sampling clock. WCLK is the data sampling frequency, which can be 8KHz, 16KHz, or 24KHz. BCLK is the bit rate. LIS25BA data contains 8 slots and 16-bit data. According to the requirements of the above three clocks in the manual, MCLK is fixed to 12.288MHz, BCLK and WCLK must be divisible by MCLK, and BCLK must also be an integer multiple of WCLK. This can ensure that the sampling data and timing are strictly consistent.
When MCLK is not the standard 12.288MHz, as long as the three clocks are integer multiples, data can be collected stably, but the corresponding sampling frequency of the data (such as 16KKHz) will change accordingly.
Under this requirement, the frequency of MCLK needs to be set to 1536 times, 768 times and 512 times of WCLK at 8KHz, 16KHz and 24KHz respectively. From the F7 manual, it is found that the frequency of MCLK is fixed to 256 times of WCLK frequency. This requires an additional synchronous clock to be used as MCLK. I enabled another SAI MCLK to obtain a 12.288NHz clock output.
The program configuration uses STM32CubeMX, and configures SAI1, SAI2, I2C1 and the corresponding DMA functions. SAI1 is used to collect data from LIS25BA, 16KHz, 8SLOT. DMA transmission is enabled.
In terms of clock, SAI1 uses a 32MHz PLLSAI clock, and SAI2 uses a 96MHz PLLI2S clock, so that the MCLK frequency of SAI2 is 3 times the frequency of SAI1, that is, 768 times the MCLK frequency of SAI1.
The following is the LIS25BA data collected by the program. You only need to extract the first three of the eight SLOT data to get the XYZ three-axis data of the sensor.
|