Download Print this page

ElecMaster JY-61 Series User Manual page 11

High precision gyroscope module

Advertisement

The data packet is used to indicate the module whether enter into the IIC mode, the module
will release the IIC MPU6050 bus, and the user can access to the original data of the MPU6050
chip by IIC. If you receive 0x55 0x50 at the beginning of the data packet, the module works in the
IIC mode, when you want to switch to the serial mode, please send a command 0xFF 0xAA 0x61,
or use the PC program to modify.
5.3 Data analysis sample code(Language C):
double
a[3],w[3],Angle[3],T;
void DecodeIMUData(unsigned char
{
switch(chrTemp[1])
{
case
0x51:
a[0] = ((short)(chrTemp[3]<<8|chrTemp[2]))/32768.0*16;
a[1] = ((short) (chrTemp[5]<<8|chrTemp[4]))/32768.0*16;
a[2] = ((short) (chrTemp[7]<<8|chrTemp[6]))/32768.0*16;
T = ((short) (chrTemp[9]<<8|chrTemp[8]))/340.0+36.25;
break;
case
0x52:
w[0] = ((short) (chrTemp[3]<<8|chrTemp[2]))/32768.0*2000;
w[1] = ((short) (chrTemp[5]<<8|chrTemp[4]))/32768.0*2000;
w[2] = ((short) (chrTemp[7]<<8|chrTemp[6]))/32768.0*2000;
T = ((short) (chrTemp[9]<<8|chrTemp[8]))/340.0+36.25;
break;
case
0x53:
Angle[0] = ((short) (chrTemp[3]<<8|chrTemp[2]))/32768.0*180;
Angle[1] = ((short) (chrTemp[5]<<8|chrTemp[4]))/32768.0*180;
Angle[2] = ((short)(chrTemp[7]<<8|chrTemp[6]))/32768.0*180;
T = ((short)(chrTemp[9]<<8|chrTemp[8]))/340.0+36.25;
printf("a =
%4.3f\t%4.3f\t%4.3f\t\r\n",a[0],a[1],a[2]);
printf("w =
%4.3f\t%4.3f\t%4.3f\t\r\n",w[0],w[1],w[2]);
printf("Angle =
%4.2f\t%4.2f\t%4.2f\tT=%4.2f\r\n",Angle[0],Angle[1],Angle[2],T);
break;
}
}
5.4 Examples of analytical data in embedded environment
The code is divided into two parts, one is in interrupt to receive, to find the data's head, and
then put the packet into the array. The other is data analysis in the main code.
Interrupt part(The following is the AVR microcontroller code. The other microcontroller will
be a little difference)
unsigned char Re_buf[11],counter=0;
unsigned char sign;
interrupt [USART_RXC] void usart_rx_isr(void) //USART receive
{
Re_buf[counter]=UDR;// Slight difference between different microcontroller
if(counter==0&&Re_buf[0]!=0x55) return;
counter++;
if(counter==11) // Receive 11 data
{
counter=0; // Re assignment, prepare for the next frame of data receiving
sign=1;
}
}
Main code:
float a[3],w[3],angle[3],T;
extern unsigned char Re_buf[11],counter;
extern unsigned char sign;
chrTemp[])
// if the first data is not frame header, skip
http://www.aliexpress.com/store/1836321
- 11 -

Advertisement

loading
Need help?

Need help?

Do you have a question about the JY-61 Series and is the answer not in the manual?

Subscribe to Our Youtube Channel