You are on page 1of 37

Machine Translated by Google

Mr. Deng
///
Machine Translated by Google

CONTENT
Table of contents
Machine Translated by Google

I. Overview Deng FOC driver supports driving high-current motors, and can

realize FOC position, speed and torque closed-loop control

system.
Deng FOC is a highly integrated FOC driver for three-phase brushless DC

motors and permanent magnet synchronous motors.

The encoder supports ABZ mode and SPI mode

(onboard), and capable of real-time detection of drive temperature.

Deng FOC reserves a variety of interfaces, including USB,

CAN, UART and FPC serial ports (can realize screen display or

wireless control), so that everyone can develop freely as much as

possible .

More importantly, we also further reduce costs,

Committed to creating the most cost-effective, high-performance

Based on the powerful and stable open source project ODrive, FOC motor driver that everyone can play together !

We further optimize the circuit, reduce the volume, optimize the interface,

Improve the overall scalability of the drive.

01 02
Machine Translated by Google

2. Introduction

Input voltage 12V-24V

Working current 30A

peak current 50A

Supported motor types DC brushless motor

size 42mm*42mm

braking method power dissipation resistor

ab

Onboard encoder type AS5047P

Support encoder signal ABI SPI PWM HALL

USB CAN UART Step/Dir


Communication Interface

analog input

SWD program download/debugging

other Power indicator VCC

DRV fault status indication (nFault )

03 04
Machine Translated by Google

Among them, the 2*7P GPIO pins of ÿ are shown as follows:

For encoders, Deng FOC is available in two models, available at

Pin1 Pin3 Pin5 Pin7 Taobao page to buy.

UART.TX digital input


digital input
step PWM input

Pin2 Pin4 Pin6 Pin8

UART.RX digital input

Dir PWM input

DIO 3 A3 ///
SWDIO Digital 3.3V Analog 3.3V

CLK G 5

SWCLK GND 5V

05 06
Machine Translated by Google

///

07 08
Machine Translated by Google

3. Check

Each Deng FOC has undergone careful visual inspection and routine testing before

delivery, so generally there will be no problems.

However, it is inevitable that damage may occur during packaging and transportation.

Therefore, it is recommended to conduct a general inspection after receiving it before powering on.
///

[Pre-use inspection] After the completion, you can start to prepare

The hardware described in this article performs the first power-up test.

///

09 10
Machine Translated by Google

first step

hardware list
Connect the Type-C data cable, the blue light (power indicator

light) and red light (DRV fault indicator light) on the board
ÿ Deng FOC
Both light up.

ÿ 12V-24V DC DC power supply

ÿ Type-C data cable (pay attention to distinguish

data cable and charging cable)

ÿ 1.14 inch LCD display (optional)

ÿ Dissipating resistor (optional)

11 12
Machine Translated by Google

second step
The screen details are as follows:

If the screen is selected, on the FPC connector on the back of the driver board

Connect screen. Gently press the black locks on both sides of the FPC connector

Pull it out, insert the screen cable according to the direction of the figure below, make sure

After the gold finger is fully inserted into the connector, press the lock into the connector

Connector.

Information ÿ status ÿ Voltage

displayed
ÿ mode ÿ Current
on the screen:

ÿ Moment ÿ MOS temperature

ÿ current q/d ÿ speed ÿ current value

ÿ Target value

ÿ location

13 14
Machine Translated by Google

4. Environment Configuration

first step

Connect to the DC_BUS power supply ( insert


Odrivetool is a python module that can be used to configure and debug odrive and Deng
into the XT30 interface first, then turn on

FOC. Before using it, you need to configure the python environment first.
power switch), the red light goes out.

second step

Check the output 5V of the voltage regulator circuit, and the digital power supply 3.3V

and analog power supply 3.3V If it is already installed, you can skip this step. We recommend using

anaconda, because it contains many tools, and


Using virtual environment configuration will not mess up the original environment.

The following takes installing anaconda as an example:

15 16
Machine Translated by Google

A Download anaconda official website URL: C pay attention to uncheck "Add Anaconda to

my PATH environment Variable",


https://www.anaconda.com/products/
After the installation is complete, configure it manually.
individual , choose the version that suits you. here

The choice is 64-Bit Graphical Installer

(477MB)

B chooses Ann

Installation path:

Not finished, continued on next page...

17 18
Machine Translated by Google

D After the installation is complete, find and open it on the start interface

Anaconda Prompt (Anaconda3), enter "conda info" to verify

whether the installation is successful.

Control Panel -> System and Security -> System -> Advanced System Settings

Settings -> Environment Variables -> User Variables -> Add in PATH

The Scripts folder of the anaconda installation directory. Check the path where

you installed anaconda and find the Scripts folder. My path here is (anaconda
EConfigure environment variables.
installation path)\Scripts.

See right page for details

19 20
Machine Translated by Google

B Activate the newly created environment

A opens the command line cmd and creates a virtual environment:


conda activate python39

conda create -n python39 python=3.9

C install odrivetool

pip install odrive==0.5.1.post0

twenty one twenty two


Machine Translated by Google

D Input odrivetool to test whether the installation is successful.

A run zadig-2.5 with administrator privileges


EIf the following error occurs:

B pops up an update reminder, select no (do not update)

implement:

pip install pywin32==225

twenty three twenty four


Machine Translated by Google

C Select List All Devices in Options ESelect the up and down arrows, select libusb-win32(v

1.2.6.0), click Repalce Driver

D drop-down menu, select Odrive 3.5 Native F Wait for the driver replacement to complete

Interface (Interface 2)

25 26
Machine Translated by Google

G When done, close the Zadig window C connects odrivetool in Python39 environment, enter

the command: odrivetool

D appears "Connected to ODrive xx as

odrv0", means the connection is successful. xx is

Motherboard serial number for Odrive

A is plugged into the USB, the blue light on the board is on

B activation environment (Python39)

27 28
Machine Translated by Google

5. Start using

Glue the magnet on the motor shaft: (the magnet must be a radial magnet and it ,

is attached with the board)


hardware list

ÿ Deng FOC

ÿ Motor

ÿ ABI encoder (with onboard encoder

type ignored)

ÿ 12V-24V DC power supply


ÿIf you are using the on-board encoder type, fix the DengFOC board

and motor so that the encoder on the back of the DengFOC is aligned
ÿ Type-C data cable

with the magnet, with an interval of about 1-3mm.


ÿ 1.14 inch LCD display (optional)
ÿIf the external encoder type is used, the fixed encoder

ÿ Dissipating resistor (optional) module and motor, align the encoder chip to the magnet, and

The sample distance is about 1-3mm.

29 30
Machine Translated by Google

Connect the USB, motor and power supply. The picture below shows the board Connect the computer with USB (the power can not be turned on first, just

The connection diagram of the load-encoder type. model in the picture connect the USB), activate the odrivetool where

It can be downloaded and printed in the after-sales group. Conda environment, enter "odrivetool". Appear

Tips for a successful connection:

It is recommended to clear the existing configuration before starting a new configuration, in

Execute commands on odrivetool:

odrv0.erase_configuration()

31 32
Machine Translated by Google

///
Deng FOC has prepared a python program that can

key to configure parameters and calibrate. at the beginning of the program

And defined the required basic parameters according to the actual situation

After modification, all parameters can be configured after running, and

Calibrate.

For different motors, it is mainly necessary to set the dissipation resistor

value, brake return current value, the number of pole pairs of the motor,

KV value and encoder position reading mode, CPR

value (for the time being, only the ABI mode of AS5047P is supported

mode and SPI mode). For other parameters, please refer to

Section 5.2 and Chapter 6. bit set by the parameter in the program

Set as shown on the right: /// ///

33 34
Machine Translated by Google

After setting the required parameters, we can set the

The motor has been parameterized and calibrated.

A Activate the installation of odrive in 4.1 in the terminal

python environment

B runs in the directory where the python program is located

program

In C ABI mode, follow the prompts to configure parameters

with calibration, as shown on the right

35 36
Machine Translated by Google

D for on-board encoder type: due to ODrive Configure the parameters first, but do not calibrate the motor,

SPI encoder support is a bit problematic, if Encoder and enter closed-loop mode, then save the settings,

If you need to use the SPI mode of AS5047P, you need reboot.

To follow these steps:

Step 2: Execute the program again


Step 1: Execute the program

Instead of configuring the parameters again, a calibration step is performed.

37 38
Machine Translated by Google

EIf an error occurs during parameter setting, the program

It will stop the operation and print out the error reason, as shown below

When the number of pole pairs is not set correctly, resulting in encoder calibration

error.
Modify the following parameters according to the actual situation (the specific parameters say

You can read Chapter 6)

Modify specific parameters according to the motor used. by

SUNNYSKY V4008 KV380 motor as an example,

The motor parameters are:

39 40
Machine Translated by Google

Then the corresponding parameters set in the configuration program are:

Since Deng FOC's on-board encoder model is AS5047P, the ABI mode and SPI mode of

AS5047P are taken as an example to introduce

Describes the configuration parameters.

41 42
Machine Translated by Google

Also, since the external encoder only supports the ABI


In the controller settings, first set the
mode, so if you need to configure other encoders,
Basic parameters:
You can also use the above "5047_ABI" to configure, and modify the

corresponding cpr and other parameters.

It should be noted that the AS5047P-ABI module

The motion calibration must be performed each time the power is turned on, and the use of

Deng FOC can realize the speed/position/torque motion control of the motor,
The advantage of the AS5047P-SPI is that it can be selected as long as the
and each motion control supports multiple inputs

Once the encoder is calibrated, it is not necessary to enter the subsequent power-on
Modes such as direct input, climb mode, etc. each model

Line encoder motion calibration, shortened calibration time,


The formula will have corresponding parameter configuration, such as the position of the trapezoidal track

Avoid the influence of calibration movement on other components. but make


In the setting mode, the speed limit of the trapezoidal trajectory needs to be set,

Using AS5047P-SPI will be more error-prone.


Acceleration and deceleration limits of trapezoidal trajectory, etc.
///

43 44
Machine Translated by Google

The calibration procedure consists of calibration, programming of the motors performed separately
ÿFor convenience, the program has set 6 modes to

Configure, including: Encoder calibration, and motor position closed-loop test, as follows:

0: speed direct mode

1: speed climbing mode

2: Position direct mode

3: Position trapezoidal trajectory mode

The calibration program also saves a different encoding by default


4: Moment direct mode
Different boot processes in device read mode.

5: Torque climb mode

When the encoder reading mode is ABI mode, the encoder must be

calibrated when the power is turned on, so the set

The preset power-on mode is motor pre-calibration (that is, there is


The one-key configuration and calibration procedure already includes the calibration of the motor

no "beep"), and the encoder is calibrated after power-on (that is,


standard procedure. When using a certain motor for the first time or clear
After power-on calibration, the motor will rotate back and forth 0), and then
After configuration, calibration must be performed.

Then enter the position closed loop mode.

45 46
Machine Translated by Google

When the encoder reading mode is SPI absolute encoder mode,

Once calibrated for the first use, subsequent Set position directly or trapezoidal track position mode, run with one key

Encoder recalibration is no longer required, so the designed After configuring the program and calibrating the motor, open in conda

Open odrivetool, enter


The power-on mode is to power on and calibrate the motor (that is,

"beep" ), pre-calibrate the encoder (that is, it will not rotate back and odrv0.axis0.controller.input_pos = [position target value]

forth ), and then enter the position closed-loop mode.


Realize position control while seeing real-time changes on the screen.

Set the torque direct or torque climbing mode, and run one-key configuration

After setting up the program and calibrating the motor, open odrivetool in

Set the speed direct or speed ramp mode, run the one-key configuration conda , enter

program and calibrate the motor, open in conda


odrv0.axis0.controller.input_torque = [position target value]
odrivetool, enter
Realize torque control and see real-time changes on the screen at the same time.
odrv0.axis0.controller.input_vel = [velocity target value]

Realize speed control, and at the same time, real-time changes can be seen on the screen.

47 48
Machine Translated by Google

6. Parameter description If you don't want to use it, just keep it as the default value. in addition

Because there may also be some resistance in the wiring and terminals,

So if you have any problems with the brakes, try turning the
Deng FOC can use ODrive Tool to
This parameter increases by 0.05ÿ.
axis0 for parameter configuration.

odrv0.config.dc_max_positive_current[A]

odrv0.config.enable_brake_resistor

odrv0.config.dc_max_negative_current[A]
If a dissipative resistor is to be used, set it to

True. If you use battery power, you generally don't need to set it. That is, the maximum current value that the power supply can sink.

Usually a negative value. The default conservative setting is 10mA.

If it occurs in the case of using a power resistor

DC_BUS_OVER_REGEN_CURRENT error, just increase


odrv0.config.brake_resistance [ÿ]

this parameter slightly.

49 50
Machine Translated by Google

And when the power resistor is not used, it is necessary to return the current to the battery

source, set this parameter to the safety of the power supply

In the whole range, this parameter should be higher than the electric

Machine current limit + current limit margin. odrv0.axis0.motor.config.pole_pairs

The number of poles of the motor is divided by 2.

odrv0.config.dc_bus_undervoltage_trip_level [V]

odrv0.config.dc_bus_overvoltage_trip_level [V] odrv0.axis0.motor.config.motor_type

Deng FOC supports a voltage range of 12-24V, and it is recommended


Two types are currently supported:

to set it to 26V.
ÿHigh current motor

MOTOR_TYPE_HIGH_CURRENT ÿGimbal motor

odrv0.config.max_regen_current[A]
MOTOR_TYPE_GIMBAL

If a DC stabilized voltage source is used, it does not have the ability to recover electric energy,
Note: Do not select on non-gimbal motors

It is configured as 0. If it is battery powered, it can be


MOTOR_TYPE_GIMBAL, which may cause the motor or Deng FOC to

The backflow current that the battery actually withstands is set. higher than the
overheat.

The return current of the parameter will be dissipated by the dissipation resistor.

51 52
Machine Translated by Google

Choice of motor type: For the sake of safety, you can start to set the current of 10A

ÿIf the current noise of 100mA is harmful to the motor Limits to ensure stable operation of Deng FOC. After the configuration is

completed later, modify the appropriate motor current limit. (Note: Motor
If it is considered "small", then you can choose a high-current motor
current and power supply current are not the same thing, simply

ÿIf the current noise of 100mA is considered "big" for the motor ,
Said that the higher the speed of the motor, the supply current and the motor current will be

and the motor speed does not need to be very high,


closer).

If the internal resistance of the motor is greater than 1ÿ, choose the gimbal motor

odrv0.axis0.motor.config.calibration_current [A]

odrv0.axis0.motor.config.torque_constant Sets the maximum calibration current. If the motor is under load, set

Too small motor is not strong enough to rotate and calibrate, you need to increase the calibration
Usually set to 8.27/KV value, which is every 1A current flows to
quasi-current for complete and correct motor calibration.
The ratio of the torque produced by the motor. If you want to take current A

To set the moment in units, set this parameter to 1.

odrv0.axis0.motor.config.resistance_calib_max_voltage[V]

The phase resistance of the motor is small, if this parameter is set too high, it will cause over-current protection

odrv0.axis0.motor.config.current_lim[A].
mistake. Specifically, it can be roughly set by Ohm's law.

53 54
Machine Translated by Google

The ABI mode of the AMS5047P and the SPI mode of the
odrv0.axis0.controller.config.vel_limit [turn/s].

settings to illustrate.
As the name suggests, it is used to limit the speed of the motor.

instruction ABI mode SPI mode

coding
odrv0.axis0.en
ENCODER_MODE MODE_SPI_
odrv0.axis0.motor.config.requested_current_range[A] coder.config.mode
Devices
_INCREMENTAL ABS_AMS
type

coding
odrv0.axis0.en

device
coder.config.c pr 4000 16384

CPR

SPI
odrv0.axis0.en
model coder.config.a
bs_spi_cs_gpio_pin 8
CS

pin

odrv0.axis0.en

bandwidth
coder.config.b 3000
andwidth

55 56
Machine Translated by Google

There are many input modes, and the commonly used input modes are listed below.

And the parameters that indicate that each input mode needs to be set accordingly:

ÿ Close input - INPUT_MODE_INACTIVE ÿ Direct control


odrv0.axis0.controller.config.control_mode
- INPUT_MODE_PASSTHROUGH
Common control modes include:

In this input mode, according to the set control mode


ÿTorque control
control_mode to control the motor, the command includes
CONTROL_MODE_TORQUE_CONTROL
input_pos/input_vel/input_torque, the motor runs directly to the target
ÿSpeed Control
value after the command is input.
CONTROL_MODE_VELOCITY_CONTROL

ÿPosition Control ÿ Velocity Ramp - INPUT_MODE_VEL_RAMP

CONTROL_MODE_POSITION_CONTROL
In this input mode, the drive needs to be in speed control mode

down, and will gradually climb/fall from the current speed value to the

target speed value input to input_vel. In this mode, you need to

odrv0.axis0.controller.config.control_mode configure

57 58
Machine Translated by Google

ÿ rate of climb
In this mode, you need to configure
odrv0.axis0.controller.config.vel_ramp_rate[turn/sec]
ÿ Speed limitation under trapezoidal trajectory
ÿ Load inertia
odrv0.axis0.trap_traj.config.vel_limit
odrv0.axis0.controller.config.inertia[Nm/(turn/s²)]

ÿ Acceleration limitation on trapezoidal trajectory

ÿ Trapezoid Trajectory - INPUT_MODE_TRAP_TRAJ


odrv0.axis0.trap_traj.config.accel_limit

In this input mode, the drive needs to be in the position control mode ÿ Acceleration limitation on trapezoidal trajectory

In the formula, the target position value is input through input_pos, and the motor reaches odrv0.axis0.trap_traj.config.dccel_limit

the set position according to acceleration-constant speed-deceleration, that is, the speed

ÿ Torque ramp - INPUT_MODE_TORQUE_RAMP


The trajectory of the degree change is trapezoidal, and the position change is close to the curve.

In this input mode, the driver needs to be in the torque control mode,

and will gradually climb/fall from the current torque value to the input to

The target velocity value of input_tor. In this mode, the required

configuration

ÿ Moment rate of climb

odrv0.axis0.controller.config.torque_ramp_rate

59 60
Machine Translated by Google

7. Common problems and their solutions

ÿ Speed loop gain

odrv0.axis0.controller.config.vel_gain

ÿ Speed loop integral

odrv0.axis0.controller.config.vel_integrator_gain

ÿ Position loop gain

odrv0.axis0.controller.config.pos_gain

ÿ Position loop integral

odrv0.axis0.controller.config.pos_integrator_gain

61 62
Machine Translated by Google

(2) If there is no problem, turn off the power and measure whether the lower tube DS is on.

If it is turned on, the problem is that the lower tube of the power dissipation circuit is damaged

(3) If there is no problem, remove the two MOS tubes of the dissipative circuit. If it still flashes

after power on, the problem is that the inverter circuit is faulty. If

If it is no longer flashing, the problem is a power dissipation circuit failure

(1) LM5109 damaged


ÿ If it is still flashing, remove the inverter circuit A/B/C three by group

(2) Short circuit between AUX_H and AUX_L


Phase the upper and lower tubes until no longer flashing, replace the group

(3) The lower tube of the power dissipation circuit is damaged


MOS is enough

(4) The MOS tube of the inverter circuit is damaged


ÿ If it is no longer flashing, measure the upper and lower tubes G of the dissipation circuit at the same time

Pole signal, observe whether it will lead to simultaneous conduction of the upper and

lower tubes, or replace the dissipation circuit MOS tube, if there is simultaneous conduction

or still flashing, the problem is that the LM5109 is damaged

(1) Turn off the power to measure whether AUX_H and AUX_L are short-circuited, and
Bad, just replace the LM5109

the problem is that AUX_H and AUX_L are short-circuited

63 64
Machine Translated by Google

(1) Test whether the USB socket DP and DM are short-circuited, and test

USB socket DM and DP, DM/DP and microcontroller

The resistance between PA11/PA12 is short-circuited and the resistance is too large

If it is less than 22ÿ, the problem is the welding problem of the USB socket

False soldering of MOS G pole of inverter circuit


(2) Use an oscilloscope to observe whether the crystal oscillator starts to oscillate, if not

If a sine wave of 8MHz is observed, it is determined that the crystal oscillator is damaged.

You should try to replace the crystal oscillator, if the problem persists, you should check

Whether VCC/AVCC is 3.3V, if the voltage is normal, continue

Continue to replace the crystal oscillator

(3) Use VS code to debug, the call stack is

"MX_FREERTOS_Init" function, "construct_objects" function,

(1) Soldering problem of USB socket

(2) The CAN transceiver is damaged


"MX_CAN1_Init" function, the problem is located in CAN

(3) The crystal oscillator is damaged


The transceiver is damaged, just replace the CAN transceiver

65 66
Machine Translated by Google

(1) DRV8303 damaged

(2) The EN_GATE of DEV8303 is soldered


Poor motor contact

Measure GVDD/AVDD/DVDD to see if it Re-calibrate and code the motor by hand-compressing the connector

They are about 11V/6V/3.3V respectively, if it is close to 0, Calibration, if improved, the problem is the motor contact

Then you should check whether the EN_GATE is soldered or not. If Bad, just replace the connector or directly solder the wire

there is no soldering, you should try to replace the DRV8303 and test again

67 68
Machine Translated by Google

Check whether the three-phase line is in good contact with the board.

LP5907 damaged

"ERROR_CPR_POLEPAIRS_MISMATCH"

Use an oscilloscope to observe AVCC, if the ripple is too large, this

It is determined that the LP5907 is damaged, just replace the LP5907


(1) The number of pole pairs of the motor is set incorrectly

(2) Encoder mode or CPR setting error

(3) The SPI mode is not configured according to 5.2

(4) The motor magnet is too far away from the encoder, the required distance is 1-3mm

"ERROR_PHASE_RESISTANCE_OUT_OF_RANGE"

Check the possible causes one by one.

Generally, the wiring of the motor terminal is in poor contact.

69 70

You might also like