Merge remote-tracking branch 'gitea/main'

This commit is contained in:
Lucien RENAUD 2023-01-15 20:44:04 +01:00
commit c6e1449b33
1 changed files with 10 additions and 8 deletions

View File

@ -2,8 +2,8 @@
The aim of this project is to be able to use the 3-axis DJI gimbal with a custom open source controller like [SimpleFOC](https://docs.simplefoc.com/). This high quality gimbal is very tiny and easy to find as a replacement part which makes it very suitable for DIY projects.
<img src="docs/overview.jpg" height=250>
<img src="docs/working.gif" height=250>
<img src="https://git.lurenaud.com/lurenaud/DJI-Gimbal-FOC/raw/branch/main/docs/overview.jpg" height=250>
<img src="https://git.lurenaud.com/lurenaud/DJI-Gimbal-FOC/raw/branch/main/docs/working.gif" height=250>
## Pinout identification
The Gimbal is composed of a flex PCB with a main connector and 3 smaller for each motor. The main end connector is a 40-pin mezzanine board to board connectors. In order to work easily I have designed a breakout board which open to a 2.54" header. (Kicad folder)
@ -13,7 +13,7 @@ Here is the strategy I followed to find the pinout:
2. Group remaining pins by motor with the multimeter find all the pins connected to the motor connector. (Reapeat 3 times for the other connectors)
<img src="Kicad/Breakout_DJI_Gimbal.png" height=400> <img src="docs/setup.jpg" height=400>
<img src="https://git.lurenaud.com/lurenaud/DJI-Gimbal-FOC/raw/branch/main/Kicad/Breakout_DJI_Gimbal.png" height=400> <img src="https://git.lurenaud.com/lurenaud/DJI-Gimbal-FOC/raw/branch/main/docs/setup.jpg" height=400>
### Open-loop control
@ -29,9 +29,9 @@ Connected directly to a MCU (here a STM32 Nucleo F401RE) and with the Simple FOC
## Position estimation with the integrated linear hall sensors
### 1. Setup
Each motor is composed of two linear hall sensors. (Texas Instrument DRV5053 Analog-Bipolar Hall Effect Sensor) They are placed at around 120º from each other (eyes measured) and measure the magnetic field of the rotor.
Each motor is composed of two absolute linear hall sensors. (Texas Instrument DRV5053 Analog-Bipolar Hall Effect Sensor) They are placed at around 120º from each other (eyes measured) and measure the magnetic field of the rotor.
<img src="docs/Hallmotor.jpg" height=300>
<img src="https://git.lurenaud.com/lurenaud/DJI-Gimbal-FOC/raw/branch/main/docs/Hallmotor.jpg" height=300>
They are linear sensor, the output voltage correspond to a magnetic fields, regardless of the voltage supplied. In our case the output signal is between 1V and 1.65V.
@ -40,20 +40,22 @@ They are linear sensor, the output voltage correspond to a magnetic fields, rega
These oscilloscope traces are the sensor output when rotating the rotor forth and back. (a bit less than 180º on the 3rd motor)
The channel 0 (Yellow) is the Hall 1 and the Channel 1 (Green) is the Hall 2
<img src="docs/courbes.png" height=250> <img src="docs/cosSinEncoderDiagram.png" height=250>
<img src="https://git.lurenaud.com/lurenaud/DJI-Gimbal-FOC/raw/branch/main/docs/courbes.png" height=250> <img src="https://git.lurenaud.com/lurenaud/DJI-Gimbal-FOC/raw/branch/main/docs/cosSinEncoderDiagram.png" height=250>
We can see that in the first movement (positive rotation), the green is out of phase of π/2.`
### 3. Encoding the position
1. Get the absolute angle within a period
Since the 2 signals correspond to cos and sin signals, it is possible to compute the angle inside the period using arctan2 function. However, we have more than one period, it is so necessary to increment a position.
Since the 2 signals correspond to a cos and sin signals, it is possible to compute the angle inside the period using arctan2 function. However, we have more than one period, it is so necessary to increment a position.
$$\theta= atan2(a,b)$$
2. Incremental position
To increment the position, it is necessary to start from 0 at a known postion. For that the motor is moved in open loop to one end and the position is set to 0.
Then we need to sum all the delta of movement at each measure sample.
$$\phi_t=\phi_{t-1} + (\theta_t - \theta_{t-1})mod(-\pi;\pi)$$
## Coding the solution
@ -102,4 +104,4 @@ To achieve position control it is necessary to have first, a velocity controller
However, the motors of the gimbal have hard stops and can only rotate around a half turn. It was so necessary to remove these mechanical stops. I drilled with a 1.6 mm drill the two little holes to remove it. Then the motor was able to rotate freely and PID can be tuned.
<img src="docs/drilling.jpg" height=250> <img src="docs/freeturn.gif" height=250>
<img src="https://git.lurenaud.com/lurenaud/DJI-Gimbal-FOC/raw/branch/main/docs/drilling.jpg" height=250> <img src="https://git.lurenaud.com/lurenaud/DJI-Gimbal-FOC/raw/branch/main/docs/freeturn.gif" height=250>