Advertisement
Guest User

racemode/acro first success w stock tx 04feb2018 175105

a guest
Feb 4th, 2018
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.75 KB | None | 0 0
  1.  
  2. #include "defines.h"
  3. #include "hardware.h"
  4.  
  5. // pids in pid.c
  6. // NotFastEnuf Note: My personal rates and expo are loaded so that you do not have to do anything in the transmitter
  7. // rate in deg/sec
  8. // for acro mode
  9. #define MAX_RATE 360.0
  10. #define MAX_RATEYAW 360.0
  11.  
  12. // max angle for level mode
  13. #define MAX_ANGLE_HI 70.0f
  14.  
  15. #define LOW_RATES_MULTI 0.30f // 0.01f = 1%, 0.5f = 50%, 1.0f = 100%
  16.  
  17. // disable inbuilt expo functions
  18. //#define DISABLE_EXPO
  19.  
  20. // use if your tx has no expo function
  21. // also comment out DISABLE_EXPO to use
  22. // -1 to 1 , 0 = no exp
  23. // positive = less sensitive near center
  24. //#define EXPO_XY 0.8
  25. //#define EXPO_YAW 0.6
  26. #define EXPO_XY 0.4
  27. #define EXPO_YAW 0.8
  28.  
  29.  
  30. // battery saver
  31. // do not start software if battery is too low
  32. // flashes 2 times repeatedly at startup
  33. #define STOP_LOWBATTERY
  34.  
  35. // under this voltage the software will not start
  36. // if STOP_LOWBATTERY is defined above
  37. #define STOP_LOWBATTERY_TRESH 3.3
  38.  
  39. // voltage to start warning
  40. // volts
  41. #define VBATTLOW 3.5
  42.  
  43. // lvc starts flashing under this raw value regardless of throttle
  44. #define VBATTLOW_MIN 2.7
  45. // compensation for battery voltage vs throttle drop
  46. // increase if battery low comes on at max throttle
  47. // decrease if battery low warning goes away at high throttle
  48. // in volts
  49. #define VDROP_FACTOR 0.7
  50.  
  51. //#define AUTO_VDROP_FACTOR
  52.  
  53. // voltage hysteresys
  54. // in volts
  55. #define HYST 0.10
  56.  
  57.  
  58.  
  59. // lower throttle when battery below treshold
  60. // NotFastEnuf Note: I commented out the line below to turn off a forced landing on low voltage. I am a battery abuser
  61. // and feel that only toys tell you when to land. Uncomment if you prefer to have the features below adjust a forced
  62. // landing on low battery based on the settings you choose.
  63. #define LVC_LOWER_THROTTLE
  64. #define LVC_LOWER_THROTTLE_VOLTAGE 3.40
  65. #define LVC_LOWER_THROTTLE_VOLTAGE_RAW 2.80
  66. #define LVC_LOWER_THROTTLE_KP 3.0
  67.  
  68.  
  69.  
  70. // NotFastEnuf Note: I am now using the weakest and fastest hardware filtering of the gyro signal to reduce latency
  71. // and further clean the signal with software filtering.
  72. // Gyro LPF filter frequency
  73. // gyro filter 0 = 250hz delay 0.97mS
  74. // gyro filter 1 = 184hz delay 2.9mS
  75. // gyro filter 2 = 92hz delay 3.9mS
  76. // gyro filter 3 = 41hz delay 5.9mS (Default)
  77. // gyro filter 4 = 20hz
  78. // gyro filter 5 = 10hz
  79. // gyro filter 6 = 5hz
  80. // gyro filter 7 = 3600hz delay 0.17mS
  81. #define GYRO_LOW_PASS_FILTER 3
  82.  
  83. // NotFastEnuf Note: I selected software filtering 2nd order 43hz as all true motion occures below this point and is is a strong filter
  84. // with reasonable latency when paired with minimal hardware filtering. The result is reduced latency over defaults
  85. // while maintaining strong resistance to vibration induced negative flight behaviours.
  86. // software gyro lpf ( iir )
  87. // set only one below
  88. //#define SOFT_LPF_1ST_023HZ
  89. //#define SOFT_LPF_1ST_043HZ
  90. //#define SOFT_LPF_1ST_100HZ
  91. //#define SOFT_LPF_2ND_043HZ
  92. #define SOFT_LPF_2ND_088HZ
  93. //#define SOFT_LPF_4TH_088HZ
  94. //#define SOFT_LPF_4TH_160HZ
  95. //#define SOFT_LPF_4TH_250HZ
  96. //#define SOFT_LPF_NONE
  97.  
  98.  
  99.  
  100.  
  101. // switch function selection
  102.  
  103. // H8 protocol channels
  104. // CH_FLIP - flip, CH_HEADFREE - headfree, CH_RTH - headingreturn
  105. // CH_EXPERT , CH_INV (inv h101 tx)
  106. // CH_RLL_TRIM , CH_PIT_TRIM - trim buttons pitch, roll
  107.  
  108. // cg023 protocol chanels
  109. // CH_CG023_FLIP , CH_CG023_VIDEO , CH_CG023_STILL , CH_CG023_LED
  110.  
  111. // H7 channels
  112. // CH_H7_FLIP , CH_H7_VIDEO , CH_H7_FS
  113.  
  114. // CX10
  115. // CH_CX10_CH0 (unknown) , CH_CX10_CH2 ( rates mid)
  116.  
  117. // DEVO channels (bayang protocol)
  118. // DEVO_CHAN_5 - DEVO_CHAN_10
  119.  
  120. // Multiprotocol can use MULTI_CHAN_5 - MULTI_CHAN_10 (bayang protocol)
  121.  
  122. // CH_ON - on always ( all protocols)
  123. // CH_OFF - off always ( all protocols)
  124.  
  125. #define HEADLESSMODE CH_OFF
  126.  
  127. // rates / expert mode
  128. #define RATES CH_EXPERT
  129.  
  130. //#define LEVELMODE DEVO_CHAN_5 // for use with devo transmitter
  131. #define LEVELMODE CH_AUX1
  132.  
  133. //#define LEDS_ON DEVO_CHAN_7 // for use with devo transmitter
  134. //#define LEDS_ON CH_ON // LEDs ON
  135. #define LEDS_ON CH_OFF // LEDs OFF
  136.  
  137. // switch for fpv / other, requires fet
  138. // comment out to disable
  139. //#define FPV_ON CH_ON
  140.  
  141. // aux1 channel starts on if this is defined, otherwise off.
  142. #define AUX1_START_ON
  143.  
  144. // improves reception and enables trims if used
  145. // trims are incompatible with DEVO TX when used
  146. //#define USE_STOCK_TX
  147.  
  148. // NotFastEnuf Note: automatically remove center bias ( needs throttle off for 1 second - does not work on devo )
  149. //#define STOCK_TX_AUTOCENTER
  150.  
  151. // NotFastEnuf Note: a deadband has been added for transmitter sticks that don't perfectly center - this value equates to a percentage of stick travel
  152. // for example .01f is 1% of stick range - comment out to disable if not needed
  153. #define STICKS_DEADBAND .01f
  154.  
  155. // Gestures enable ( gestures 1 = acc only)
  156. //#define GESTURES1_ENABLE
  157. #define GESTURES2_ENABLE
  158.  
  159. // enable motor filter
  160. // hanning 3 sample fir filter
  161. #define MOTOR_FILTER
  162.  
  163. // clip feedforward attempts to resolve issues that occur near full throttle
  164. //#define CLIP_FF
  165.  
  166. // pwm frequency for motor control
  167. // a higher frequency makes the motors more linear
  168. // in Hz
  169. #define PWMFREQ 24000
  170.  
  171. // motor curve to use
  172. // the pwm frequency has to be set independently
  173. // 720motors - use 8khz and curve none.
  174. //NotFastEnuf Note: I feel like the e011 works best on 8.5mm 32khz curve.
  175. // If you have any hover or mid throttle instabilities try different curves - this affects the strength of the corrections that
  176. // the pid controler makes to the motors across the throttle range - it is completely seperate from actual pwm frequency.
  177. // Actual motor thrust is not linear so its important to find a curve that matches the motors' actual performance.
  178. // Custom motor curve has now also been added - this is an exponential curve adjustable up to 1 being straight linear.
  179. //#define MOTOR_CURVE_NONE
  180. //#define MOTOR_CURVE_6MM_490HZ
  181. //#define MOTOR_CURVE_85MM_8KHZ
  182. //#define MOTOR_CURVE_85MM_32KHZ
  183. //#define BOLDCLASH_716MM_8K
  184. #define BOLDCLASH_716MM_24K
  185. //#define CUSTOM_MOTOR_CURVE .3
  186.  
  187. #define THROTTLE_TRANSIENT_COMPENSATION
  188.  
  189. // lost quad beeps using motors (30 sec timeout)
  190. #define MOTOR_BEEPS
  191.  
  192. // throttle angle compensation in level mode
  193. // comment out to disable
  194. //#define AUTO_THROTTLE
  195.  
  196. // enable auto lower throttle near max throttle to keep control
  197. // comment out to disable
  198. #define MIX_LOWER_THROTTLE
  199. //NotFastEnuf Note: adjust the percentage below to compensate for any thrust imbalances
  200. // for example - if you punch the throttle and the craft does not hold it attitude well (don't raise I gain - its high enough already)
  201. // the lower you can keep this - the less top end performance you will lose
  202. #define MIX_THROTTLE_REDUCTION_PERCENT 10
  203. //#define MIX_INCREASE_THROTTLE
  204.  
  205. // Radio protocol selection
  206. // select only one
  207. //#define RX_CG023_PROTOCOL
  208. //#define RX_H7_PROTOCOL
  209. #define RX_BAYANG_PROTOCOL
  210. //#define RX_BAYANG_PROTOCOL_TELEMETRY
  211. //#define RX_BAYANG_PROTOCOL_BLE_BEACON
  212. //#define RX_BAYANG_BLE_APP // for use with telemetry app, for monitoring PIDs and battery
  213. //#define RX_CX10BLUE_PROTOCOL
  214.  
  215. // 0 - 7 - power for telemetry
  216. #define TX_POWER 0
  217.  
  218. // 0 - 7 - power for app
  219. //#define TX_POWER_GENERAL 4 // enable this when using BLE_APP for telemetry. Perhaps set higher than 4. Touch antenna to give it signal, or touch antenna to metal to extend it to connect to app, or set quad directly on phone.
  220.  
  221. // Flash saving features
  222. #define DISABLE_HEADLESS
  223. #define DISABLE_FLIP_SEQUENCER
  224.  
  225. // led brightness in-flight ( solid lights only)
  226. // 0- 15 range
  227. #define LED_BRIGHTNESS 15
  228.  
  229.  
  230. // external buzzer - pins in hardware.h
  231. //#define BUZZER_ENABLE
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240. //##################################
  241. // debug / other things
  242. // this should not be usually changed
  243.  
  244.  
  245.  
  246. // enable serial driver ( pin SWCLK after calibration)
  247. // WILL DISABLE PROGRAMMING AFTER GYRO CALIBRATION - 2 - 3 seconds after powerup)
  248. //#define SERIAL_ENABLE
  249. // enable some serial info output
  250. //#define SERIAL_INFO
  251.  
  252.  
  253. // level mode "manual" trims ( in degrees)
  254. // pitch positive forward
  255. // roll positive right
  256. #define TRIM_PITCH 0.0
  257. #define TRIM_ROLL 0.0
  258.  
  259. // disable motors for testing
  260. //#define NOMOTORS
  261.  
  262. // throttle direct to motors for thrust measure
  263. // #define MOTORS_TO_THROTTLE
  264.  
  265. // loop time in uS
  266. // this affects soft gyro lpf frequency if used
  267. #define LOOPTIME 1000
  268.  
  269. // failsafe time in uS
  270. #define FAILSAFETIME 1000000 // one second
  271.  
  272. // max rate used by level pid ( limit )
  273. #define LEVEL_MAX_RATE 360
  274.  
  275. // invert yaw pid for hubsan motors
  276. //#define INVERT_YAW_PID
  277.  
  278. // debug things ( debug struct and other)
  279. //#define DEBUG
  280.  
  281. // rxdebug structure
  282. //#define RXDEBUG
  283.  
  284. // enable motors if pitch / roll controls off center (at zero throttle)
  285. // possible values: 0 / 1
  286. // use in acro build only
  287. #define ENABLESTIX 0
  288. #define ENABLESTIX_TRESHOLD 0.3
  289. #define ENABLESTIX_TIMEOUT 1e6
  290.  
  291. // overclock to 64Mhz
  292. //#define ENABLE_OVERCLOCK
  293.  
  294.  
  295. // limit minimum motor output to a value (0.0 - 1.0)
  296. //#define MOTOR_MIN_ENABLE
  297. #define MOTOR_MIN_VALUE 0.02
  298.  
  299. // limit max motor output to a value (0.0 - 1.0)
  300. //#define MOTOR_MAX_ENABLE
  301. #define MOTOR_MAX_VALUE 1.0
  302.  
  303.  
  304.  
  305.  
  306. #pragma diag_warning 1035 , 177 , 4017
  307. #pragma diag_error 260
  308.  
  309. //--fpmode=fast
  310.  
  311.  
  312.  
  313.  
  314.  
  315. // define logic - do not change
  316. ///////////////
  317.  
  318. // used for pwm calculations
  319. #ifdef ENABLE_OVERCLOCK
  320. #define SYS_CLOCK_FREQ_HZ 64000000
  321. #else
  322. #define SYS_CLOCK_FREQ_HZ 48000000
  323. #endif
  324.  
  325.  
  326.  
  327. #ifdef MOTOR_BEEPS
  328. #ifdef USE_ESC_DRIVER
  329. #warning "MOTOR BEEPS_WORKS WITH BRUSHED MOTORS ONLY"
  330. #endif
  331. #endif
  332.  
  333.  
  334. //needed for rssi
  335. //#ifdef OSD_LTM_PROTOCOL
  336. //#define RXDEBUG
  337. //#endif
  338.  
  339.  
  340. // for the ble beacon to work after in-flight reset
  341. #ifdef RX_BAYANG_PROTOCOL_BLE_BEACON
  342. #undef STOP_LOWBATTERY
  343. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement