Skip to content

OpenGimbal protocols ​

To control OpenGimbal, you simply need to send a few bytes over UART. This page describes how to do it.

D1 ​

D1 commands have three parts: a setup byte, a command byte and optional command-specific data.

Setup byte ​

LEN[3:0]DSTADDR[3:0]

Setup byte is split into two halves. Most significant bits (LEN[3:0]) contain the number of the remaining bytes (excluding setup byte!). Least significant bits contain the address of the destination board.

Each board (C1, D1) on the data line must have a unique address that are allocated as follows:

AddressDescription
0x0Controller (C1)
0x1 - 0xEMotor (D1)
0xFMotor broadcast (D1)

Address 0 (0x0) is reserved for the controller, while address 15 (0xF) will apply to all drivers on the data line. Otherwise, drivers are addressed individually by their address.

Command byte ​

SRCADDR[3:0]CMD[3:0]

Command byte is split in two, similar to the setup byte. Most significant bits contain the address of the board that sent the command (useful for knowing which board responded, for instance) while least significant bits contain the command code itself. Currently, the following commands are supported:

CodeCommand
0x0Sleep
0x1Idle
0x2Wake
0x3Move
0x4Tone
0x5Haptic
0x6Adjust offset
0xESet variable
0xFGet variable

Variables ​

Drivers store certain information as variables that can be read and written. Variables supported by D1 are listed here.

Command description ​

Sleep command ​

Instructs the driver to enter the deepest sleep mode. Rising edge on the data line will wake the driver. Not compatible with standart UART!

Idle command ​

Instructs the driver to enter sleep mode. Any command except Sleep and Idle will wake the driver.

Wake command ​

Dedicated command that tells the driver to wake from sleep mode. Any other command except Sleep and Idle will also wake the driver but the Wake command is guaranteed to have no side effects.

Move command ​

Instructs the driver to move the motor into a specified position. Accepts the following data:

PWR[3:0]POS[11:8]
POS[7:0]

Arguments

  • PWR: Motor torque. 0 is no torque, 15 is maximum
  • POS: Target position

Tone command ​

Changes the PWM frequency of the driver. Lower frequencies produce an audible tone, while retaining full motor control. Set to 25+ kHz to disable sound.

FREQ[15:8]
FREQ[7:0]

Arguments

  • FREQ: Tone frequency

Haptic command ​

Generates haptic feedback, from single pings to longer vibration patterns.

INTN[3:0]DUR[11:8]
DUR[7:0]

Arguments

  • INTN: Haptic feedback intensity
  • DUR: Duration in milliseconds

Adjust offset command ​

Adjusts the offset of the driver so that the current (measured) offset becomes the target value. Useful for setting zero position.

-OFFVAL[11:8]
OFFVAL[7:0]

Arguments

  • OFFVAL: Offset value that will correspond to current position

Set variable command ​

Instructs the driver to set the variable to the given value.

VID[7:0]

VID byte should be followed by one or more bytes containing the value of the variable.

Arguments:

  • VID: ID of the variable to be written

Get variable command ​

Instructs the driver to return the value of a given variable. Only works with individual driver addresses 0x1-0xe (address 0xf will be ignored).

The addressed driver will respond with the command following the same structure, except for the swapped DSTADDR and SRCADDR.

VID[7:0]

Arguments:

  • VID: ID of the variable to be read

D1 variables ​

VIDNameSizeModePersistentDescriptionAllowed valuesComments
0x00Options1R/WYesDriver optionsBit mask. Bit 0 - Calibration, bit 1 - invert directionWriting 1 to the calibration bit will immediately start the calibration
0x01Offset2R/WYesLogical motor offset0-4096
0x02Position2RNoCurrent motor position

C1 ​

C1 commands are organized the same way as D1 commands. The setup byte in the case of C1 only contains the command ID. When using UART, the command needs to be prefixed with a byte containing the length of the remaining bytes (excluding the length byte itself!).

LEN (UART only)CMDCommand data bytes

C1 commands ​

CodeCommand
0x00Disable
0x01Enable
0x0DSet variable
0x0EGet variable
0x0FMotor passthrough

Disable command ​

Disables C1 and power to the motors.

Enable command ​

Enables C1 and power to the motors.

Set/get variable ​

Writes and reads variables similar to D1. The list of C1 variables can be found here.

Motor passthrough ​

Passes bytes following the command byte to the motors as is.

C1 variables ​

VIDNameSizeModePersistentDescriptionAllowed values
0x00Orientation6R/WNoHead orientation as Euler angles (yaw, pitch, roll)3 signed 16-bit values. Scaling factor pi/32768
0x01Handle orientation6RNoHandle orientation as Euler angles (yaw, pitch, roll)3 signed 16-bit values. Scaling factor pi/32768
0x02Mode1R/WGimbal mode0-3
0x03Battery voltageRNo0-255

Gimbal modes ​

IDModeComments
0x00HorizonPitch and roll locked, only yaw follows the handle
0x01FollowRoll locked, yaw and pitch follow the handle
0x02FPVYaw, pitch and roll follow the handle
0x03TiltSame as FPV, except the joystick controls camera roll instead of yaw