cancel
Showing results for 
Search instead for 
Did you mean: 

Inclinometer Murata SCL3300, wrong results if I read more angles

toman
Associate II

Hi, I solve a problem with reading more parameters from the inclinometer Murata SCL3300. The communication works without errors, the init state is OK and when I read more parameters, I get the wrong results.

For SPI communication I use HAL_SPI_TransmitReceive(&hspi2, tx_data, rx_data, 1, 100); I attached my code.

Does anyone have the same problem?

1 ACCEPTED SOLUTION

Accepted Solutions

The problem was in reading data. Responses are shifted as shown in the datasheet. The data reading code should look like this:

// first command
         transfer(RdAngX);
         if (crcerr || statuserr) errorflag = true;
 
// second command 
	  transfer(RdAngY);
	  if (crcerr || statuserr) errorflag = true;
 
// response to the first command 
	  angleX = (SCL3300_DATA / 16384.) * 90.;
 
// third command 
	  transfer(RdAngZ);
	  if (crcerr || statuserr) errorflag = true;
 
// response to the second command 
	  angleY = (SCL3300_DATA / 16384.) * 90.; 
 
	  transfer(RdStatSum);
	  if (crcerr || statuserr) errorflag = true;
	  angleZ = (SCL3300_DATA / 16384.) * 90.; 
 
	  transfer(Read_WHOAMI);
	  if (crcerr || statuserr) errorflag = true;

View solution in original post

4 REPLIES 4
Eleon BORLINI
ST Employee

Hi @toman​ ,

which MCU are you using?

Since the inclinometer is manufactured by Murata, I suggest you to post your question on their online support page, to get a direct help --> LINK.

-Eleon

toman
Associate II

Hi @Eleon BORLINI​ ,

thanks for your answer and suggestion. I try to add this question on the Murata support page. I use a basic processor STMF103C8T6. 

I think the problem will be in using the function HAL_SPI_TransmitReceive. The protocol needs to send 4 bytes and receive 4 bytes (see screens from the datasheet). In my case, I use this code:

for (int i = 3; i >= 0; i--) {

tx_data[0] = dataorig.bit8[i];

status = HAL_SPI_TransmitReceive(&hspi2, tx_data, rx_data, 1, 100);

dataorig.bit8[i] = rx_data[0];

The first parameter read OK (for example TiltX), but the second is invalid (e.g. TiltY). I think, there is a collision in the data flow. Is there any description of the function HAL_SPI_TransmitReceive?

0693W00000Y6vtaQAB.png0693W00000Y6vtzQAB.pngThank you. Tomas

The problem was in reading data. Responses are shifted as shown in the datasheet. The data reading code should look like this:

// first command
         transfer(RdAngX);
         if (crcerr || statuserr) errorflag = true;
 
// second command 
	  transfer(RdAngY);
	  if (crcerr || statuserr) errorflag = true;
 
// response to the first command 
	  angleX = (SCL3300_DATA / 16384.) * 90.;
 
// third command 
	  transfer(RdAngZ);
	  if (crcerr || statuserr) errorflag = true;
 
// response to the second command 
	  angleY = (SCL3300_DATA / 16384.) * 90.; 
 
	  transfer(RdStatSum);
	  if (crcerr || statuserr) errorflag = true;
	  angleZ = (SCL3300_DATA / 16384.) * 90.; 
 
	  transfer(Read_WHOAMI);
	  if (crcerr || statuserr) errorflag = true;

Hi @toman​ ,

I'm glad you solved the issue and reported it!

-Eleon