SimpleBGC_2_6_Serial_Protocol_Specification
SimpleBGC_2_6_Serial_Protocol_Specification
specification
Applicable for all 32-bit gimbal controllers
Last updated: Oct 21, 2024
Revision history:
• rev. 0.1 - 24.03.2015: this is first revision
• rev. 0.2 – 27.03.2015: add missed data
• rev. 0.3 – 30.04.2015: add missed data in CMD_READ_PARAMS_EXT
• rev. 0.4 – 01.07.2015: extended CMD_CONTROL; add MENU_CMD_LEVEL_ROLL_PITCH; FRAME_ANGLE_XX replaced
by ROTOR_ANGLE_XX in the CMD_REALTIME_DATA_4; updated CMD_AHRS_HELPER.
• rev. 0.5 – 30.07.2015: extended set PROFILE_FLAGS1, GENERAL_FLAGS1; extended set CMD_EXECUTE_MENU;
deprecated FRAME_CAM_ANGLE_XX.
• rev. 0.6 – 12.08.2015: new mode for CMD_CONTROL; new commands CMD_GET_ANGLES_EXT,
CMD_SET_ADJ_VARS_VAL.
• rev. 0.7 – 22.10.2015: new parameters ORDER_OF_AXES, EULER_ORDER; set of PROFILE_FLAGS1,
GENERAL_FLAGS1 extended; SKIP_GYRO_CALIB options extended.
• rev. 0.8 – 09.11.2015: CMD_AHRS_HELPER is extended.
• rev. 0.9 – 22.12.2015: new command CMD_GYRO_CORRECTION; new adj. var. FRAME_HEADING_ANLGE and
GYRO_HEADING_CORRECTION; extended GENERAL_FLAGS1 and PROFILE_FLAGS1.
• rev. 0.10 – 13.02.2016: updated CMD_AUTO_PID; extended range of NOTCH_GAIN.
• rev. 0.11 – 07.03.2016: new command CMD_READ_PARAMS_EXT2; new parameter MOTOR_MAG_LINK_FINE; new
command CMD_CALIB_MOTOR_MAG_LINK; ACC_LIMITER split to axes; extended form of CMD_HELPER_DATA.
• rev. 0.12 – 02.04.2016: new commands CMD_DATA_STREAM_INTERVAL, CMD_REALTIME_DATA_CUSTOM.
• rev. 0.13 – 05.06.2016: new command CMD_BEEP_SOUND; new adjustment variables.
• rev. 0.14 – 21.06.2016: CMD_ADJ_VARS_STATE described.
• rev. 0.15 – 09.07.2016: extended CMD_READ_PARAMS_EXT2; extended CFG_FLAGS in CMD_AUTO_PID; new command
CMD_CALIB_INFO; corrected CMD_DATA_STREAM_INTERVAL.
• rev. 0.16 – 10.08.2016: added MavLink parameters in CMD_READ_PARAMS_EXT2.
• rev. 0.17 – 21.10.2016: new commands CMD_CONTROL_CONFIG, CMD_CALIB_ORIENT_CORR; extended
CMD_READ_PARAMS_EXT2.
• rev. 0.18 – 23.03.2017: new parameter FRAME_HEADING in CMD_HELPER_DATA; new flag
CONTROL_FLAG_AUTO_TASK in CMD_CONTROL; new command CMD_CALIB_ACC_EXT_REF; document structure is
updated.
• rev. 0.19 – 08.09.2017: add CMD_EVENT; updated CMD_DATA_STREAM_INTERVAL.
• rev. 0.20 – 10.30.2017: updated parameter EXT_FC_GAIN in CMD_READ_PARAMS_3; updated
CMD_READ_PARAMS_EXT2.
• rev. 0.21 – 10.01.2018: new parameters in CMD_READ_PARAMS_EXT2;
• rev. 0.24 – 29.03.2018: updated CMD_EXECUTE_MENU; add AHRS_DEBUG_INFO and MOTOR4_CONTROL data
structures; extended CMD_REALTIME_DATA_CUSTOM; add CMD_EXT_IMU_DEBUG_INFO; add
CMD_READ_PARAMS_EXT3, CMD_WRITE_PARAMS_EXT3;
• rev. 0.25 – 27.11.2018: add protocol V2 specification.
• rev. 0.26 - 21.03.2019: add command CMD_AUTO_PID2.
• rev. 0.27 – 18.09.2019: add command CMD_EXT_IMU_CMD.
• rev. 0.28 – 31.01.2020: extended CMD_READ_PARAMS_EXT3.
• rev. 0.29 – 01.04.2020: add FLAGS description in CMD_RESET; updated CMD_AHRS_HELPER (extended examples section
and described additional flags).
• rev. 0.30 – 10.09.2020: add CMD_READ_STATE_VARS; new flag in CMD_AHRS_HELPER; added Appendix D.
• rev. 0.31 – 10.11.2019: fixed CMD_READ_PARAMS_EXT;
• rev. 0.32 – 11.10.2021: added command description: CMD_CALIB_COGGING, CMD_CAN_DEVICE_SCAN,
CMD_WRITE_PARAMS_SET
• rev. 0.33 - 02.11.2022: added CMD_EXT_SENS_CMD;
• rev. 0.40 – 13.02.2022: document structure was redesigned and added table of contents
• rev. 0.41 – 15.05.2024: added CAN_DRV_TELEMETRY; EXT_MOTORS_xx commands
• rev. 0.42 – 27.05.2024: added CMD_CONTROL_QUAT_x commands; CMD_ADJ_VARS_INFO
© Basecamelectronics® 2024
Overview SimpleBGC32 Serial API protocol specification
Overview
Serial API allows for an external application or device to communicate with the SimpleBGC controller via
serial port (UART). Each controller has several UART ports that can be used to send or receive Serial API
commands. All models are equipped with the USB port that is visible as Virtual Com Port (VCP) for the host
machine. Depending on controller, USB may be dedicated or shared with the one of UARTs.
Commands may be used to retrieve actual system state and realtime data, change settings, control gimbal,
trigger pin state, execute various actions, get access to internal EEPROM and I2C bus, and so on. Moreover,
SimpleBGC GUI software uses the same Serial API protocol to communicate with the board, so all of its
functions may be implemented in third-party applications.
Communications is initiated from the remote side (host) by sending outgoing commands. The controller may
do some action and send response (for the host it is an incoming command).
Board can work on different serial baud rates, adjustable by the parameters, with the 115200 as default
value. Host can automatically find the proper baud rate by sending the CMD_BOARD_INFO command in a
loop, altering the speed ant waiting for a response, until valid response is received, or should allow to specify
a baud rate in its settings.
Additionally, board can auto-detect the "parity" parameter. EVEN and NONE parity are supported (NONE is
selected by default after start, and EVEN is detected automatically). It means that beside the baud rates,
host application should vary the parity setting, when connecting through an intermediate layer that can have
this parameter unknown (like Bluetooth modules). For the direct UART or USB VCP connection, it is enough
to set parity to "NONE".
Throughout capacity
The controller parses incoming command queue each 8ms, so there is no reason to send commands of the
same type with the higher rate. Commands of different type may be sent without delay between them. It is
responsibility of the host application to prevent an overflow of the input and output buffers of the controller
(255 bytes each). If new serial data comes when the input buffer is full, the whole message will be lost. If
controller has to generate an answer that does not fit into the output buffer, it hangs until buffer will have
enough space to accept new data. It may negatively affect the normal operation and even make whole
system unstable. The only exception is the CMD_REALTIME_DATA_xx and several others, that are
considered as non-obligatory for delivery.
You can calculate the safe rates according to the size of incoming and outgoing commands and the
configured baud rate for the serial port. Take into account the bandwidth and the buffering strategy of the
intermediate transmission layer. For example, BLE modules have a very limited bandwidth and small buffers.
Also, almost all radio modems have effective transmission rate less then 100Kbit/s in optimal conditions.
Debugging
You can configure SimpleBGC32 GUI to display all incoming and outgoing commands that it receives/sends.
To do it, run it in a "console" mode using the "run_console.bat" script. Commands will be displayed in the
"Debug" tab in format:
<local_time> <direction>: [<command_id>,<payload_length>] <payload_data_hex>
Note that several commands with high rate are not displayed (like CMD_REALTIME_DATA_xx).
Starting from the firmware and GUI version 2.66b4, it's possible to monitor all serial API messages on all
other ports, by connecting GUI to any available serial port, configured for the SBGC Serial API mode, and
enabling the "Debug" – "Set as debug port" option for it. Controller will forward all incoming and outgoing
Serial API commands from all other ports to this port. Commands will be displayed in the "Debug" tab in
format:
© Basecamelectronics® 2024 2
Overview SimpleBGC32 Serial API protocol specification
In this case, the "in" direction means "to the board", "out" – "from the board".
Note, that only the successfully parsed commands are forwarded. All unknown data is ignored.
Message format
Each command consists of the header and the body, both with checksum. Commands with the wrong header
or body checksum, or with the body size that differs from expected, should be ignored. Parser should scan
incoming datastream for the next start character and try to restore synchronization from it.
Input and output commands have the same format.
Protocol version 1
header body
start command payload header payload payload
character ID, size checksum variable size N checksum
> (0x3E) 0..255 N=0..255
0 1 2 3 4 ... 4+N-1 4+N
header body
0 1 2 3 4 5
0x3E 0x52 0x01 0x53 0x01 0x01
Protocol version 2
Starting from firmware version 2.68b0, firmware additionally supports protocol version 2, that has better error
rejection by replacing the old 8 bit simple checksum (over payload only) to CRC16 checksum (over header +
payload).
Compared to version 1, it has a different start character "$" and a different checksum calculation:
payload checksum is calculated as a CRC16 over the header bytes and payload bytes, starting from index 1
to index 4+N-1. A reference implementation of CRC16 using polynomial 0x8005 is given in the Appendix A.
© Basecamelectronics® 2024 3
Overview SimpleBGC32 Serial API protocol specification
NOTE: order of parameters in arrays is always ROLL,PITCH,YAW, but it doesn't corresponds to the order of Euler angles
used to express a rotation – it is variable and defined by the parameter 'EULER_ORDER'.
© Basecamelectronics® 2024 4
Table of contents SimpleBGC32 Serial API protocol specification
Table of contents
Overview.................................................................................................................................................................................................... 2
Throughout capacity.......................................................................................................................................................................2
Debugging.......................................................................................................................................................................................... 2
Message format................................................................................................................................................................................ 3
Data type notation...........................................................................................................................................................................4
Table of contents.................................................................................................................5
Device information...............................................................................................................9
Requests..................................................................................................................................................................................................... 9
CMD_BOARD_INFO (#86) – request board and firmware information...........................................................................9
CMD_BOARD_INFO_3 (#20) – request additional board information............................................................................9
Responses.................................................................................................................................................................................................. 9
CMD_BOARD_INFO (#86) – version and board information..............................................................................................9
CMD_BOARD_INFO_3 (#20) – additional board information..........................................................................................10
Configuring gimbal.............................................................................................................12
Requests.................................................................................................................................................................................................. 12
CMD_READ_PARAMS (#82), CMD_READ_PARAMS_3 (#21) – request parameters from the board
CMD_READ_PARAMS_EXT (#33) – request extended parameters part1 CMD_READ_PARAMS_EXT2 (#62) –
request extended parameters part2 CMD_READ_PARAMS_EXT3 (#104) – request extended parameters
part3................................................................................................................................................................................................... 12
CMD_WRITE_PARAMS (#87), CMD_WRITE_PARAMS_3 (#22) - write parameters to board and saves to
EEPROM CMD_WRITE_PARAMS_EXT (#34) – write extended parameters part1 CMD_WRITE_PARAMS_EXT2
(#63) – write extended parameters part2 CMD_WRITE_PARAMS_EXT3 (#105) – write extended parameters
part3................................................................................................................................................................................................... 12
CMD_WRITE_PARAMS_SET (#119) – start or end of the writing parameters sequence........................................12
CMD_USE_DEFAULTS (#70) – reset to factory defaults....................................................................................................12
CMD_CALIB_OFFSET (#79)– calibrate follow offset..........................................................................................................13
CMD_READ_PROFILE_NAMES (#28) – Request profile names stored in EEPROM...................................................13
CMD_WRITE_PROFILE_NAMES (#29) – Writes profile names to EEPROM..................................................................13
CMD_PROFILE_SET (#95) – manage profile sets.................................................................................................................13
Responses............................................................................................................................................................................................... 13
CMD_READ_PARAMS_3 (#21) – read/write system configuration part 1....................................................................13
CMD_READ_PARAMS_EXT (#33) – read/write system configuration part 2...............................................................18
CMD_READ_PARAMS_EXT2 (#62) – read/write system configuration part 3............................................................20
CMD_READ_PARAMS_EXT3 (#104) – read/write system configuration part 3.........................................................23
CMD_READ_PROFILE_NAMES (#28) – receive profile names from EEPROM............................................................26
Calibrating.........................................................................................................................27
Requests.................................................................................................................................................................................................. 27
CMD_CALIB_ACC (#65) – calibrate accelerometer CMD_CALIB_GYRO (#103) – calibrate gyroscope
CMD_CALIB_MAG (#59) – calibrate magnetometer...........................................................................................................27
CMD_CALIB_EXT_GAIN (#71) – calibrate EXT_FC gains....................................................................................................27
CMD_CALIB_POLES (#80) – calibrate poles and direction...............................................................................................27
CMD_CALIB_BAT (#66) - calibrate internal voltage sensor..............................................................................................27
CMD_ENCODERS_CALIB_OFFSET_4 (#26) - calibrate offset of encoders....................................................................27
CMD_ENCODERS_CALIB_FLD_OFFSET_4 (#27) - start field offset calibration of encoders..................................28
CMD_CALIB_ORIENT_CORR (#91) – start the calibration of sensor misalignment correction (frw. ver. 2.61+)
............................................................................................................................................................................................................. 28
CMD_CALIB_ACC_EXT_REF (#94) – refine the accelerometer calibration of the main IMU sensor...................28
CMD_CALIB_COGGING (#93) – starts the motor non-linearities calibration.............................................................29
© Basecamelectronics® 2024 5
Table of contents SimpleBGC32 Serial API protocol specification
CMD_SYNC_MOTORS (#123) – mechanically align motors working in parallel for a single axis......................29
Real-time state monitoring and diagnostics.....................................................................31
Requests.................................................................................................................................................................................................. 31
CMD_REALTIME_DATA_CUSTOM (#88) – request configurable realtime data..........................................................31
CMD_REALTIME_DATA (#68), CMD_REALTIME_DATA_3 (#23) – request real-time data, response is
CMD_REALTIME_DATA_3..............................................................................................................................................................31
CMD_REALTIME_DATA_4 (#25) – request extended real-time data, response is CMD_REALTIME_DATA_4....31
CMD_DATA_STREAM_INTERVAL (#85) – register or update data stream – a commands sent by the controller
with the fixed rate without request........................................................................................................................................32
CMD_READ_RC_INPUTS (#100) - read values for the selected RC inputs...................................................................33
CMD_GET_ANGLES (#73), CMD_GET_ANGLES_EXT (#61) - Request information related to IMU angles and
RC control state.............................................................................................................................................................................. 33
CMD_SELECT_IMU_3 (#24) – Select which IMU to calibrate or send realtime data..............................................33
CMD_DEBUG_VARS_INFO_3 (#253) – request information about debug variables................................................33
CMD_DEBUG_VARS_3 (#254) – request values of debug variables..............................................................................34
CMD_CALIB_INFO (#49) – request information required for the "Calibration helper" dialog window.............34
CMD_READ_STATE_VARS (#111)– request reading system persistent state variables, cumulative statistics
and maintenance data................................................................................................................................................................. 34
CMD_WRITE_STATE_VARS (#112) – write system persistent state variables, cumulative statistics and
maintenance data.......................................................................................................................................................................... 34
CMD_SET_DEBUG_PORT (#249) – use this port for debugging.....................................................................................34
CMD_EXT_MOTORS_STATE (#131) – request real-time data for external auxiliary motors................................35
CMD_CONTROL_QUAT_STATUS (#141) – request real-time data related to gimbal control in quaternions.35
Responses............................................................................................................................................................................................... 35
CMD_REALTIME_DATA_CUSTOM (#88) – configurable realtime data..........................................................................35
CMD_REALTIME_DATA_3 (#23) - receive real-time data...................................................................................................38
CMD_REALTIME_DATA_4 (#25) - receive extended version of real-time data...........................................................40
CMD_GET_ANGLES (#73) - Information about actual gimbal control state...............................................................40
CMD_GET_ANGLES_EXT (#61) - Information about angles in different format........................................................41
CMD_DEBUG_VARS_INFO_3 (#253) – receive a specification of the debug variables...........................................41
CMD_DEBUG_VARS_3 (#254) – values of debug variables reflecting a state of the system...............................41
CMD_CALIB_INFO (#49) – receive information required for the "Calibration helper" dialog window..............42
CMD_SCRIPT_DEBUG (#58) – state of execution of user-written script.....................................................................42
CMD_ADJ_VARS_STATE (#46) – receive the state of adjustable variables..................................................................43
CMD_READ_RC_INPUTS (#100) - answer to the requested RC sources.......................................................................43
CMD_READ_STATE_VARS (#111) – result of reading system persistent state variables, cumulative statistics
and maintenance data................................................................................................................................................................. 43
CMD_SET_DEBUG_PORT (#249) – receive serial API commands from all other ports for a debugging..........44
CMD_CAN_DRV_TELEMETRY (#127) – receive CAN_DRV telemetry.............................................................................44
CMD_EXT_MOTORS_STATE (#131) – real-time data related to auxiliary motors....................................................45
CMD_CONTROL_QUAT_STATUS (#141) – real-time data related to gimbal control in quaternions.................46
Run-time gimbal parameters.............................................................................................48
Requests.................................................................................................................................................................................................. 48
CMD_ADJ_VARS_INFO (#132) – Query the list of all available variables (frw. Ver. 2.73.0).....................................48
CMD_SET_ADJ_VARS_VAL (#31) – Update the value of selected parameter(s).........................................................48
CMD_GET_ADJ_VARS_VAL (#64) – Query the actual value of selected parameter(s)..............................................48
CMD_READ_ADJ_VARS_CFG (#43) – request configuration of mapping of control inputs to adjustable
variables............................................................................................................................................................................................49
CMD_WRITE_ADJ_VARS_CFG (#44) – writes configuration of mapping of control inputs to adjustable
variables............................................................................................................................................................................................49
CMD_SAVE_PARAMS_3 (#32) – Saves the current values of parameters linked to adjustable variables in
© Basecamelectronics® 2024 6
Table of contents SimpleBGC32 Serial API protocol specification
EEPROM............................................................................................................................................................................................ 49
CMD_ADJ_VARS_STATE (#46) – request the state of adjustable variable in the given trigger and analog
slots.................................................................................................................................................................................................... 49
Responses............................................................................................................................................................................................... 50
CMD_ADJ_VARS_INFO (#132) – the list of available variables (frw. Ver. 2.73.0)........................................................50
CMD_SET_ADJ_VARS_VAL (#31) – receive the values of adjustable variables..........................................................50
CMD_READ_ADJ_VARS_CFG (#43) – receive the configuration for adjustable variables.......................................50
IMU correction and diagnostic..........................................................................................52
Requests.................................................................................................................................................................................................. 52
CMD_HELPER_DATA (#72) – provide helper data for AHRS system.............................................................................52
CMD_AHRS_HELPER (#56) – send or request attitude of the IMU sensor.................................................................54
CMD_GYRO_CORRECTION (#75) – correct the gyroscope sensor's zero bias manually........................................56
Responses............................................................................................................................................................................................... 56
CMD_AHRS_HELPER (#56) – current attitude in vector form.........................................................................................56
AHRS_DEBUG_INFO - information about the AHRS state................................................................................................56
CMD_EXT_IMU_DEBUG_INFO (#106) – debug information for the external IMU sensor.....................................57
Controlling gimbal movements..........................................................................................58
Requests.................................................................................................................................................................................................. 58
CMD_CONTROL (#67) – controls gimbal movement.........................................................................................................58
CMD_CONTROL_EXT (#121) – controls gimbal movement, extended version.........................................................61
CMD_CONTROL_CONFIG (#90) – configure the handling of CMD_CONTROL command......................................62
CMD_API_VIRT_CH_CONTROL (#45) – update a state of 32 virtual channels..........................................................63
CMD_API_VIRT_CH_HIGH_RES (#116) – update a state of 32 virtual channels.......................................................64
CMD_CONTROL_QUAT (#140) – control gimbal position in quaternions...................................................................64
CMD_CONTROL_QUAT_CONFIG (#142) – configure the quaternion-based control mode...................................65
Controlling extra auxiliary motors....................................................................................67
Requests.................................................................................................................................................................................................. 67
CMD_EXT_MOTORS_ACTION (#128) – execute an action on the selected motor(s)...............................................67
CMD_EXT_MOTORS_CONTROL (#129) – control the selected motor(s)......................................................................67
CMD_EXT_MOTORS_CONTROL_CONFIG (#130) – configure run-time parameters for the selected motor(s)
............................................................................................................................................................................................................. 68
Miscellaneous commands.................................................................................................69
Requests.................................................................................................................................................................................................. 69
CMD_RESET (#114) – reset device...........................................................................................................................................69
CMD_BOOT_MODE_3 (#51) – enter bootloader mode to upload firmware...............................................................69
CMD_TRIGGER_PIN (#84) - trigger output pin.....................................................................................................................69
CMD_MOTORS_ON (#77) - switch motors ON......................................................................................................................70
CMD_MOTORS_OFF (#109) - switch motors OFF................................................................................................................70
CMD_EXECUTE_MENU (#69) - execute menu command..................................................................................................70
CMD_AUTO_PID (#35) – Starts automatic PID calibration..............................................................................................71
CMD_AUTO_PID2 (#108) – Starts automatic PID calibration ver.2...............................................................................72
CMD_SERVO_OUT (#36) – Output PWM signal on the servo1..4 pins.........................................................................73
CMD_SERVO_OUT_EXT (#133) – Output PWM signal on the servo pins (internal and external).......................73
CMD_I2C_WRITE_REG_BUF (#39) – writes data to any device connected to I2C line............................................74
CMD_I2C_READ_REG_BUF (#40) – requests reading from any device connected to I2C line..............................74
CMD_RUN_SCRIPT (#57) – start or stop user-written script...........................................................................................74
CMD_BEEP_SOUND (#89) – play melody by motors or emit standard beep sound................................................74
CMD_SIGN_MESSAGE (#50) – sign message by secret keys............................................................................................75
CMD_EXT_IMU_CMD (#110) – forward message from the controller to the connected external IMU sensor
............................................................................................................................................................................................................. 75
CMD_EXT_SENS_CMD (#150) – forward message to the GPS_IMU sensor................................................................75
© Basecamelectronics® 2024 7
Table of contents SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2024 8
Device information SimpleBGC32 Serial API protocol specification
Device information
Requests
Responses
© Basecamelectronics® 2024 9
Device information SimpleBGC32 Serial API protocol specification
ACC_AUTO_CALIB = (1<<14)
BIG_FLASH = (1<<15) – firmware needs 256Kb of FLASH
CONNECTION_FLAG 1u Bit set:
CONNECTION_USB = 1
FRW_EXTRA_ID 4u Used for specific builds only
SCRIPT_SLOT1_SIZE 2u*5 size of user-written scripts stored in five slots, 0 if slot is empty.
...
SCRIPT_SLOT5_SIZE
PROFILE_SET_SLOTS 1u bit0..bit5: bit is set if the corresponding profile set is not empty.
bit0 for profile set#1, bit2 for profile set#2, bit5 for profile set
backup
IMU_CALIB_INFO 2b
SCRIPT_SLOT6_SIZE 2u*5 size of user-written scripts stored in five additional slots, 0 if slot
... is empty.
SCRIPT_SLOT10_SIZE
HW_FLAGS 2u Bit set for the board hardware configuration:
Bit0: one-wire crypto IC is installed
© Basecamelectronics® 2024 10
Device information SimpleBGC32 Serial API protocol specification
CAN_DRV_MAIN_LIMIT 1u The number of licensed external motor drivers “CAN Driver” for
CAN_DRV_AUX_LIMIT 1u the main stabilization axes and auxiliary motors
(frw. 2.72.3)
ADJ_VARS_TOTAL_NUM 1u A total number of adjustable variables in the system
(frw. 2.73.0)
RESERVED 10b
© Basecamelectronics® 2024 11
Configuring gimbal SimpleBGC32 Serial API protocol specification
Configuring gimbal
Requests
CMD_READ_PARAMS (#82),
CMD_READ_PARAMS_3 (#21) – request parameters from the board
CMD_READ_PARAMS_EXT (#33) – request extended parameters part1
CMD_READ_PARAMS_EXT2 (#62) – request extended parameters part2
CMD_READ_PARAMS_EXT3 (#104) – request extended parameters part3
(frw.ver. 2.66+)
CMD_WRITE_PARAMS (#87),
CMD_WRITE_PARAMS_3 (#22) - write parameters to board and saves to EEPROM
CMD_WRITE_PARAMS_EXT (#34) – write extended parameters part1
CMD_WRITE_PARAMS_EXT2 (#63) – write extended parameters part2
CMD_WRITE_PARAMS_EXT3 (#105) – write extended parameters part3
(frw.ver. 2.66+)
Data structure is the same as for the corresponding CMD_READ_PARAMS_xx incoming command.
On success, confirmation CMD_CONFIRM is sent in response and new values are applied. Some changes
require system to be restarted, so full reset occurs in 1 second after this command, if there are no other
CMD_WRITE_PARAMSxx have came in that time. It's recommended to send these commands in the
“configuration” mode, activated by the CMD_WRITE_PARAMS_SET.
© Basecamelectronics® 2024 12
Configuring gimbal SimpleBGC32 Serial API protocol specification
PROFILE_SET_ACTION_CLEAR = 2
cleat the selected slot
PROFILE_SET_ACTION_LOAD = 3
load configuration from the given slot
RESERVED 8b
Responses
© Basecamelectronics® 2024 13
Configuring gimbal SimpleBGC32 Serial API protocol specification
RC_LPF 1u 0 15 *Range depends on the flag “Extend LPF range” in GUI settings
(255)*
RC_SPEED 1u 0 255
RC_FOLLOW 1u -127 127 ROLL, PITCH: this value specify follow rate for
flight controller.
YAW: if value != 0, “follow motor” mode is
enabled.
GYRO_TRUST 1u 0 255
USE_MODEL 1u 0 1
PWM_FREQ 1u PWM_FREQ_LOW = 0
PWM_FREQ_HIGH = 1
PWM_FREQ_ULTRA_HIGH = 2
SERIAL_SPPED 1u Baud rate for the main UART1 port (where USB normally
connects)
115200 = 0
57600 = 1
38400 = 2
19200 = 3
9600 = 4
256000 = 5
RC_TRIM[3] 1s*3 -127 127
RC_DEADBAND 1u 0 255
RC_EXPO_RATE 1u 0 100
RC_MAP_ROLL 1u*6 Assign input as a signal source. Bits 0..4 for channel number,
© Basecamelectronics® 2024 14
Configuring gimbal SimpleBGC32 Serial API protocol specification
RC_MAP_PITCH bits 5..7 for a type. Value 0 means that input is not assigned.
RC_MAP_YAW
RC_MAP_CMD PWM source
RC_INPUT_ROLL = 1
RC_MAP_FC_ROLL
RC_INPUT_PITCH = 2
RC_MAP_FC_PITCH EXT_FC_INPUT_ROLL = 3
EXT_FC_INPUT_PITCH = 4
RC_INPUT_YAW = 5
Analog source
Channel = 1..3, type = 32 (5th bit is set)
ADC1 = 33
ADC2 = 34
ADC3 = 35
FOLLOW_EXPO_RATE 1u 0 100
FOLLOW_OFFSET[3] 1s*3 -127 127 Starting from frw. ver. 2.70+ replaced by the
FOLLOW_OFFSET_EXT[3]
AXIS_TOP 1s Main IMU and frame IMU orientation:
AXIS_RIGHT 1s X = 1
FRAME_AXIS_TOP 1s Y = 2
1s Z = 3
FRAME_AXIS_RIGHT
-X = -1
-Y = -2
-Z = -3
FRAME_IMU_POS 1u Location of the frame IMU:
FRAME_IMU_DISABLED = 0
FRAME_IMU_BELOW_YAW = 1
FRAME_IMU_ABOVE_YAW = 2
FRAME_IMU_BELOW_YAW_PID_SOURCE = 3
GYRO_DEADBAND 1u 0 255 Units: 0.1 of gyro sensor's units.
GYRO_SENS 1u deprecated
© Basecamelectronics® 2024 15
Configuring gimbal SimpleBGC32 Serial API protocol specification
MENU_BTN_CMD_1
MENU_BTN_CMD_2
MENU_BTN_CMD_3
MENU_BTN_CMD_4
MENU_BTN_CMD_5
MENU_BTN_CMD_LONG
BEEP_BY_MOTORS=128
(if this flag is set, motors emit sound instead of internal buzzer)
FOLLOW_ROLL_MIX_STAR 1u 0 90
T
FOLLOW_ROLL_MIX_RAN 1u 0 90
GE
FRAME_ANGLE_FROM_M 1u 0 1
OTORS
RC_MEMORY[3] 2s*3 -36767 32767 Initial angle that is set at system start-up, in 14bit resolution
© Basecamelectronics® 2024 16
Configuring gimbal SimpleBGC32 Serial API protocol specification
ADAPTIVE_PID_RATE 1u 1 255
ADAPTIVE_PID_RECOVER 1u 0 10
Y_FACTOR
FOLLOW_LPF[3] 1u*3 0 15
© Basecamelectronics® 2024 17
Configuring gimbal SimpleBGC32 Serial API protocol specification
6 DSMX/11ms/11bit
7 DSMX/22ms/10bit
8 DSMX/22ms/11bit
ORDER_OF_AXES 1u Order of hardware axes, counting from a camera:
PITCH_ROLL_YAW = 0
YAW_ROLL_PITCH = 1
ROLL_YAW_PITCH* = 2
ROLL_PITCH_YAW = 3
PITCH_ROLL_YAW = 0
ROLL_PITCH_YAW = 1
LOCAL_ROLL* = 2
ROLL_LOCAL* = 3
YAW_ROLL_PITCH = 4
NOTCH_FREQ[3] 1u*3 0 255 Center frequency, x2 Hz (value 10 means 20Hz), for each axis
R,P,Y
NOTCH_WIDTH[3] 1u*3 0 255 Width of -3dB gain band, Hz, for each axis R,P,Y
© Basecamelectronics® 2024 18
Configuring gimbal SimpleBGC32 Serial API protocol specification
RESERVED 2b
FOLLOW_INSIDE_DEADBA 1u 0 255
ND
MOTOR_GEARING[3] 2u*3 Real number encoded as 8.8 fixed point (1.0f → 256)
BEEPER_VOLUME 1u 0 255
RESERVED 3b
MAG_AXIS_TOP 1s X = 1
MAG_AXIS_RIGHT 1s Y = 2
Z = 3
-X = -1
-Y = -2
-Z = -3
© Basecamelectronics® 2024 19
Configuring gimbal SimpleBGC32 Serial API protocol specification
MAG_TRUST 1u 0 255
MAV_COMP_ID 1u 0 255
MAV_RESERVED 4b
FRAME_CAM_ANGLE_MIN[ 2s*3 Software limits for motor's angles (frw. ver. 2.61+)
3] 2s*3 Units: 1 degree
FRAME_CAM_ANGLE_MAX
[3]
© Basecamelectronics® 2024 20
Configuring gimbal SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2024 21
Configuring gimbal SimpleBGC32 Serial API protocol specification
The following parameters are applied for the firmware ver. 2.66+
STARTUP_ACTION[4] 1u*4 bits 0..6: action, as listed in the
CMD_EXECUTE_MENU.CMD_ID
bit7: if set, menu button should be pressed
STARTUP_ACTION_SRC[2] 1u*8 Signal source, as listed in the RC_MAP_ROLL parameter
[4]
FORCE_POSITION_CFG[3] 1u*3 bits 0..2: snap angle, one of the 0, 45, 90, 180
bits 4..7: flags:
FORCE_POSITION_FLAG_BUTTON_PRESS = (1<<4)
FORCE_POSITION_FLAG_STARTUP = (1<<5)
FORCE_POSITION_FLAG_IGNORE_LIMITS = (1<<6)
FORCE_POSITION_FLAG_FINE_ADJUST = (1<<7)
STEP_SIGNAL_SRC 1u Signal source, as listed in the RC_MAP_ROLL parameter
STEP_SIGNAL_CFG 1u bits 0..2: number of steps, one of the [2, 3, 5, 10, 15,
25, 50, 100]
N=1..6
AUTO_PID_MOMENTUM 1u 0 255
© Basecamelectronics® 2024 22
Configuring gimbal SimpleBGC32 Serial API protocol specification
MAV_CTRL_MODE 1u 0 2 0 – disabled
1 – ROLL and PITCH axes
2 – all axes
RC_SERIAL_SPEED 1u*2 See the SERIAL_SPEED parameter definition
UART2_SPEED
© Basecamelectronics® 2024 23
Configuring gimbal SimpleBGC32 Serial API protocol specification
FRAME_CAM_ANGLE_MIN, FRAME_CAM_ANGLE_MAX
Units: 0.1 degrees
ADC_REPLACE_SRC[3] 1u*3 See RC_MAP_ROLL description for possible values
GLOCK_MID_MOT_POS_C 1u 0 255
ORR_RATE
EXTRA_BTN_CFG[5] 5b Extra buttons connected to controller's pins.
Bits0..4: MCU pin source, see PIN_ID in CMD_TRIGGER_PIN
Bit6: latching mode if set
Bit7: invert action if set
POWER_CTRL_CFG 8b 1u: overcurrent_protection, units: 0.5A
1u: power_on_delay, units: 100ms
1u: power_off_delay, units: 100ms
1u: power_on_limiter, 0..255
4b: reserved
RESERVED 3b
CAN_IMU_EXT_SENS_TYP 1u 0 disabled
E 1 KVH 1725
2 KVH 1750 (ACC 2G)
3 KVH 1750 (ACC 10G)
4 KVH 1750 (ACC 30G)
5 KVH 1775 (ACC 10G)
6 KVH 1775 (ACC 25G)
7 KVH 1760
8 ADXRS453
9 ADIS16460
10 STIM210
11 STIM300
12 SCHA63X
64 Vectornav VN100/200 (UART)
65 Vectornav VN100/200 (SPI)
PROFILE_FLAGS2 2u FOLLOW_PITCH_DISABLED = (1<<0)
LOW_ANGLE_PRIOR_ROLL = (1<<1)
LOW_ANGLE_PRIOR_PITCH = (1<<2)
LOW_ANGLE_PRIOR_YAW = (1<<3)
HEADING_TRIPOD_MODE = (1<<4)
MOT_ROLL_DISABLED = (1<<5)
MOT_PITCH_DISABLED = (1<<6)
MOT_YAW_DISABLED = (1<<7)
RC_OUT_DUTY1 = (1<<8)
RC_OUT_DUTY4 = (1<<11)
DISABLE_FOLLOW_STARTUP = (1<<12)
SERVO_MODE = (1<<13)
RC_EXPO_DEADBAND_SPLIT = (1<<14)
RESERVED 3b
GENERAL_FLAGS3 4u ENC_LUT_EN_ROLL = (1<<0)
ENC_LUT_EN_PITCH = (1<<1)
ENC_LUT_EN_YAW = (1<<2)
MAVLINK_YAW_ABSOLUTE = (1<<3)
EXT_SENS_AS_REFERENCE = (1<<4)
DISABLE_BT = (1<<5)
ALLOW_SENSOR_RECOVERY = (1<<6)
UART2_ALT = (1<<7)
PASS_LIMIT_ROLL = (1<<8)
PASS_LIMIT_YAW = (1<<10)
DONT_PUSH_SOFT_LIMITS_ROLL = (1<<11)
DONT_PUSH_SOFT_LIMITS_PITCH = (1<<12)
DONT_PUSH_SOFT_LIMITS_YAW = (1<<13)
TRIPOD_MODE_AUTO = (1<<14)
TRIPOD_MODE_GYRO_ONLINE_CALIB = (1<<15)
© Basecamelectronics® 2024 24
Configuring gimbal SimpleBGC32 Serial API protocol specification
RETRACTED_POSITION_MOTORS_OFF = (1<<16)
CAN_IMU_THERMOSTAT_ENABLE = (1<<17)
RETRACTED_POSITION_SHORTEST = (1<<18)
RETRACTED_POSITION_RC_CONTROL = (1<<19)
ACC_LIMIT_EXT_RANGE = (1<<20)
FOLLOW_OFFSET_EXT[3] 2s*3 -16384 16384 Frw. ver. 2.70+: replaces old 8-bit FOLLOW_OFFSET[3]
Units: 0,02197265625 degree
MOTOR_STARTUP_DELAY 2u Units: ms
IMU_MODEL_MAIN 1u
IMU_MODEL_FRAME 1u
STAB_THRESHOLD_ANGL 1u*3 15 80
E[3]
EXT_BUZZER_PIN 1u
ENC_LIMIT_RETURN_SPE 1u*3
ED[3]
TRIPOD_MODE_AUTO_TH 1u
RESHOLD
RC_DEADBAND_PITCH 1u If the flag PROFILE_FLAGS2.RC_EXPO_DEADBAND_SPLIT
RC_DEADBAND_YAW 1u is set, use this values for PITCH and YAW axes; otherwise,
RC_EXPO_RATE_PITCH 1u common RC_DEADBAND and RC_EXPO_RATE variables are
RC_EXPO_RATE_YAW 1u used for all axes.
PROFILE_FLAGS3 4u
DEFAULT_PROFILE 1u 0 4
RETRACTED_ANGLE[3] 2s*3
SHAKE_GENERATOR_CFG (size 22 bytes)
AMPLITUDE[3] 1u*3 0 255 Applied in logarithmic scale in order ROLL, TILT, PAN
BASE_FREQ 1u 0 255 base_freq_hz = 0.3 + BASE_FREQ * 0.05
FREQ_RANGE 1u 0 100 freq_range_mult = 1.5 + FREQ_RANGE * 0.1
PAUSE_PERIOD 1u 0 255 pause_period_ms = 500 + PAUSE_PERIOD * 20
PAUSE_BALANCE 1u 0 100
PAUSE_ATTENUATION 1u 0 100
PAUSE_RANDOMNESS 1u 0 100
PAUSE_PHASE_VAR 1u 0 100
RESONANCE_GAIN[3] 1u*3 0 255 resonance_gain_db = RESONANCE_GAIN * 0.2
RESONANCE_FREQ 1u 0 255 resonance_freq_hz = 0.3 + RESONANCE_FREQ * 0.1
FREQ_SHIFT[3] 1s*3 -127 127 Mapped to logarithmic scale 1/3 … 3
RESERVED 5b
EXT_MOTOR_DRV_IDS[7] 1u*7 CAN_DRV ids assigned to auxiliary motors #1..7
ENCODER_CFG_EXT[3] 2u*3 Extra configuration for the main encoders:
bit0..4: resolution + 12
bit5..7: multi-turn (no, 12, 16, 20, 24)
EXT_SENS_PARAMS 16b Parameters for CAN_IMU external sensor. Structure depends
on its type
RESERVED 64b
© Basecamelectronics® 2024 25
Configuring gimbal SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2024 26
Calibrating SimpleBGC32 Serial API protocol specification
Calibrating
Requests
Extended format:
If all parameters are valid, confirmation is sent immediately on reception and in the end of calibration.
Confirmation is sent.
© Basecamelectronics® 2024 27
Calibrating SimpleBGC32 Serial API protocol specification
(frw. ver. 2.68b7+) optional parameter FOR_MOTOR (1u): value 0..2 to calibrate offset only for the given
motor ROLL, PITCH or YAW. Value 255 – for all motors.
Confirmation is sent immediately. After calibration is finished, CMD_READ_PARAMS_EXT2 is sent with new
values in the IMU_ORIENTATION_CORR[3].
Conditions:
• One of the sensor's axis should be aligned to a gravity vector with the 20-degree tolerance
• Existing ACC calibration should be good enough
© Basecamelectronics® 2024 28
Calibrating SimpleBGC32 Serial API protocol specification
1. Rotate gimbal to a leveled position by the CMD_CONTROL and run this command – X,Y-axis offset
will be refined
2. Tilt gimbal 90-degree down and run it again – Z-axis offset and Y-axis scale will be refined.
3. Return gimbal back to leveled position and run it again – Z-axis scale will be refined. This is enough
to have correct ACC readings inside the working range ROLL=0, PITCH = [0..90].
Calibration takes about 0.5 seconds (controller averages multiple data samples to reduce noise).
Confirmation is sent only if all conditions are satisfied.
ITERATIONS_NUM 1u 2 -
RESERVED 9b
Command CMD_CONFIRM is sent in response with the DATA = 1 or 2 on success, 254 on error.
Another command CMD_CONFIRM with the DATA = 255 is sent when calibration finishes.
CMD_SYNC_MOTORS (#123) – mechanically align motors working in parallel for a single axis
(frw. ver. 2.70b9+)
Command CMD_CONFIRM is sent in response immediately and another command CMD_CONFIRM with
the DATA = 1 is sent when the calibration finishes.
© Basecamelectronics® 2024 29
Calibrating SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2024 30
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
CMD_REALTIME_DATA (#68),
CMD_REALTIME_DATA_3 (#23) – request real-time data, response is CMD_REALTIME_DATA_3
No parameters
© Basecamelectronics® 2024 31
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
SYNC_TO_DATA != 0:
Sample rate divider
CMD_REALTIME_DATA_3
CMD_REALTIME_DATA_4
no parameters
CMD_REALTIME_DATA_CUSTOM
• flags – 4u, see command specification.
CMD_AHRS_HELPER
• imu_type – 1u (0 – main IMU, 1 – frame IMU).
CMD_CAN_DRV_TELEMETRY
• flags – 4u, see command specification.
• drv_id – 1u, driver ID, 0..6
CMD_EXT_MOTORS_STATE
• for_motors – 1u
• data_set - 4u
Data types:
© Basecamelectronics® 2024 32
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
If the data stream is successfully registered or updated, the CMD_CONFIRM is sent in answer.
For the command CMD_EVENT, the behavior is different. This message is sent only once when the event is
triggered, so the parameter INTERVAL_MS does not matter and should be set to any non-zero value. But it
is still used for the "continuous" events like EVENT_TYPE_HOLD. The "event_type" parameter can be used
to select which events to report.
Examples:
• Send CMD_REALTIME_DATA_4 with the rate 20Hz:
19 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
• Send CMD_REALTIME_DATA_CUSTOM (IMU angles + RC target angles) with the rate 10Hz:
58 64 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
• Send CMD_EVENT when the mode button is pressed and released (once), and held (at 10Hz):
66 64 00 01 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
In response, CMD_READ_RC_INPUTS is returned with the values for the requested RC sources.
© Basecamelectronics® 2024 33
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
CMD_CALIB_INFO (#49) – request information required for the "Calibration helper" dialog
window
Name Type Min Max Possible values, remarks
IMU_TYPE 1u 1 – main IMU, 2 – frame IMU
RESERVED 11b
© Basecamelectronics® 2024 34
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
8: CMD_HELPER_DATA,
9: CMD_AHRS_HELPER,
10: CMD_GYRO_CORRECTION,
11: CMD_CONTROL,
12: CMD_SET_ADJ_VARS_VAL,
13: CMD_API_VIRT_CH_CONTROL,
14: CMD_API_VIRT_CH_HIGH_RES
RESERVED 11b
Command CMD_CONFIRM is sent in response. All in and out commands from other ports that were passed
the filter, are sent in CMD_SET_DEBUG_PORT incoming command. If there are no enough room in TX buffer,
command will be dropped.
Multiple CMD_EXT_MOTORS_STATE are sent in response (one for each command) for the selected
motors.
Responses
© Basecamelectronics® 2024 35
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
The set of varaibles below depends on requested data, see the CMD_REALTIME_DATA_CUSTOM request specifications
ENCODER_RAW24[3] 3b*3 Encoder raw angles in a high resolution (24bit per full turn), 3
bytes for each encoder in a sequence for ROLL, PITCH, YAW
motors, lower byte first. Total 9 bytes.
(frw. ver. 2.68+)
IMU_ANGLES_RAD[3] 4f*3 -Pi Pi Main IMU Euler angles in radians
(frw. ver. 2.68b7+)
SCRIPT_VARS_FLOAT[10] 4f*10 Script variables in floats
SYSTEM_POWER_STATE (frw. ver. 2.70b6+) WARNING: specification is not final, may be changed in future!
MOT_POWER 2s -10000 10000 Effective power that produces torque, 10000 for 100%
Encoder firmware: sign corresponds to the torque direction
MOT_CURRENT 2u 0 65535 Estimated or measured current consumption per motor
Units: mA
motor =(1..3)
© Basecamelectronics® 2024 36
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
I2C_ERRORS 2u
SERIAL_ERRORS 2u
CAN_ERRORS 2u
© Basecamelectronics® 2024 37
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2024 38
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
ERR_CALIB_ACC (1<<1)
ERR_SET_POWER (1<<2)
ERR_CALIB_POLES (1<<3)
ERR_PROTECTION (1<<4)
ERR_SERIAL (1<<5)
Beside that, extended error contains bits:
ERR_LOW_BAT1 (1<<6)
ERR_LOW_BAT2 (1<<7)
ERR_GUI_VERSION (1<<8)
ERR_MISS_STEPS (1<<9)
ERR_SYSTEM (1<<10)
ERR_EMERGENCY_STOP (1<<11)
SYSTEM_SUB_ERROR 1u See Appendix E: “Emergency stop” error codes
RESERVED 3b
EXT_FC_ROLL 2s 1000 2000 External FC PWM values. May be zero if their inputs are
EXT_FC_PITCH 2s mapped to RC control or command.
IMU_ANGLE[3] 2s*3 -32768 32767 IMU angles in 14-bit resolution per full turn
CUR_IMU 1u Currently selected IMU that provides angles and raw sensor
data
IMU_TYPE_MAIN=1
IMU_TYPE_FRAME=2
CUR_PROFILE 1u 0 4 Currently selected profile
© Basecamelectronics® 2024 39
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
FRAME_CAM_ANGLE[3] 2s*3 Relative angle of joints between two arms of gimbal structure,
measured by encoder (with offset and gearing calibration is
applied), by 2nd IMU or by other algorithms. Value 0 corresponds
to normal position (each arms forms 90 degrees with the next
order arm).
Units: 0,02197265625 degree
RESERVED 1b
BALANCE_ERROR[3] 2s*3 -512 512 Error in balance (0 – perfect balance, 512 - 100% of the motor
power is required to hold a camera)
CURRENT 2u Actual current consumption.
Units: mA
MAG_DATA[3] 2s*3 -1000 1000 Raw data from magnetometer
Units: relative, calibrated for current environment to give ±1000
for each axis.
IMU_TEMPERATURE 1s -127 127 Temperature of IMU sensors.
FRAME_IMU_TEMPERATU 1s Units: Celsius
RE
IMU_G_ERR 1u 0 255 Error between estimated gravity vector and reference vector for
currently active IMU
Units: 0.1 degree
IMU_H_ERR 1u 0 255 Error between estimated heading vector and reference vector
for currently active IMU
Units: 0.1 degree
MOTOR_OUT[3] 2s*3 -10000 10000 Motor effective output, proportional to torque. Max. value of
±10000 equals to applying full power.
(encoder firmware ver. 2.61+)
CALIB_MODE 1u 0 See CMD_REALTIME_DATA_CUSTOM.SYSTEM_STATE.CALIB_MODE
CAN_IMU_EXT_SENS_ERR 1u Error code from the external sensor connected to the CAN_IMU
(codes are specific to sensors).
ACTUAL_ANGLE[3] 2s*3 Frw.ver. 2.72b0+
Depending on the current stabilization mode:
- for inertial angles it's the same as IMU_ANGLE[3]
- for motor-related modes (“Servo mode”, mixed inertial + motor
having (M) notation), it encodes the motor angle
SYSTEM_STATE_FLAGS 4u See CMD_REALTIME_DATA_CUSTOM.SYSTEM_STATE.FLAGS
(frw. ver. 2.73.0)
RESERVED 18b
© Basecamelectronics® 2024 40
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
TARGET_SPEED 2s Target speed that gimbal should keep, over Euler axes
Units: 0,1220740379 degree/sec
VAR_TYPE_UINT8 = 1
VAR_TYPE_INT8 = 2
VAR_TYPE_UINT16 = 3
VAR_TYPE_INT16 = 4
VAR_TYPE_UINT32 = 5
VAR_TYPE_INT32 = 6
VAR_TYPE_FLOAT = 7 (IEEE-754)
4..7bits - flags:
VAR_FLAG_ROLL = 16 its belong to ROLL axis
VAR_FLAG_PITCH = 32 its belong to PITCH axis
VAR_FLAG_YAW = 48 its belong to YAW axis
VAR_FLAG_ANGLE14 = 64 its an angle (14bit per turn)
RESERVED 2b
© Basecamelectronics® 2024 41
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
CMD_CALIB_INFO (#49) – receive information required for the "Calibration helper" dialog
window.
Name Type Min Max Possible values, remarks
PROGRESS 1u 0 100 Progress of operation in percents
IMU_TYPE 1u 1 – main IMU, 2 – frame IMU
ACC_DATA[3] 2s*3 Data from the accelerometer sensor with the calibrations
applied, expressed in END coordinate system, sign is inverted.
Units: 1/512 G
GYRO_ABS_VAL 2u Amplitude of gyro signal
ACC_CUR_AXIS 1u 0 2 ACC axis to be calibrated
ACC_LIMITS_INFO 1u Bit set of calibrated limits, where bits 0...5 corresponds to the
index in array [+X,-X,+Y,-Y,+Z,-Z]
IMU_TEMP_CELS 1s -127 127 IMU temperature, Celsius
TEMP_CALIB_GYRO_ENAB 1u 0 1 Set to 1 if gyro temperature calibration is enabled
LED
© Basecamelectronics® 2024 42
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
TRIGGER_ACTION 1u 0 255 ID of the triggered action. The full set of actions is given in the
specification of MENU_BTN_CMD_1..5 parameters
ANALOG_RC_DATA 2s -500 500 RC signal for the "analog" variable slot
RESERVED 6b
TRIGGER_ACTION 1u 0 255 ID of the triggered action. The full set of actions is given in the
specification of MENU_BTN_CMD_1..5 parameters
ANALOG_SRC_VALUE 2s -16384 16384 Signal value requested in the ANALOG_SRC_ID
LUT_SRC_VALUE 2s -16384 16384 Signal value requested in the LUT_SRC_ID. Always encoded in
a range -16384..16384.
LUT_VAR_VALUE 4f Current value of variable requested in the LUT_VAR_ID
© Basecamelectronics® 2024 43
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
CMD_SET_DEBUG_PORT (#249) – receive serial API commands from all other ports for a
debugging
This is for debug mode initiated by the CMD_SET_DEBUG_PORT outgoing command.
The DATA field of this command depends on the 'flags' parameter of the request, where bits 0..31 defines the
variables to be sent in response:
© Basecamelectronics® 2024 44
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
3 TEMP_MOTOR 1s Units: °C
4 AVG_CURRENT 2u Units: mA
5 BUS_VOLTAGE 2u Units: mV
6 PIN_STATE 1u State for some digital inputs, each bit is 0|1 for low/high state
(see bits definition below)
7 PHASE_CURRENT[3] 2s*3 Units: mA
8 ENCODER_ERROR_CNT 2u
9 IQ_CURRENT 2s Iq is effective current (providing torque)
ID_CURRENT 2s Units: mA
10 MOTOR_SPEED 2s Units: RPM
11 PID_POS_ERR 2s
12 PID_SPEED_ERR 2s
13 IQ_REF 2s Commanded torque, ±32768 corresponds to ±100%
14 PID_CURRENT_ERR 2s
PIN_STATE bits:
Bit Pin
0 LIMIT
1 INDEX
2 EMERGENCY
3 AUX1
4 AUX2
5 AUX3
6 HALF_BRIDGE_ENABLE
7 ENCODER_SPI_CS
The DATA field of this command depends on the 'DATA_SET' parameter of the request, where bits 0..31
defines the variables to be included in response:
© Basecamelectronics® 2024 45
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
TODO:
• error flags
12 MAX_SPEED 2u Units equal to corresponding variables in the command
CMD_EXT_MOTORS_CONFIGURE
13 MAX_ACCELERATION 2u
14 JERK_SLOPE 2u
15 MAX_TORQUE 2u
16 CURRENT 2u Units: mA
17 BATTERY_VOLTAGE 2u Units: mV
18 MOTOR_TEMPERATURE 1s Units: °C
19 DRIVER_TEMPERATURE 1s Units: °C
© Basecamelectronics® 2024 46
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
ATTITUDE in a form of unit quaternion [w, x, y, z] and SPEED in a form of rotation vector [x, y, z] with
units 0,06103701895 degree/sec, both in END coordinate system (see Coordinate system conversions)
© Basecamelectronics® 2024 47
Run-time gimbal parameters SimpleBGC32 Serial API protocol specification
CMD_ADJ_VARS_INFO (#132) – Query the list of all available variables (frw. Ver. 2.73.0)
This command requests a full list of all available variables with its names and actual values.
On success, CMD_ADJ_VARS_INFO is sent in response.
© Basecamelectronics® 2024 48
Run-time gimbal parameters SimpleBGC32 Serial API protocol specification
for N = (1..NUM_PARAMS)
CMD_ADJ_VARS_STATE (#46) – request the state of adjustable variable in the given trigger
and analog slots.
Firmware ver. prior to 2.62b5:
Name Type Min Max Possible values, remarks
TRIGGER_SLOT 1u 0 9
ANALOG_SLOT 1u 0 14
© Basecamelectronics® 2024 49
Run-time gimbal parameters SimpleBGC32 Serial API protocol specification
Responses
* NOTE: depending on the firmware version, some variables may be not supported, resulting a gap in the IDs
distribution.
© Basecamelectronics® 2024 50
Run-time gimbal parameters SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2024 51
IMU correction and diagnostic SimpleBGC32 Serial API protocol specification
COORD_SYS_GROUND = 2
END Global system: X-axis matches true East ,Y-axis matches
true North, Z-axis matches nadir.
Notes: END system differs from commonly used NED system.
To convert, swap X and Y values in vectors.
A magnetometer sensor should be installed and calibrated to
give global reference for the main IMU. If no magnetometer
present, Y-axis points arbitrary direction, so it is required to
additionally provide the FRAME_HEADING parameter and use
encoders to allow synchronization of the local coordinate
system to earth-related system.
© Basecamelectronics® 2024 52
IMU correction and diagnostic SimpleBGC32 Serial API protocol specification
COORD_SYS_FRAME = 3
Coordinate system linked to the gimbal's outer frame: Y-axis
matches frame's "forward", X-axis matches frame's "right", Z-
axis matches frame's "down". For example, having an
accelerometer-measured vector acc_raw in NED system in
units m/s/s, compensate it for the gravity acc = acc_raw –
acc_1g and convert it the following way:
FRAME_ACC[0] = -acc.y*52.19164
FRAME_ACC[1] = -acc.x*52.19164
FRAME_ACC[2] = -acc.z*52.19164
Remarks:
*bit7 in the FLAGS parameter should be set to use this value.
*Provided angle may be wrapped to +-180 degrees or 0..360
degrees.
*Special value of 32767 stops the use of this reference and
makes IMU heading unreferenced.
*”Heading angle” is YAW angle expressed in Euler order PITCH-
ROLL-YAW. Starting from firmware 2.70b7+, the FLAGS : bit6
can change it to “ROLL-PITCH-YAW”.
* This correction has a priority compared to the correction
received from the external IMU, if it's connected.
For the lateral acceleration compensation, it is enough to provide only the FRAME_ACC data, leaving all
other fields empty. Feed fresh ACC and angles data with the pretty low rate 10-20 Hz, because strong low-
pass filter is applied internally. If the FRAME_SPEED data need to be provided, data rate should be much
higher, up to 125 Hz.
© Basecamelectronics® 2024 53
IMU correction and diagnostic SimpleBGC32 Serial API protocol specification
How to ensure that the ACC correction is applied properly, on the bench:
1. Temporarily set the "ACC LPF" filter parameter in the GUI to 5-10Hz – it will remove noise but keep
fast reaction of the "IMU_G_ERR" variable in the "Monitoring" tab of the GUI. This variable shows
the distance between the estimated gravity vector and vector, measured by accelerometer.
2. Without motion, when you tilt the frame, the FRAME_ACC vector should have all components close
to zero. The IMU_G_ERR variable should be near zero, too.
3. Without correction, when you shake gimbal, you see that the IMU_G_ERR changes significantly.
With the correction applied, when you shake gimbal, IMU_G_ERR always stays near zero - it means
that the external accelerations are compensated.
4. When you rotate frame relative to earth in all directions, or rotate camera relative to frame, the 3rd
test is still passed correctly – it means that the ACC correction vector is translated to the main IMU
sensor properly.
REMARKS ON FLAGS
© Basecamelectronics® 2024 54
IMU correction and diagnostic SimpleBGC32 Serial API protocol specification
Bit3 is taken into account only if all motor angles are known
from encoders or may be estimated using other ways. Bit 3
should be set if reference IMU is located on the frame and you
need to correct main IMU located on the stabilized platform.
Bits 8,9 may be useful if system has the frame IMU enabled and
the source of a reference attitude is located in a different
position. For example, if the frame IMU is “below outer motor”
but the external IMU is mounted on the gimbal's frame, before
applying the correction we convert it to the coordinate system,
linked to the frame IMU.
GET MODES
SET MODES
* Note that we use system END that differs from commonly used NED. See Appendix D: Coordinate system conversions
** MODE may be 1u or 2u for the extended flags supported starting from frw. ver. 2.69b5
© Basecamelectronics® 2024 55
IMU correction and diagnostic SimpleBGC32 Serial API protocol specification
Responses
• Note that we use system END that differs from commonly used NED. See Appendix D: Coordinate system
conversions
•
REF_NO = 0 - no reference
REF_INTERNAL = 1 - reference is provided by the internal
sensor like accelerometer or magnetometer
REF_EXTERNAL = 2 - reference is set externally by the serial
API or external IMU
REF_TRANSLATE = 3 - translate reference from other IMU
(frame -> main, main -> frame)
© Basecamelectronics® 2024 56
IMU correction and diagnostic SimpleBGC32 Serial API protocol specification
EXT_IMU_PARSE_ERR_CN 2u 0 65535
T
DCM 9*4f -1.0f 1.0f Rotation matrix (DCM) received from the external IMU and
converted to the (END) (East-North-Down) coordinates.
ACC_BODY 3*4f Linear acceleration (with the gravity vector subtracted) in
sensor's local coordinates.
© Basecamelectronics® 2024 57
Controlling gimbal movements SimpleBGC32 Serial API protocol specification
Modes:
MODE_NO_CONTROL=0
Finish serial control and restore normal RC control.
MODE_IGNORE=7 (frw.ver.2.70b4)
Ignore this axis and all parameters, keeping it in the
actual state
MODE_SPEED=1
Gimbal travels with the given speed in the Euler
coordinates until the next CMD_CONTROL command
comes. Given angle is ignored.
MODE_ANGLE=2
MODE_ANGLE_SHORTEST=8 (frw.ver.2.70b7)
Gimbal travels to the given Euler angle with the
automatically calculated speed according to the
acceleration limit. The nominal speed may be provided
by the SPEED parameter. Speed is additionally
attenuated near target to keep the control smooth (if
CONTROL_FLAG_TARGET_PRECISE is not set).
• MODE_ANGLE: gimbal travels to the new absolute
setpoint angle, making multiple turns if needed,
but limiting a rotation by ±720° per command
due to limited 16bit parameter range.
• MODE_ANGLE_SHORTEST: gimbal travels to the point
on a 360° circle by the shortest path, taking into
account the software limits of encoders when
choosing a direction (so it can go by the long
path if the short path is blocked)
MODE_SPEED_ANGLE=3
Gimbal travels with the given SPEED parameter.
Additionally, controller keeps the given angle and fixes
the accumulated error by adjusting the actual speed in
a direction of error minimization, defined by the “Outer
P” GUI parameter. This error may appear because the
estimated target angle (integral of SPEED by dt) may
differ from the actual target angle, because the actual
target speed is internally filtered by LPF and
acceleration limit, if they are enabled. This mode
should be chosen when it's required to exactly repeat
the rotation of the user-operated device (like joystick or
wheel), precisely tracking its speed and angle.
MODE_RC=4
The ANGLE parameter is used as RC signal and
overrides any other signal source, assigned to this
© Basecamelectronics® 2024 58
Controlling gimbal movements SimpleBGC32 Serial API protocol specification
MODE_ANGLE_REL_FRAME=5
First, the neutral point of a camera relative to a frame is
found in the Euler coordinates for a given axis. Than,
the given angle (in ±360° range) is added to this point,
and camera travels to it. Note that the given angle does
not relate to a particular motor, it relates to global Euler
angles!
Flags:
CONTROL_FLAG_AUTO_TASK=(1<<6)
Firmware version: 2.62b7
Applicable for: MODE_ANGLE, MODE_ANGLE_SHORTEST,
MODE_ANGLE_REL_FRAME
The task is processed with the speed and acceleration
configured for automated tasks. If the SPEED parameter
is provided, it's used instead. When all target angles
are reached with the 1-degree tolerance, confirmation
is sent: CMD_CONFIRM(CMD_CONTROL, 1).
Use this flag to move gimbal to a certain position as
fast as possible, and receive confirmation when the
target is reached. If system can't process the planned
trajectory for some reasons, motion will be interrupted
after 10-second timeout.
CONTROL_FLAG_FORCE_RC_SPEED=(1<<6)
Firmware version: 2.62b7
Applicable for: MODE_RC
This flag forces a control in the "SPEED" mode, with
the dead-band, trimming and inversion settings are
NOT applied to the provided RC signal, but the LPF,
Expo curve and ACC limiter are still applied. Use this
flag to control gimbal from remote applications, where
signal is well-defined and you need to have a direction
of rotation that does not depend on gimbal's "Inverse"
and "Mode" parameters.
CONTROL_FLAG_HIGH_RES_SPEED=(1<<7)
Firmware version: 2.60b0
Applicable for: all modes
Speed units changed to 0.001 deg/sec for extremely
slow motion (like timelapse shooting)
CONTROL_FLAG_TARGET_PRECISE=(1<<5)
Firmware version: 2.70b1
Applicable for: MODE_ANGLE, MODE_ANGLE_SHORTEST,
MODE_ANGLE_REL_FRAME
If this flag is set, the speed is not decreased in a
vicinity of target. It allows to get more predictive speed
profile for the motion trajectory. If not set, actual speed
is decreased near target to smooth over the jerks when
© Basecamelectronics® 2024 59
Controlling gimbal movements SimpleBGC32 Serial API protocol specification
CONTROL_FLAG_MIX_FOLLOW=(1<<4)
Firmware version: 2.70b5
Applicable for: MODE_SPEED, MODE_ANGLE,
MODE_ANGLE_SHORTEST
If this flag is set, the follow mode is not overridden, but
is mixed with the commanded motion, like it happens
for the regular RC control in SPEED or ANGLE mode.
If this flag is not set, the commanded motion
completely overrides the follow control for this axis.
Extended format (firmware ver. 2.55b5+): mode is set independently for each axes
CONTROL_MODE[3] 1u*3 see definition above
MODE_SPEED, MODE_SPEED_ANGLE:
• the values is signed (negative for opposite direction)
© Basecamelectronics® 2024 60
Controlling gimbal movements SimpleBGC32 Serial API protocol specification
separately for SPEED and ANGLE parameters, with the rule: the lower the rate, the more filtering is required.
• Automated tasks has greater priority then CMD_CONTROL. For example, executing menu command "Level
ROLL to horizon" overrides CMD_CONTROL for ROLL axis until task is finished.
• The ANGLE rage is limited by ±720°. It's possible to get rid of this limitation by sending multiple commands in
a sequence: when gimbal approaches the current setpoint, send a new setpoint with the ANGLE computed
using natural C++ integer arithmetics with wrap-around overflow. Example: to make 3 full turns (1080°) the first
command sends axis to 720° (ANGLE=32767) and the second command sends it to 1080° (ANGLE=-16384,
which is computed as 32767+16384 in int16_t variable).
Starting from firmware 2.70b8, it's possible to send several commands in sequence immediately one after
another (the only condition is that the distance between two setpoints does not exceed 720° or 32768), or use
CMD_CONTROL_EXT were 20bit ANGLE parameter does not have such limitation and allows to command a
rotation up to 4096 full turns in a single command.
• The ANGLE parameter doesn't always match the TARGET_ANGLE variable (reported in CMD_ANGLES,
CMD_REALTIME_DATA and others), which means “the setpoint angle that gimbal should keep right now”.
Only after the motion sequence is finished, they match (excepting cases when CONTROL_MODE and flags
change the resulting setpoint before the motion starts, like “travel shortest distance” or “mix with the follow
mode”).
• This command is developing permanently: new modes and flags are added and behavior is improved, so old
firmware versions may handle this mode differently then described in this document.
© Basecamelectronics® 2024 61
Controlling gimbal movements SimpleBGC32 Serial API protocol specification
ANGLE_LPF 1u 0 15 LPF factor for filtering the 'ANGLE' parameter in the modes
"MODE_ANGLE", "MODE_SPEED_ANGLE". Helps to mitigate
a step-wise response if update rate is low.
© Basecamelectronics® 2024 62
Controlling gimbal movements SimpleBGC32 Serial API protocol specification
0 – do not change.
ACC_LIMIT 1) 2u 0 65535 Acceleration limiter filter, applied to speed profile in all control
(frw.ver. 2.70b1) modes.
0 – do not change
>0 – it overrides the default value from system settings.
Units: degrees/sec2
JERK_SLOPE 1) 1u 0 255 The rate of change of an acceleration, forming S-curve in a
(frw.ver. 2.70b8+) speed profile, increasing the smoothness of control. This
parameter defines the time required to rise the acceleration
from zero to a nominal value.
Special values:
0 – ignore this parameter
1 – disable jerk slope function
Units: 20ms
RESERVED 1b
FLAG_SERVO_MODE_ENABLE=(1<<1)
FLAG_SERVO_MODE_DISABLE=(1<<2)
(frw.ver. 2.72b0)
Enable or disable servo mode – in which the commanded
rotation is done around the motors' axes rather than the Euler
axes; ANGLE is relative to the calibrated neutral point for each
motor.
EULER_ORDER 1) 1u 0: don't change
(frw.ver. 2.72b0) 1: Cam - PITCH - ROLL - YAW
2: Cam - ROLL - PITCH - YAW
3: Cam - PITCH(M) - ROLL – YAW(M)
4: Cam - ROLL - PITCH(M) - YAW(M)
5: Cam - YAW - ROLL – PITCH
10: Screen-related X,Y,Z
RESERVED 9b
All changes in these parameters valid only while serial control is active. When serial control finishes, the
1)
© Basecamelectronics® 2024 63
Controlling gimbal movements SimpleBGC32 Serial API protocol specification
RC inputs)
* Starting from firmware 2.70b5, any number of channels (1..31) may be provided, to save bandwidth by
omitting the unused channels.
* Any number of channels (1..31) may be provided, to save bandwidth by omitting the unused channels.
MODE_SPEED = 1
Gimbal rotates with the TARGET_SPEED. The
TARGET_ATTITUDE is ignored and should be omitted.
No motion profile is applied in this mode, excepting the
low-pass filtering, if enabled in
CMD_CONTROL_QUAT_CONFIG
MODE_ATTITUDE = 2
Gimbal moves to the TARGET_ATTITUDE with the
configured speed profile. TARGET_SPEED is ignored
and should be omitted.
MODE_SPEED_ATTITUDE = 5
Gimbal rotates with the TARGET_SPEED and if the
actual position differs from the provided
TARGET_ATTITUDE, it’s corrected in order to match.
MODE_SPEED_LIMITED = 9
The same as MODE_SPEED but the motion profile
(acceleration limit) is applied
FLAGS 1u FLAG_CONFIRM = (1<<0)
If set, CMD_CONFIRM is sent in response.
FLAG_ATTITUDE_PACKED = (1<<1)
If set, TARGET_ATTITUDE is packed to 8 bytes (see
Appendix F for format description)
FLAG_ATTITUDE_LIMITED_180 = (1<<2)
If set, TARGET_ATTITUDE is considered to be limited
by ±180° and a ‘phase unwrap’ filter is applied by
comparing the new value to the previous value and
© Basecamelectronics® 2024 64
Controlling gimbal movements SimpleBGC32 Serial API protocol specification
FLAG_AUTO_TASK=(1<<6)
Applicable for: MODE_ATTITUDE
(TO BE IMPLEMENTED LATER)
The task is processed with the speed and acceleration
configured for automated tasks. When the target
attitude is reached with the 1-degree tolerance,
confirmation is sent:
CMD_CONFIRM(CMD_CONTROL_QUAT, 1),then gimbal
switches to a normal operation mode.
Use this flag to move gimbal to a certain position as
fast as possible, and receive confirmation when the
target is reached. If system can't process the planned
trajectory for some reasons, motion will be interrupted
after 10-second timeout.
TARGET_ATTITUDE[4]* 4f*4 Target attitude in a form of unit quaternion [w, x, y, z]
Units: rad/sec.
NOTE: Rotation vector and quaternion are in END coordinate system. See Coordinate system conversions.
No confirmation is sent unless FLAG_CONFIRM is set. In case of wrong format or wrong gimbal state,
CMD_ERROR is sent in response.
In order to query the real-time state related to this type of control, use CMD_CONTROL_QUAT_STATUS (#141)
bit0: MAX_SPEED[3]
bit1: ACC_LIMIT[3]
bit2: JERK_SLOPE[3]
bit3: FLAGS
bit4: ATTITUDE_LPF_FREQ
bti5: SPEED_LPF_FREQ
MAX_SPEED[3] 2u*3 Motion profile max. speed limit for [X,Y,Z] axes.
Units: degrees/sec2
Default value is taken form RC settings
JERK_SLOPE[3] 2u*3 The rate of change of an acceleration for [X,Y,Z] axes.
This parameter defines the time required to rise the acceleration
© Basecamelectronics® 2024 65
Controlling gimbal movements SimpleBGC32 Serial API protocol specification
Units: ms
Default value is taken form RC settings
FLAGS 2u FLAG_MOTION_PROFILE_SPLIT_XYZ = (1<<0)
Applicable for: MODE_ATTITUDE,
MODE_SPEED_LIMITED,
Default value: disabled
If set, the motion profile is applied separately for X,Y,Z
axes according to the acceleration limit settings for
ROLL (Y), PITCH (X), YAW (Z) axes.
If not set, the motion profile is applied to the speed
along the shortest path trajectory. Configuration is
taken from the X axis (PITCH in Euler settings)
Units: 1Hz
Default value: disabled
© Basecamelectronics® 2024 66
Controlling extra auxiliary motors SimpleBGC32 Serial API protocol specification
Requests
MOTOR_OFF_BRAKE = 2
turn off and brake (default)
MOTOR_OFF_SAFE = 3
compensate for external force to slow down the
rotation, then turn off with brake
MOTOR_ON = 4
turn on
HOME_POSITION = 5
move to home position
SEARCH_HOME = 6
search home period for multiturn or geared motors
ARGS ? Reserved. Optional arguments, depending on action.
SETPOINT16 2s Torque mode: ±32767 for the maximum torque the driver can
provide
© Basecamelectronics® 2024 67
Controlling extra auxiliary motors SimpleBGC32 Serial API protocol specification
Motor = (1..7)
In order to query the extra motor real-time state, use CMD_EXT_MOTORS_STATE (#131)
© Basecamelectronics® 2024 68
Miscellaneous commands SimpleBGC32 Serial API protocol specification
Miscellaneous commands
Requests
Extended format:
Extended format:
Note: don’t send any Serial API messages to the port after this command is issued, as it can confuse the
bootloader and it’s ability to communicate further using the STM32 boot protocol.
RC_INPUT_ROLL = 1
RC_INPUT_PITCH = 2
EXT_FC_INPUT_ROLL = 3
EXT_FC_INPUT_PITCH = 4
RC_INPUT_YAW = 5
PIN_AUX1 = 16
PIN_AUX2 = 17
© Basecamelectronics® 2024 69
Miscellaneous commands SimpleBGC32 Serial API protocol specification
PIN_AUX3 = 18
PIN_BUZZER = 32
PIN_SSAT_POWER** = 33
Confirmation is sent only if pin is not occupied for other functions and was really triggered.
© Basecamelectronics® 2024 70
Miscellaneous commands SimpleBGC32 Serial API protocol specification
MENU_CMD_BUTTON_PRESS = 22
MENU_CMD_RUN_SCRIPT1 = 23
MENU_CMD_RUN_SCRIPT2 = 24
MENU_CMD_RUN_SCRIPT3 = 25
MENU_CMD_RUN_SCRIPT4 = 26
MENU_CMD_RUN_SCRIPT5 = 27
MENU_CMD_CALIB_MAG = 33
MENU_CMD_LEVEL_ROLL_PITCH = 34
MENU_CMD_CENTER_YAW = 35
MENU_CMD_UNTWIST_CABLES = 36
MENU_CMD_SET_ANGLE_NO_SAVE = 37
MENU_HOME_POSITION_SHORTEST = 38
MENU_CENTER_YAW_SHORTEST = 39
MENU_ROTATE_YAW_180 = 40
MENU_ROTATE_YAW_180_FRAME_REL = 41
MENU_SWITCH_YAW_180_FRAME_REL = 42
MENU_SWITCH_POS_ROLL_90 = 43
MENU_START_TIMELAPSE = 44
MENU_CALIB_MOMENTUM = 45
MENU_LEVEL_ROLL = 46
MENU_REPEAT_TIMELAPSE = 47
MENU_LOAD_PROFILE_SET1 = 48
MENU_LOAD_PROFILE_SET2 = 49
MENU_LOAD_PROFILE_SET3 = 50
MENU_LOAD_PROFILE_SET4 = 51
MENU_LOAD_PROFILE_SET5 = 52
MENU_LOAD_PROFILE_SET_BACKUP = 53
MENU_INVERT_RC_ROLL = 54
MENU_INVERT_RC_PITCH = 55
MENU_INVERT_RC_YAW = 56
MENU_SNAP_TO_FIXED_POSITION = 57
MENU_CAMERA_REC_PHOTO_EVENT = 58
MENU_CAMERA_PHOTO_EVENT = 59
MENU_MOTORS_SAFE_STOP = 60
MENU_CALIB_ACC_AUTO = 61
MENU_RESET_IMU = 62
MENU_FORCED_FOLLOW_TOGGLE = 63
MENU_AUTO_PID_GAIN_ONLY = 64
MENU_LEVEL_PITCH = 65
MENU_MOTORS_SAFE_TOGGLE 66
MENU_TIMELAPSE_STEP1 67
MENU_EXT_GYRO_ONLINE_CALIB 68
MENU_DISABLE_FOLLOW_TOGGLE 69
MENU_SET_CUR_POS_AS_HOME 70
MENU_STOP_SCRIPT 71
MENU_TRIPOD_MODE_OFF 72
MENU_TRIPOD_MODE_ON 73
MENU_SET_RC_TRIM 74
MENU_HOME_POSITION_MOTORS 75
MENU_RETRACTED_POSITION 76
MENU_SHAKE_GENERATOR_OFF 77
MENU_SHAKE_GENERATOR_ON 78
© Basecamelectronics® 2024 71
Miscellaneous commands SimpleBGC32 Serial API protocol specification
CFG_FLAGS 1u AUTO_PID_CFG_ROLL = 1
AUTO_PID_CFG_PITCH = 2
AUTO_PID_CFG_YAW = 4
AUTO_PID_CFG_SEND_GUI = 8
- if set, sends a progress of tuning to the GUI in the
CMD_AUTO_PID after each iteration
AUTO_PID_CFG_KEEP_CURRENT = 16
- if set, starts from existing settings. If not set, starts
from zero
AUTO_PID_CFG_TUNE_LPF_FREQ = 32
- if set, tunes LPF filters, too
AUTO_PID_CFG_ALL_PROFILES = 64
- if set, updates tuned parameters in all profiles.
Otherwise, updates only the selected profile.
GAIN_VS_STABILITY 1u 0 255 0 - better stability,
255 - better tracking of a reference
MOMENTUM 1u 0 255 0 - detect automatically,
1 - low weight and strong motor,
255 - big weight and weak motor
ACTION 1u 0 – start tuning
RESERVED 14b
CFG_VERSION 1u Version = 1
AXIS_FLAGS 1u bit0: this axis is enabled
bit1: tune LPF
bits2..3: number of notch filters to tune, 0-3
for axis = (1..3)
© Basecamelectronics® 2024 72
Miscellaneous commands SimpleBGC32 Serial API protocol specification
When finished, the controller writes new values to EEPROM and sends new configuration to this port (series
of CMD_READ_PARAMS_XX for the current profile).
frw.ver 2.70b8+:
in a special PWM duty cycle output mode, value 1000
corresponds to 0% duty cycle, value 2000 to 100% duty cycle.
RESERVED 8b
CMD_SERVO_OUT_EXT (#133) – Output PWM signal on the servo pins (internal and external)
(Frw.ver. 2.73.2)
© Basecamelectronics® 2024 73
Miscellaneous commands SimpleBGC32 Serial API protocol specification
CMD_I2C_READ_REG_BUF (#40) – requests reading from any device connected to I2C line
Name Type Min Max Possible values, remarks
DEVICE_ADDR 1u bit0: I2C port
0 for external I2C port
1 for internal I2C port (where on-board I2C devices are
connected)
* for example, to read from ICM-20602 on address 0x68 from 'who am I' register, payload is “D0 75 01”
© Basecamelectronics® 2024 74
Miscellaneous commands SimpleBGC32 Serial API protocol specification
BEEPER_MODE_INTRO = (1<<6)
Custom melody:
BEEPER_MODE_CUSTOM_MELODY = (1<<15)
NOTE_LENGTH 1u 1 255 The duration of each note in custom melody mode.
Units: 8ms samples
DECAY_FACTOR 1u 0 15 Set the envelope "attack-decay" after each pause,that makes
sound more natural. The bigger value, the longer decay. 0 - no
decay.
*Note: envelope takes effect only in the encoder-enabled
firmware or when motors are OFF. The same is true for the
'volume' parameter in the GUI.
RESERVED 8b
NOTE_FREQ_HZ[N] 2u*N 554 21000 Array of 2u elements, size N = 0..50, - melody to play if
mode=BEEPER_MODE_CUSTOM_MELODY. Special value
21000 used to restart the envelope. Value > 21000 restarts
envelope and makes a pause with the duration (val – 21000)
8ms-samples.
Units: Hz
Example1: simple melody with short B5, D6, G6 notes and envelope:
00 80 05 03 00 00 00 00 00 00 00 00 DB 03 DB 03 08 52 DB 03 DB 03 08 52 96 04 96 04 08
52 1F 06 1F 06 1F 06 1F 06 1F 06
CMD_EXT_IMU_CMD (#110) – forward message from the controller to the connected external
IMU sensor
Name Type Min Max Possible values, remarks
CMD_ID 1u Command ID (see GPS_IMU API specification for available
commands)
DATA ... Payload
The response from the external IMU will be sent back in the CMD_EXT_IMU_CMD incoming command.
© Basecamelectronics® 2024 75
Miscellaneous commands SimpleBGC32 Serial API protocol specification
Forward message to the GPS_IMU sensor connected by CAN bus and acting as a main IMU.
All messages that GPS_IMU sends in response, are wrapped by CMD_EXT_SENS_CMD incoming message.
CMD_MODULE_LIST (#76) – request a version information for the connected CAN devices
CMD_TRANSPARENT_SAPI (#151) – send data to serial port on any device via CAN bus
(min. frw.ver. 2.72b0, “Extended” family only)
Command forwards data to a distant serial port on the device connected by CAN bus and supporting
“transparent serial” functionality. Serial port on the target device should be enabled and configured for the
function “Transparent serial via Serial API” in the GUI’s “Service” tab. The serial data received on this serial
ports’ Rx will be forwarded via the same message to the device + port configured as “Target port”
NOTE: The outgoing data may be sent from any Serial API -enabled port, but the incoming data
always goes to the target port specified in the configuration.
© Basecamelectronics® 2024 76
Miscellaneous commands SimpleBGC32 Serial API protocol specification
Responses
© Basecamelectronics® 2024 77
Miscellaneous commands SimpleBGC32 Serial API protocol specification
ERR_FILE_SIZE = 6
ERR_CRC = 7
ERR_LIMIT_REACHED = 8
ERR_FILE_CORRUPTED = 9
ERR_WRONG_PARAMS = 10
ERROR_DATA 4b
TRACKING_ERROR float Current error between the target and actual system response
RESERVED 6b
RESERVED 10b
MOTOR4_CONTROL - provides data for the external controller of the 4th axis motor
(frw.ver. 2.68+)
It's not a separate command. This structure is included as a part of other commands.
Name Type Min Max Possible values, remarks
FF_SPEED 2s Feed-forward control
Units: 0,06103701895 degree/sec
ANGLE_ERROR 2s Distance to reach the target angle of 4th axis
Units: 0,02197265625 degree
PID_OUT 4f The output of the internal PID loop running over the
ANGLE_ERROR with the FF_SPEED mixed, scaled by the
© Basecamelectronics® 2024 78
Miscellaneous commands SimpleBGC32 Serial API protocol specification
EVENT_ID_MOTOR_STATE = 2
generated on the motors ON/OFF action.
Supported types: EVENT_TYPE_OFF, EVENT_TYPE_ON.
EVENT_ID_EMERGENCY_STOP = 3
generated on the emergency stop error.
Supported types: EVENT_TYPE_OFF, EVENT_TYPE_ON
EVENT_ID_CAMERA = 4
generated on the menu commands "Camera Rec[Photo] event"
Supported types: EVENT_TYPE_REC_PHOTO,
EVENT_TYPE_PHOTO
EVENT_ID_RETRACTED_POSITION = 6 (frw.ver.2.73.1)
generated when the gimbal reaches a retracted position
(EVENT_TYPE_ON) and after several seconds turns OFF the
motors (EVENT_TYPE_OFF)
EVENT_TYPE 1u Possible value and its meaning depends on the EVENT_ID
parameter.
EVENT_TYPE_OFF = 1
state changed to OFF (button is released, motor is turned OFF)
EVENT_TYPE_ON = 2
state is changed to ON (button is pressed, motors is turned ON)
EVENT_TYPE_HOLD = 4
state is remaining ON (button is held).
EVENT_TYPE_REC_PHOTO = 1
EVENT_TYPE_PHOTO = 2
menu commands "Camera Rec/Photo event" and "Camera
photo event"
PARAM1 2b Possible value and its meaning depends on the EVENT_ID and
EVENT_TYPE parameters:
EVENT_ID_MENU_BUTTON
for the "release" and "hold" events, encodes the time period
when the button was held (unsigned value in milliseconds)
EVENT_ID_SCRIPT
© Basecamelectronics® 2024 79
Miscellaneous commands SimpleBGC32 Serial API protocol specification
CMD_EXT_IMU_CMD (#110) – forwarded message received from the connected external IMU
sensor
Name Type Min Max Possible values, remarks
CMD_ID 1u Command ID (see GPS_IMU API specification for available
commands)
DATA ... Payload
DATA All remaining bytes are for payload. It doesn't include header
and checksum.
CMD_CAN_DEVICE_SCAN (#96) – result of scanning all connected CAN devices, with the ID
assigned to them.
Name Type Min Max Possible values, remarks
N=(1..DeviceNum)
© Basecamelectronics® 2024 80
Miscellaneous commands SimpleBGC32 Serial API protocol specification
CMD_TRANSPARENT_SAPI (#151) – receive data from serial port on any device via CAN bus
(min. frw.ver. 2.72b0, “Extended” family only)
See the corresponding command definition CMD_TRANSPARENT_SAPI
© Basecamelectronics® 2024 81
EEPROM and internal file system SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2024 82
EEPROM and internal file system SimpleBGC32 Serial API protocol specification
CMD_EEPROM_READ (#48) – request a reading of block of data from EEPROM at the specified
address and size.
Name Type Min Max Possible values, remarks
ADDR 4u 0 32767 address should be aligned to 64.
* *EEPROM size in all SBGC32 controllers is 32Kbytes.
SIZE 2u 64 192 size should be aligned to 64
CMD_WRITE_EXTERNAL_DATA (#41) – stores any user data to the dedicated area in the
EEPROM
Name Type Min Max Possible values, remarks
DATA 128b
© Basecamelectronics® 2024 83
EEPROM and internal file system SimpleBGC32 Serial API protocol specification
Responses
In case of errors:
Name Type Min Max Possible values, remarks
ERR_CODE 1u see error definitions in the CMD_WRITE_FILE command
CMD_EEPROM_READ (#48) – receive a portion of data read from EEPROM at the specified
address.
Name Type Min Max Possible values, remarks
ADDR 4u Address of a portion of data, 64-byte aligned
DATA ? All remaining bytes are counted as data. Size is specified in
the CMD_EEPROM_READ outgoing command.
© Basecamelectronics® 2024 84
Appendix SimpleBGC32 Serial API protocol specification
Appendix
Command ID definitions
#define CMD_READ_PARAMS 82
#define CMD_WRITE_PARAMS 87
#define CMD_REALTIME_DATA 68
#define CMD_BOARD_INFO 86
#define CMD_CALIB_ACC 65
#define CMD_CALIB_GYRO 103
#define CMD_CALIB_EXT_GAIN 71
#define CMD_USE_DEFAULTS 70
#define CMD_CALIB_POLES 80
#define CMD_RESET 114
#define CMD_HELPER_DATA 72
#define CMD_CALIB_OFFSET 79
#define CMD_CALIB_BAT 66
#define CMD_MOTORS_ON 77
#define CMD_MOTORS_OFF 109
#define CMD_CONTROL 67
#define CMD_TRIGGER_PIN 84
#define CMD_EXECUTE_MENU 69
#define CMD_GET_ANGLES 73
#define CMD_CONFIRM 67
#define CMD_BOARD_INFO_3 20
#define CMD_READ_PARAMS_3 21
#define CMD_WRITE_PARAMS_3 22
#define CMD_REALTIME_DATA_3 23
#define CMD_REALTIME_DATA_4 25
#define CMD_SELECT_IMU_3 24
#define CMD_READ_PROFILE_NAMES 28
#define CMD_WRITE_PROFILE_NAMES 29
#define CMD_QUEUE_PARAMS_INFO_3 30
#define CMD_SET_ADJ_VARS_VAL 31
#define CMD_SAVE_PARAMS_3 32
#define CMD_READ_PARAMS_EXT 33
#define CMD_WRITE_PARAMS_EXT 34
#define CMD_AUTO_PID 35
#define CMD_SERVO_OUT 36
#define CMD_BODE_TEST_START_STOP 37
#define CMD_I2C_WRITE_REG_BUF 39
#define CMD_I2C_READ_REG_BUF 40
#define CMD_WRITE_EXTERNAL_DATA 41
#define CMD_READ_EXTERNAL_DATA 42
#define CMD_READ_ADJ_VARS_CFG 43
#define CMD_WRITE_ADJ_VARS_CFG 44
#define CMD_API_VIRT_CH_CONTROL 45
#define CMD_ADJ_VARS_STATE 46
#define CMD_EEPROM_WRITE 47
#define CMD_EEPROM_READ 48
#define CMD_CALIB_INFO 49
#define CMD_SIGN_MESSAGE 50
#define CMD_BOOT_MODE_3 51
#define CMD_SYSTEM_STATE 52
#define CMD_READ_FILE 53
#define CMD_WRITE_FILE 54
© Basecamelectronics® 2024 85
Appendix SimpleBGC32 Serial API protocol specification
#define CMD_FS_CLEAR_ALL 55
#define CMD_AHRS_HELPER 56
#define CMD_RUN_SCRIPT 57
#define CMD_SCRIPT_DEBUG 58
#define CMD_CALIB_MAG 59
#define CMD_GET_ANGLES_EXT 61
#define CMD_READ_PARAMS_EXT2 62
#define CMD_WRITE_PARAMS_EXT2 63
#define CMD_GET_ADJ_VARS_VAL 64
#define CMD_CALIB_MOTOR_MAG_LINK 74
#define CMD_GYRO_CORRECTION 75
#define CMD_MODULE_LIST 76
#define CMD_DATA_STREAM_INTERVAL 85
#define CMD_REALTIME_DATA_CUSTOM 88
#define CMD_BEEP_SOUND 89
#define CMD_ENCODERS_CALIB_OFFSET_4 26
#define CMD_ENCODERS_CALIB_FLD_OFFSET_4 27
#define CMD_CONTROL_CONFIG 90
#define CMD_CALIB_ORIENT_CORR 91
#define CMD_COGGING_CALIB_INFO 92
#define CMD_CALIB_COGGING 93
#define CMD_CALIB_ACC_EXT_REF 94
#define CMD_PROFILE_SET 95
#define CMD_CAN_DEVICE_SCAN 96
#define CMD_CAN_DRV_HARD_PARAMS 97
#define CMD_CAN_DRV_STATE 98
#define CMD_CAN_DRV_CALIBRATE 99
#define CMD_READ_RC_INPUTS 100
#define CMD_REALTIME_DATA_CAN_DRV 101
#define CMD_EVENT 102
#define CMD_READ_PARAMS_EXT3 104
#define CMD_WRITE_PARAMS_EXT3 105
#define CMD_EXT_IMU_DEBUG_INFO 106
#define CMD_SET_DEVICE_ADDR 107
#define CMD_AUTO_PID2 108
#define CMD_EXT_IMU_CMD 110
#define CMD_READ_STATE_VARS 111
#define CMD_WRITE_STATE_VARS 112
#define CMD_SERIAL_PROXY 113
#define CMD_IMU_ADVANCED_CALIB 115
#define CMD_API_VIRT_CH_HIGH_RES 116
#define CMD_CALIB_ENCODER_LUT 117
#define CMD_CALIB_ENCODER_LUT_RES 118
#define CMD_WRITE_PARAMS_SET 119
#define CMD_CALIB_CUR_SENS 120
#define CMD_CONTROL_EXT 121
#define CMD_ENC_INT_CALIB 122
#define CMD_SYNC_MOTORS 123
#define CMD_EXT_LICENSE_INFO 124
#define CMD_VIBRATION_TEST_START_STOP 125
#define CMD_VIBRATION_TEST_DATA 126
#define CMD_CAN_DRV_TELEMETRY 127
#define CMD_EXT_MOTORS_ACTION 128
#define CMD_EXT_MOTORS_CONTROL 129
#define CMD_EXT_MOTORS_CONTROL_CONFIG 130
#define CMD_EXT_MOTORS_STATE 131
#define CMD_ADJ_VARS_INFO 132
© Basecamelectronics® 2024 86
Appendix SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2024 87
Appendix SimpleBGC32 Serial API protocol specification
crc[0] = crc_register;
crc[1] = (crc_register >> 8);
}
© Basecamelectronics® 2024 88
Appendix SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2024 89
Appendix SimpleBGC32 Serial API protocol specification
FOLLOW_ROLL_MIX_START 34 1u 0 90
FOLLOW_ROLL_MIX_RANGE 35 1u 0 90
GYRO_TRUST 36 1u 0 255 Special value 0 disables
accelerometer completely
FRAME_HEADING_ANGLE 37 2s -1800 1800 The frame's heading (YAW)
angle expressed in Euler order
frame-PITCH-ROLL-YAW used
as an absolute heading
reference for the gyrosope
sensor. Effect is similar to the
FRAME_HEADING variable in
the CMD_HELPER_DATA.
Units: 0.1 degrees
Special value 0x7FFF disables
the correction
GYRO_HEADING_CORRECTION 38 2s -20000 20000 Units: 0.001 of gyro sensor
units
ACC_LIMITER_ROLL 39 2s 0 1275
ACC_LIMITER_PITCH 40 Units: degrees/sec2
ACC_LIMITER_YAW 41
PID_GAIN_ROLL 42 1u 0 255 Prior to frw. 2.73.2:
PID_GAIN_PITCH 43 gain_f = 0.1 + gain_int*0.02
PID_GAIN_YAW 44
4f 0.02 50.0 After 2.73.2: floating point type
0.02..50 range
LPF_FREQ_ROLL 45 2u 10 400
LPF_FREQ_PITCH 46 Units: Hz
LPF_FREQ_YAW 47
TIMELAPSE_TIME 48 2u 1 3600 Units: sec
MAV_CTRL_MODE 49 1u 0 2 0 – disabled
1 – ROLL and PITCH only
2 – enabled for all axes
H_CORR_FACTOR 2.68b7 50 1u 0 255 Heading correction factor from
external reference
SW_LIM_MIN.ROLL 2.68b8 51 2s -3600 3600 Software limits for each motor,
SW_LIM_MAX.ROLL 52 degrees (encoder firmware
SW_LIM_MIN.PITCH 53 only)
SW_LIM_MAX.PITCH 54 Note: set new values only in
SW_LIM_MIN.YAW 55 pairs, min should go prior to
SW_LIM_MAX.YAW 56 max!
FOLLOW_RANGE.ROLL 2.68b9 57 1u 0 255
FOLLOW_RANGE.PITCH 58 Units: degrees
FOLLOW_RANGE.YAW 59
AUTO_PID_TARGET 2.68b9 60 1u 0 255 Stability-precision slider for
automatic PID tuing algorithm
RC_MODE.ROLL 2.69b3 61 1u 0 – ANGLE
RC_MODE.PITCH 62 1 – SPEED
RC_MODE.YAW 63 2 – TRACKING
EULER_ORDER 2.69b3 64 1u 0 – PITCH-ROLL-YAW
1 – ROLL-PITCH-YAW
2 – PITCH(M)-ROLL-YAW(M)
3 – ROLL-PITCH(M)-YAW(M)
4 – YAW-ROLL-PITCH
FOLLOW_IN_DBAND 2.70b4 65 1u 0 255 “Follow inside deadband”
parameter
© Basecamelectronics® 2024 90
Appendix SimpleBGC32 Serial API protocol specification
RC_LIMIT_MIN.ROLL 2.72b0 66 2s -3600 3600 Angle limits for the Euler axes,
RC_LIMIT_MAX.ROLL 67 degrees.
RC_LIMIT_MIN.PITCH 68 Note: set new values only in
RC_LIMIT_MAX.PITCH 69 pairs, min should go prior to
RC_LIMIT_MIN.YAW 70 max!
RC_LIMIT_MAX.YAW 71
RC_DEADBAND.PITCH 2.72b0 72 1u 0 255 See RC_DEADBAND
RC_DEADBAND.YAW 73
RC_EXPO_RATE.PITCH 2.72b0 74 1u 0 100 See RC_EXPO
RC_EXPO_RATE.YAW 75
SHAKE_AMP.ROLL 2.73.0 76 1u 0 255 See SHAKE_GENERATOR_CFG
SHAKE_AMP.TILT 77 specification
SHAKE_AMP.PAN 78
SHAKE_FREQ 79 1u 0 255
SHAKE_FREQ_RANGE 80 1u 0 100
SHAKE_PAUSE_PERIOD 81 2u 500 5600
SHAKE_PAUSE_BALANCE 82 1u
SHAKE_PAUSE_RANDOMNESS 83 1u 0 100
SHAKE_RESONANCE_GAIN.ROLL 84 1u 0 255
SHAKE_RESONANCE_GAIN.TILT 85 1u 0 255
SHAKE_RESONANCE_GAIN.PAN 86 1u 0 255
SHAKE_FREQ_SHIFT.ROLL 87 1s -127 127
SHAKE_FREQ_SHIFT.TILT 88 1s -127 127
SHAKE_FREQ_SHIFT.PAN 89 1s -127 127
SHAKE_MASTER_GAIN 90 1u 0 255 (0...255) is mapped to (0...10)
master gain in logarithmic
scale; default value 132 for
gain=1.0
© Basecamelectronics® 2024 91
Appendix SimpleBGC32 Serial API protocol specification
Option 2) is more tolerant in this case. You can use it to compensate the attitude drift caused by an
accelerated motion and the heading drift causing by an unreferenced YAW gyroscope. Attitude/heading is
still computed inside the gimbal's controller, using an internal accelerometer and gyroscope. You need to
pass linear accelerations (with the gravity subtracted) in the command CMD_HELPER_DATA. Also, for 3-axis
systems, you have to provide heading information to synchronize the camera's heading angle with the UAV's
heading. “Heading” here is the Euler's YAW angle expressed in order “frame-PITCH-ROLL-YAW” (note that
the order of angles does matter; the commonly used in aeronautics “ROLL-PITCH-YAW” will give different
values for the same physical orientation).
As a drawback, option 2) does not help to compensate for a drift caused by the thermal instability of the
gyroscope and accelerometer sensors.
© Basecamelectronics® 2024 92
Appendix SimpleBGC32 Serial API protocol specification
Rotation matrix
CMD_AHRS_HEPER provides and takes orientation data in a form of rotation matrix (DCM), but first row is
omitted to save the bandwidth. The full rotation matrix can be reconstructed from two vectors H_VECT and
Z_VECT:
( )( )
Ax A y Az AVECT
DCM END = H x H y H z = H VECT ,
Zx Zy Zz Z VECT
AVECT =H VECT ×Z VECT
Z_VECT and H_VECT can be considered as unit vectors in body reference system pointing down and North
directions.
To convert rotation matrix from / to commonly used NED coordinate system, just swap first two rows:
( )
H x H y Hz
DCM NED = A x A y A z
Z x Z y Zx
Note that some systems need an alternative definition of rotation matrix: (body-to-world or world-to-body
defines the same rotations but in opposite direction), so DCM may need to be transposed (i.e. rows arranged
as columns).
Quaternions
Serial API support for quaternions was added starting from firmware version 2.73.0.
Euler angles
Serial API provides and takes all angles in a form of Euler angles. Attitude/heading can be reconstructed
from Euler angles, but it is important taking into account the order of Euler rotations. SBGC32 supports
several orders that may be configured in system parameters. Since this order is not knows in advance, it's
better to avoid using Euler angles to represent the rotations in calculations. Another problem is that Euler
rotations are not free from gimbal lock problem. Rotation matricies or quaternions are free from this problem
and correctly represents all possible positions.
© Basecamelectronics® 2024 93
Appendix SimpleBGC32 Serial API protocol specification
If converted from/to the commonly used convention, the PITCH angle should be inverted.
© Basecamelectronics® 2024 94
Appendix SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2024 95
Appendix SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2024 96
Appendix SimpleBGC32 Serial API protocol specification
1. Find the largest component and store its index (0..3) in the ‘largest’ field. If the value is negative, set
the ‘largest_sign’ bit to 1.
2. Take an absolute value of other 3 components, multiply them by SCALE_FACTOR and store to a, b, c
fields (preserving the original order). If any value is negative, set the corresponding sign bit to 1.
Functions for compression and dercomression are available in Serial API C library.
© Basecamelectronics® 2024 97