Bebop/BLDC

From PaparazziUAV
Revision as of 16:06, 16 November 2014 by Fvantienen (talk | contribs) (→‎Checksum)
Jump to navigation Jump to search

General

The BLDC of the Bebop is the Brushless Driver Controller that controls all 4 brushless motors from the Bebop. This BLDC contains a closed loop RPM controller, and also reads out the battery voltage.

Protocol

  • 0x02 SET_REF_SPEED
  • 0x20 GET_OBS_DATA
  • 0x40 START_PROP
  • 0x4D TOGGLE_GPIO
  • 0x60 STOP_PROP
  • 0x80 CLEAR_ERROR
  • 0x82 PLAY_SOUND
  • 0xA0 GET_INFO

SET_REF_SPEED (0x02)

Sets the RPM reference of the motors.

Arguments: 9 bytes

  • 0-1: RPM reference Left Front motor (uint16)
  • 2-3: RPM reference Right Front motor (uint16)
  • 4-5: RPM reference Right Back motor (uint16)
  • 6-7: RPM reference Left Back motor (uint16)
  • 8: Reserved (0x00)

GET_OBS_DATA (0x20)

Gets the observed data from the motors and battery.

Arguments: 0 bytes Receive: 8 bytes or 13 bytes

  • 0-1: RPM observed Left Front motor (uint16)*
  • 2-3: RPM observed Right Front motor (uint16)*
  • 4-5: RPM observed Right Back motor (uint16)*
  • 6-7: RPM observed Left Back motor (uint16)*
  • 8-9: Battery voltage in mV (uint16)
  • 10: Status (uint8)
  • 11: Errno (uint8)
  • 12: Temperature in degrees Celcius (uint8)

* Bit 15 is reserved for detecting maximum RPM (depending on voltage and altitude)

Status

  • 0: Init
  • 1: Idle
  • 2: Ramping
  • 3/4: Spinning
  • 5: Stopping
  • 6: Suicided

Errno

  • 0: No error
  • 2: Motor stalled
  • 3: Propeller security
  • 4: Communication lost
  • 9: Battery voltage too low

START_PROP (0x40)

Starts the propellers. The propellers will not start when the current error is not cleared.

Arguments: 0 bytes or 1 byte

  • 0: Motor bitmask (0000ABCD, A:Left Upper, B:Right Upper, C: Right Back, D: Left Back) where 1 is clockwise and 0 is counterclockwise

Receive: 0 bytes

TOGGLE_GPIO (0x4D)

Toggle GPIO outputs. The reset will put the BLDC into bootloader mode.

Arguments: 1 byte

  • 0: GPIO bitmask (bit 0: Reset, bit 1: Red LED, bit 2: Green LED)

Receive: 0 bytes

STOP_PROP (0x60)

Stop the propellers when turning.

Arguments: 0 bytes Receive: 0 bytes

CLEAR_ERROR (0x80)

Clear the current error.

Arguments: 0 bytes Receive: 0 bytes

PLAY_SOUND (0x82)

Play a sound. A negative number will loop the sound.

Arguments: 1 byte

  • 0: Sound number (0: None, 1: Short beep, 2: Boot beep, 3: Be-Bop-Ah-Lula, negative: repeat) (int8)

Receive: 0 bytes

GET_INFO (0xA0)

Get information about the BLDC.

Arguments: 0 bytes Receive: 4 bytes or 13 bytes

  • 0: Software version (major)
  • 1: Software version (minor)
  • 2: Software type
  • 3: Number of motors
  • 4-5: Number of flights (uint16)
  • 4-5: Time last flight (uint16)
  • 6-9: Full flight time (uint32)
  • 10: Last error code

Checksum

For all the packets with arguments or where we receive bytes there is a checksum byte at the end. This checksum is a simple XOR algorithm including the first command byte.

checksum = CMD_BYTE;
for(int i = 0; i < packet_size; i++)
   checksum = checksum ^ packet[i];

Credits to Christophe de Wagter for figuring out the Checksum.