#$ TITLE: Karate 'Viper Lite' Race  5"
#$ FIRMWARE_VERSION: 4.5
#$ CATEGORY: TUNE
#$ STATUS:  OFFICIAL
#$ KEYWORDS: karate, race, 5 inch, 5", sugarK, limon, ctzsnooze, KarateBrot, ultralite, viper, viper lite, bezerkrc, neuron, nano, 2024 sliders
#$ AUTHOR: sugarK

#$ PARSER: MARKED

#$ DESCRIPTION:
#$ DESCRIPTION: <img src="https://user-images.githubusercontent.com/19867640/176932353-fdc42c5e-33ae-42d7-b34c-e981b6cffa3f.png" style="max-width: 100%; margin-left: auto; margin-right: auto; display: block;"/>
#$ DESCRIPTION: <h1>Karate Viper Lite race</h1>
#$ DESCRIPTION: <br>
#$ DESCRIPTION:
#$ DESCRIPTION: This racing tune was developed from the Karate Race tune to suit my new Viper lite ultralite 5" racer project. [Viper Lite](https://rotorbuilds.com/build/29775)
#$ DESCRIPTION: The continued development comes from my new racing setup the Bezerk RC [Neuron nano](https://rotorbuilds.com/build/32174#c51556) 
#$ DESCRIPTION: <br>
#$ DESCRIPTION:
#$ DESCRIPTION: This tune should be used with 48khz PWM settings or firmware and it 'SHOULD' work with other ultralite 5" frames eg the ET-5.
#$ DESCRIPTION: From Betaflight 4.4 the tune  is slider based to make it easier to adjust for personal taste but use at your own risk.
#$ DESCRIPTION:
#$ DESCRIPTION: <br>
#$ DESCRIPTION:
#$ DESCRIPTION: ## Things to note:
#$ DESCRIPTION: - **YOU HAVE TO USE RPM FILTERING WITH THIS TUNE!** Failure to do so might result in fire 🔥
#$ DESCRIPTION: - Regarding DShot600: if your setup has errors in the motor tab using bidirectional DShot, change to **8k/4k and DShot300**
#$ DESCRIPTION: - Also this should be applied to a clean flash after you've setup your rates, swtiches, vtx tables etc.
#$ DESCRIPTION: - To test arm the quad with props on, it should **sound clean with no grinding**. If it passes that then hover test and check motor temps.
#$ DESCRIPTION: - **If anything is off, don't fly it!!**
#$ DESCRIPTION:
#$ DESCRIPTION: <br>
#$ DESCRIPTION:
#$ DESCRIPTION: ## Second note... Radio links:
#$ DESCRIPTION: 1. Make sure your radio firmware is up to date using either EdgeTX or OpenTX
#$ DESCRIPTION: 1. Make sure your **ADC Filter is OFF** in the hardware page
#$ DESCRIPTION: 1. Go to the radio (RC_LINK) presets and apply the correct setup for your system and link speed

#$ DISCUSSION: https://github.com/betaflight/firmware-presets/pull/332

#$ INCLUDE_WARNING: misc/warnings/en/rpm_filters.txt
#$ INCLUDE: presets/4.5/tune/defaults.txt
#$ INCLUDE: presets/4.5/filters/defaults.txt

# -- Gyro Lowpass Filters --
set gyro_lpf1_static_hz = 0
set gyro_lpf1_dyn_min_hz = 500
set gyro_lpf1_dyn_max_hz = 1000
set gyro_lpf1_dyn_expo = 7
set simplified_gyro_filter = OFF

# -- Gyro Dynamic Notches --
set dyn_notch_count = 2
set dyn_notch_q = 450
set dyn_notch_min_hz = 125
set dyn_notch_max_hz = 650

# -- Dterm Filtering --
set dterm_lpf1_dyn_expo = 7

# -- RPM Filtering --
set dshot_bidir = ON
set rpm_filter_fade_range_hz = 100

# -- Misc --
set yaw_spin_recovery = AUTO
set thrust_linear = 20

# -- iTerm  --
set iterm_relax_cutoff = 45

# -- PIDsum Limits --
set iterm_limit = 500
set pidsum_limit_yaw = 1000


# -- PID Values --
set simplified_pids_mode = RP
set simplified_i_gain = 115
set simplified_d_gain = 75
set simplified_pi_gain = 85
set simplified_dmax_gain = 125
set simplified_pitch_d_gain = 90
set simplified_pitch_pi_gain = 110
simplified_tuning apply

# -- Feedforward --
set feedforward_max_rate_limit = 100

# -- TPA --
set tpa_rate = 60
set tpa_breakpoint = 1250

#$ OPTION BEGIN (CHECKED): Dshot600
    set dshot_bidir = ON
    set motor_pwm_protocol = DSHOT600
#$ OPTION END

#$ OPTION BEGIN (UNCHECKED): Dshot300
    set dshot_bidir = ON
    set motor_pwm_protocol = Dshot300
#$ OPTION END

#$ OPTION BEGIN (UNCHECKED): Dynamic Idle for 4s 2850-3000kv
    #dynamic idle for 4s 2850-3000kv
    set dyn_idle_min_rpm = 50
    set dyn_idle_p_gain = 35
#$ OPTION END

#$ OPTION BEGIN (UNCHECKED): Vbat Sag Compensation
    set vbat_sag_compensation = 100
#$ OPTION END

#$ OPTION BEGIN (UNCHECKED): Bosch (BMI) gyro - EXPERIMANTAL
    set gyro_lpf1_dyn_min_hz = 0
    set gyro_lpf1_dyn_max_hz = 0
#$ OPTION END

#$ OPTION_GROUP BEGIN: Some popular RC Links

    #$ OPTION BEGIN (UNCHECKED): Tracer/ELRS 250Hz
        # Tracer/ELRS 250Hz
        
        feature RX_SERIAL
        set serialrx_provider = CRSF

        #$ INCLUDE: presets/4.3/rc_link/generic/250hz_race.txt

    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): ELRS 500Hz
        # ERLS 500Hz
        
        feature RX_SERIAL
        set serialrx_provider = CRSF

        #$ INCLUDE: presets/4.3/rc_link/generic/500hz_race.txt

    #$ OPTION END
    
    #$ OPTION BEGIN (UNCHECKED): ELRS 1000Hz
        # ELRS 1000Hz
       
        feature RX_SERIAL
        set serialrx_provider = CRSF

         #$ INCLUDE: presets/4.3/rc_link/generic/1000hz_race.txt
         
    #$ OPTION END
    
    #$ OPTION BEGIN (UNCHECKED): Ghost 250Hz
        # Ghost 250Hz
      
        feature RX_SERIAL
        set serialrx_provider = GHST

         #$ INCLUDE:presets/4.3/rc_link/generic/250hz_race.txt

    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): Ghost 500Hz
        # Ghost 500Hz
       
        feature RX_SERIAL
        set serialrx_provider = GHST

         #$ INCLUDE: presets/4.3/rc_link/generic/500hz_race.txt
         
    #$ OPTION END

    #$ OPTION BEGIN (UNCHECKED): Secret sauce stick feel 
        set feedforward_jitter_factor = 0
        
    #$ OPTION END
    
#$ OPTION_GROUP END

#$ OPTION_GROUP BEGIN: Old Spice
    #$ OPTION BEGIN (UNCHECKED): Spicy Filters
        
        # -- Gyro Lowpass Filters --
        set gyro_lpf2_static_hz = 650
        
        # -- Gyro Dynamic Notches --
        set dyn_notch_count = 1
        set dyn_notch_q = 500
        
        # -- RPM Filtering --
        set rpm_filter_harmonics = 2
        
        # -- Dterm Filtering --
        set dterm_lpf1_dyn_expo = 10
        
    #$ OPTION END
    #$ OPTION BEGIN (UNCHECKED): Spicy PIDs (not for 6s)
        
        # -- PID Values --
        set simplified_pids_mode = RP
        set simplified_master_multiplier = 110
        set simplified_i_gain = 115
        set simplified_d_gain = 75
        set simplified_pi_gain = 85
        set simplified_dmax_gain = 125
        set simplified_pitch_d_gain = 90
        set simplified_pitch_pi_gain = 110
        simplified_tuning apply
        
    #$ OPTION END

#$ OPTION_GROUP END

#$ OPTION_GROUP BEGIN: New Spice (mid 2024)
    #$ OPTION BEGIN (UNCHECKED): New Spicy Filters and Iterm
        
        # -- Gyro Lowpass Filters --
       set gyro_lpf1_dyn_min_hz = 0
        
        # -- Gyro Dynamic Notches --
        set dyn_notch_count = 1
        set dyn_notch_q = 450
        set dyn_notch_min_hz = 125
        set dyn_notch_max_hz = 650
        
        # -- RPM Filtering --
        set rpm_filter_harmonics = 3
        set rpm_filter_weights = 100,20,100
        set rpm_filter_fade_range_hz = 100
        
    #$ OPTION END
    #$ OPTION BEGIN (UNCHECKED): 4s Tune
    
        # --set profile 1 to 4s
        profile 0
        set profile_name = 4s
        
        # -- 4s PID and Filter Values --
        set simplified_pids_mode = RP
        set simplified_master_multiplier = 110
        set simplified_i_gain = 115
        set simplified_d_gain = 80
        set simplified_pi_gain = 85
        set simplified_dmax_gain = 125
        set simplified_pitch_d_gain = 90
        set simplified_dterm_filter_multiplier = 110
        simplified_tuning apply
        set yaw_lowpass_hz = 50
        
    #$ OPTION END
    #$ OPTION BEGIN (UNCHECKED): 6s Tune
    
        # --set profile 2 to 4s
        profile 1
        set profile_name = 6s
        
        # -- 6s PID and Filter Values --
        set simplified_pids_mode = RP
        set simplified_i_gain = 115
        set simplified_d_gain = 85
        set simplified_pi_gain = 85
        set simplified_dmax_gain = 125
        set simplified_pitch_d_gain = 90
        set simplified_pitch_pi_gain = 110
        set simplified_dterm_filter_multiplier = 90
        simplified_tuning apply
        set yaw_lowpass_hz = 50
        
    #$ OPTION END
#$ OPTION_GROUP END


#$ OPTION_GROUP BEGIN: Optional rates
    #$ OPTION BEGIN (UNCHECKED): sugarK's rates
        #$ INCLUDE: presets/4.3/rates/SugarK.txt
        
    #$ OPTION END
    
    #$ OPTION BEGIN (UNCHECKED): Throttle curve for 6s ultralite racer
        set thr_mid = 25
        set thr_expo = 65
        
     #$ OPTION END

#$ OPTION_GROUP END