Thread Tools
Feb 18, 2020, 09:43 PM
Registered User
Thread OP
Cool

Introducing the Heliflight 3D (HF3D) open-source Helicopter flight controller (FBL)


I'm going to use this thread to collect my thoughts and progress reports for a new Betaflight fork intended to be used with single-rotor helicopters. I cloned the Betaflight repository at version 4.1 on 1/15/2020 and I have began optimizing the flight controller solely for line-of-sight control of collective pitch single-rotor helicopters. My goal is to create an open-source flight controller that supports hard smack 3D flying on modern electric helicopter setups.

I think that the time has come for someone to move forward with 3D helicopter flight control that utilizes the excellent framework that Betaflight has built up over the last few years. The Betaflight team has pushed the limits of supporting everything you would ever want from inputs (receiver and telemetry support) and outputs (ESC interfaces over bidirectional DSHOT w/telemetry). This will enable helicopter builds utilizing the economical and powerful F7 flight controllers and minimalist ESCs originally designed for mini-quad use.

The development work will be done on F7 boards made for Betaflight. I hope that as the project gains traction we will be able to bring FC and ESC manufacturers on-board to the idea of optimizing some of their board designs for helicopter use instead. Specific examples would be 20x20 stacks with a 2in1 ESC (one large, one small ESC to accommodate motor driven tails) with a beefy 5V-9V adjustable voltage regulator and offset servo pin headers, a FC board designed to interconnect with the ESC/servo distribution board, etc. There are already 65A standalone ESCs available designed for mini quads that have bi-directional single-wire RPM telemetry and 16kHz+ update rates (DSHOT) for improved governor response. I estimate that the cost of implementing this setup (RX+ESC+FC+BEC) on a 6S 380mm class helicopter would be $110 vs. the $280-$300 of a comparable modern FBL system with telemetry.

To simplify the codebase and reduce the potential for errors, I have begun the work of stripping out the miniquad-specific code in Betaflight and implementing helicopter specific features in their place. The helicopter-specific features will include:
  • High-speed predictive main motor governor using BlHeli32 ESCs with BiDirectional DSHOT
  • Support for motor-driven, variable pitch, and combination MD+VP tails
  • Full configuration via Transmitter telemetry (initially FrSky LUA support)
  • Configurable Bailout/Rescue function
  • Tail pre-comp for collective changes / piro compensation / collective governor boost / etc.
  • Re-work the Betaflight configurator to support the HF3D functionality as necessary
All of the great stuff that exists in Betaflight that is relevant to helicopters will remain:
  • Stabilization modes
  • 1-wire Bi-directional DSHOT w/ RPM telemetry
  • DSHOT telemetry output support
  • ESC configuration with BLHeli passthrough
  • Configuration via Transmitter telemetry
  • Blackbox logging and vibration analysis
  • Excellent RC input filtering/smoothing
  • Vibration filtering
  • 1-wire RX interface w/ telemetry (FPORT, etc.)
  • GPS Rescue could eventually work
Hopefully this project has sparked the interest of some people. As it grows I will welcome the involvement of others to add features and improve HeliFlight 3D.

Initial testing and development is being done with an OMPHOBBY M2 using a motor-driven tail since it is high-performance, fits a 20x20 controller stack nicely, and I can fly it in the front yard. Once I am happy with the state of the flight controller I will move development on to my Gaui X3 for adapting HF3D to a variable pitch tail.

The initial codebase can be found on Github at the links below:
Last edited by eqtrian; Feb 20, 2020 at 10:11 PM.
Sign up now
to remove ads between posts
Feb 18, 2020, 09:43 PM
Registered User
Thread OP
Reserved
Feb 18, 2020, 09:57 PM
Registered User
Thread OP
Here's some pictures of my OMP M2 heli with the original flight controller/ESC combo swapped out for a 20x20mm iFlight Succex-D Mini TwinG F7 flight controller and 4x 40A ESC combo. Yes, this FC was originally intended for miniquads with DJI air vtx unit. It's the best arrangement I could find for pad layout to make it compatible with 2x ESCs and 3x servos on a 20x20 board. I will probably look for a different board when I go to a variable pitch tail (4x servo outputs), but for the OMP M2 with the motor driven tail it is perfect.

I'm using an R-XSR receiver in single-wire bi-directional F.Port mode. I'm obviously only using 2 of the 4 ESCs, and both are running DSHOT 300 with single-wire bi-directional RPM telemetry back to the flight controller. The flight controller is running 8kHz on both the gyro and PID loop rate.

The OMP M2 servos are running at 400Hz PWM control from Heliflight.

Here's the link to the FC+ESC stack I'm using: https://www.iflight-rc.com/index.php...roduct_id=1060
Feb 18, 2020, 10:00 PM
Registered User
Thread OP
Update copied from the OMP M2 thread here on RCGroups:

Quote:
Hi folks, just a quick update on my custom flight controller project for the OMP M2.

I got it flying back at the end of January, but then I went on vacation for a week, came home, got a bad case of the flu for a week, and now am finally getting back after the project. After tuning the feedback loop PIDs to the limit of oscillations the tail was holding fairly well, but I wasn't really happy with the cyclic control performance. Analyzing the logs showed that the limiting factor was the 35ms system delay caused by the servo travel time and the phase delay in the rotor head. I tried a couple of interesting things to mitigate this including coding up a delay compensation block, but the obvious and final solution was just to use a big helping of feed-forward from the cyclic input commands directly to the servo output mixer. It's now flying pretty dang nice and robotic on the cyclic, much like the original M2 controller.

My next step is to begin adding code into Betaflight so that it will know what Collective Pitch is. Right now I'm just passing the collective channel directly through into the swashplate mixing. Once I start keeping track of collective inputs I can begin using that information to do pre-compensation for the tail motor control. After that I'll write a simple governor for the main motor that also uses collective pre-compensation logic.

I also tested out the self-leveling mode in Betaflight by assigning it to a button on my TX. It works nicely after a bit of tuning. I'll need to tinker with the code for the self-leveling mode to create a true "rescue" mode that ignores cyclic inputs and gives a collective punch-out after leveling the heli, but that should be pretty straightforward once I get the time to do it.

Overall I'm really pleased with the progress and hope to make a lot more headway in the next week or two.
Feb 18, 2020, 10:05 PM
Registered User
Thread OP
Here's the most recent settings diff that I was flying tonight. Note that there is some hard-coded stuff in the code currently that expects things like 8kHz loop rate, etc. It wouldn't be wise to stray too far off of the beaten path without really looking through the code first. I've tagged most of the future things to update/fix with "HF3D TODO" in the code.

Code:
# diff
###WARNING: NO CUSTOM DEFAULTS FOUND###

# version
# Betaflight / STM32F7X2 (S7X2) 4.2.0 Feb 17 2020 / 20:44:13 (82f708925) MSP API: 1.43
# manufacturer_id: IFRC   board_name: EXF722DUAL   custom defaults: NO

# start the command batch
batch start

board_name EXF722DUAL
manufacturer_id IFRC

# resources
resource MOTOR 1 C08
resource MOTOR 2 C07
resource MOTOR 3 C09
resource MOTOR 4 C06
resource SERVO 1 A01
resource SERVO 2 B10
resource SERVO 3 B11
resource SERIAL_TX 1 A09
resource SERIAL_TX 2 A02
resource SERIAL_TX 4 C10
resource SERIAL_TX 5 C12
resource SERIAL_RX 1 A10
resource SERIAL_RX 2 A03
resource SERIAL_RX 4 C11
resource SERIAL_RX 5 D02
resource LED 1 C04
resource SPI_SCK 1 A05
resource SPI_SCK 2 B13
resource SPI_SCK 3 B03
resource SPI_MISO 1 A06
resource SPI_MISO 2 B14
resource SPI_MISO 3 B04
resource SPI_MOSI 1 A07
resource SPI_MOSI 2 B15
resource SPI_MOSI 3 B05
resource ADC_BATT 1 C01
resource ADC_RSSI 1 C00
resource ADC_CURR 1 C02
resource PINIO 1 C13
resource PINIO 2 C14
resource PINIO 3 B08
resource FLASH_CS 1 B09
resource OSD_CS 1 B12
resource GYRO_EXTI 1 A08
resource GYRO_EXTI 2 B02
resource GYRO_CS 1 A15
resource GYRO_CS 2 C03

# timer
timer A01 AF1
# pin A01: TIM2 CH2 (AF1)
timer B11 AF1
# pin B11: TIM2 CH4 (AF1)
timer B10 AF1
# pin B10: TIM2 CH3 (AF1)
timer C08 AF3
# pin C08: TIM8 CH3 (AF3)
timer C06 AF3
# pin C06: TIM8 CH1 (AF3)
timer C09 AF3
# pin C09: TIM8 CH4 (AF3)
timer C07 AF3
# pin C07: TIM8 CH2 (AF3)
timer A03 AF3
# pin A03: TIM9 CH2 (AF3)
timer B06 AF2
# pin B06: TIM4 CH1 (AF2)
timer B07 AF2
# pin B07: TIM4 CH2 (AF2)
timer B01 AF2
# pin B01: TIM3 CH4 (AF2)
timer B00 AF2
# pin B00: TIM3 CH3 (AF2)

# dma
dma ADC 3 0
# ADC 3: DMA2 Stream 0 Channel 2
dma pin A01 0
# pin A01: DMA1 Stream 6 Channel 3
dma pin C08 1
# pin C08: DMA2 Stream 4 Channel 7
dma pin C06 0
# pin C06: DMA2 Stream 2 Channel 0
dma pin C09 0
# pin C09: DMA2 Stream 7 Channel 7
dma pin C07 1
# pin C07: DMA2 Stream 3 Channel 7

# mixer
mixer CUSTOMAIRPLANE
mmix 0  5.000  0.000  0.000  0.000
mmix 1  0.300  0.000  0.000  1.000

# servo
servo 2 1000 2000 1400 100 -1
servo 3 1000 2000 1600 100 -1
servo 4 1000 2000 1400 100 -1

# servo mixer
smix 0 2 8 100 0 0 100 0
smix 1 2 1 100 0 0 100 0
smix 2 3 8 100 0 0 100 0
smix 3 3 0 87 0 0 100 0
smix 4 3 1 -50 0 0 100 0
smix 5 4 8 -100 0 0 100 0
smix 6 4 0 87 0 0 100 0
smix 7 4 1 50 0 0 100 0

# feature
feature -RX_PARALLEL_PWM
feature -AIRMODE
feature -ANTI_GRAVITY
feature RX_SERIAL
feature SOFTSERIAL

# serial
serial 0 64 115200 57600 0 115200

# aux
aux 0 0 1 1700 2100 0 0
aux 1 1 3 1700 2100 0 0
aux 2 26 2 1725 2075 0 0

# rxrange
rxrange 4 232 0

# master
set yaw_spin_recovery = OFF
set gyro_to_use = BOTH
set acc_calibration = -126,-16,-56,1
set mag_bustype = NONE
set mag_i2c_device = 2
set baro_bustype = NONE
set baro_i2c_device = 2
set min_check = 1000
set max_check = 2000
set serialrx_provider = FPORT
set serialrx_inverted = ON
set serialrx_halfduplex = ON
set adc_device = 3
set blackbox_device = SPIFLASH
set dshot_idle_value = 210
set dshot_burst = ON
set dshot_bidir = ON
set motor_pwm_protocol = DSHOT600
set motor_poles = 24
set align_board_yaw = 180
set vbat_max_cell_voltage = 0
###ERROR: CORRUPTED CONFIG: vbat_max_cell_voltage = 0###
set vbat_min_cell_voltage = 0
###ERROR: CORRUPTED CONFIG: vbat_min_cell_voltage = 0###
set current_meter = ADC
set battery_meter = ADC
set ibata_scale = 100
set beeper_inversion = ON
set beeper_od = OFF
set servo_pwm_rate = 400
set pid_process_denom = 1
set runaway_takeoff_prevention = OFF
set thrust_linear = 50
set debug_mode = RPM_FILTER
set max7456_spi_bus = 2
set pinio_config = 129,1,1,1
set pinio_box = 0,255,255,255
set flash_spi_bus = 3
set gyro_1_bustype = SPI
set gyro_1_spibus = 1
set gyro_1_sensor_align = CW270
set gyro_1_align_yaw = 2700
set gyro_2_spibus = 1
set gyro_2_sensor_align = DEFAULT
set gyro_rpm_notch_min = 50
set dterm_rpm_notch_min = 50

profile 0

# profile 0
set dyn_lpf_dterm_min_hz = 45
set iterm_relax = OFF
set throttle_boost = 0
set p_pitch = 18
set i_pitch = 30
set d_pitch = 10
set f_pitch = 100
set p_roll = 18
set i_roll = 30
set d_roll = 10
set f_roll = 100
set p_yaw = 85
set i_yaw = 45
set d_yaw = 30
set f_yaw = 55
set angle_level_strength = 100
set d_min_roll = 0
set d_min_pitch = 0
set d_min_yaw = 9

rateprofile 0

# rateprofile 0
set roll_srate = 50
set pitch_srate = 50
set yaw_srate = 50
set tpa_rate = 0

# end the command batch
batch end
Feb 18, 2020, 11:27 PM
Slideways at warp speed.......
kiwi_craig's Avatar
subscribed ! top work
Feb 19, 2020, 12:57 AM
Į\_(ツ)_/Į
Dave778's Avatar
Yes, thanks for the work. I am interested in messing around with it on a 450.

I would like to get the same controller. Can you post a link? Is every F7 board the same? I am amazed https://oscarliang.com/betaflight-f7-fc/
Last edited by Dave778; Feb 19, 2020 at 01:03 AM.
Feb 19, 2020, 01:10 AM
UK 550/600 Tarot distributor
Smoggie's Avatar
Interesting!.. the controller looks much smaller and lighter than the stock OMP M2 system.
Feb 19, 2020, 05:05 AM
Registered User
this could be awesome! with a tiny whoop size board, anything from a nano cps size heli could benefit... I wonder though, will it support linear servos? 2 of the three helis I own that I think would get the largest benefit from this have linear servos and would be difficult to change to rotary...
Feb 19, 2020, 07:08 AM
Registered User
Thread OP
Quote:
Originally Posted by Dave778
Yes, thanks for the work. I am interested in messing around with it on a 450.

I would like to get the same controller. Can you post a link? Is every F7 board the same? I am amazed https://oscarliang.com/betaflight-f7-fc/
FC boards come in different sizes, with various connectors and solder pads/through holes, and different pins exposed from the F7 chip. I havenít spent any time looking for boards that will support 4 servo outputs yet. Larger boards generally have more pins broken out from the F7 chip. This is important because a single timer on the F7 can only support a single PWM frequency, and different timers are assigned to different banks of pins. It gets a bit complicated.

Honestly, at this point in time unless you have an interest in going pretty deep into embedded microcontrollers and c programming Iíd advise to wait. It will likely be a while before I move on from the M2 to other helicopters, just for the simple reason that there is a lot of work to do and the M2 is my easiest test rig to use.
Feb 19, 2020, 07:22 AM
Registered User
Thread OP
Quote:
Originally Posted by Wayne Moyer
this could be awesome! with a tiny whoop size board, anything from a nano cps size heli could benefit... I wonder though, will it support linear servos? 2 of the three helis I own that I think would get the largest benefit from this have linear servos and would be difficult to change to rotary...
Anything is possible. Just from a quick glance it looks like the linear servos use normal servo PWM inputs. Not that it matters, the FC could put out anything required with code changes.

The first challenge will be finding a FC with the right combination of brushed/brushless motor speed controllers as well as 3 solder points that can be successfully used for the 3 servo outputs considering the pin/timer needs. Someone who is really good at board design could probably just design and build an optimal board for the job if necessary.

The second challenge will be the coding required to make it work. This could be fairly minor or more involved depending on what needs to be adapted to the micro helis.

Iím unfortunately not in position of free time to support either one of those problems at the moment. My goal right now is to get the M2 flying as well as I possibly can, mostly as a proof of concept and as a platform to test various ideas to help improve control performance.
Feb 19, 2020, 03:47 PM
'n boer maak 'n plan
yufasa's Avatar
Subscribed!
Feb 19, 2020, 04:21 PM
Registered User
Quote:
Originally Posted by eqtrian
Anything is possible. Just from a quick glance it looks like the linear servos use normal servo PWM inputs. Not that it matters, the FC could put out anything required with code changes.

The first challenge will be finding a FC with the right combination of brushed/brushless motor speed controllers as well as 3 solder points that can be successfully used for the 3 servo outputs considering the pin/timer needs. Someone who is really good at board design could probably just design and build an optimal board for the job if necessary.

The second challenge will be the coding required to make it work. This could be fairly minor or more involved depending on what needs to be adapted to the micro helis.

Iím unfortunately not in position of free time to support either one of those problems at the moment. My goal right now is to get the M2 flying as well as I possibly can, mostly as a proof of concept and as a platform to test various ideas to help improve control performance.
it took me a minute (or longer) to process... you are talking about 20mmX20mm... that would fit 100 size helis, though the ESC amperage would be serious overkill... yes, it will work with linear servos... this may well be the solution to at least a pesky Blade 130S (which I believe could be easily adapted to a direct drive main and tail, essentially making a smaller, lighter M2. I will still have to wait for your testing as I am just starting to learn how to use the GUI interface for BetaFlight...
Feb 19, 2020, 08:14 PM
Registered User
Atomic Skull's Avatar
Quote:
Originally Posted by eqtrian
I'm going to use this thread to collect my thoughts and progress reports for a new Betaflight fork intended to be used with single-rotor helicopters. I cloned the Betaflight repository at version 4.1 on 1/15/2020 and I have began optimizing the flight controller solely for line-of-sight control of collective pitch single-rotor helicopters. My goal is to create an open-source flight controller that supports hard smack 3D flying on modern electric helicopter setups.

I think that the time has come for someone to move forward with 3D helicopter flight control that utilizes the excellent framework that Betaflight has built up over the last few years. The Betaflight team has pushed the limits of supporting everything you would ever want from inputs (receiver and telemetry support) and outputs (ESC interfaces over bidirectional DSHOT w/telemetry). This will enable helicopter builds utilizing the economical and powerful F7 flight controllers and minimalist ESCs originally designed for mini-quad use.

The development work will be done on F7 boards made for Betaflight. I hope that as the project gains traction we will be able to bring FC and ESC manufacturers on-board to the idea of optimizing some of their board designs for helicopter use instead. Specific examples would be 20x20 stacks with a 2in1 ESC (one large, one small ESC to accommodate motor driven tails) with a beefy 5V-9V adjustable voltage regulator and offset servo pin headers, a FC board designed to interconnect with the ESC/servo distribution board, etc. There are already 65A standalone ESCs available designed for mini quads that have bi-directional single-wire RPM telemetry and 16kHz+ update rates (DSHOT) for improved governor response. I estimate that the cost of implementing this setup (RX+ESC+FC+BEC) on a 6S 380mm class helicopter would be $110 vs. the $280-$300 of a comparable modern FBL system with telemetry.

To simplify the codebase and reduce the potential for errors, I have begun the work of stripping out the miniquad-specific code in Betaflight and implementing helicopter specific features in their place. The helicopter-specific features will include:
  • High-speed predictive main motor governor using BlHeli32 ESCs with BiDirectional DSHOT
  • Support for motor-driven, variable pitch, and combination MD+VP tails
  • Full configuration via Transmitter telemetry (initially FrSky LUA support)
  • Configurable Bailout/Rescue function
  • Tail pre-comp for collective changes / piro compensation / collective governor boost / etc.
  • Re-work the Betaflight configurator to support the HF3D functionality as necessary
All of the great stuff that exists in Betaflight that is relevant to helicopters will remain:
  • Stabilization modes
  • 1-wire Bi-directional DSHOT w/ RPM telemetry
  • DSHOT telemetry output support
  • ESC configuration with BLHeli passthrough
  • Configuration via Transmitter telemetry
  • Blackbox logging and vibration analysis
  • Excellent RC input filtering/smoothing
  • Vibration filtering
  • 1-wire RX interface w/ telemetry (FPORT, etc.)
  • GPS Rescue could eventually work
Hopefully this project has sparked the interest of some people. As it grows I will welcome the involvement of others to add features and improve HeliFlight 3D.

Initial testing and development is being done with an OMPHOBBY M2 using a motor-driven tail since it is high-performance, fits a 20x20 controller stack nicely, and I can fly it in the front yard. Once I am happy with the state of the flight controller I will move development on to my Gaui X3 for adapting HF3D to a variable pitch tail.

The initial codebase can be found on Github at the links below:
Could I also recommend support for CCPM coaxial and tandem? Collective pitch coaxial isn't as hard as it seems you basically just need to implement mixing the rudder channel output into the CCPM servos. Tandem is similar except you mix yaw into the aileron servos at the front and back with opposite mixing on each side. with Coaxial there are mixer arms on the upper rotor head that change the pitch using the rudder servo via a pushrod that runs up the center of the mainshaft and at the same time the rudder channel output is also mixed into collective such that both rotors maintain the same amount of overall collective pitch. So for example the rudder servo increases the collective on the upper head and then the rudder servo channel output from the gyro is also mixed into the collective which reduces the pitch of both the upper and lower head in the opposite direction. In this way the overall lift of the rotor system doesn't change just how much torque each rotor is exerting.

The 3DIGI supports this with a custom swash mix page and something similar could be implemented here.
Feb 20, 2020, 02:26 PM
Registered User
Hello eqtrian,

brilliant idea. I have a couple of f7 flight controlles that i could use for my modded xk k130 with direct motor drive, or to replace the omphobby m2 flybarless unit if it breaks.

I will follow this thread with interest.

Best regards


Quick Reply
Message:

Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion Brain FPV Flight Controller - Full Graphic OSD - Open Source - Made in USA - 36x36mm HeliShredder FPV Equipment 162 Nov 27, 2016 08:31 AM
Question CX 20 open source vrs non open source shane.oneill2015 Beginner Multirotor Drones 3 Apr 11, 2016 02:09 PM
Discussion Open source 3D gimbal controller software for handheld gimbal? brisk5181 Multirotor Drone Talk 0 Aug 12, 2015 11:42 AM
New Product Brain FPV Flight Controller - Full Graphic OSD - Open Source - Made in USA - 36x36mm HeliShredder Multirotor Drone Electronics 1 Jan 23, 2015 06:53 AM