This FOC driver board, based on the DRV8313,
is suitable for 4008/4010 gimbal brushless motors and operates on a voltage not exceeding 16V. The main controller is an STM32F103C8T6, and the driver chip is the DRV8313/AT8313, with a maximum current of 2.5A. It uses low-side current sampling and integrates a CAN transceiver for CAN communication control.

This project is adapted from an open-source project by Bilibili UP user: 会飞的车_S, with the following hardware modifications:
The original bus current sampling was changed to low-side current sampling. Bus current sampling places higher demands on the op-amp, requiring a high-precision bidirectional op-amp with better PWM suppression than conventional amplifiers. The original design used the INA240, which is relatively expensive. Low-side sampling has fewer requirements for the op-amp, so the INA181 is used here.

The op-amp reference voltage uses a resistor divider and a voltage follower to reduce impedance. The reference voltage is 1.65V, which meets the voltage bias requirements for bidirectional current sampling. OPA333 or OPA348 can be used; OPA348 is cheaper.

Originally designed on a square board, it was later changed to a round board, and many layouts were directly copied without modification, so it looks a bit strange, but it works.
Only two op-amps need to be soldered: the U-phase and V-phase; the W-phase (within the red box) can be left unsoldered.

The
firmware is modified from Bilibili UP: 会飞的车_S and group owner: 小孩可吊了. The modifications are as follows:
The original software-triggered current sampling in the timer update interrupt has been changed to timer channel 4 output OC4REF triggering AD sampling. ADC1 and ADC2 injection groups are used to sample the current of the U-phase and V-phase respectively, and a rule group is used to sample the power supply voltage.
CAN control instructions have been added. The
FreeRTOS
GIT repository address has been added (final version not yet pushed, still being modified).