Products
Technology
SMS solutions
PBX systems
Databases
Robotics
Building robot hardware
Building electronics
Building robot software
Introduction/Protocols
Architecture
How to develop a devhandler
Line protocol
DeviceHandlers
Oz433Mhz Transceiver
OzAnalogJoystickController
OzAnalogSensor
OzBatteryController
OzBuzzerController
OzButtonController
OzDCMotorControllerL298N
OzDHTController
OzDoorphoneController
OzEEPROMManager
OzGyroControllerMPU6050
Example
OzIDManager
OzLCDController
OzNfcController
OzOpticalGateController
OzRegisterController
OzRGBLedController
OzRotaryController
OzServoController
OzStepCounter
OzStepperMotorMultiController
OzSwitchController
OzTemperatureController
OzTimer
OzUltrasonicController
Examples
Bootloader
Company


Oz Gyro Controller MPU6050

This protocol sends MPU6050 gyroscope data in timed cycles to the user. You can set the type of data you need and the cycle time. Defaultly it sends these data: acceleration including gravity, actual angle and temperature) in every second.

The default settings are the following:
  • accelerometer: +/- 2g (all setttings: 2, 4, 8, 16)
  • gyroscope: +/- 250 degrees/sec (all setttings: 250, 500, 1000, 2000)
  • Sets the clock source to use the X Gyro for reference, which is slightly better than the default internal clock source.

How to build a test circuit with an MPU6050 and an Arduino MEGA?
Arduino codes are included.

I. "welcome" event

Example

c=welcome&id=XnSicK&type=OzGyroControllerMPU6050&pos=2&t=1

Parameters

Parameter Type Range Functionality
c String "welcome" Identifies the welcome message.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
type String "OzGyroControllerMPU6050" Determines the type of the device.
pos Byte 0-255 Determines the position of the device on the list of the ID manager of the microcontroller. Please make sure there are no devices on the same position on the same microcontroller!
t Byte 0-255 Counts the number of responses and events sent combined. Counts from 0 to 255 then from 0 again. Be aware that the t of the commands differs from the t of the responses and events.



II. Commands from .Net

"auto_conf" command

Measures the offsets of your newly connected MPU6050 and calibrates it, this can take a minute, just lay it flat on the table and do NOT touch it, just sit back and relax. This is important for the MPU6050 to work properly.

The MPU6050 automatically saves the calibration so you do not need to recalibrate it everytime.

Example

//the measurement sample size is 1100:
c=auto_conf&sample_size=1100&id=XnSicK&t=0
Parameter Type Range Functionality
c String "auto_conf" Identifies the command.
sample_size unsigned int 0-65535 Optional parameter, default value: 1000. The size of the measurement sample during the calibration. The longer the sample size the more time the calibration will take.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of commands sent combined. Counts from 0 to 255 then from 0 again. Be aware that the t of the commands differs from the t of the responses and events.

Response

//it lets you know when the offset configuration is ready
c=auto_conf_resp&sample_size=1100&id=XnSicK&t=10
Parameter Type Range Functionality
c String "auto_conf_resp" Identifies the command.
sample_size unsigned int 0-65535 The size of the measurement sample during the calibration.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of responses and events sent combined. Counts from 0 to 255 then from 0 again. Be aware that the t of the commands differs from the t of the responses and events.

"set_info" command

Sets the 'accel_info', 'rotation_info' and 'angle_info' events. You can set the time-cycle of the events in milliseconds.

If not set these data are sent in every second:

  • acceleration including gravity ('accel_info' event)
  • actual angle ('angle_info' event)
  • current temperature (shown in every info event)

Example

//sets the time cycle to 100 ms
//and activates the 'accel_info' event
//with temperature added
//the 'rotation_info' event is deactivated
//the 'angle_info' event is deactivated
c=set_info&delay=100&accinfo=1&rotinfo=0&angleinfo=0&tempinfo=1&id=XnSicK&t=1

Parameters

Parameter Type Range Functionality
c String "set_info" Identifies the command.
delay Unsigned Int 0-65535 Sets the timeframe between the events. All required events are sent simultaneously.
accinfo Bool 0,1 0: The 'accel_info' event won't be sent. 1: The 'accel_info' event will be sent.
rotinfo Bool 0,1 0: The 'rotation_info' event won't be sent. 1: The 'rotation_info' event will be sent.
angleinfo Bool 0,1 0: The 'angle_info' event won't be sent. 1: The 'angle_info' event will be sent.
tempinfo Bool 0,1 0: The current temperature won't be sent in the events. 1: The current temperature will be sent in the events.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of commands sent combined. Counts from 0 to 255 then from 0 again. Be aware that the t of the commands differs from the t of the responses and events.

Response

c=set_info_resp&delay=100&accinfo=1&rotinfo=0&angleinfo=0&tempinfo=1&id=XnSicK&t=3

Parameters

Parameter Type Range Functionality
c String "set_info_resp" Identifies the response.
delay Unsigned Int 0-65535 Sets the timeframe between the events. All required events are sent simultaneously.
accinfo Bool 0,1 0: The 'accel_info' event won't be sent. 1: The 'accel_info' event will be sent.
rotinfo Bool 0,1 0: The 'rotation_info' event won't be sent. 1: The 'rotation_info' event will be sent.
angleinfo Bool 0,1 0: The 'angle_info' event won't be sent. 1: The 'angle_info' event will be sent.
tempinfo Bool 0,1 0: The current temperature won't be sent in the events. 1: The current temperature will be sent in the events.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of responses and events sent combined. Counts from 0 to 255 then from 0 again. Be aware that the t of the commands differs from the t of the responses and events.



"set" command

Sets the acceleration range, gyroscope speed range and the clock source.

    The default settings are the following:
  • accelerometer: +/- 2g (all setttings: 2, 4, 8, 16)
    The smaller the range the more precise is the measurement, because all axis (x,y,z) is measured on 16 bits.
  • gyroscope: +/- 250 degrees/sec (all setttings: 250, 500, 1000, 2000)
  • Sets the clock source to use the X Gyro for reference, which is slightly better than the default internal clock source.

Example

//this example sets the accel range to +/- 16g
//the speed range to +/- 2000 degrees/sec
//and the clk source to internal oscillator
c=set&acc_range=16&gyro_range=2000&clk_source=0&id=XnSicK&t=2

Parameters

Parameter Type Range Functionality
c String "set" Identifies the command.
acc_range specific bytes 2, 4, 8, 16 Sets the +/- g range of the accelerometer.
gyro_range specific ints 250, 500, 1000, 2000 Sets the gyroscope's +/- degrees/s speed range
clk_source specific bytes 0,1,2,3,4,5,6,7 0: Internal oscillator
1: PLL with X Gyro reference
2: PLL with Y Gyro reference
3: PLL with Z Gyro reference
4: PLL with external 32.768kHz reference
5: PLL with external 19.2MHz reference
6: Reserved
7: Stops the clock and keeps the timing generator in reset
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of commands sent combined. Counts from 0 to 255 then from 0 again. Be aware that the t of the commands differs from the t of the responses and events.

Response

c=set_resp&acc_range=16&gyro_range=2000&clk_source=0&id=XnSicK&t=4

Parameters

Parameter Type Range Functionality
c String "set_resp" Identifies the response.
acc_range specific bytes 2, 4, 8, 16 The +/- g range of the accelerometer is set.
gyro_range specific ints 250, 500, 1000, 2000 The gyroscope to +/- degrees/s speed range is set.
clk_source specific bytes 0,1,2,3,4,5,6,7 0: Internal oscillator
1: PLL with X Gyro reference
2: PLL with Y Gyro reference
3: PLL with Z Gyro reference
4: PLL with external 32.768kHz reference
5: PLL with external 19.2MHz reference
6: Reserved
7: Stops the clock and keeps the timing generator in reset
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of responses and events sent combined. Counts from 0 to 255 then from 0 again. Be aware that the t of the commands differs from the t of the responses and events.



III. Event from the device

"accel_info" event

This event shows the acceleration component of the forces effecting the MPU6050. When layed on surface it shows the gravity (9.80 m/s2). It can show the temperature too.

Default range: +/- 2g (1g = 9.80 m/s2) (The lower the range, the more precise is the measurement.)

Example

//from the example you can see that the MPU6050 is set on a flat plane
//so only the gravitational force works on it (1g = 9.80)
c=accel_info&x=0.03&y=0.02&z=9.84&temp=24.91&id=XnSicK&t=119
//this is how a freefall would look like: c=accel_info&x=0.02&y=0.03&z=0.12&temp=18.34&id=XnSicK&t=68

Parameters

Parameter Type Range Functionality
c String "accel_info" Identifies the command.
x Float -156.80 to 156.80 (in case of +/- 16g) Shows the acceleration including gravity in x direction.
y Float -156.80 to 156.80 Shows the acceleration including gravity in y direction.
z Float -156.80 to 156.80 Shows the acceleration including gravity in z direction.
temp Float -40.00 to 85.00 Shows the current temperature in celsius. This parameter is optional (use the 'set' command). It can mistake +/- 1%
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of commands sent combined. Counts from 0 to 255 then from 0 again. Be aware that the t of the commands differs from the t of the responses and events.

"rotation_info" event

This event shows the actual rotation speed in degrees/s of the MPU6050 chip. It can show the temperature too.

Default range: +/- 250 degrees/s (The lower the range, the more precise will the measurement be.)

Example

//the MPU6050 is currently not turning (rotating) in any direction:
c=rotation_info&x=-0.18&y=0.19&z=0.02&temp=25.09&id=XnSicK&t=15
//the MPU6050 is currently moving in 756 degrees/s in X direction:
c=rotation_info&x=756.00&y=0.19&z=0.02&temp=25.09&id=XnSicK&t=34

Parameters

Parameter Type Range Functionality
c String "rotation_info" Identifies the command.
x Float -2000 to 2000 degrees/s (if set in the highest range) Show the current rotation speed in X direction of the MPU chip.
y Float -2000 to 2000 degrees/s Show the current rotation speed in Y direction of the MPU chip.
z Float -2000 to 2000 degrees/s Show the current rotation speed in Z direction of the MPU chip.
temp Float -40.00 to 85.00 Shows the current temperature in celsius. This parameter is optional (use the 'set' command). It can mistake +/- 1%
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of commands sent combined. Counts from 0 to 255 then from 0 again. Be aware that the t of the commands differs from the t of the responses and events.

"angle_info" event

This event shows the actual angles of the MPU6050 chip. It can show the temperature too.

TOP VIEW, THE ORIGO IS THE MPU6050 CENTERPOINT:

Example

//made 10 turns around Z (rz=3600)
//and unkown rounds around x and y
//x and y must be between -90 and +90
c=angle_info&x=-40.18&y=10.19&z=3600.02&temp=25.09&id=XnSicK&t=16

Parameters

Parameter Type Range Functionality
c String "angle_info" Identifies the command.
x Double -90.00 to +90.00 Degrees. The current angle in X direction of the MPU chip. It is relative to the calibrated ("auto_conf" command) angle which is 0.
y Double -90.00 to +90.00 Degrees. The current angle in Y direction of the MPU chip. It is relative to the calibrated ("auto_conf" command) angle which is 0.
z Double Full Double range Degrees. The current angle in Z direction of the MPU chip. It is relative to the bootup angle which is 0.
temp Float -40.00 to 85.00 Shows the current temperature in celsius. This parameter is optional (use the 'set' command). It can mistake +/- 1%
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
t Byte 0-255 Counts the number of commands sent combined. Counts from 0 to 255 then from 0 again. Be aware that the t of the commands differs from the t of the responses and events.

Copyright © 2000- - Ozeki Informatics Ltd. | info@ozeki.hu | Tel: +36 1 371 0150
Home > Technology > Robotics > Building robot software > Introduction/Protocols > DeviceHandlers > OzGyroControllerMPU6050
Page: 1597