SimpleBGC_2_6_Serial_Protocol_Specification (1)
SimpleBGC_2_6_Serial_Protocol_Specification (1)
specification
Applicable for all 32-bit gimbal controllers
Last updated: Jun 22, 2023
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
© Basecamelectronics® 2023
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® 2023 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® 2023 3
Overview SimpleBGC32 Serial API protocol specification
• 1s – 1 byte signed
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® 2023 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..............................................................24
Calibrating.......................................................................................................................................................... 26
Requests.......................................................................................................................................................................................................26
CMD_CALIB_ACC (#65) – calibrate accelerometer
CMD_CALIB_GYRO (#103) – calibrate gyroscope
CMD_CALIB_MAG (#59) – calibrate magnetometer..............................................................................................................26
CMD_CALIB_EXT_GAIN (#71) – calibrate EXT_FC gains......................................................................................................26
CMD_CALIB_POLES (#80) – calibrate poles and direction.................................................................................................26
CMD_CALIB_BAT (#66) - calibrate internal voltage sensor................................................................................................26
CMD_ENCODERS_CALIB_OFFSET_4 (#26) - calibrate offset of encoders.....................................................................26
CMD_ENCODERS_CALIB_FLD_OFFSET_4 (#27) - start field offset calibration of encoders..................................27
CMD_CALIB_ORIENT_CORR (#91) – start the calibration of sensor misalignment correction (frw. ver. 2.61+)
© Basecamelectronics® 2023 5
Table of contents SimpleBGC32 Serial API protocol specification
..................................................................................................................................................................................................................27
CMD_CALIB_ACC_EXT_REF (#94) – refine the accelerometer calibration of the main IMU sensor ..................27
CMD_CALIB_COGGING (#93) – starts the motor non-linearities calibration.............................................................28
CMD_SYNC_MOTORS (#123) – mechanically align motors working in parallel for a single axis......................28
Real-time state monitoring and diagnostics...............................................................................................29
Requests.......................................................................................................................................................................................................29
CMD_REALTIME_DATA_CUSTOM (#88) – request configurable realtime data...........................................................29
CMD_REALTIME_DATA (#68),
CMD_REALTIME_DATA_3 (#23) – request real-time data, response is CMD_REALTIME_DATA_3........................29
CMD_REALTIME_DATA_4 (#25) – request extended real-time data, response is CMD_REALTIME_DATA_4....29
CMD_DATA_STREAM_INTERVAL (#85) – register or update data stream – a commands sent by the
controller with the fixed rate without request .....................................................................................................................29
CMD_READ_RC_INPUTS (#100) - read values for the selected RC inputs....................................................................31
CMD_GET_ANGLES (#73), CMD_GET_ANGLES_EXT (#61) - Request information related to IMU angles and
RC control state..................................................................................................................................................................................31
CMD_SELECT_IMU_3 (#24) – Select which IMU to calibrate or send realtime data................................................31
CMD_DEBUG_VARS_INFO_3 (#253) – request information about debug variables.................................................31
CMD_DEBUG_VARS_3 (#254) – request values of debug variables................................................................................31
CMD_CALIB_INFO (#49) – request information required for the "Calibration helper" dialog window.............31
CMD_READ_STATE_VARS (#111)– request reading system persistent state variables, cumulative statistics
and maintenance data ....................................................................................................................................................................32
CMD_WRITE_STATE_VARS (#112) – write system persistent state variables, cumulative statistics and
maintenance data..............................................................................................................................................................................32
CMD_SET_DEBUG_PORT (#249) – use this port for debugging.......................................................................................32
Responses....................................................................................................................................................................................................32
CMD_REALTIME_DATA_CUSTOM (#88) – configurable realtime data............................................................................32
CMD_REALTIME_DATA_3 (#23) - receive real-time data......................................................................................................34
CMD_REALTIME_DATA_4 (#25) - receive extended version of real-time data ...........................................................35
CMD_GET_ANGLES (#73) - Information about actual gimbal control state................................................................36
CMD_GET_ANGLES_EXT (#61) - Information about angles in different format.........................................................37
CMD_DEBUG_VARS_INFO_3 (#253) – receive a specification of the debug variables............................................37
CMD_DEBUG_VARS_3 (#254) – values of debug variables reflecting a state of the system................................37
CMD_CALIB_INFO (#49) – receive information required for the "Calibration helper" dialog window..............38
CMD_SCRIPT_DEBUG (#58) – state of execution of user-written script .....................................................................38
CMD_ADJ_VARS_STATE (#46) – receive the state of adjustable variables...................................................................38
CMD_READ_RC_INPUTS (#100) - answer to the requested RC sources.........................................................................39
CMD_READ_STATE_VARS (#111) – result of reading system persistent state variables, cumulative statistics
and maintenance data ....................................................................................................................................................................39
CMD_SET_DEBUG_PORT (#249) – receive serial API commands from all other ports for a debugging..........40
Run-time gimbal parameters......................................................................................................................... 41
Requests.......................................................................................................................................................................................................41
CMD_SET_ADJ_VARS_VAL (#31) – Update the value of selected parameter(s)..........................................................41
CMD_GET_ADJ_VARS_VAL (#64) – Query the actual value of selected parameter(s)...............................................41
CMD_READ_ADJ_VARS_CFG (#43) – request configuration of mapping of control inputs to adjustable
variables................................................................................................................................................................................................41
CMD_WRITE_ADJ_VARS_CFG (#44) – writes configuration of mapping of control inputs to adjustable
variables................................................................................................................................................................................................42
CMD_SAVE_PARAMS_3 (#32) – Saves current values of parameters linked to adjustable variables, to
EEPROM.................................................................................................................................................................................................42
CMD_ADJ_VARS_STATE (#46) – request the state of adjustable variable in the given trigger and analog
slots. .......................................................................................................................................................................................................42
© Basecamelectronics® 2023 6
Table of contents SimpleBGC32 Serial API protocol specification
Responses....................................................................................................................................................................................................42
CMD_SET_ADJ_VARS_VAL (#31) – receive the values of adjustable variables. .........................................................42
CMD_READ_ADJ_VARS_CFG (#43) – receive the configuration for adjustable variables.......................................42
IMU correction and diagnostic....................................................................................................................... 44
Requests.......................................................................................................................................................................................................44
CMD_HELPER_DATA (#72) – provide helper data for AHRS system...............................................................................44
CMD_AHRS_HELPER (#56) – send or request attitude of the IMU sensor...................................................................46
CMD_GYRO_CORRECTION (#75) – correct the gyroscope sensor's zero bias manually.........................................48
Responses....................................................................................................................................................................................................48
CMD_AHRS_HELPER (#56) – current attitude in vector form. .........................................................................................48
AHRS_DEBUG_INFO - information about the AHRS state ................................................................................................48
CMD_EXT_IMU_DEBUG_INFO (#106) – debug information for the external IMU sensor .....................................49
Controlling gimbal movements..................................................................................................................... 50
Requests.......................................................................................................................................................................................................50
CMD_CONTROL (#67) – controls gimbal movement............................................................................................................50
CMD_CONTROL_EXT (#121) – controls gimbal movement, extended version .........................................................53
CMD_CONTROL_CONFIG (#90) – configure the handling of CMD_CONTROL command ......................................54
CMD_API_VIRT_CH_CONTROL (#45) – update a state of 32 virtual channels............................................................55
CMD_API_VIRT_CH_HIGH_RES (#116) – update a state of 32 virtual channels .......................................................55
Miscellaneous commands............................................................................................................................... 57
Requests.......................................................................................................................................................................................................57
CMD_RESET (#114) – reset device..............................................................................................................................................57
CMD_BOOT_MODE_3 (#51) – enter bootloader mode to upload firmware................................................................57
CMD_TRIGGER_PIN (#84) - trigger output pin........................................................................................................................57
CMD_MOTORS_ON (#77) - switch motors ON.........................................................................................................................58
CMD_MOTORS_OFF (#109) - switch motors OFF...................................................................................................................58
CMD_EXECUTE_MENU (#69) - execute menu command....................................................................................................58
CMD_AUTO_PID (#35) – Starts automatic PID calibration.................................................................................................59
CMD_AUTO_PID2 (#108) – Starts automatic PID calibration ver.2.................................................................................60
CMD_SERVO_OUT (#36) – Output PWM signal on the servo1..4 pins...........................................................................61
CMD_I2C_WRITE_REG_BUF (#39) – writes data to any device connected to I2C line.............................................61
CMD_I2C_READ_REG_BUF (#40) – requests reading from any device connected to I2C line..............................62
CMD_RUN_SCRIPT (#57) – start or stop user-written script.............................................................................................62
CMD_BEEP_SOUND (#89) – play melody by motors or emit standard beep sound.................................................62
CMD_SIGN_MESSAGE (#50) – sign message by secret keys..............................................................................................63
CMD_EXT_IMU_CMD (#110) – forward message from the controller to the connected external IMU sensor
..................................................................................................................................................................................................................63
CMD_EXT_SENS_CMD (#150) – forward message to the GPS_IMU sensor.................................................................63
CMD_CAN_DEVICE_SCAN (#96) – scan for the connected CAN devices.......................................................................64
Responses....................................................................................................................................................................................................64
CMD_CONFIRM (#67) – confirmation of previous command or finished calibration..............................................64
CMD_ERROR (#255) – error executing previous command...............................................................................................64
CMD_I2C_READ_REG_BUF (#40) – result of reading from I2C device..........................................................................64
CMD_AUTO_PID (#35) – progress of PID auto tuning..........................................................................................................64
CMD_RESET (#114) – notification on device reset...............................................................................................................65
MOTOR4_CONTROL - provides data for the external controller of the 4th axis motor .......................................65
CMD_EVENT (#102) – sent when event is triggered ...........................................................................................................65
CMD_SIGN_MESSAGE (#50) – result of message signing...................................................................................................66
CMD_EXT_IMU_CMD (#110) – forwarded message received from the connected external IMU sensor.........66
CMD_EXT_SENS_CMD (#150) – forward message from the GPS_IMU sensor............................................................66
CMD_CAN_DEVICE_SCAN (#96) – result of scanning all connected CAN devices, with the ID assigned to
© Basecamelectronics® 2023 7
Table of contents SimpleBGC32 Serial API protocol specification
them........................................................................................................................................................................................................67
EEPROM and internal file system................................................................................................................... 68
Requests.......................................................................................................................................................................................................68
CMD_READ_FILE (#53) – read file from internal filesystem.............................................................................................68
CMD_WRITE_FILE (#54) – write file to internal filesystem...............................................................................................68
CMD_FS_CLEAR_ALL (#55) – delete all files from internal filesystem.........................................................................69
CMD_EEPROM_WRITE (#47) – writes a block of data to EEPROM to specified address........................................69
CMD_READ_EXTERNAL_DATA (#42) – receive user data, stored in the EEPROM......................................................69
CMD_EEPROM_READ (#48) – request a reading of block of data from EEPROM at the specified address and
size...........................................................................................................................................................................................................69
CMD_WRITE_EXTERNAL_DATA (#41) – stores any user data to the dedicated area in the EEPROM................69
CMD_READ_EXTERNAL_DATA (#42) – request user data, stored in the EEPROM.....................................................69
Responses....................................................................................................................................................................................................70
CMD_READ_FILE (#53) – result of reading file from internal filesystem.....................................................................70
CMD_EEPROM_READ (#48) – receive a portion of data read from EEPROM at the specified address. ...........70
Appendix............................................................................................................................................................ 71
Command ID definitions........................................................................................................................................................................71
Appendix A: Examples and libraries..................................................................................................................................................73
CRC16 reference implementation in C......................................................................................................................................73
Appendix B: Run-time parameters definition (adjustable variables)...................................................................................74
Appendix C: Providing external reference attitude/heading information from UAV.....................................................76
Using high-grade IMU for a correction......................................................................................................................................76
Notes on data rates and how to interrupt the correction..................................................................................................76
Appendix D: Coordinate system conversions.................................................................................................................................77
Rotation matrix...................................................................................................................................................................................77
Quaternions.........................................................................................................................................................................................77
Euler angles.........................................................................................................................................................................................77
Appendix E: “Emergency stop” error codes.....................................................................................................................................78
© Basecamelectronics® 2023 8
Device information SimpleBGC32 Serial API protocol specification
Device information
Requests
Responses
© Basecamelectronics® 2023 9
Device information SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2023 10
Device information SimpleBGC32 Serial API protocol specification
RESERVED 31b
© Basecamelectronics® 2023 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® 2023 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® 2023 13
Configuring gimbal SimpleBGC32 Serial API protocol specification
POWER 1u 0 255
INVERT 1u 0 1
axis = (1..3)
POLES 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,
RC_MAP_PITCH bits 5..7 for a type. Value 0 means that input is not assigned.
© Basecamelectronics® 2023 14
Configuring gimbal SimpleBGC32 Serial API protocol specification
RC_MAP_YAW
RC_MAP_CMD PWM source
RC_MAP_FC_ROLL RC_INPUT_ROLL = 1
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® 2023 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® 2023 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® 2023 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
YAW_PITCH_ROLL = 5
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® 2023 18
Configuring gimbal SimpleBGC32 Serial API protocol specification
R[3]
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
MAG_AXIS_TOP 1s X = 1
MAG_AXIS_RIGHT 1s Y = 2
Z = 3
-X = -1
© Basecamelectronics® 2023 19
Configuring gimbal SimpleBGC32 Serial API protocol specification
-Y = -2
-Z = -3
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® 2023 20
Configuring gimbal SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2023 21
Configuring gimbal SimpleBGC32 Serial API protocol specification
bit4: YAW
OUTER_MOT_TILT_ANGLE 1s -90 90 Units: degrees
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
MAV_CTRL_MODE 1u 0 2 0 – disabled
1 – ROLL and PITCH axes
2 – all axes
© Basecamelectronics® 2023 22
Configuring gimbal SimpleBGC32 Serial API protocol specification
EXT_IMU_TYPE 1u MavLink1 = 1
MavLink2 = 2
Vectornav VN200 = 3
Inertialsense uAHRS = 4
EXT_IMU_PORT 1u Disabled = 0
UART1 = 1
RC_SERIAL = 2
UART2 = 3
USB VCP = 4
EXT_IMU_POSITION 1u BELOW_OUTER = 1
ABOVE_OUTER = 2
BELOW_MIDDLE = 8
MAIN_IMU = 9
EXT_IMU_ORIENTATION 1u index in array [X, Y, Z, -X, -Y, -Z]
bit0..2 for the TOP axis
bit3..5 for the RIGHT axis
EXT_IMU_FLAGS 2u EXT_IMU_FLAG_ACC_COMP_ONLY = 2
EXT_IMU_FLAG_REPLACE = 4
EXT_IMU_FLAG_Z = 8
EXT_IMU_FLAG_H = 16
EXT_IMU_FLAG_FRAME_UPSIDE_DOWN_UPDATE = 32
EXT_IMU_FLAG_AS_FRAME_IMU = 64
EXT_IMU_FLAG_GYRO_CORR = 128 (frw.ver. 2.68b7+)
EXT_IMU_ALIGN_CORREC 2s*3 Rotation over X,Y,Z axes
TION[3] Units: 0.001 degrees
EXT_IMU_RESERVED 4b
© Basecamelectronics® 2023 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
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)
RESERVED 3b
RESERVED 140b
© Basecamelectronics® 2023 24
Configuring gimbal SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2023 25
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® 2023 26
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® 2023 27
Calibrating SimpleBGC32 Serial API protocol specification
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
© Basecamelectronics® 2023 28
Calibrating SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2023 29
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® 2023 30
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
Take care of the serial bandwidth: if data flow exceeds bandwidth, particular messages may be skipped.
The interval is maintained with the +-1ms tolerance for the individual sample, but the averaged sample rate
exactly matches to the specified.
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).
Data types:
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
© Basecamelectronics® 2023 31
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
• 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.
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® 2023 32
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
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.
Responses
© Basecamelectronics® 2023 33
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[3] 4f*3 Script variables in floats
SYSTEM_POWER_STATE (frw. ver. 2.70b6+) WARNING: specification is not final, may be changed in future!
motor =(1..3)
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
MOT_TEMP 1s Motor temperature estimated by heating model (if configured) or
measured by the hardware sensors (if present)
Units: °C
MOT_FLAGS 2u bit0: software limit in motor is violated
bit1: current exceeds the limit
bit2: motor driver is enabled (motor energized)
© Basecamelectronics® 2023 34
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
MOT_RESERVED 6b
© Basecamelectronics® 2023 35
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
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
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
© Basecamelectronics® 2023 36
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
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 If not 0, calibration or automatic task is performed:
CALIB_MODE_EXT_GAIN 1
CALIB_MODE_SET_ANGLE_AND_SAVE 2
CALIB_MODE_POLES 3
CALIB_MODE_ACC 4
CALIB_MODE_GYRO 5
CALIB_MODE_ENCODER_OFFSET 6
CALIB_MODE_ENCODER_FLD_OFFSET 7
CALIB_MODE_AUTO_PID 8
CALIB_MODE_BODE_TEST 9
CALIB_MODE_GYRO_TEMP 10
CALIB_MODE_ACC_TEMP 11
CALIB_MODE_MAG 12
CALIB_MODE_SET_ANGLE 13
CALIB_MODE_SYSTEM_IDENT 14
CALIB_MODE_MOTOR_MAG_LINK 15
CALIB_MODE_SEARCH_LIMITS 16
CALIB_MODE_SET_OPERATION_POS 17
CALIB_MODE_IMU_ORIENTATION_CORR 18
CALIB_MODE_TIMELAPSE 19
CALIB_MODE_MOMENTUM 20
CALIB_MODE_MOMENTUM_AUTO 21
CALIB_MODE_COGGING 22
CALIB_MODE_ACC_EXT_REF 23
CALIB_MODE_SAFE_STOP 24
CALIB_MODE_ACC_SPHERE 25
CALIB_MODE_GYRO_AXES_ALIGNMENT 26
CALIB_MODE_EXT_IMU_GYRO 27
CALIB_MODE_EXT_IMU_ALIGN 28
CALIB_MODE_ACC_GYRO_MULTIPOINT 34
CAN_IMU_EXT_SENS_ERR 1u Error code from the external sensor connected to the CAN_IMU
(codes are specific to sensors).
RESERVED 28b
© Basecamelectronics® 2023 37
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
axis = (1..3)
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® 2023 38
Real-time state monitoring and diagnostics SimpleBGC32 Serial API protocol specification
CMD_DEBUG_VARS_INFO_3 structure
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® 2023 39
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® 2023 40
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.
© Basecamelectronics® 2023 41
Run-time gimbal parameters SimpleBGC32 Serial API protocol specification
PARAM<N>_ID 1u
(adjustable variables) for a list of available variables.
PARAM<N>_VALUE 4b Value depends on type of parameter.
...
Values are packed according to C-language memory model,
little-endian order. 1- or 2-byte types converted to 4-byte using
C-language type conversions. Floats are packed according to
IEEE-754.
PARAM<N>_ID 1u
(adjustable variables) for a list of available variables.
© Basecamelectronics® 2023 42
Run-time gimbal parameters SimpleBGC32 Serial API protocol specification
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
Responses
© Basecamelectronics® 2023 43
Run-time gimbal parameters SimpleBGC32 Serial API protocol specification
RC signal level, where full range is split into 5 levels. “Analog” type is used to adjust parameter by RC
signal. MIN_VAL and MAX_VAL specify a working range, that is mapped to a native range of particular
parameter.
© Basecamelectronics® 2023 44
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.
COORD_SYS_FRAME = 3
© Basecamelectronics® 2023 45
IMU correction and diagnostic SimpleBGC32 Serial API protocol specification
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® 2023 46
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 3 rd
test is still passed correctly – it means that the ACC correction vector is translated to the main IMU
sensor properly.
REMARKS ON FLAGS
© Basecamelectronics® 2023 47
IMU correction and diagnostic SimpleBGC32 Serial API protocol specification
8,9.
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® 2023 48
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® 2023 49
IMU correction and diagnostic SimpleBGC32 Serial API protocol specification
Units: 0.1°
MAIN_IMU_H_REF_ERR 1u Error between the reference defined by the
MAIN_IMU_REF_SRC, and the estimated heading
Units: 0.1°
FRAME_IMU_Z_REF_ERR 1u Error between the reference defined by the
FRAME_IMU_REF_SRC, and the estimated attitude
Units: 0.1°
FRAME_IMU_H_REF_ERR 1u Error between the reference defined by the
FRAME_IMU_REF_SRC, and the estimated heading
Units: 0.1°
EXT_IMU_STATUS 1u bits 0..2 for status:
STATUS_DISABLED = 0
STATUS_NOT_CONNECTED = 1
STATUS_UNKNOWN = 2
STATUS_ERROR = 3
STATUS_BAD = 4
STATUS_COARSE = 5
STATUS_GOOD = 6
STATUS_FINE = 7
(values 4..7 encode the quality of the attitude estimation)
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® 2023 50
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 joystic 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® 2023 51
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® 2023 52
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)
• When CMD_CONTROL comes first time, it overrides the regular RC or Follow mode control, unless
CONTROL_FLAG_MIX_FOLLOW is set. To switch back to a normal mode, send this command with the MODE=0
for all axes, and all data set to zeros. All parameters that were changed by the CMD_CONTROL_CONFIG, will be
restored to their default values.
Behavior is different if CONTROL_FLAG_AUTO_TASK is set: when the commanded motion is finished, system
returns to a normal mode automatically.
• The optimal rate of sending this command is 50..125 Hz. If the rate of CMD_CONTROL command is lower, use a
low-pass filtering to prevent step-wise response. It can be set by the command CMD_CONTROL_CONFIG
© Basecamelectronics® 2023 53
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® 2023 54
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 keep
smooth control even if update rate is slow.
© Basecamelectronics® 2023 55
Controlling gimbal movements SimpleBGC32 Serial API protocol specification
Units: degrees/sec2
JERK_SLOPE 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 (leave the value set before or default
value from system configuration)
1 – disable jerk slope function
Units: 20ms
RESERVED 1b
Note: all changes in control parameters are applicable only for CMD_CONTROL and acts only while it's
being active. When control finishes, the GUI-configured values are restored.
© Basecamelectronics® 2023 56
Controlling gimbal movements SimpleBGC32 Serial API protocol specification
API_VIRT_CH32* ignored)
* Any number of channels (1..32) may be provided, to save bandwidth by omitting unused channels.
© Basecamelectronics® 2023 57
Miscellaneous commands SimpleBGC32 Serial API protocol specification
Miscellaneous commands
Requests
Extended format:
Extended format:
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
PIN_AUX3 = 18
PIN_BUZZER = 32
PIN_SSAT_POWER** = 33
© Basecamelectronics® 2023 58
Miscellaneous commands SimpleBGC32 Serial API protocol specification
Confirmation is sent only if pin is not occupied for other functions and was really triggered.
© Basecamelectronics® 2023 59
Miscellaneous commands SimpleBGC32 Serial API protocol specification
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
© Basecamelectronics® 2023 60
Miscellaneous commands SimpleBGC32 Serial API protocol specification
RESERVED 14b
CFG_VERSION 1u version 1
RESERVED 6b
© Basecamelectronics® 2023 61
Miscellaneous commands SimpleBGC32 Serial API protocol specification
When finished, the controller sends a full set of tuned parameters to the GUI (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
© Basecamelectronics® 2023 62
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”
NOTE_FREQ_HZ[N] 2u*N 554 21000 Array of 2u elements, size N = 0..50, - melody to play if
© Basecamelectronics® 2023 63
Miscellaneous commands SimpleBGC32 Serial API protocol specification
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® 2023 64
Miscellaneous commands SimpleBGC32 Serial API protocol specification
All messages that GPS_IMU sends in response, are wrapped by CMD_EXT_SENS_CMD incoming message.
Controller scans all connected CAN devices and answers with the CMD_CAN_DEVICE_SCAN incoming command.
CMD_ERROR is sent in case of problems, with the ERROR_CODE related to file operations.
Responses
© Basecamelectronics® 2023 65
Miscellaneous commands SimpleBGC32 Serial API protocol specification
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
'scale factor' parameter.
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
© Basecamelectronics® 2023 66
Miscellaneous commands SimpleBGC32 Serial API protocol specification
EVENT_ID_CAMERA = 4
generated on the menu commands "Camera Rec[Photo] event"
Supported types: EVENT_TYPE_REC_PHOTO,
EVENT_TYPE_PHOTO
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
slot from where the script is executed, starting from 0.
NOTE: this command may be expanded by extra parameters in future versions...
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
© Basecamelectronics® 2023 67
Miscellaneous commands SimpleBGC32 Serial API protocol specification
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)
Bit7: ID is hardware-assigned
© Basecamelectronics® 2023 68
EEPROM and internal file system SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2023 69
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® 2023 70
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® 2023 71
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_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
#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
© Basecamelectronics® 2023 72
Appendix SimpleBGC32 Serial API protocol specification
#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_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_EXT_SENS_CMD 150
© Basecamelectronics® 2023 73
Appendix SimpleBGC32 Serial API protocol specification
crc[0] = crc_register;
crc[1] = (crc_register >> 8);
}
© Basecamelectronics® 2023 74
Appendix SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2023 75
Appendix SimpleBGC32 Serial API protocol specification
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
Gain is calculated as
PID_GAIN_PITCH 43
0.1 + PID_GAIN[axis]*0.02
PID_GAIN_YAW 44
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® 2023 76
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® 2023 77
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:
( )( )
A x 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 does not provide quaternions prior to firmware version 3.00x, but the rotation matrix can be
converted to / from quaternion without loss of precision.
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 matrix is free from this problem and correctly
represents all possible positions.
© Basecamelectronics® 2023 78
Appendix SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2023 79
Appendix SimpleBGC32 Serial API protocol specification
© Basecamelectronics® 2023 80