AnsweredAssumed Answered

Read data from ADIS16445

Question asked by Edward1980 on Feb 27, 2017
Latest reply on Feb 28, 2017 by Edward1980

Hello Guys,

 

I have an ADIS16445 connected to my STM32F407 SPI1 pins , I am trying to read XACCL_OUT & YACCL_OUT & ZACCL_OUT & XGYRO_OUT & YGYRO_OUT & ZGYRO_OUT and TEMP_OUT in normal mode described in datasheet , I already have EXTI interrupt on rising edge of pin that connected to DIO1 , in this interrupt I can read single data ( XACCL_OUT and etc ... ) from connected device by setting CS pin to low , transfer request , received value and setting CS pin to high like this :

 

 

            GPIO_ResetBits(GPIOA, GPIO_Pin_1); // CS pin low
            a = transfer(XACCL_OUT);
            b = transfer(0x00);
            GPIO_SetBits(GPIOA, GPIO_Pin_1); // CS pin high
            e = (a << 8) | (b & 0xFF);
            int signedData = 0;
            int isNeg = e & 0x8000;
            if (isNeg == 0x8000)
                signedData = e - 0xFFFF;
            else
                signedData = e;
            float finalData = signedData * 0.00025;
            snprintf(str, 30, "%.2f", finalData);
            USART_Send_Str(str);

 

but when I'm trying to read all desired data continuously , I can not read correct values . this is my code :

 

            GPIO_ResetBits(GPIOA, GPIO_Pin_1);
            a = transfer(XACCL_OUT);
            b = transfer(0x00);
            GPIO_SetBits(GPIOA, GPIO_Pin_1);
            e = (a << 8) | (b & 0xFF);
            int signedData = 0;
            int isNeg = e & 0x8000;
            if (isNeg == 0x8000)
                signedData = e - 0xFFFF;
            else
                signedData = e;
            float finalData = signedData * 0.00025;
            snprintf(str, 30, "%.2f", finalData);
            USART_Send_Str(str);
            USART1_Send_Byte(',');
            Delay_us(40);    // Stall Time
            //////
            GPIO_ResetBits(GPIOA, GPIO_Pin_1);
            a = transfer(YACCL_OUT);
            b = transfer(0x00);
            GPIO_SetBits(GPIOA, GPIO_Pin_1);
            e = (a << 8) | (b & 0xFF);
            signedData = 0;
            isNeg = e & 0x8000;
            if (isNeg == 0x8000)
                signedData = e - 0xFFFF;
            else
                signedData = e;
            finalData = signedData * 0.00025;
            snprintf(str, 30, "%.2f", finalData);
            USART_Send_Str(str);
            USART1_Send_Byte(',');
            Delay_us(40);
            //////
            GPIO_ResetBits(GPIOA, GPIO_Pin_1);
            a = transfer(ZACCL_OUT);
            b = transfer(0x00);
            GPIO_SetBits(GPIOA, GPIO_Pin_1);
            e = (a << 8) | (b & 0xFF);
            signedData = 0;
            isNeg = e & 0x8000;
            if (isNeg == 0x8000)
                signedData = e - 0xFFFF;
            else
                signedData = e;
            finalData = signedData * 0.00025;
            snprintf(str, 30, "%.2f", finalData);
            USART_Send_Str(str);
            USART1_Send_Byte(',');
            Delay_us(40);
            USART1_Send_Byte(13);
            USART1_Send_Byte(10);  

 

            USART_Send_Str("Gyros : ");
            GPIO_ResetBits(GPIOA, GPIO_Pin_1);
            a = transfer(XGYRO_OUT);
            b = transfer(0x00);
            GPIO_SetBits(GPIOA, GPIO_Pin_1);
            e = (a << 8) | (b & 0xFF);
            signedData = 0;
            isNeg = e & 0x8000;
            if (isNeg == 0x8000)
                signedData = e - 0xFFFF;
            else
                signedData = e;
            finalData = signedData * 0.01;
            snprintf(str, 30, "%.2f", finalData);
            USART_Send_Str(str);
            USART1_Send_Byte(',');
            Delay_us(40);
            //////
            GPIO_ResetBits(GPIOA, GPIO_Pin_1);
            a = transfer(YGYRO_OUT);
            b = transfer(0x00);
            GPIO_SetBits(GPIOA, GPIO_Pin_1);
            e = (a << 8) | (b & 0xFF);
            signedData = 0;
            isNeg = e & 0x8000;
            if (isNeg == 0x8000)
                signedData = e - 0xFFFF;
            else
                signedData = e;
            finalData = signedData * 0.01;
            snprintf(str, 30, "%.2f", finalData);
            USART_Send_Str(str);
            USART1_Send_Byte(',');
            Delay_us(40);
            //////
            GPIO_ResetBits(GPIOA, GPIO_Pin_1);
            a = transfer(ZGYRO_OUT);
            b = transfer(0x00);
            GPIO_SetBits(GPIOA, GPIO_Pin_1);
            e = (a << 8) | (b & 0xFF);
            signedData = 0;
            isNeg = e & 0x8000;
            if (isNeg == 0x8000)
                signedData = e - 0xFFFF;
            else
                signedData = e;
            finalData = signedData * 0.01;
            snprintf(str, 30, "%.2f", finalData);
            USART_Send_Str(str);
            USART1_Send_Byte(',');
            Delay_us(40);
            USART1_Send_Byte(13);
            USART1_Send_Byte(10);  
        }

 

this is my result on serial port :

Accels : 0.00,-0.00,0.02,
Gyros : 40.05,0.19,-0.01,
Accels : 0.00,-0.00,0.03,
Gyros : 40.01,0.32,0.08,
Accels : 0.00,-0.00,0.03,
Gyros : 40.05,0.23,-0.01,
Accels : 0.00,-0.00,0.02,
Gyros : 40.07,0.27,0.05,
Accels : 0.00,-0.00,0.02,
Gyros : 40.04,0.12,-0.02,
Accels : 0.00,-0.00,0.02,
Gyros : 40.07,0.38,-0.04,
Accels : 0.00,-0.00,0.02,
Gyros : 39.98,0.35,-0.01,
Accels : 0.00,-0.00,0.02,
Gyros : 39.99,0.17,-0.18,
Accels : 0.00,-0.00,0.02,
Gyros : 39.93,0.27,0.00,
Accels : 0.00,-0.01,0.02,
Gyros : 40.04,0.12,-0.05,
Accels : 0.00,-0.00,0.02,
Gyros : 40.02,0.24,0.19,
Accels : 0.00,-0.01,0.02,
Gyros : 40.08,0.26,0.08,
Accels : 0.00,-0.01,0.02,
Gyros : 40.04,0.43,-0.02,
Accels : 0.01,-0.00,0.02,
Gyros : 40.07,0.12,-0.05,
Accels : 0.00,-0.01,0.02,
Gyros : 40.01,0.07,-0.01,
Accels : 0.00,-0.00,0.02,
Gyros : 40.04,0.09,0.02,
Accels : 0.00,-0.01,0.03,
Gyros : 40.05,0.38,0.02,
Accels : 0.00,-0.00,0.02,
Gyros : 39.97,0.20,-0.03,
Accels : 0.00,-0.00,0.02,
Gyros : 40.05,0.29,-0.09,

 

the sensor is on the table with no movement .

 

if I remove reading gyros part of my code I will receive these result :

 

Accels : 1.00,-0.00,0.03,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.01,0.02,
Accels : 1.00,-0.01,0.02,
Accels : 1.00,-0.01,0.02,
Accels : 1.00,-0.01,0.02,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.01,0.02,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.01,0.02,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.01,0.03,
Accels : 1.00,-0.00,0.03,
Accels : 1.00,-0.00,0.03,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.01,0.03,
Accels : 1.00,-0.01,0.02,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.01,0.02,
Accels : 1.00,-0.01,0.03,
Accels : 1.00,-0.01,0.02,
Accels : 1.00,-0.01,0.03,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.00,0.02,
Accels : 1.00,-0.01,0.02,

 

the sensor is still on the table with no movement . you can see changes in the values .

 

one another strange problem is on gyros values in °/sec format , I expected to read 250°/sec as maximum value when I rotate the sensor , but I can see 300°/sec even more that 300°/sec .

 

I need your help to understand how to read correct values from ADIS16445 , please guide me .

 

Best Regards,

Edward .

Outcomes