From 5fe9b903e26a0776fcf09b1a0bdfa5a7b3db8bf6 Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Mon, 2 Feb 2015 11:26:56 -0800 Subject: [PATCH 01/60] Create Rates Expo TPA.md --- docs/Rates Expo TPA.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 docs/Rates Expo TPA.md diff --git a/docs/Rates Expo TPA.md b/docs/Rates Expo TPA.md new file mode 100644 index 0000000000..ee2172678c --- /dev/null +++ b/docs/Rates Expo TPA.md @@ -0,0 +1,40 @@ +#Rates, Expo, & TPA + +RC Rates (on the RECEIVER tab in the GUI) and Pitch & Roll and Yaw Rates (on the PID TUNING tab of the GUI); + +What is the difference? + +* RC Rates affect the entire contorl input range. To decrease sensitivity at the center of the ranges, RC Expo can be used. +* Pitch & Roll and Yaw Rates target the endpoints of the inputs while having little or no effect on the center of the input ranges. + +##RC Rate + +RC Rate defines the sensitivity to PITCH and ROLL throughout the entire input range. +* A lower # reduces the over all responsiveness. +* A Higher # increases the over all responsiveness. + +If you feel your aircraft is too reactive to your inputs, decrease the value. If you feel it is too sluggish, increase the value. + +##RC Expo + +RC Expo defines a smoother, less sensitive, zone at the center of the PITCH and ROLL input range without affecting the ends of the inputs. +The higher the value, the less sensitive the Pitch and Roll inputs will be when in the center of their range. The lower the value, the more sensitive the Pitch and Roll inputs will be when at the center of their range. +The most sensitive at the center of the inputs is 0 Expo. + +##Pitch & Roll and Yaw Rates + +These values affect mostly the endpoints of the input. For example, If the over all control of the aircraft is good, i.e you have your RC Rates dialed in, but extreme enpoint controls need to be faster or slower, like for aerobatics, then these rates can be used to increase the response withoug effecting the center of the input ranges as much. + +##TPA and TPA Breakpoint + +An Example: With TPA = 50 (or .5 in the GUI) and tpa_breakpoint = 1500 + +At full throttle, your P value is reduced by 50% +at 3/4 throttle (say 1750), your P value is reduced by 25% (1/2 the differnce of 1500 and 2000 = 1/2 of 50% = 25%) +at half throttle (1500), your P vallue is reduced by ~0 + +So how do you use this? + +If you're getting oscillations starting at say 3/4 throttle, set tpa_breakpoint = 1750 or lower (remember, this is assuming your throttle range is 1000-2000), and then slowly increase TPA until your oscillations are gone. Usually, you will want tpa_breakpoint to start a little sooner then when your oscillations start so you'll want to experiment with the values to reduce/remove the oscillations. + +In theory, this should allow you to bump your PIDs a tiny bit more because now you can focus your PID tune to how you fly and not have to worry about bringing it down some to compensate for high throttle oscillations. From 4e6e664229f6674bd2f9b0db4bff6701378c49d6 Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Mon, 2 Feb 2015 11:30:35 -0800 Subject: [PATCH 02/60] Update Rates Expo TPA.md --- docs/Rates Expo TPA.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/Rates Expo TPA.md b/docs/Rates Expo TPA.md index ee2172678c..323d43ccad 100644 --- a/docs/Rates Expo TPA.md +++ b/docs/Rates Expo TPA.md @@ -27,6 +27,8 @@ These values affect mostly the endpoints of the input. For example, If the ove ##TPA and TPA Breakpoint +* Note that TPA is set via CLI or on the PID TUNING tab of the GUI. tpa_breakpoint is set via CLI + An Example: With TPA = 50 (or .5 in the GUI) and tpa_breakpoint = 1500 At full throttle, your P value is reduced by 50% @@ -35,6 +37,6 @@ at half throttle (1500), your P vallue is reduced by ~0 So how do you use this? -If you're getting oscillations starting at say 3/4 throttle, set tpa_breakpoint = 1750 or lower (remember, this is assuming your throttle range is 1000-2000), and then slowly increase TPA until your oscillations are gone. Usually, you will want tpa_breakpoint to start a little sooner then when your oscillations start so you'll want to experiment with the values to reduce/remove the oscillations. +If you're getting oscillations starting at say 3/4 throttle, set tpa breakpoint = 1750 or lower (remember, this is assuming your throttle range is 1000-2000), and then slowly increase TPA until your oscillations are gone. Usually, you will want tpa breakpoint to start a little sooner then when your oscillations start so you'll want to experiment with the values to reduce/remove the oscillations. In theory, this should allow you to bump your PIDs a tiny bit more because now you can focus your PID tune to how you fly and not have to worry about bringing it down some to compensate for high throttle oscillations. From 72434674ca0b0fe43563a76c8e4f4c7654958003 Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Mon, 2 Feb 2015 11:36:36 -0800 Subject: [PATCH 03/60] Update Rates Expo TPA.md --- docs/Rates Expo TPA.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/Rates Expo TPA.md b/docs/Rates Expo TPA.md index 323d43ccad..cd636f4843 100644 --- a/docs/Rates Expo TPA.md +++ b/docs/Rates Expo TPA.md @@ -29,6 +29,8 @@ These values affect mostly the endpoints of the input. For example, If the ove * Note that TPA is set via CLI or on the PID TUNING tab of the GUI. tpa_breakpoint is set via CLI +TPA applies a 'P' value reduction in relation to full Throttle. It is used to 'soften' the P value at extream throttle which sometimes induces oscellation in the aircraft. + An Example: With TPA = 50 (or .5 in the GUI) and tpa_breakpoint = 1500 At full throttle, your P value is reduced by 50% From 1cbdf89cf187372d859fc3ce236d5dc5c0ea70ed Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Mon, 2 Feb 2015 11:45:21 -0800 Subject: [PATCH 04/60] Update PID tuning.md --- docs/PID tuning.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/PID tuning.md b/docs/PID tuning.md index a7788134bb..6a75441cb7 100644 --- a/docs/PID tuning.md +++ b/docs/PID tuning.md @@ -29,6 +29,24 @@ changing slowly (so the P and I terms aren't having enough impact on reaching th in the correction in order to reach the target sooner. If the error is rapidly converging to zero, the D term causes the strength of the correction to be backed off in order to avoid overshooting the target. +##TPA and TPA Breakpoint + +* Note that TPA is set via CLI or on the PID TUNING tab of the GUI. tpa_breakpoint is set via CLI + +TPA applies a 'P' value reduction in relation to full Throttle. It is used to 'soften' the P value at extream throttle which sometimes induces oscellation in the aircraft. + +An Example: With TPA = 50 (or .5 in the GUI) and tpa_breakpoint = 1500 + +At full throttle, your P value is reduced by 50% +at 3/4 throttle (say 1750), your P value is reduced by 25% (1/2 the differnce of 1500 and 2000 = 1/2 of 50% = 25%) +at half throttle (1500), your P vallue is reduced by ~0 + +So how do you use this? + +If you're getting oscillations starting at say 3/4 throttle, set tpa breakpoint = 1750 or lower (remember, this is assuming your throttle range is 1000-2000), and then slowly increase TPA until your oscillations are gone. Usually, you will want tpa breakpoint to start a little sooner then when your oscillations start so you'll want to experiment with the values to reduce/remove the oscillations. + +In theory, this should allow you to bump your PIDs a tiny bit more because now you can focus your PID tune to how you fly and not have to worry about bringing it down some to compensate for high throttle oscillations. + ## PID controllers Cleanflight has 6 built-in PID controllers which each have different flight behavior. Each controller requires From 6be883a392e5f279c0adef918c4d6f82d184f641 Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Mon, 2 Feb 2015 11:45:38 -0800 Subject: [PATCH 05/60] Update Rates Expo TPA.md --- docs/Rates Expo TPA.md | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/docs/Rates Expo TPA.md b/docs/Rates Expo TPA.md index cd636f4843..33801b475b 100644 --- a/docs/Rates Expo TPA.md +++ b/docs/Rates Expo TPA.md @@ -25,20 +25,4 @@ The most sensitive at the center of the inputs is 0 Expo. These values affect mostly the endpoints of the input. For example, If the over all control of the aircraft is good, i.e you have your RC Rates dialed in, but extreme enpoint controls need to be faster or slower, like for aerobatics, then these rates can be used to increase the response withoug effecting the center of the input ranges as much. -##TPA and TPA Breakpoint -* Note that TPA is set via CLI or on the PID TUNING tab of the GUI. tpa_breakpoint is set via CLI - -TPA applies a 'P' value reduction in relation to full Throttle. It is used to 'soften' the P value at extream throttle which sometimes induces oscellation in the aircraft. - -An Example: With TPA = 50 (or .5 in the GUI) and tpa_breakpoint = 1500 - -At full throttle, your P value is reduced by 50% -at 3/4 throttle (say 1750), your P value is reduced by 25% (1/2 the differnce of 1500 and 2000 = 1/2 of 50% = 25%) -at half throttle (1500), your P vallue is reduced by ~0 - -So how do you use this? - -If you're getting oscillations starting at say 3/4 throttle, set tpa breakpoint = 1750 or lower (remember, this is assuming your throttle range is 1000-2000), and then slowly increase TPA until your oscillations are gone. Usually, you will want tpa breakpoint to start a little sooner then when your oscillations start so you'll want to experiment with the values to reduce/remove the oscillations. - -In theory, this should allow you to bump your PIDs a tiny bit more because now you can focus your PID tune to how you fly and not have to worry about bringing it down some to compensate for high throttle oscillations. From 59012c9ae70926d990fabbb1fba752a663ede04e Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Mon, 2 Feb 2015 11:47:05 -0800 Subject: [PATCH 06/60] Update and rename Rates Expo TPA.md to Rates & Expo.md --- docs/{Rates Expo TPA.md => Rates & Expo.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename docs/{Rates Expo TPA.md => Rates & Expo.md} (80%) diff --git a/docs/Rates Expo TPA.md b/docs/Rates & Expo.md similarity index 80% rename from docs/Rates Expo TPA.md rename to docs/Rates & Expo.md index 33801b475b..23d341b6a6 100644 --- a/docs/Rates Expo TPA.md +++ b/docs/Rates & Expo.md @@ -1,4 +1,4 @@ -#Rates, Expo, & TPA +#Rates & Expo RC Rates (on the RECEIVER tab in the GUI) and Pitch & Roll and Yaw Rates (on the PID TUNING tab of the GUI); @@ -23,6 +23,6 @@ The most sensitive at the center of the inputs is 0 Expo. ##Pitch & Roll and Yaw Rates -These values affect mostly the endpoints of the input. For example, If the over all control of the aircraft is good, i.e you have your RC Rates dialed in, but extreme enpoint controls need to be faster or slower, like for aerobatics, then these rates can be used to increase the response withoug effecting the center of the input ranges as much. +These values affect mostly the endpoints of the input. For example, If the over all control of the aircraft is good but extreme enpoint controls need to be faster or slower, like for aerobatics, then these rates can be used to increase the response withoug effecting the center of the input ranges as much. From 20600dc21196a97e7a1cd07c02c8711e930a4e38 Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Mon, 2 Feb 2015 11:57:57 -0800 Subject: [PATCH 07/60] Delete Rates & Expo.md --- docs/Rates & Expo.md | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 docs/Rates & Expo.md diff --git a/docs/Rates & Expo.md b/docs/Rates & Expo.md deleted file mode 100644 index 23d341b6a6..0000000000 --- a/docs/Rates & Expo.md +++ /dev/null @@ -1,28 +0,0 @@ -#Rates & Expo - -RC Rates (on the RECEIVER tab in the GUI) and Pitch & Roll and Yaw Rates (on the PID TUNING tab of the GUI); - -What is the difference? - -* RC Rates affect the entire contorl input range. To decrease sensitivity at the center of the ranges, RC Expo can be used. -* Pitch & Roll and Yaw Rates target the endpoints of the inputs while having little or no effect on the center of the input ranges. - -##RC Rate - -RC Rate defines the sensitivity to PITCH and ROLL throughout the entire input range. -* A lower # reduces the over all responsiveness. -* A Higher # increases the over all responsiveness. - -If you feel your aircraft is too reactive to your inputs, decrease the value. If you feel it is too sluggish, increase the value. - -##RC Expo - -RC Expo defines a smoother, less sensitive, zone at the center of the PITCH and ROLL input range without affecting the ends of the inputs. -The higher the value, the less sensitive the Pitch and Roll inputs will be when in the center of their range. The lower the value, the more sensitive the Pitch and Roll inputs will be when at the center of their range. -The most sensitive at the center of the inputs is 0 Expo. - -##Pitch & Roll and Yaw Rates - -These values affect mostly the endpoints of the input. For example, If the over all control of the aircraft is good but extreme enpoint controls need to be faster or slower, like for aerobatics, then these rates can be used to increase the response withoug effecting the center of the input ranges as much. - - From 9a74e15afd24b0db6d4c98671835416497b63567 Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Mon, 2 Feb 2015 12:06:58 -0800 Subject: [PATCH 08/60] Update PID tuning.md --- docs/PID tuning.md | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/docs/PID tuning.md b/docs/PID tuning.md index 6a75441cb7..a7788134bb 100644 --- a/docs/PID tuning.md +++ b/docs/PID tuning.md @@ -29,24 +29,6 @@ changing slowly (so the P and I terms aren't having enough impact on reaching th in the correction in order to reach the target sooner. If the error is rapidly converging to zero, the D term causes the strength of the correction to be backed off in order to avoid overshooting the target. -##TPA and TPA Breakpoint - -* Note that TPA is set via CLI or on the PID TUNING tab of the GUI. tpa_breakpoint is set via CLI - -TPA applies a 'P' value reduction in relation to full Throttle. It is used to 'soften' the P value at extream throttle which sometimes induces oscellation in the aircraft. - -An Example: With TPA = 50 (or .5 in the GUI) and tpa_breakpoint = 1500 - -At full throttle, your P value is reduced by 50% -at 3/4 throttle (say 1750), your P value is reduced by 25% (1/2 the differnce of 1500 and 2000 = 1/2 of 50% = 25%) -at half throttle (1500), your P vallue is reduced by ~0 - -So how do you use this? - -If you're getting oscillations starting at say 3/4 throttle, set tpa breakpoint = 1750 or lower (remember, this is assuming your throttle range is 1000-2000), and then slowly increase TPA until your oscillations are gone. Usually, you will want tpa breakpoint to start a little sooner then when your oscillations start so you'll want to experiment with the values to reduce/remove the oscillations. - -In theory, this should allow you to bump your PIDs a tiny bit more because now you can focus your PID tune to how you fly and not have to worry about bringing it down some to compensate for high throttle oscillations. - ## PID controllers Cleanflight has 6 built-in PID controllers which each have different flight behavior. Each controller requires From 23c966c6f15f09b601f3324d4b07036ce60ab498 Mon Sep 17 00:00:00 2001 From: Gregor Ottmann Date: Tue, 3 Feb 2015 19:04:04 +0100 Subject: [PATCH 09/60] Update Spektrum bind.md Added a description for connecting the SAT to a Flip32+ board --- docs/Spektrum bind.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/Spektrum bind.md b/docs/Spektrum bind.md index eb50eb31ce..76c86d15a1 100644 --- a/docs/Spektrum bind.md +++ b/docs/Spektrum bind.md @@ -47,3 +47,11 @@ http://wiki.openpilot.org/display/Doc/Spektrum+Satellite ### Supported Hardware NAZE, NAZE32PRO, CJMCU, SPARKY, EUSTM32F103RC, CC3D targets and ALIENWIIF1, ALIENWIIF3 targets with hardware bind plug + +### Connecting an Orange R100 to a Flip32+ flight controller + +The Flip32+ is wired in a rather strange way, i.e. the dedicated connector for the satellite module uses the same UART pins as the USB adapter. This means that you can't use that connector as it maps to UART1 which you really shouldn't assign to SERIAL_RX as that will break USB functionality. + +In order to connect the Orange R100 to a Flip32+, you have to wire the serial data pin to RC_CH4. This is the fourth pin from the top in the left column of the 3x6 header on the right side of the board. GND and +3.3V may either be obtained from the dedicated SAT connector or from any ground pin and pin 1 of the BOOT connector which also provides 3.3V. + +Using this connection, binding an Orange R100 to a Spektrum DX6i was successfully performed with a bind value of 3. From ac5f45d7f21ff9123d6a87aabaee452df8710f85 Mon Sep 17 00:00:00 2001 From: Gregor Ottmann Date: Wed, 4 Feb 2015 08:39:36 +0100 Subject: [PATCH 10/60] Update Spektrum bind.md Section about connecting a satellite to the Flip32+ was changed so it wasn't specific for the Orange RX anymore. --- docs/Spektrum bind.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/Spektrum bind.md b/docs/Spektrum bind.md index 76c86d15a1..cd1ea30995 100644 --- a/docs/Spektrum bind.md +++ b/docs/Spektrum bind.md @@ -48,10 +48,14 @@ http://wiki.openpilot.org/display/Doc/Spektrum+Satellite NAZE, NAZE32PRO, CJMCU, SPARKY, EUSTM32F103RC, CC3D targets and ALIENWIIF1, ALIENWIIF3 targets with hardware bind plug -### Connecting an Orange R100 to a Flip32+ flight controller +### Connecting a Spektrum-compatible satellite to a Flip32+ flight controller The Flip32+ is wired in a rather strange way, i.e. the dedicated connector for the satellite module uses the same UART pins as the USB adapter. This means that you can't use that connector as it maps to UART1 which you really shouldn't assign to SERIAL_RX as that will break USB functionality. -In order to connect the Orange R100 to a Flip32+, you have to wire the serial data pin to RC_CH4. This is the fourth pin from the top in the left column of the 3x6 header on the right side of the board. GND and +3.3V may either be obtained from the dedicated SAT connector or from any ground pin and pin 1 of the BOOT connector which also provides 3.3V. +In order to connect the satellite to a Flip32+, you have to wire the serial data pin to RC_CH4. This is the fourth pin from the top in the left column of the 3x6 header on the right side of the board. GND and +3.3V may either be obtained from the dedicated SAT connector or from any ground pin and pin 1 of the BOOT connector which also provides 3.3V. -Using this connection, binding an Orange R100 to a Spektrum DX6i was successfully performed with a bind value of 3. +#### Tested satellite transmitter combinations + +| Satellite | Remote | Bind Value | +| ----------- | ------------- | ---------- | +| Orange R100 | Spektrum DX6i | 3 | From e9e3829cf5952899089cb0eb43f06445724cfa62 Mon Sep 17 00:00:00 2001 From: Gregor Ottmann Date: Wed, 4 Feb 2015 11:55:16 +0100 Subject: [PATCH 11/60] Update Spektrum bind.md Added tested satellite transmitter combinations as given by MJ666 --- docs/Spektrum bind.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/Spektrum bind.md b/docs/Spektrum bind.md index cd1ea30995..ecee0cd20c 100644 --- a/docs/Spektrum bind.md +++ b/docs/Spektrum bind.md @@ -56,6 +56,9 @@ In order to connect the satellite to a Flip32+, you have to wire the serial data #### Tested satellite transmitter combinations -| Satellite | Remote | Bind Value | -| ----------- | ------------- | ---------- | -| Orange R100 | Spektrum DX6i | 3 | +| Satellite | Remote | Remark | +| -------------------- | ------------- | --------------------------------- | +| Orange R100 | Spektrum DX6i | Bind value 3 | +| Lemon RX DSM2/DSMX | Spektrum DX8 | | +| Lemon RX DSMX Devo10 | | Deviation 4.01 up to 12 channels | +| Lemon RX DSM2 Devo7 | | Deviation | From 5867f3a6dbbfd21a5571a55b6fc652794334d3f4 Mon Sep 17 00:00:00 2001 From: Gregor Ottmann Date: Wed, 4 Feb 2015 12:34:54 +0100 Subject: [PATCH 12/60] Update Spektrum bind.md Updated as per MJ666's instructions --- docs/Spektrum bind.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/Spektrum bind.md b/docs/Spektrum bind.md index ecee0cd20c..0c545e9105 100644 --- a/docs/Spektrum bind.md +++ b/docs/Spektrum bind.md @@ -56,9 +56,9 @@ In order to connect the satellite to a Flip32+, you have to wire the serial data #### Tested satellite transmitter combinations -| Satellite | Remote | Remark | -| -------------------- | ------------- | --------------------------------- | -| Orange R100 | Spektrum DX6i | Bind value 3 | -| Lemon RX DSM2/DSMX | Spektrum DX8 | | -| Lemon RX DSMX Devo10 | | Deviation 4.01 up to 12 channels | -| Lemon RX DSM2 Devo7 | | Deviation | +| Satellite | Remote | Remark | +| -------------------- | -------------- | ------------------------------------------ | +| Orange R100 | Spektrum DX6i | Bind value 3 | +| Lemon RX DSM2/DSMX | Spektrum DX8 | | +| Lemon RX DSMX | Walkera Devo10 | Deviation firmware 4.01 up to 12 channels | +| Lemon RX DSM2 | Walkera Devo7 | Deviation firmware | From a408041df84c86cd8028eeaa3dfe3ae37d53ec8a Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Wed, 4 Feb 2015 14:52:10 -0800 Subject: [PATCH 13/60] Update PID tuning.md --- docs/PID tuning.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/PID tuning.md b/docs/PID tuning.md index 6a75441cb7..62ee316835 100644 --- a/docs/PID tuning.md +++ b/docs/PID tuning.md @@ -33,19 +33,21 @@ strength of the correction to be backed off in order to avoid overshooting the t * Note that TPA is set via CLI or on the PID TUNING tab of the GUI. tpa_breakpoint is set via CLI -TPA applies a 'P' value reduction in relation to full Throttle. It is used to 'soften' the P value at extream throttle which sometimes induces oscellation in the aircraft. +TPA applies a PID value reduction in relation to full Throttle. It is used to apply dampening of PID values as full throttle is reached. + +TPA = % of dampening that will occur at full throttle. + +tpa_breakpoint = the point in the throttle curve at which TPA will begin to be applied. An Example: With TPA = 50 (or .5 in the GUI) and tpa_breakpoint = 1500 -At full throttle, your P value is reduced by 50% -at 3/4 throttle (say 1750), your P value is reduced by 25% (1/2 the differnce of 1500 and 2000 = 1/2 of 50% = 25%) -at half throttle (1500), your P vallue is reduced by ~0 +* At 1500 on the throttle channel, the PIDs will begin to be dampened. +* At 3/4 throttle (1750), PIDs are reduced by 25% (half way between 1500 and 2000 the dampening will be 50% of the total TPA value) +* At full throttle (2000) the full amount of dampening set in TPA is applied. (50% in this example) -So how do you use this? +How to use this? -If you're getting oscillations starting at say 3/4 throttle, set tpa breakpoint = 1750 or lower (remember, this is assuming your throttle range is 1000-2000), and then slowly increase TPA until your oscillations are gone. Usually, you will want tpa breakpoint to start a little sooner then when your oscillations start so you'll want to experiment with the values to reduce/remove the oscillations. - -In theory, this should allow you to bump your PIDs a tiny bit more because now you can focus your PID tune to how you fly and not have to worry about bringing it down some to compensate for high throttle oscillations. +If you are getting oscillations starting at say 3/4 throttle, set tpa breakpoint = 1750 or lower (remember, this is assuming your throttle range is 1000-2000), and then slowly increase TPA until your oscillations are gone. Usually, you will want tpa breakpoint to start a little sooner then when your oscillations start so you'll want to experiment with the values to reduce/remove the oscillations. ## PID controllers From e0e815ce7321f79fc270ebcd8e9db5637d61fa76 Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Wed, 4 Feb 2015 16:26:01 -0800 Subject: [PATCH 14/60] Update PID tuning.md --- docs/PID tuning.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/PID tuning.md b/docs/PID tuning.md index 62ee316835..ccd9362e04 100644 --- a/docs/PID tuning.md +++ b/docs/PID tuning.md @@ -31,7 +31,7 @@ strength of the correction to be backed off in order to avoid overshooting the t ##TPA and TPA Breakpoint -* Note that TPA is set via CLI or on the PID TUNING tab of the GUI. tpa_breakpoint is set via CLI +*Note that TPA is set via CLI or on the PID TUNING tab of the GUI. tpa_breakpoint is set via CLI* TPA applies a PID value reduction in relation to full Throttle. It is used to apply dampening of PID values as full throttle is reached. @@ -42,8 +42,8 @@ tpa_breakpoint = the point in the throttle curve at which TPA will begin to be a An Example: With TPA = 50 (or .5 in the GUI) and tpa_breakpoint = 1500 * At 1500 on the throttle channel, the PIDs will begin to be dampened. -* At 3/4 throttle (1750), PIDs are reduced by 25% (half way between 1500 and 2000 the dampening will be 50% of the total TPA value) -* At full throttle (2000) the full amount of dampening set in TPA is applied. (50% in this example) +* At 3/4 throttle (1750), PIDs are reduced by approximately 25% (half way between 1500 and 2000 the dampening will be 50% of the total TPA value of 50% in this example) +* At full throttle (2000) the full amount of dampening set in TPA is applied. (50% reduction in this example) How to use this? From c28d2f437777b5b88f249a2273ce3023e641f33b Mon Sep 17 00:00:00 2001 From: JohnieBraaf Date: Thu, 5 Feb 2015 01:52:47 +0100 Subject: [PATCH 15/60] Update Hardware Debugging.md Added reference to detailed guide in the wiki, and visual studio IDE setup --- docs/development/Hardware Debugging.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/development/Hardware Debugging.md b/docs/development/Hardware Debugging.md index 48025f60d9..a620452957 100644 --- a/docs/development/Hardware Debugging.md +++ b/docs/development/Hardware Debugging.md @@ -2,6 +2,12 @@ The code can be compiled with debugging information, you can then upload a debug version to a board via a JLink/St-Link debug adapter and step through the code in your IDE. +More information about the necessary hardware can and setting up the eclipse IDE can be found int the wiki: +https://github.com/cleanflight/cleanflight/wiki/Debugging-in-Eclipse + +A guide for visual studio can be found here: +http://visualgdb.com/tutorials/arm/st-link/ + ## Compilation options use `DEBUG=GDB` make argument. From fddf3a5761b6c71b7008611a6c1f14231a2d6304 Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Wed, 4 Feb 2015 17:33:47 -0800 Subject: [PATCH 16/60] Update PID tuning.md --- docs/PID tuning.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/PID tuning.md b/docs/PID tuning.md index ccd9362e04..240d00c8e2 100644 --- a/docs/PID tuning.md +++ b/docs/PID tuning.md @@ -45,7 +45,10 @@ An Example: With TPA = 50 (or .5 in the GUI) and tpa_breakpoint = 1500 * At 3/4 throttle (1750), PIDs are reduced by approximately 25% (half way between 1500 and 2000 the dampening will be 50% of the total TPA value of 50% in this example) * At full throttle (2000) the full amount of dampening set in TPA is applied. (50% reduction in this example) -How to use this? +![tpa example chart](https://cloud.githubusercontent.com/assets/1668170/6053290/655255dc-ac92-11e4-9491-1a58d868c131.png "TPA Example Chart") + + +**How and Why to use this?** If you are getting oscillations starting at say 3/4 throttle, set tpa breakpoint = 1750 or lower (remember, this is assuming your throttle range is 1000-2000), and then slowly increase TPA until your oscillations are gone. Usually, you will want tpa breakpoint to start a little sooner then when your oscillations start so you'll want to experiment with the values to reduce/remove the oscillations. From 8c18b5953094108a71e2f72bc6c9a7822fcb8c6d Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Wed, 4 Feb 2015 17:52:13 -0800 Subject: [PATCH 17/60] Update PID tuning.md --- docs/PID tuning.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/PID tuning.md b/docs/PID tuning.md index 240d00c8e2..d08f369b77 100644 --- a/docs/PID tuning.md +++ b/docs/PID tuning.md @@ -16,15 +16,17 @@ Basically, the goal of the PID controller is to bring the craft's rotation rate you're commanding with your sticks. An error is computed which is the difference between your target rotation rate and the actual one measured by the gyroscopes, and the controller tries to bring this error to zero. -The P term controls the strength of the correction that is applied to bring the craft toward the target angle or +##PIDs + +**The P term** controls the strength of the correction that is applied to bring the craft toward the target angle or rotation rate. If the P term is too low, the craft will be difficult to control as it won't respond quickly enough to keep itself stable. If it is set too high, the craft will rapidly oscillate/shake as it continually overshoots its target. -The I term corrects small, long term errors. If it is set too low, the craft's attitude will slowly drift. If it is +**The I term** corrects small, long term errors. If it is set too low, the craft's attitude will slowly drift. If it is set too high, the craft will oscillate (but with slower oscillations than with P being set too high). -The D term attempts to increase system stability by monitoring the rate of change in the error. If the error is +**The D term** attempts to increase system stability by monitoring the rate of change in the error. If the error is changing slowly (so the P and I terms aren't having enough impact on reaching the target) the D term causes an increase in the correction in order to reach the target sooner. If the error is rapidly converging to zero, the D term causes the strength of the correction to be backed off in order to avoid overshooting the target. From b07a0012980d258b5fabd09353116e31d5038971 Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Wed, 4 Feb 2015 22:41:56 -0800 Subject: [PATCH 18/60] Update PID tuning.md --- docs/PID tuning.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/docs/PID tuning.md b/docs/PID tuning.md index d08f369b77..6e586bb842 100644 --- a/docs/PID tuning.md +++ b/docs/PID tuning.md @@ -26,10 +26,7 @@ target. **The I term** corrects small, long term errors. If it is set too low, the craft's attitude will slowly drift. If it is set too high, the craft will oscillate (but with slower oscillations than with P being set too high). -**The D term** attempts to increase system stability by monitoring the rate of change in the error. If the error is -changing slowly (so the P and I terms aren't having enough impact on reaching the target) the D term causes an increase -in the correction in order to reach the target sooner. If the error is rapidly converging to zero, the D term causes the -strength of the correction to be backed off in order to avoid overshooting the target. +**The D term** attempts to increase system stability by monitoring the rate of change in the error. If the error is rapidly converging to zero, the D term causes the strength of the correction to be backed off in order to avoid overshooting the target. ##TPA and TPA Breakpoint @@ -37,11 +34,11 @@ strength of the correction to be backed off in order to avoid overshooting the t TPA applies a PID value reduction in relation to full Throttle. It is used to apply dampening of PID values as full throttle is reached. -TPA = % of dampening that will occur at full throttle. +**TPA** = % of dampening that will occur at full throttle. -tpa_breakpoint = the point in the throttle curve at which TPA will begin to be applied. +**tpa_breakpoint** = the point in the throttle curve at which TPA will begin to be applied. -An Example: With TPA = 50 (or .5 in the GUI) and tpa_breakpoint = 1500 +An Example: With TPA = 50 (or .5 in the GUI) and tpa_breakpoint = 1500 (assumed throttle range 1000 - 2000) * At 1500 on the throttle channel, the PIDs will begin to be dampened. * At 3/4 throttle (1750), PIDs are reduced by approximately 25% (half way between 1500 and 2000 the dampening will be 50% of the total TPA value of 50% in this example) From fb822c0009b98f66c57c14911e37849d6fd8dbd9 Mon Sep 17 00:00:00 2001 From: Max Winterstein Date: Thu, 5 Feb 2015 23:22:31 +0100 Subject: [PATCH 19/60] Update Oneshot.md BLHeli rev13.0 also supports oneshot125. see https://github.com/bitdump/BLHeli/blob/master/Atmel/BLHeli.asm#L33 --- docs/Oneshot.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/Oneshot.md b/docs/Oneshot.md index c91ee2038e..cd6ca5ddb2 100644 --- a/docs/Oneshot.md +++ b/docs/Oneshot.md @@ -6,12 +6,13 @@ It does this in two ways: 1. Use a signal that varies between 125 µs and 250 µs (instead of the normal PWM timing of 1000µs to 2000µs) -1. Only send a 'shot' once per flight controller loop, and do this as soon as the flight controller has calculated the required speed of the motors. +2. Only send a 'shot' once per flight controller loop, and do this as soon as the flight controller has calculated the required speed of the motors. ## Supported ESCs -At present, only the FlyDuino KISS ESCs are able to use the Oneshot125 protocol. +FlyDuino KISS ESCs are able to use the Oneshot125 protocol out of the box. There is only one soldering needed. +BLHeli rev13.0 also supports Oneshot125 and will be automatically selected by the ESC without additional work. ## Supported Boards From 8e6946da5a48a4e11e3841b5ac80a3271c8aa577 Mon Sep 17 00:00:00 2001 From: Petr Ledvina Date: Sat, 7 Feb 2015 16:58:50 +0100 Subject: [PATCH 20/60] Starting PID internals documentation --- docs/development/PID Internals.md | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 docs/development/PID Internals.md diff --git a/docs/development/PID Internals.md b/docs/development/PID Internals.md new file mode 100644 index 0000000000..19f3e70969 --- /dev/null +++ b/docs/development/PID Internals.md @@ -0,0 +1,39 @@ +### IO variables + +gyroData/8192*2000 = deg/s +gyroData/4 ~ deg/s + +rcCommand - -500-500 nominal, but is scaled with rcRate/100, max +-1250 + +inclination - in 0.1 degree, default 50 degrees (500 units) + +axisPID - output to mixer, will be added to throttle(1000-2000), output range is (default <1150 - 1850>) + +### PID controller 0, "MultiWii" (default) + + + +## Leveling term + +error = constrain(2*rcCommand[axis], limit +- max_angle_inclination) - inclination[axis] +P = constrain(P8[PIDLEVEL]/100 * error, limit +- D8[PIDLEVEL] * 5) +I = intergrate(error, limit +-10000) * I8[PIDLEVEL] / 4096 + +## Gyro term + +P = rcCommand[axis]; +error = rcCommand[axis] * 10 * 8 / pidProfile->P8[axis] - gyroData[axis] / 4; (conversion so that error is in deg/s ?) +I = integrate(error, limit +-16000) / 10 / 8 * I8[axis] / 100 (conversion back to mixer units ?) +reset I term if + - axis rotation rate > +-64deg/s + - axis is YAW and rcCommand>+-100 + +## Mode dependent mix(yaw is always from gyro) + +HORIZON - proportionally according to max deflection +Gyro - gyro term +Angle - leveling term + +## Gyro stabilization +P = -gyroData[axis] / 4 * dynP8 / 10 / 8 +D = -mean(diff(gyroData[axis] / 4), 3) * 3 * dynP8 / 32 \ No newline at end of file From 03900bab40e53f62a52545ea38f710e9a5d8d9ad Mon Sep 17 00:00:00 2001 From: Petr Ledvina Date: Sat, 7 Feb 2015 17:01:53 +0100 Subject: [PATCH 21/60] formating --- docs/development/PID Internals.md | 47 ++++++++++++++++++------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/docs/development/PID Internals.md b/docs/development/PID Internals.md index 19f3e70969..a4ed3fce28 100644 --- a/docs/development/PID Internals.md +++ b/docs/development/PID Internals.md @@ -1,39 +1,46 @@ ### IO variables -gyroData/8192*2000 = deg/s -gyroData/4 ~ deg/s +`gyroData/8192*2000 = deg/s` -rcCommand - -500-500 nominal, but is scaled with rcRate/100, max +-1250 +`gyroData/4 ~ deg/s` -inclination - in 0.1 degree, default 50 degrees (500 units) +`rcCommand` - `<-500 - 500>` nominal, but is scaled with `rcRate/100`, max +-1250 -axisPID - output to mixer, will be added to throttle(1000-2000), output range is (default <1150 - 1850>) +`inclination` - in 0.1 degree, default 50 degrees (500) + +`axisPID` - output to mixer, will be added to throttle(`<1000-2000>`), output range is `` (default `<1150 - 1850>`) ### PID controller 0, "MultiWii" (default) - -## Leveling term - +#### Leveling term +``` error = constrain(2*rcCommand[axis], limit +- max_angle_inclination) - inclination[axis] -P = constrain(P8[PIDLEVEL]/100 * error, limit +- D8[PIDLEVEL] * 5) +P = constrain(P8[PIDLEVEL]/100 * error, limit +- 5 * D8[PIDLEVEL]) I = intergrate(error, limit +-10000) * I8[PIDLEVEL] / 4096 - -## Gyro term - +``` +#### Gyro term +``` P = rcCommand[axis]; error = rcCommand[axis] * 10 * 8 / pidProfile->P8[axis] - gyroData[axis] / 4; (conversion so that error is in deg/s ?) I = integrate(error, limit +-16000) / 10 / 8 * I8[axis] / 100 (conversion back to mixer units ?) +``` + reset I term if - - axis rotation rate > +-64deg/s - - axis is YAW and rcCommand>+-100 + - axis rotation rate > +-64deg/s + - axis is YAW and rcCommand>+-100 -## Mode dependent mix(yaw is always from gyro) +##### Mode dependent mix(yaw is always from gyro) -HORIZON - proportionally according to max deflection -Gyro - gyro term -Angle - leveling term +- HORIZON - proportionally according to max deflection -## Gyro stabilization +- gyro - gyro term + +- ANGLE - leveling term + +#### Gyro stabilization + +``` P = -gyroData[axis] / 4 * dynP8 / 10 / 8 -D = -mean(diff(gyroData[axis] / 4), 3) * 3 * dynP8 / 32 \ No newline at end of file +D = -mean(diff(gyroData[axis] / 4), over 3 samples) * 3 * dynP8 / 32 +``` \ No newline at end of file From 8edce9062f40a45b4edd45d14102769acf81f35d Mon Sep 17 00:00:00 2001 From: Petr Ledvina Date: Mon, 9 Feb 2015 08:30:30 +0100 Subject: [PATCH 22/60] fix typo --- docs/development/PID Internals.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/development/PID Internals.md b/docs/development/PID Internals.md index a4ed3fce28..5b921522ed 100644 --- a/docs/development/PID Internals.md +++ b/docs/development/PID Internals.md @@ -42,5 +42,5 @@ reset I term if ``` P = -gyroData[axis] / 4 * dynP8 / 10 / 8 -D = -mean(diff(gyroData[axis] / 4), over 3 samples) * 3 * dynP8 / 32 +D = -mean(diff(gyroData[axis] / 4), over 3 samples) * 3 * dynD8 / 32 ``` \ No newline at end of file From 3272b44410a3aed50dfc1a1261e05b20c95a8acf Mon Sep 17 00:00:00 2001 From: tricopterY Date: Thu, 12 Feb 2015 00:10:57 +1100 Subject: [PATCH 23/60] Update inverter.c Fixes #494 --- src/main/drivers/inverter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/drivers/inverter.c b/src/main/drivers/inverter.c index b8f014c8f2..000597087d 100644 --- a/src/main/drivers/inverter.c +++ b/src/main/drivers/inverter.c @@ -33,7 +33,8 @@ void initInverter(void) gpio_config_t cfg; } gpio_setup = { .gpio = INVERTER_GPIO, - .cfg = { INVERTER_PIN, Mode_Out_OD, Speed_2MHz } + // configure for Push-Pull + .cfg = { INVERTER_PIN, Mode_Out_PP, Speed_2MHz } }; RCC_APB2PeriphClockCmd(INVERTER_PERIPHERAL, ENABLE); From 519cc5f238a0dda4bd2a09bb3a0ecec8a3342363 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Wed, 11 Feb 2015 19:44:00 +0000 Subject: [PATCH 24/60] CC3D - Updating docs regarding inverter. --- docs/Board - CC3D.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/Board - CC3D.md b/docs/Board - CC3D.md index 0f725e533d..e672fee61c 100644 --- a/docs/Board - CC3D.md +++ b/docs/Board - CC3D.md @@ -66,16 +66,24 @@ The 6 pin RC_Output connector has the following pinouts when used in RX_PARALLEL # Serial Ports -| Value | Identifier | Board Markings | Notes | -| ----- | ------------ | -------------- | -----------------------------------------| -| 1 | VCP | USB PORT | | -| 2 | USART1 | MAIN PORT | Has a hardware inverter for S.BUS | -| 3 | USART3 | FLEX PORT | | -| 4 | SoftSerial | RC connector | Pins 4 and 5 (Tx and Rx respectively) | +| Value | Identifier | Board Markings | Notes | +| ----- | ------------ | -------------- | ------------------------------------------| +| 1 | VCP | USB PORT | | +| 2 | USART1 | MAIN PORT | Connected to an MCU controllable inverter | +| 3 | USART3 | FLEX PORT | | +| 4 | SoftSerial | RC connector | Pins 4 and 5 (Tx and Rx respectively) | The SoftSerial port is not available when RX_PARALLEL_PWM is used. The transmission data rate is limited to 19200 baud. -To connect the GUI to the flight controller you just need a USB cable to use the Virtual Com Port (VCP). +To connect the GUI to the flight controller you just need a USB cable to use the Virtual Com Port (VCP) or you can use UART1 (Main Port). + +CLI access is only available via the VCP by default. + +# Main Port + +The main port has MSP support enabled on it by default. + +The main port is connected to an inverter which is automatically enabled as required. For example, if the main port is used for SBus Serial RX then an external inverter is not required. # Flex Port From d12d1952ebcb8c59de71ba8ad080448baea94ff6 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Thu, 12 Feb 2015 01:58:59 +0000 Subject: [PATCH 25/60] Fix PWM/UART2 clash on F1 targets caused by using wrong #define value. --- src/main/main.c | 2 +- src/main/version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/main.c b/src/main/main.c index b3f01f9e64..d99a40fdc8 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -295,7 +295,7 @@ void init(void) pwm_params.airplane = true; else pwm_params.airplane = false; -#if defined(SERIAL_PORT_USART2) && defined(STM32F10X) +#if defined(USE_USART2) && defined(STM32F10X) pwm_params.useUART2 = doesConfigurationUsePort(SERIAL_PORT_USART2); #endif pwm_params.useVbat = feature(FEATURE_VBAT); diff --git a/src/main/version.h b/src/main/version.h index faf7da75e9..eb315aaaec 100644 --- a/src/main/version.h +++ b/src/main/version.h @@ -17,7 +17,7 @@ #define FC_VERSION_MAJOR 1 // increment when a major release is made (big new feature, etc) #define FC_VERSION_MINOR 7 // increment when a minor release is made (small new feature, change etc) -#define FC_VERSION_PATCH_LEVEL 1 // increment when a bug is fixed +#define FC_VERSION_PATCH_LEVEL 2 // increment when a bug is fixed #define STR_HELPER(x) #x #define STR(x) STR_HELPER(x) From adf6f710f4072500d55ce7cd71c9ebd26d7a7973 Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Thu, 12 Feb 2015 09:48:48 -0800 Subject: [PATCH 26/60] Update PID tuning.md Added note about TPA not being used by all PID controllers. --- docs/PID tuning.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/PID tuning.md b/docs/PID tuning.md index 6e586bb842..c29b1f2152 100644 --- a/docs/PID tuning.md +++ b/docs/PID tuning.md @@ -32,6 +32,8 @@ set too high, the craft will oscillate (but with slower oscillations than with P *Note that TPA is set via CLI or on the PID TUNING tab of the GUI. tpa_breakpoint is set via CLI* +Also note that TPA and tpa_breakpoint may not be used in certain PID Contorllers. Check the description on the individual controller. + TPA applies a PID value reduction in relation to full Throttle. It is used to apply dampening of PID values as full throttle is reached. **TPA** = % of dampening that will occur at full throttle. From fe31a3016cb1de2b1568d3dab1815a18a15476e8 Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Thu, 12 Feb 2015 09:49:40 -0800 Subject: [PATCH 27/60] Update PID tuning.md --- docs/PID tuning.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/PID tuning.md b/docs/PID tuning.md index c29b1f2152..5c16c5d0c4 100644 --- a/docs/PID tuning.md +++ b/docs/PID tuning.md @@ -30,7 +30,7 @@ set too high, the craft will oscillate (but with slower oscillations than with P ##TPA and TPA Breakpoint -*Note that TPA is set via CLI or on the PID TUNING tab of the GUI. tpa_breakpoint is set via CLI* +Note that TPA is set via CLI or on the PID TUNING tab of the GUI. tpa_breakpoint is set via CLI Also note that TPA and tpa_breakpoint may not be used in certain PID Contorllers. Check the description on the individual controller. From c9747f397e9bb6773f86c387d14bfe3db5bdb8d2 Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Thu, 12 Feb 2015 09:57:43 -0800 Subject: [PATCH 28/60] Update PID tuning.md Added note on PID cont. 1 about P_Level that has been merged since this PR was created. --- docs/PID tuning.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/PID tuning.md b/docs/PID tuning.md index 5c16c5d0c4..f64f2dabc9 100644 --- a/docs/PID tuning.md +++ b/docs/PID tuning.md @@ -87,7 +87,7 @@ affecting yaw, roll or pitch rotation rates (which are tuned by the dedicated ro settings). In Angle mode, this controller uses the LEVEL "P" PID setting to decide how strong the auto-level correction should -be. +be. Note that the default value for P_Level is 90. This is more than likely too high of a value for most, and will cause the model to be very unstable in Angle Mode, and could result in loss of control. It is recommended to change this value to 20 before using PID Controller 2 in Angle Mode. In Horizon mode, this controller uses the LEVEL "I" PID setting to decide how much auto-level correction should be applied. The default Cleanflight setting for "I" will result in virtually no auto-leveling being applied, so that will From 733c5fe971120400677f97673dd630f14263a307 Mon Sep 17 00:00:00 2001 From: wiebel Date: Fri, 13 Feb 2015 13:14:19 +0100 Subject: [PATCH 29/60] Some Linux secific remarks --- docs/Board - Sparky.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/Board - Sparky.md b/docs/Board - Sparky.md index 8bef9801f0..b72d9c9b39 100644 --- a/docs/Board - Sparky.md +++ b/docs/Board - Sparky.md @@ -77,7 +77,7 @@ The status bar will show the upload progress and confirm that the upload is comp Disconnect and reconnect the board from USB and continue to configure it via the Cleanflight configurator as per normal -## Via Device Firmware Upload (DFU, USB) - Mac OS X +## Via Device Firmware Upload (DFU, USB) - Mac OS X / Linux These instructions are for dfu-util, tested using dfu-util 0.7 for OSX from the OpenTX project. @@ -144,6 +144,13 @@ can't detach Resetting USB to switch back to runtime mode ``` +On Linux you might want to take care that the modemmanager isn't trying to use your sparky as modem getting it into bootloader mode while doing so. In doubt you probably want to uninstall it. It could also be good idea to get udev fixed. It looks like teensy did just that -> http://www.pjrc.com/teensy/49-teensy.rules (untested) + +To make a full chip erase you can use a file created by +``` +dd if=/dev/zero of=zero.bin bs=1 count=262144 +``` +This can be used by dfu-util. ## Via SWD From eb9841c41ccedff93e4835806dfe9e556c0e20ce Mon Sep 17 00:00:00 2001 From: tracernz Date: Sat, 14 Feb 2015 13:00:54 +1300 Subject: [PATCH 30/60] Clarify Virtual Current Meter docs The tuning method for the parameters wasn't totally clear. --- docs/Battery.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/Battery.md b/docs/Battery.md index aac57415d4..bf63acc4ce 100644 --- a/docs/Battery.md +++ b/docs/Battery.md @@ -100,9 +100,14 @@ The virtual sensor uses the throttle position to calculate as estimated current | Setting | Description | | ----------------------------- | -------------------------------------------------------- | | `current_meter_scale` | The throttle scaling factor [centiamps, i.e. 1/100th A] | -| `current_meter_offset` | The current at zero throttle [centiamps, i.e. 1/100th A] | +| `current_meter_offset` | The current at zero throttle (while armed) [centiamps, i.e. 1/100th A] | -If you know your current at zero throttle (Imin) and maximum throttle(Imax) you can calculate the scaling factors using the following formulas where Tmax is maximum throttle offset (i.e. for `max_throttle` = 1850, Tmax = 1850 - 1000 = 850): +There are two simple methods to tune the parameters depending in whether it is possible to measure current draw for your craft. + +#### Tuning Using Battery Charger Measurement +It may be difficult to adjust `current_meter_offset` using this method unless you can measure the actual current draw with the craft armed at minimum throttle. Adjust `current_meter_scale` until the mAh draw reported by Cleanflight matches the charging data given by your battery charger after the flight (if the mAh draw is lower than reported by your battery charger, increase `current_meter_scale`, and vice-versa). +#### Tuning Using Actual Current Measurements +If you know your crafts current draw at zero throttle while armed (Imin) and maximum throttle(Imax) you can calculate the scaling factors using the following formulas where Tmax is maximum throttle offset (i.e. for `max_throttle` = 1850, Tmax = 1850 - 1000 = 850): ``` current_meter_scale = (Imax - Imin) * 100000 / (Tmax + (Tmax * Tmax / 50)) current_meter_offset = Imin * 100 From 09c13f16afb4ce35421982a1d52c95d33bfaba02 Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Sat, 14 Feb 2015 09:05:03 -0800 Subject: [PATCH 31/60] Update PID tuning.md Added tpa note on Controller 1. --- docs/PID tuning.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/PID tuning.md b/docs/PID tuning.md index f64f2dabc9..931f754b3c 100644 --- a/docs/PID tuning.md +++ b/docs/PID tuning.md @@ -94,6 +94,7 @@ applied. The default Cleanflight setting for "I" will result in virtually no aut need to be increased in order to perform like PID controller 0. The LEVEL "D" setting is not used by this controller. +TPA is not used by this controller. ### PID controller 2, "LuxFloat" From d83455226172d8157e679c85d8129fe03be40ab9 Mon Sep 17 00:00:00 2001 From: Dave Pitman Date: Sat, 14 Feb 2015 09:07:12 -0800 Subject: [PATCH 32/60] Update PID tuning.md --- docs/PID tuning.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/PID tuning.md b/docs/PID tuning.md index 931f754b3c..129eb30075 100644 --- a/docs/PID tuning.md +++ b/docs/PID tuning.md @@ -94,6 +94,7 @@ applied. The default Cleanflight setting for "I" will result in virtually no aut need to be increased in order to perform like PID controller 0. The LEVEL "D" setting is not used by this controller. + TPA is not used by this controller. ### PID controller 2, "LuxFloat" From 9a7de3cf3c691b8cfe0d2723d9cfbaf823f2df89 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Sat, 14 Feb 2015 23:49:55 +0000 Subject: [PATCH 33/60] Improve ESC compatibility by enabling PWM output as soon as possible. A user reported a problem where if the board was powered up before connecting the main battery the ESCs would work, however when the board and ESCs were powered at the same time the ESCs would not initialise correctly. --- src/main/main.c | 72 ++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/main/main.c b/src/main/main.c index d99a40fdc8..cbf0e50be8 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -178,6 +178,42 @@ void init(void) timerInit(); // timer must be initialized before any channel is allocated + memset(&pwm_params, 0, sizeof(pwm_params)); + // when using airplane/wing mixer, servo/motor outputs are remapped + if (masterConfig.mixerMode == MIXER_AIRPLANE || masterConfig.mixerMode == MIXER_FLYING_WING) + pwm_params.airplane = true; + else + pwm_params.airplane = false; +#if defined(USE_USART2) && defined(STM32F10X) + pwm_params.useUART2 = doesConfigurationUsePort(SERIAL_PORT_USART2); +#endif + pwm_params.useVbat = feature(FEATURE_VBAT); + pwm_params.useSoftSerial = feature(FEATURE_SOFTSERIAL); + pwm_params.useParallelPWM = feature(FEATURE_RX_PARALLEL_PWM); + pwm_params.useRSSIADC = feature(FEATURE_RSSI_ADC); + pwm_params.useCurrentMeterADC = feature(FEATURE_CURRENT_METER) + && masterConfig.batteryConfig.currentMeterType == CURRENT_SENSOR_ADC; + pwm_params.useLEDStrip = feature(FEATURE_LED_STRIP); + pwm_params.usePPM = feature(FEATURE_RX_PPM); + pwm_params.useOneshot = feature(FEATURE_ONESHOT125); + pwm_params.useSerialRx = feature(FEATURE_RX_SERIAL); + pwm_params.useServos = isMixerUsingServos(); + pwm_params.extraServos = currentProfile->gimbalConfig.gimbal_flags & GIMBAL_FORWARDAUX; + pwm_params.motorPwmRate = masterConfig.motor_pwm_rate; + pwm_params.servoPwmRate = masterConfig.servo_pwm_rate; + pwm_params.idlePulse = PULSE_1MS; // standard PWM for brushless ESC (default, overridden below) + if (feature(FEATURE_3D)) + pwm_params.idlePulse = masterConfig.flight3DConfig.neutral3d; + if (pwm_params.motorPwmRate > 500) + pwm_params.idlePulse = 0; // brushed motors + pwm_params.servoCenterPulse = masterConfig.escAndServoConfig.servoCenterPulse; + + pwmRxInit(masterConfig.inputFilteringMode); + + pwmOutputConfiguration_t *pwmOutputConfiguration = pwmInit(&pwm_params); + + mixerUsePWMOutputConfiguration(pwmOutputConfiguration); + #ifdef BEEPER beeperConfig_t beeperConfig = { .gpioPin = BEEP_PIN, @@ -289,42 +325,6 @@ void init(void) serialInit(&masterConfig.serialConfig); - memset(&pwm_params, 0, sizeof(pwm_params)); - // when using airplane/wing mixer, servo/motor outputs are remapped - if (masterConfig.mixerMode == MIXER_AIRPLANE || masterConfig.mixerMode == MIXER_FLYING_WING) - pwm_params.airplane = true; - else - pwm_params.airplane = false; -#if defined(USE_USART2) && defined(STM32F10X) - pwm_params.useUART2 = doesConfigurationUsePort(SERIAL_PORT_USART2); -#endif - pwm_params.useVbat = feature(FEATURE_VBAT); - pwm_params.useSoftSerial = feature(FEATURE_SOFTSERIAL); - pwm_params.useParallelPWM = feature(FEATURE_RX_PARALLEL_PWM); - pwm_params.useRSSIADC = feature(FEATURE_RSSI_ADC); - pwm_params.useCurrentMeterADC = feature(FEATURE_CURRENT_METER) - && masterConfig.batteryConfig.currentMeterType == CURRENT_SENSOR_ADC; - pwm_params.useLEDStrip = feature(FEATURE_LED_STRIP); - pwm_params.usePPM = feature(FEATURE_RX_PPM); - pwm_params.useOneshot = feature(FEATURE_ONESHOT125); - pwm_params.useSerialRx = feature(FEATURE_RX_SERIAL); - pwm_params.useServos = isMixerUsingServos(); - pwm_params.extraServos = currentProfile->gimbalConfig.gimbal_flags & GIMBAL_FORWARDAUX; - pwm_params.motorPwmRate = masterConfig.motor_pwm_rate; - pwm_params.servoPwmRate = masterConfig.servo_pwm_rate; - pwm_params.idlePulse = PULSE_1MS; // standard PWM for brushless ESC (default, overridden below) - if (feature(FEATURE_3D)) - pwm_params.idlePulse = masterConfig.flight3DConfig.neutral3d; - if (pwm_params.motorPwmRate > 500) - pwm_params.idlePulse = 0; // brushed motors - pwm_params.servoCenterPulse = masterConfig.escAndServoConfig.servoCenterPulse; - - pwmRxInit(masterConfig.inputFilteringMode); - - pwmOutputConfiguration_t *pwmOutputConfiguration = pwmInit(&pwm_params); - - mixerUsePWMOutputConfiguration(pwmOutputConfiguration); - failsafe = failsafeInit(&masterConfig.rxConfig); beepcodeInit(failsafe); rxInit(&masterConfig.rxConfig, failsafe); From cd73c253525fe1eb06f91882d1dbeb530fcb835e Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Sat, 14 Feb 2015 23:50:51 +0000 Subject: [PATCH 34/60] PORT103R - Update default hardware support. --- src/main/target/PORT103R/target.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/target/PORT103R/target.h b/src/main/target/PORT103R/target.h index d371f69727..0f4aa39046 100644 --- a/src/main/target/PORT103R/target.h +++ b/src/main/target/PORT103R/target.h @@ -19,9 +19,17 @@ #define TARGET_BOARD_IDENTIFIER "103R" -#define LED0_GPIO GPIOD -#define LED0_PIN Pin_2 // PD2 (LED) -#define LED0_PERIPHERAL RCC_APB2Periph_GPIOD +#define LED0_GPIO GPIOB +#define LED0_PIN Pin_3 // PB3 (LED) +#define LED0_PERIPHERAL RCC_APB2Periph_GPIOB + +#define LED1_GPIO GPIOB +#define LED1_PIN Pin_4 // PB4 (LED) +#define LED1_PERIPHERAL RCC_APB2Periph_GPIOB + +#define LED2_GPIO GPIOD +#define LED2_PIN Pin_2 // PD2 (LED) - Labelled LED4 +#define LED2_PERIPHERAL RCC_APB2Periph_GPIOD #define BEEP_GPIO GPIOA #define BEEP_PIN Pin_12 // PA12 (Beeper) @@ -66,12 +74,17 @@ #define BARO #define USE_BARO_MS5611 -//#define USE_BARO_BMP085 +#define USE_BARO_BMP085 #define MAG +#define USE_MAG_HMC5883 +#define USE_MAG_AK8975 + #define SONAR #define BEEPER #define LED0 +#define LED1 +#define LED2 #define INVERTER #define DISPLAY From 02166a4fd0891b1df58bb4edf3ea7a9bad8b408f Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Sun, 15 Feb 2015 09:20:33 +0000 Subject: [PATCH 35/60] Ensure mixer is configured so that PWM initialisation is correct. The isMixerUsingServos() was returing the wrong value in 9a7de3cf3c691b8cfe0d2723d9cfbaf823f2df89 --- src/main/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/main.c b/src/main/main.c index cbf0e50be8..f83d5e23f2 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -178,6 +178,8 @@ void init(void) timerInit(); // timer must be initialized before any channel is allocated + mixerInit(masterConfig.mixerMode, masterConfig.customMixer); + memset(&pwm_params, 0, sizeof(pwm_params)); // when using airplane/wing mixer, servo/motor outputs are remapped if (masterConfig.mixerMode == MIXER_AIRPLANE || masterConfig.mixerMode == MIXER_FLYING_WING) @@ -314,15 +316,13 @@ void init(void) LED0_OFF; LED1_OFF; - - imuInit(); - mixerInit(masterConfig.mixerMode, masterConfig.customMixer); - #ifdef MAG if (sensors(SENSOR_MAG)) compassInit(); #endif + imuInit(); + serialInit(&masterConfig.serialConfig); failsafe = failsafeInit(&masterConfig.rxConfig); From 51727a2d9639eb34fd86cb81c8b1f6d41f126944 Mon Sep 17 00:00:00 2001 From: tracernz Date: Mon, 16 Feb 2015 20:30:30 +1300 Subject: [PATCH 36/60] Begin Documenting CLI Vars The lack of documentation on these variables is a common complaint on the RCGroups thread. Begin to document them. --- docs/Cli.md | 181 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) diff --git a/docs/Cli.md b/docs/Cli.md index 3c1fc68305..2b18e790d5 100644 --- a/docs/Cli.md +++ b/docs/Cli.md @@ -66,4 +66,185 @@ Compare the two backups to make sure you are happy with your restored settings. Re-apply any new defaults as desired. +## CLI Command Reference +| Command | Description | +|----------------|------------------------------------------------| +| adjrange | show/set adjustment ranges settings | +| aux | show/set aux settings | +| cmix | design custom mixer | +| color | configure colors | +| defaults | reset to defaults and reboot | +| dump | print configurable settings in a pastable form | +| exit | | +| feature | list or -val or val | +| get | get variable value | +| gpspassthrough | passthrough gps to serial | +| help | | +| led | configure leds | +| map | mapping of rc channel order | +| mixer | mixer name or list | +| motor | get/set motor output value | +| profile | index (0 to 2) | +| rateprofile | index (0 to 2) | +| save | save and reboot | +| set | name=value or blank or * for list | +| status | show system status | +| version | | + +## CLI Variable Reference + +| Variable | Description/Units | Min | Max | Default | Type | Datatype | +|-------------------------------|-------------------------------------|--------|--------|---------------|--------------|----------| +| looptime | | 0 | 9000 | 3500 | Master | UINT16 | +| emf_avoidance | | 0 | 1 | 0 | Master | UINT8 | +| mid_rc | | 1200 | 1700 | 1500 | Master | UINT16 | +| min_check | | 0 | 2000 | 1100 | Master | UINT16 | +| max_check | | 0 | 2000 | 1900 | Master | UINT16 | +| rssi_channel | | 0 | 18 | 0 | Master | INT8 | +| rssi_scale | | 1 | 255 | 30 | Master | UINT8 | +| input_filtering_mode | | 0 | 1 | 0 | Master | INT8 | +| min_throttle | | 0 | 2000 | 1150 | Master | UINT16 | +| max_throttle | | 0 | 2000 | 1850 | Master | UINT16 | +| min_command | | 0 | 2000 | 1000 | Master | UINT16 | +| servo_center_pulse | | 0 | 2000 | 1500 | Master | UINT16 | +| 3d_deadband_low | | 0 | 2000 | 1406 | Master | UINT16 | +| 3d_deadband_high | | 0 | 2000 | 1514 | Master | UINT16 | +| 3d_neutral | | 0 | 2000 | 1460 | Master | UINT16 | +| 3d_deadband_throttle | | 0 | 2000 | 50 | Master | UINT16 | +| motor_pwm_rate | Default is 16000 for brushed motors | 50 | 32000 | 400 | Master | UINT16 | +| servo_pwm_rate | | 50 | 498 | 50 | Master | UINT16 | +| retarded_arm | | 0 | 1 | 0 | Master | UINT8 | +| disarm_kill_switch | | 0 | 1 | 1 | Master | UINT8 | +| auto_disarm_delay | | 0 | 60 | 5 | Master | UINT8 | +| small_angle | | 0 | 180 | 25 | Master | UINT8 | +| flaps_speed | | 0 | 100 | 0 | Master | UINT8 | +| fixedwing_althold_dir | | -1 | 1 | 1 | Master | INT8 | +| serial_port_1_scenario | | 0 | 11 | | Master | UINT8 | +| serial_port_2_scenario | | 0 | 11 | | Master | UINT8 | +| serial_port_3_scenario | | 0 | 11 | | Master | UINT8 | +| serial_port_4_scenario | | 0 | 11 | | Master | UINT8 | +| serial_port_5_scenario | | 0 | 11 | | Master | UINT8 | +| reboot_character | | 48 | 126 | 82 | Master | UINT8 | +| msp_baudrate | | 1200 | 115200 | 115200 | Master | UINT32 | +| cli_baudrate | | 1200 | 115200 | 115200 | Master | UINT32 | +| gps_baudrate | | 0 | 115200 | 115200 | Master | UINT32 | +| gps_passthrough_baudrate | | 1200 | 115200 | 115200 | Master | UINT32 | +| gps_provider | | 0 | 1 | 0 | Master | UINT8 | +| gps_sbas_mode | | 0 | 4 | 0 | Master | UINT8 | +| gps_auto_config | | 0 | 1 | 1 | Master | UINT8 | +| gps_auto_baud | | 0 | 1 | 0 | Master | UINT8 | +| gps_pos_p | | 0 | 200 | 15 | Profile | UINT8 | +| gps_pos_i | | 0 | 200 | 0 | Profile | UINT8 | +| gps_pos_d | | 0 | 200 | 0 | Profile | UINT8 | +| gps_posr_p | | 0 | 200 | 34 | Profile | UINT8 | +| gps_posr_i | | 0 | 200 | 14 | Profile | UINT8 | +| gps_posr_d | | 0 | 200 | 53 | Profile | UINT8 | +| gps_nav_p | | 0 | 200 | 25 | Profile | UINT8 | +| gps_nav_i | | 0 | 200 | 33 | Profile | UINT8 | +| gps_nav_d | | 0 | 200 | 83 | Profile | UINT8 | +| gps_wp_radius | | 0 | 2000 | 200 | Profile | UINT16 | +| nav_controls_heading | | 0 | 1 | 1 | Profile | UINT8 | +| nav_speed_min | | 10 | 2000 | 100 | Profile | UINT16 | +| nav_speed_max | | 10 | 2000 | 300 | Profile | UINT16 | +| nav_slew_rate | | 0 | 100 | 30 | Profile | UINT8 | +| serialrx_provider | | 0 | 6 | 0 | Master | UINT8 | +| spektrum_sat_bind | | 0 | 10 | 0 | Master | UINT8 | +| telemetry_provider | | 0 | 3 | 0 | Master | UINT8 | +| telemetry_switch | | 0 | 1 | 0 | Master | UINT8 | +| telemetry_inversion | | 0 | 1 | 0 | Master | UINT8 | +| frsky_default_lattitude | | -90 | 90 | 0 | Master | FLOAT | +| frsky_default_longitude | | -180 | 180 | 0 | Master | FLOAT | +| frsky_coordinates_format | | 0 | 1 | 0 | Master | UINT8 | +| frsky_unit | | 0 | 1 | 0 | Master | UINT8 | +| battery_capacity | | 0 | 20000 | 0 | Master | UINT16 | +| vbat_scale | | 0 | 255 | 110 | Master | UINT8 | +| vbat_max_cell_voltage | | 10 | 50 | 43 | Master | UINT8 | +| vbat_min_cell_voltage | | 10 | 50 | 33 | Master | UINT8 | +| vbat_warning_cell_voltage | | 10 | 50 | 35 | Master | UINT8 | +| current_meter_scale | | -10000 | 10000 | 400 | Master | INT16 | +| current_meter_offset | | 0 | 3300 | 0 | Master | UINT16 | +| multiwii_current_meter_output | | 0 | 1 | None defined! | Master | UINT8 | +| current_meter_type | | 0 | 2 | 1 | Master | UINT8 | +| align_gyro | | 0 | 8 | 0 | Master | UINT8 | +| align_acc | | 0 | 8 | 0 | Master | UINT8 | +| align_mag | | 0 | 8 | 0 | Master | UINT8 | +| align_board_roll | | -180 | 360 | 0 | Master | INT16 | +| align_board_pitch | | -180 | 360 | 0 | Master | INT16 | +| align_board_yaw | | -180 | 360 | 0 | Master | INT16 | +| max_angle_inclination | | 100 | 900 | 500 | Master | UINT16 | +| gyro_lpf | | 0 | 256 | 42 | Master | UINT16 | +| moron_threshold | | 0 | 128 | 32 | Master | UINT8 | +| gyro_cmpf_factor | | 100 | 1000 | 600 | Master | UINT16 | +| gyro_cmpfm_factor | | 100 | 1000 | 250 | Master | UINT16 | +| alt_hold_deadband | | 1 | 250 | 40 | Profile | UINT8 | +| alt_hold_fast_change | | 0 | 1 | 1 | Profile | UINT8 | +| deadband | | 0 | 32 | 0 | Profile | UINT8 | +| yaw_deadband | | 0 | 100 | 0 | Profile | UINT8 | +| throttle_correction_value | | 0 | 150 | 0 | Profile | UINT8 | +| throttle_correction_angle | | 1 | 900 | 800 | Profile | UINT16 | +| yaw_control_direction | | -1 | 1 | 1 | Master | INT8 | +| yaw_direction | | -1 | 1 | 1 | Profile | INT8 | +| tri_unarmed_servo | | 0 | 1 | 1 | Profile | INT8 | +| default_rate_profile | Default = profile number | 0 | 2 | | Profile | UINT8 | +| rc_rate | | 0 | 250 | 90 | Rate Profile | UINT8 | +| rc_expo | | 0 | 100 | 65 | Rate Profile | UINT8 | +| thr_mid | | 0 | 100 | 50 | Rate Profile | UINT8 | +| thr_expo | | 0 | 100 | 0 | Rate Profile | UINT8 | +| roll_pitch_rate | | 0 | 100 | 0 | Rate Profile | UINT8 | +| yaw_rate | | 0 | 100 | 0 | Rate Profile | UINT8 | +| tpa_rate | | 0 | 100 | 0 | Rate Profile | UINT8 | +| tpa_breakpoint | | 1000 | 2000 | 1500 | Rate Profile | UINT16 | +| failsafe_delay | | 0 | 200 | 10 | Profile | UINT8 | +| failsafe_off_delay | | 0 | 200 | 200 | Profile | UINT8 | +| failsafe_throttle | | 1000 | 2000 | 1200 | Profile | UINT16 | +| failsafe_min_usec | | 100 | 2000 | 985 | Profile | UINT16 | +| failsafe_max_usec | | 100 | 3000 | 2115 | Profile | UINT16 | +| gimbal_flags | | 0 | 255 | 1 | Profile | UINT8 | +| acc_hardware | | 0 | 9 | 0 | Master | UINT8 | +| acc_lpf_factor | | 0 | 250 | 4 | Profile | UINT8 | +| accxy_deadband | | 0 | 100 | 40 | Profile | UINT8 | +| accz_deadband | | 0 | 100 | 40 | Profile | UINT8 | +| accz_lpf_cutoff | | 1 | 20 | 5 | Profile | FLOAT | +| acc_unarmedcal | | 0 | 1 | 1 | Profile | UINT8 | +| acc_trim_pitch | | -300 | 300 | 0 | Profile | INT16 | +| acc_trim_roll | | -300 | 300 | 0 | Profile | INT16 | +| baro_tab_size | | 0 | 48 | 21 | Profile | UINT8 | +| baro_noise_lpf | | 0 | 1 | 0.6 | Profile | FLOAT | +| baro_cf_vel | | 0 | 1 | 0.985 | Profile | FLOAT | +| baro_cf_alt | | 0 | 1 | 0.965 | Profile | FLOAT | +| mag_hardware | | 0 | 3 | 0 | Master | UINT8 | +| mag_declination | | -18000 | 18000 | 0 | Profile | INT16 | +| pid_controller | | 0 | 4 | 0 | Profile | UINT8 | +| p_pitch | | 0 | 200 | 40 | Profile | UINT8 | +| i_pitch | | 0 | 200 | 30 | Profile | UINT8 | +| d_pitch | | 0 | 200 | 23 | Profile | UINT8 | +| p_roll | | 0 | 200 | 40 | Profile | UINT8 | +| i_roll | | 0 | 200 | 30 | Profile | UINT8 | +| d_roll | | 0 | 200 | 23 | Profile | UINT8 | +| p_yaw | | 0 | 200 | 85 | Profile | UINT8 | +| i_yaw | | 0 | 200 | 45 | Profile | UINT8 | +| d_yaw | | 0 | 200 | 0 | Profile | UINT8 | +| p_pitchf | | 0 | 100 | 2.5 | Profile | FLOAT | +| i_pitchf | | 0 | 100 | 0.6 | Profile | FLOAT | +| d_pitchf | | 0 | 100 | 0.06 | Profile | FLOAT | +| p_rollf | | 0 | 100 | 2.5 | Profile | FLOAT | +| i_rollf | | 0 | 100 | 0.6 | Profile | FLOAT | +| d_rollf | | 0 | 100 | 0.06 | Profile | FLOAT | +| p_yawf | | 0 | 100 | 8 | Profile | FLOAT | +| i_yawf | | 0 | 100 | 0.5 | Profile | FLOAT | +| d_yawf | | 0 | 100 | 0.05 | Profile | FLOAT | +| level_horizon | | 0 | 10 | 3 | Profile | FLOAT | +| level_angle | | 0 | 10 | 5 | Profile | FLOAT | +| sensitivity_horizon | | 0 | 250 | 75 | Profile | UINT8 | +| p_alt | | 0 | 200 | 50 | Profile | UINT8 | +| i_alt | | 0 | 200 | 0 | Profile | UINT8 | +| d_alt | | 0 | 200 | 0 | Profile | UINT8 | +| p_level | | 0 | 200 | 90 | Profile | UINT8 | +| i_level | | 0 | 200 | 10 | Profile | UINT8 | +| d_level | | 0 | 200 | 100 | Profile | UINT8 | +| p_vel | | 0 | 200 | 120 | Profile | UINT8 | +| i_vel | | 0 | 200 | 45 | Profile | UINT8 | +| d_vel | | 0 | 200 | 1 | Profile | UINT8 | +| blackbox_rate_num | | 1 | 32 | 1 | Master | UINT8 | +| blackbox_rate_denom | | 1 | 32 | 1 | Master | UINT8 | From 36c7d5d30de70b5a9bc215145a2457f710bcddc4 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Mon, 16 Feb 2015 19:40:56 +0000 Subject: [PATCH 37/60] SPRACINGF3 - Fix typo in UART3 configuration. --- src/main/drivers/serial_uart_stm32f30x.c | 8 ++++---- src/main/target/SPRACINGF3/target.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/drivers/serial_uart_stm32f30x.c b/src/main/drivers/serial_uart_stm32f30x.c index 3d8ee674cb..f7bc087e08 100644 --- a/src/main/drivers/serial_uart_stm32f30x.c +++ b/src/main/drivers/serial_uart_stm32f30x.c @@ -64,7 +64,7 @@ #ifndef UART3_GPIO #define UART3_TX_PIN GPIO_Pin_10 // PB10 (AF7) #define UART3_RX_PIN GPIO_Pin_11 // PB11 (AF7) -#define UART2_GPIO_AF GPIO_AF_7 +#define UART3_GPIO_AF GPIO_AF_7 #define UART3_GPIO GPIOB #define UART3_TX_PINSOURCE GPIO_PinSource10 #define UART3_RX_PINSOURCE GPIO_PinSource11 @@ -270,20 +270,20 @@ uartPort_t *serialUSART3(uint32_t baudRate, portMode_t mode) if (mode & MODE_TX) { GPIO_InitStructure.GPIO_Pin = UART3_TX_PIN; - GPIO_PinAFConfig(UART3_GPIO, UART3_TX_PINSOURCE, GPIO_AF_7); + GPIO_PinAFConfig(UART3_GPIO, UART3_TX_PINSOURCE, UART3_GPIO_AF); GPIO_Init(UART3_GPIO, &GPIO_InitStructure); } if (mode & MODE_RX) { GPIO_InitStructure.GPIO_Pin = UART3_RX_PIN; - GPIO_PinAFConfig(UART3_GPIO, UART3_RX_PINSOURCE, GPIO_AF_7); + GPIO_PinAFConfig(UART3_GPIO, UART3_RX_PINSOURCE, UART3_GPIO_AF); GPIO_Init(UART3_GPIO, &GPIO_InitStructure); } if (mode & MODE_BIDIR) { GPIO_InitStructure.GPIO_Pin = UART3_TX_PIN; GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; - GPIO_PinAFConfig(UART3_GPIO, UART3_TX_PINSOURCE, GPIO_AF_7); + GPIO_PinAFConfig(UART3_GPIO, UART3_TX_PINSOURCE, UART3_GPIO_AF); GPIO_Init(UART3_GPIO, &GPIO_InitStructure); } diff --git a/src/main/target/SPRACINGF3/target.h b/src/main/target/SPRACINGF3/target.h index 5f4ce66938..ae1feff44c 100644 --- a/src/main/target/SPRACINGF3/target.h +++ b/src/main/target/SPRACINGF3/target.h @@ -72,7 +72,7 @@ #ifndef UART3_GPIO #define UART3_TX_PIN GPIO_Pin_10 // PB10 (AF7) #define UART3_RX_PIN GPIO_Pin_11 // PB11 (AF7) -#define UART2_GPIO_AF GPIO_AF_7 +#define UART3_GPIO_AF GPIO_AF_7 #define UART3_GPIO GPIOB #define UART3_TX_PINSOURCE GPIO_PinSource10 #define UART3_RX_PINSOURCE GPIO_PinSource11 From 6e258a62acaf74ebcf73fff0f77bdf8144dc2f86 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Mon, 16 Feb 2015 22:45:47 +0000 Subject: [PATCH 38/60] Disable alt-hold debugging. --- src/main/flight/altitudehold.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/flight/altitudehold.c b/src/main/flight/altitudehold.c index 66195165a6..16259b381b 100644 --- a/src/main/flight/altitudehold.c +++ b/src/main/flight/altitudehold.c @@ -292,7 +292,7 @@ void calculateEstimatedAltitude(uint32_t currentTime) accAlt = accAlt * barometerConfig->baro_cf_alt + (float)BaroAlt * (1.0f - barometerConfig->baro_cf_alt); // complementary filter for altitude estimation (baro & acc) vel += vel_acc; -#if 1 +#ifdef DEBUG_ALT_HOLD debug[1] = accSum[2] / accSumCount; // acceleration debug[2] = vel; // velocity debug[3] = accAlt; // height From 24ce82b28000f7e04eda2a18beefbc87d940171c Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Mon, 16 Feb 2015 22:50:39 +0000 Subject: [PATCH 39/60] Improve SBus compatibility by timing the entire frame instead of the gap between received bytes of data. Add support for the two SBus digital channels. --- src/main/rx/sbus.c | 84 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 64 insertions(+), 20 deletions(-) diff --git a/src/main/rx/sbus.c b/src/main/rx/sbus.c index 6df723db07..b7ced34dca 100644 --- a/src/main/rx/sbus.c +++ b/src/main/rx/sbus.c @@ -35,10 +35,27 @@ #include "rx/rx.h" #include "rx/sbus.h" +/* + * Observations + * + * FrSky X8R + * time between frames: 6ms. + * time to send frame: 3ms. + */ + +#define SBUS_TIME_NEEDED_PER_FRAME 3000 + #define DEBUG_SBUS_PACKETS +#ifdef DEBUG_SBUS_PACKETS +static uint16_t sbusStateFlags = 0; -#define SBUS_MAX_CHANNEL 16 +#define SBUS_STATE_FAILSAFE (1 << 0) +#define SBUS_STATE_SIGNALLOSS (1 << 1) + +#endif + +#define SBUS_MAX_CHANNEL 18 #define SBUS_FRAME_SIZE 25 #define SBUS_FRAME_BEGIN_BYTE 0x0F @@ -46,6 +63,9 @@ #define SBUS_BAUDRATE 100000 +#define SBUS_DIGITAL_CHANNEL_MIN 173 +#define SBUS_DIGITAL_CHANNEL_MAX 1812 + static bool sbusFrameDone = false; static void sbusDataReceive(uint16_t c); static uint16_t sbusReadRawRC(rxRuntimeConfig_t *rxRuntimeConfig, uint8_t chan); @@ -53,7 +73,7 @@ static uint16_t sbusReadRawRC(rxRuntimeConfig_t *rxRuntimeConfig, uint8_t chan); static uint32_t sbusChannelData[SBUS_MAX_CHANNEL]; static serialPort_t *sBusPort; -static uint32_t sbusSignalLostEventCount = 0; + void sbusUpdateSerialRxFunctionConstraint(functionConstraint_t *functionConstraint) { @@ -77,8 +97,8 @@ bool sbusInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadRa return sBusPort != NULL; } -#define SBUS_FLAG_RESERVED_1 (1 << 0) -#define SBUS_FLAG_RESERVED_2 (1 << 1) +#define SBUS_FLAG_CHANNEL_17 (1 << 0) +#define SBUS_FLAG_CHANNEL_18 (1 << 1) #define SBUS_FLAG_SIGNAL_LOSS (1 << 2) #define SBUS_FLAG_FAILSAFE_ACTIVE (1 << 3) @@ -115,23 +135,23 @@ static sbusFrame_t sbusFrame; // Receive ISR callback static void sbusDataReceive(uint16_t c) { -#ifdef DEBUG_SBUS_PACKETS - static uint8_t sbusUnusedFrameCount = 0; -#endif - static uint8_t sbusFramePosition = 0; - static uint32_t sbusTimeoutAt = 0; + static uint32_t sbusFrameStartAt = 0; uint32_t now = micros(); - if ((int32_t)(sbusTimeoutAt - now) < 0) { + int32_t sbusFrameTime = now - sbusFrameStartAt; + + if (sbusFrameTime > (long)(SBUS_TIME_NEEDED_PER_FRAME + 500)) { sbusFramePosition = 0; } - sbusTimeoutAt = now + 2500; sbusFrame.bytes[sbusFramePosition] = (uint8_t)c; - if (sbusFramePosition == 0 && c != SBUS_FRAME_BEGIN_BYTE) { - return; + if (sbusFramePosition == 0) { + if (c != SBUS_FRAME_BEGIN_BYTE) { + return; + } + sbusFrameStartAt = now; } sbusFramePosition++; @@ -139,14 +159,11 @@ static void sbusDataReceive(uint16_t c) if (sbusFramePosition == SBUS_FRAME_SIZE) { if (sbusFrame.frame.endByte == SBUS_FRAME_END_BYTE) { sbusFrameDone = true; - } - sbusFramePosition = 0; - } else { #ifdef DEBUG_SBUS_PACKETS - if (sbusFrameDone) { - sbusUnusedFrameCount++; - } + debug[2] = sbusFrameTime; #endif + } + } else { sbusFrameDone = false; } } @@ -158,11 +175,22 @@ bool sbusFrameComplete(void) } sbusFrameDone = false; +#ifdef DEBUG_SBUS_PACKETS + debug[1] = sbusFrame.frame.flags; +#endif + if (sbusFrame.frame.flags & SBUS_FLAG_SIGNAL_LOSS) { // internal failsafe enabled and rx failsafe flag set - sbusSignalLostEventCount++; +#ifdef DEBUG_SBUS_PACKETS + sbusStateFlags |= SBUS_STATE_SIGNALLOSS; + debug[0] = sbusStateFlags; +#endif } if (sbusFrame.frame.flags & SBUS_FLAG_FAILSAFE_ACTIVE) { +#ifdef DEBUG_SBUS_PACKETS + sbusStateFlags |= SBUS_STATE_FAILSAFE; + debug[0] = sbusStateFlags; +#endif // internal failsafe enabled and rx failsafe flag set return false; } @@ -183,6 +211,22 @@ bool sbusFrameComplete(void) sbusChannelData[13] = sbusFrame.frame.chan13; sbusChannelData[14] = sbusFrame.frame.chan14; sbusChannelData[15] = sbusFrame.frame.chan15; + + if (sbusFrame.frame.flags & SBUS_FLAG_CHANNEL_17) { + sbusChannelData[16] = SBUS_DIGITAL_CHANNEL_MAX; + } else { + sbusChannelData[16] = SBUS_DIGITAL_CHANNEL_MIN; + } + + if (sbusFrame.frame.flags & SBUS_FLAG_CHANNEL_18) { + sbusChannelData[17] = SBUS_DIGITAL_CHANNEL_MAX; + } else { + sbusChannelData[17] = SBUS_DIGITAL_CHANNEL_MIN; + } + +#ifdef DEBUG_SBUS_PACKETS + sbusStateFlags = 0; +#endif return true; } From c05b4c639ba1be4ad44ac0242eb48fc981a40de0 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Mon, 16 Feb 2015 23:02:14 +0000 Subject: [PATCH 40/60] Ensure sbus debug output is reset after failsafe/signal loss conditions. --- src/main/rx/sbus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/rx/sbus.c b/src/main/rx/sbus.c index b7ced34dca..b84fa47de5 100644 --- a/src/main/rx/sbus.c +++ b/src/main/rx/sbus.c @@ -226,6 +226,7 @@ bool sbusFrameComplete(void) #ifdef DEBUG_SBUS_PACKETS sbusStateFlags = 0; + debug[0] = sbusStateFlags; #endif return true; } From 70fbeb22ba452307ab83bb68076d4c325d3c4000 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Mon, 16 Feb 2015 23:06:46 +0000 Subject: [PATCH 41/60] Disable SBUS debug on CJMCU to reduce code size. --- src/main/rx/sbus.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/rx/sbus.c b/src/main/rx/sbus.c index b84fa47de5..aeaf16f4d4 100644 --- a/src/main/rx/sbus.c +++ b/src/main/rx/sbus.c @@ -45,7 +45,9 @@ #define SBUS_TIME_NEEDED_PER_FRAME 3000 +#ifndef CJMCU #define DEBUG_SBUS_PACKETS +#endif #ifdef DEBUG_SBUS_PACKETS static uint16_t sbusStateFlags = 0; @@ -183,7 +185,7 @@ bool sbusFrameComplete(void) // internal failsafe enabled and rx failsafe flag set #ifdef DEBUG_SBUS_PACKETS sbusStateFlags |= SBUS_STATE_SIGNALLOSS; - debug[0] = sbusStateFlags; + debug[0] |= SBUS_STATE_SIGNALLOSS; #endif } if (sbusFrame.frame.flags & SBUS_FLAG_FAILSAFE_ACTIVE) { From 59198905c0151a07732555319ebfce04d8524c16 Mon Sep 17 00:00:00 2001 From: tracernz Date: Tue, 17 Feb 2015 20:31:02 +1300 Subject: [PATCH 42/60] Add safety documentation --- docs/Safety.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 docs/Safety.md diff --git a/docs/Safety.md b/docs/Safety.md new file mode 100644 index 0000000000..e8c4d59a3c --- /dev/null +++ b/docs/Safety.md @@ -0,0 +1,8 @@ +# Safety + +As many can attest, multirotors and RC models in general can be very dangerous, particularly on the test bench. Here are some simple golden rules to save you a trip to the local ER: +* **NEVER** arm your model with propellers fitted unless you intend to fly! +* **Always** remove your propellers if you are setting up for the first time, flashing firmware, or if in any doubt. + +## Feature MOTOR_STOP +The default Cleanflight configuration has the MOTOR_STOP feature DISABLED by default. What this means is that as soon as the controller is armed, the propellers *WILL* begin spinning at low speed. It is recommended that this setting be retained as it provides a good visual indication that the craft is armed. You can read more about arming and setting the MOTOR_STOP feature if desired in the relevant sections of the manual. From dc87b4bb000796ef14ece2030c157bf156a4229f Mon Sep 17 00:00:00 2001 From: tracernz Date: Tue, 17 Feb 2015 20:31:54 +1300 Subject: [PATCH 43/60] Put safety documentation after introduction --- build_docs.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build_docs.sh b/build_docs.sh index 464dbe5f6e..78ae60610d 100755 --- a/build_docs.sh +++ b/build_docs.sh @@ -3,6 +3,7 @@ filename=Manual doc_files=( 'Introduction.md' + 'Safety.md' 'Installation.md' 'Configuration.md' 'Cli.md' From 1bd091a031871d3d742c4e123630321d13d553d4 Mon Sep 17 00:00:00 2001 From: Nicholas Sherlock Date: Tue, 17 Feb 2015 22:50:10 +1300 Subject: [PATCH 44/60] Avoid reading uninitialised memory during battery unit tests --- src/test/unit/battery_unittest.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/unit/battery_unittest.cc b/src/test/unit/battery_unittest.cc index 52bd836d1c..2a67017439 100644 --- a/src/test/unit/battery_unittest.cc +++ b/src/test/unit/battery_unittest.cc @@ -39,6 +39,14 @@ TEST(BatteryTest, BatteryADCToVoltage) batteryConfig_t batteryConfig; + // batteryInit() reads a bunch of fields including vbatscale, so set up the config with useful initial values: + memset(&batteryConfig, 0, sizeof(batteryConfig)); + + batteryConfig.vbatmaxcellvoltage = 43; + batteryConfig.vbatmincellvoltage = 33; + batteryConfig.vbatwarningcellvoltage = 35; + batteryConfig.vbatscale = VBAT_SCALE_DEFAULT; + batteryInit(&batteryConfig); batteryAdcToVoltageExpectation_t batteryAdcToVoltageExpectations[] = { From 716ee9f5c4affb40effccf514df2cc5a70b4441c Mon Sep 17 00:00:00 2001 From: Nicholas Sherlock Date: Tue, 17 Feb 2015 23:33:12 +1300 Subject: [PATCH 45/60] Add "servo" CLI command to get/set servo conf, and include in dump --- src/main/io/serial_cli.c | 82 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index 276c9310a1..2437f412cb 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -97,6 +97,7 @@ static void cliProfile(char *cmdline); static void cliRateProfile(char *cmdline); static void cliReboot(void); static void cliSave(char *cmdline); +static void cliServo(char *cmdline); static void cliSet(char *cmdline); static void cliGet(char *cmdline); static void cliStatus(char *cmdline); @@ -189,6 +190,7 @@ const clicmd_t cmdTable[] = { { "profile", "index (0 to 2)", cliProfile }, { "rateprofile", "index (0 to 2)", cliRateProfile }, { "save", "save and reboot", cliSave }, + { "servo", "get/set servo configuration", cliServo }, { "set", "name=value or blank or * for list", cliSet }, { "status", "show system status", cliStatus }, { "version", "", cliVersion }, @@ -705,7 +707,7 @@ static void cliLed(char *cmdline) if (i < MAX_LED_STRIP_LENGTH) { ptr = strchr(cmdline, ' '); if (!parseLedStripConfig(i, ++ptr)) { - printf("Parse error\r\n", MAX_LED_STRIP_LENGTH); + printf("Parse error\r\n"); } } else { printf("Invalid led index: must be < %u\r\n", MAX_LED_STRIP_LENGTH); @@ -739,6 +741,80 @@ static void cliColor(char *cmdline) } #endif +static void cliServo(char *cmdline) +{ + enum { SERVO_ARGUMENT_COUNT = 6 }; + int16_t arguments[SERVO_ARGUMENT_COUNT]; + + servoParam_t *servo; + + int i; + uint8_t len; + char *ptr; + + len = strlen(cmdline); + if (len == 0) { + // print out servo settings + for (i = 0; i < MAX_SUPPORTED_SERVOS; i++) { + servo = ¤tProfile->servoConf[i]; + + printf("servo %u %d %d %d %d %d\r\n", + i, + servo->min, + servo->max, + servo->middle, + servo->rate, + servo->forwardFromChannel + ); + } + } else { + int validArgumentCount = 0; + + ptr = cmdline; + + // Command line is integers (possibly negative) separated by spaces, no other characters allowed. + + // If command line doesn't fit the format, don't modify the config + while (*ptr) { + if (*ptr == '-' || (*ptr >= '0' && *ptr <= '9')) { + if (validArgumentCount >= SERVO_ARGUMENT_COUNT) { + printf("Wrong argument count\r\n"); + return; + } + + arguments[validArgumentCount++] = atoi(ptr); + + do { + ptr++; + } while (*ptr >= '0' && *ptr <= '9'); + } else if (*ptr == ' ') { + ptr++; + } else { + printf("Bad argument\r\n"); + return; + } + } + + if (validArgumentCount != SERVO_ARGUMENT_COUNT) { + printf("Wrong argument count\r\n"); + return; + } + + if (arguments[0] < 0 || arguments[0] >= MAX_SUPPORTED_SERVOS) { + printf("Bad argument\r\n"); + return; + } + + servo = ¤tProfile->servoConf[arguments[0]]; + + servo->min = arguments[1]; + servo->max = arguments[2]; + servo->middle = arguments[3]; + servo->rate = arguments[4]; + servo->forwardFromChannel = arguments[5]; + } +} + static void dumpValues(uint16_t mask) { uint32_t i; @@ -874,6 +950,10 @@ static void cliDump(char *cmdline) cliAdjustmentRange(""); + printf("\r\n# servo\r\n"); + + cliServo(""); + printSectionBreak(); dumpValues(PROFILE_VALUE); From 155a3694914e222e8361e26c716ff32bb48a1e28 Mon Sep 17 00:00:00 2001 From: Nicholas Sherlock Date: Wed, 18 Feb 2015 13:07:26 +1300 Subject: [PATCH 46/60] Reduce code size of serial_cli by 104 bytes with some small tweaks: Avoid calling strlen() just to check if a string is empty Shorter error messages and reuse messages for cliServo Use cliPrint rather than printf when not using placeholders --- src/main/io/serial_cli.c | 105 +++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 60 deletions(-) diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index 2437f412cb..bc462fd8b4 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -190,7 +190,7 @@ const clicmd_t cmdTable[] = { { "profile", "index (0 to 2)", cliProfile }, { "rateprofile", "index (0 to 2)", cliRateProfile }, { "save", "save and reboot", cliSave }, - { "servo", "get/set servo configuration", cliServo }, + { "servo", "servo config", cliServo }, { "set", "name=value or blank or * for list", cliSet }, { "status", "show system status", cliStatus }, { "version", "", cliVersion }, @@ -470,14 +470,18 @@ static char *processChannelRangeArgs(char *ptr, channelRange_t *range, uint8_t * return ptr; } +// Check if a string's length is zero +static bool isEmpty(const char *string) +{ + return *string == '\0'; +} + static void cliAux(char *cmdline) { int i, val = 0; - uint8_t len; char *ptr; - len = strlen(cmdline); - if (len == 0) { + if (isEmpty(cmdline)) { // print out aux channel settings for (i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) { modeActivationCondition_t *mac = ¤tProfile->modeActivationConditions[i]; @@ -526,11 +530,9 @@ static void cliAux(char *cmdline) static void cliAdjustmentRange(char *cmdline) { int i, val = 0; - uint8_t len; char *ptr; - len = strlen(cmdline); - if (len == 0) { + if (isEmpty(cmdline)) { // print out adjustment ranges channel settings for (i = 0; i < MAX_ADJUSTMENT_RANGE_COUNT; i++) { adjustmentRange_t *ar = ¤tProfile->adjustmentRanges[i]; @@ -605,9 +607,7 @@ static void cliCMix(char *cmdline) float mixsum[3]; char *ptr; - len = strlen(cmdline); - - if (len == 0) { + if (isEmpty(cmdline)) { cliPrint("Custom mixer: \r\nMotor\tThr\tRoll\tPitch\tYaw\r\n"); for (i = 0; i < MAX_SUPPORTED_MOTORS; i++) { if (masterConfig.customMixer[i].throttle == 0.0f) @@ -691,12 +691,10 @@ static void cliCMix(char *cmdline) static void cliLed(char *cmdline) { int i; - uint8_t len; char *ptr; char ledConfigBuffer[20]; - len = strlen(cmdline); - if (len == 0) { + if (isEmpty(cmdline)) { for (i = 0; i < MAX_LED_STRIP_LENGTH; i++) { generateLedConfig(i, ledConfigBuffer, sizeof(ledConfigBuffer)); printf("led %u %s\r\n", i, ledConfigBuffer); @@ -707,7 +705,7 @@ static void cliLed(char *cmdline) if (i < MAX_LED_STRIP_LENGTH) { ptr = strchr(cmdline, ' '); if (!parseLedStripConfig(i, ++ptr)) { - printf("Parse error\r\n"); + cliPrint("Parse error\r\n"); } } else { printf("Invalid led index: must be < %u\r\n", MAX_LED_STRIP_LENGTH); @@ -718,11 +716,9 @@ static void cliLed(char *cmdline) static void cliColor(char *cmdline) { int i; - uint8_t len; char *ptr; - len = strlen(cmdline); - if (len == 0) { + if (isEmpty(cmdline)) { for (i = 0; i < CONFIGURABLE_COLOR_COUNT; i++) { printf("color %u %d,%u,%u\r\n", i, masterConfig.colors[i].h, masterConfig.colors[i].s, masterConfig.colors[i].v); } @@ -732,7 +728,7 @@ static void cliColor(char *cmdline) if (i < CONFIGURABLE_COLOR_COUNT) { ptr = strchr(cmdline, ' '); if (!parseColor(i, ++ptr)) { - printf("Parse error\r\n", CONFIGURABLE_COLOR_COUNT); + cliPrint("Parse error\r\n"); } } else { printf("Invalid color index: must be < %u\r\n", CONFIGURABLE_COLOR_COUNT); @@ -749,11 +745,9 @@ static void cliServo(char *cmdline) servoParam_t *servo; int i; - uint8_t len; char *ptr; - len = strlen(cmdline); - if (len == 0) { + if (isEmpty(cmdline)) { // print out servo settings for (i = 0; i < MAX_SUPPORTED_SERVOS; i++) { servo = ¤tProfile->servoConf[i]; @@ -778,7 +772,7 @@ static void cliServo(char *cmdline) while (*ptr) { if (*ptr == '-' || (*ptr >= '0' && *ptr <= '9')) { if (validArgumentCount >= SERVO_ARGUMENT_COUNT) { - printf("Wrong argument count\r\n"); + cliPrint("Parse error\r\n"); return; } @@ -790,18 +784,14 @@ static void cliServo(char *cmdline) } else if (*ptr == ' ') { ptr++; } else { - printf("Bad argument\r\n"); + cliPrint("Parse error\r\n"); return; } } - if (validArgumentCount != SERVO_ARGUMENT_COUNT) { - printf("Wrong argument count\r\n"); - return; - } - - if (arguments[0] < 0 || arguments[0] >= MAX_SUPPORTED_SERVOS) { - printf("Bad argument\r\n"); + // Check we got the right number of args and the servo index is correct (don't validate the other values) + if (validArgumentCount != SERVO_ARGUMENT_COUNT || arguments[0] < 0 || arguments[0] >= MAX_SUPPORTED_SERVOS) { + cliPrint("Parse error\r\n"); return; } @@ -868,11 +858,11 @@ static void cliDump(char *cmdline) if (dumpMask & DUMP_MASTER) { - printf("\r\n# version\r\n"); + cliPrint("\r\n# version\r\n"); cliVersion(NULL); - printf("\r\n# dump master\r\n"); - printf("\r\n# mixer\r\n"); + cliPrint("\r\n# dump master\r\n"); + cliPrint("\r\n# mixer\r\n"); #ifndef USE_QUAD_MIXER_ONLY printf("mixer %s\r\n", mixerNames[masterConfig.mixerMode - 1]); @@ -887,23 +877,23 @@ static void cliDump(char *cmdline) yaw = masterConfig.customMixer[i].yaw; printf("cmix %d", i + 1); if (thr < 0) - printf(" "); + cliWrite(' '); printf("%s", ftoa(thr, buf)); if (roll < 0) - printf(" "); + cliWrite(' '); printf("%s", ftoa(roll, buf)); if (pitch < 0) - printf(" "); + cliWrite(' '); printf("%s", ftoa(pitch, buf)); if (yaw < 0) - printf(" "); + cliWrite(' '); printf("%s\r\n", ftoa(yaw, buf)); } printf("cmix %d 0 0 0 0\r\n", i + 1); } #endif - printf("\r\n\r\n# feature\r\n"); + cliPrint("\r\n\r\n# feature\r\n"); mask = featureMask(); for (i = 0; ; i++) { // disable all feature first @@ -918,7 +908,7 @@ static void cliDump(char *cmdline) printf("feature %s\r\n", featureNames[i]); } - printf("\r\n\r\n# map\r\n"); + cliPrint("\r\n\r\n# map\r\n"); for (i = 0; i < 8; i++) buf[masterConfig.rxConfig.rcmap[i]] = rcChannelLetters[i]; @@ -926,10 +916,10 @@ static void cliDump(char *cmdline) printf("map %s\r\n", buf); #ifdef LED_STRIP - printf("\r\n\r\n# led\r\n"); + cliPrint("\r\n\r\n# led\r\n"); cliLed(""); - printf("\r\n\r\n# color\r\n"); + cliPrint("\r\n\r\n# color\r\n"); cliColor(""); #endif printSectionBreak(); @@ -937,20 +927,20 @@ static void cliDump(char *cmdline) } if (dumpMask & DUMP_PROFILE) { - printf("\r\n# dump profile\r\n"); + cliPrint("\r\n# dump profile\r\n"); - printf("\r\n# profile\r\n"); + cliPrint("\r\n# profile\r\n"); cliProfile(""); - printf("\r\n# aux\r\n"); + cliPrint("\r\n# aux\r\n"); cliAux(""); - printf("\r\n# adjrange\r\n"); + cliPrint("\r\n# adjrange\r\n"); cliAdjustmentRange(""); - printf("\r\n# servo\r\n"); + cliPrint("\r\n# servo\r\n"); cliServo(""); @@ -960,9 +950,9 @@ static void cliDump(char *cmdline) } if (dumpMask & DUMP_CONTROL_RATE_PROFILE) { - printf("\r\n# dump rates\r\n"); + cliPrint("\r\n# dump rates\r\n"); - printf("\r\n# rateprofile\r\n"); + cliPrint("\r\n# rateprofile\r\n"); cliRateProfile(""); printSectionBreak(); @@ -1159,12 +1149,11 @@ static void cliMotor(char *cmdline) { int motor_index = 0; int motor_value = 0; - int len, index = 0; + int index = 0; char *pch = NULL; - len = strlen(cmdline); - if (len == 0) { - printf("Usage:\r\nmotor index [value] - show [or set] motor value\r\n"); + if (isEmpty(cmdline)) { + cliPrint("Usage:\r\nmotor index [value] - show [or set] motor value\r\n"); return; } @@ -1193,7 +1182,7 @@ static void cliMotor(char *cmdline) } if (motor_value < PWM_RANGE_MIN || motor_value > PWM_RANGE_MAX) { - printf("Invalid motor value, 1000..2000\r\n"); + cliPrint("Invalid motor value, 1000..2000\r\n"); return; } @@ -1203,11 +1192,9 @@ static void cliMotor(char *cmdline) static void cliProfile(char *cmdline) { - uint8_t len; int i; - len = strlen(cmdline); - if (len == 0) { + if (isEmpty(cmdline)) { printf("profile %d\r\n", getCurrentProfile()); return; } else { @@ -1223,11 +1210,9 @@ static void cliProfile(char *cmdline) static void cliRateProfile(char *cmdline) { - uint8_t len; int i; - len = strlen(cmdline); - if (len == 0) { + if (isEmpty(cmdline)) { printf("rateprofile %d\r\n", getCurrentControlRateProfile()); return; } else { @@ -1421,7 +1406,7 @@ static void cliGet(char *cmdline) val = &valueTable[i]; printf("%s = ", valueTable[i].name); cliPrintVar(val, 0); - printf("\r\n"); + cliPrint("\r\n"); matchedCommands++; } From 8c1d9c37d9db18fd050767076f91b0227f31202b Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Wed, 18 Feb 2015 00:36:05 +0000 Subject: [PATCH 47/60] Add comment regarding observations made on the Futaba SBus receivers. --- src/main/rx/sbus.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/rx/sbus.c b/src/main/rx/sbus.c index aeaf16f4d4..85dd83ebf5 100644 --- a/src/main/rx/sbus.c +++ b/src/main/rx/sbus.c @@ -41,6 +41,10 @@ * FrSky X8R * time between frames: 6ms. * time to send frame: 3ms. +* + * Futaba R6208SB/R6303SB + * time between frames: 11ms. + * time to send frame: 3ms. */ #define SBUS_TIME_NEEDED_PER_FRAME 3000 From 64181161302c175643f26b42b7b0c6ecf2630ecc Mon Sep 17 00:00:00 2001 From: tracernz Date: Wed, 18 Feb 2015 19:16:13 +1300 Subject: [PATCH 48/60] Add baseflight docs --- docs/Cli.md | 308 ++++++++++++++++++++++++++-------------------------- 1 file changed, 154 insertions(+), 154 deletions(-) diff --git a/docs/Cli.md b/docs/Cli.md index 2b18e790d5..93b5bf1820 100644 --- a/docs/Cli.md +++ b/docs/Cli.md @@ -94,157 +94,157 @@ Re-apply any new defaults as desired. ## CLI Variable Reference -| Variable | Description/Units | Min | Max | Default | Type | Datatype | -|-------------------------------|-------------------------------------|--------|--------|---------------|--------------|----------| -| looptime | | 0 | 9000 | 3500 | Master | UINT16 | -| emf_avoidance | | 0 | 1 | 0 | Master | UINT8 | -| mid_rc | | 1200 | 1700 | 1500 | Master | UINT16 | -| min_check | | 0 | 2000 | 1100 | Master | UINT16 | -| max_check | | 0 | 2000 | 1900 | Master | UINT16 | -| rssi_channel | | 0 | 18 | 0 | Master | INT8 | -| rssi_scale | | 1 | 255 | 30 | Master | UINT8 | -| input_filtering_mode | | 0 | 1 | 0 | Master | INT8 | -| min_throttle | | 0 | 2000 | 1150 | Master | UINT16 | -| max_throttle | | 0 | 2000 | 1850 | Master | UINT16 | -| min_command | | 0 | 2000 | 1000 | Master | UINT16 | -| servo_center_pulse | | 0 | 2000 | 1500 | Master | UINT16 | -| 3d_deadband_low | | 0 | 2000 | 1406 | Master | UINT16 | -| 3d_deadband_high | | 0 | 2000 | 1514 | Master | UINT16 | -| 3d_neutral | | 0 | 2000 | 1460 | Master | UINT16 | -| 3d_deadband_throttle | | 0 | 2000 | 50 | Master | UINT16 | -| motor_pwm_rate | Default is 16000 for brushed motors | 50 | 32000 | 400 | Master | UINT16 | -| servo_pwm_rate | | 50 | 498 | 50 | Master | UINT16 | -| retarded_arm | | 0 | 1 | 0 | Master | UINT8 | -| disarm_kill_switch | | 0 | 1 | 1 | Master | UINT8 | -| auto_disarm_delay | | 0 | 60 | 5 | Master | UINT8 | -| small_angle | | 0 | 180 | 25 | Master | UINT8 | -| flaps_speed | | 0 | 100 | 0 | Master | UINT8 | -| fixedwing_althold_dir | | -1 | 1 | 1 | Master | INT8 | -| serial_port_1_scenario | | 0 | 11 | | Master | UINT8 | -| serial_port_2_scenario | | 0 | 11 | | Master | UINT8 | -| serial_port_3_scenario | | 0 | 11 | | Master | UINT8 | -| serial_port_4_scenario | | 0 | 11 | | Master | UINT8 | -| serial_port_5_scenario | | 0 | 11 | | Master | UINT8 | -| reboot_character | | 48 | 126 | 82 | Master | UINT8 | -| msp_baudrate | | 1200 | 115200 | 115200 | Master | UINT32 | -| cli_baudrate | | 1200 | 115200 | 115200 | Master | UINT32 | -| gps_baudrate | | 0 | 115200 | 115200 | Master | UINT32 | -| gps_passthrough_baudrate | | 1200 | 115200 | 115200 | Master | UINT32 | -| gps_provider | | 0 | 1 | 0 | Master | UINT8 | -| gps_sbas_mode | | 0 | 4 | 0 | Master | UINT8 | -| gps_auto_config | | 0 | 1 | 1 | Master | UINT8 | -| gps_auto_baud | | 0 | 1 | 0 | Master | UINT8 | -| gps_pos_p | | 0 | 200 | 15 | Profile | UINT8 | -| gps_pos_i | | 0 | 200 | 0 | Profile | UINT8 | -| gps_pos_d | | 0 | 200 | 0 | Profile | UINT8 | -| gps_posr_p | | 0 | 200 | 34 | Profile | UINT8 | -| gps_posr_i | | 0 | 200 | 14 | Profile | UINT8 | -| gps_posr_d | | 0 | 200 | 53 | Profile | UINT8 | -| gps_nav_p | | 0 | 200 | 25 | Profile | UINT8 | -| gps_nav_i | | 0 | 200 | 33 | Profile | UINT8 | -| gps_nav_d | | 0 | 200 | 83 | Profile | UINT8 | -| gps_wp_radius | | 0 | 2000 | 200 | Profile | UINT16 | -| nav_controls_heading | | 0 | 1 | 1 | Profile | UINT8 | -| nav_speed_min | | 10 | 2000 | 100 | Profile | UINT16 | -| nav_speed_max | | 10 | 2000 | 300 | Profile | UINT16 | -| nav_slew_rate | | 0 | 100 | 30 | Profile | UINT8 | -| serialrx_provider | | 0 | 6 | 0 | Master | UINT8 | -| spektrum_sat_bind | | 0 | 10 | 0 | Master | UINT8 | -| telemetry_provider | | 0 | 3 | 0 | Master | UINT8 | -| telemetry_switch | | 0 | 1 | 0 | Master | UINT8 | -| telemetry_inversion | | 0 | 1 | 0 | Master | UINT8 | -| frsky_default_lattitude | | -90 | 90 | 0 | Master | FLOAT | -| frsky_default_longitude | | -180 | 180 | 0 | Master | FLOAT | -| frsky_coordinates_format | | 0 | 1 | 0 | Master | UINT8 | -| frsky_unit | | 0 | 1 | 0 | Master | UINT8 | -| battery_capacity | | 0 | 20000 | 0 | Master | UINT16 | -| vbat_scale | | 0 | 255 | 110 | Master | UINT8 | -| vbat_max_cell_voltage | | 10 | 50 | 43 | Master | UINT8 | -| vbat_min_cell_voltage | | 10 | 50 | 33 | Master | UINT8 | -| vbat_warning_cell_voltage | | 10 | 50 | 35 | Master | UINT8 | -| current_meter_scale | | -10000 | 10000 | 400 | Master | INT16 | -| current_meter_offset | | 0 | 3300 | 0 | Master | UINT16 | -| multiwii_current_meter_output | | 0 | 1 | None defined! | Master | UINT8 | -| current_meter_type | | 0 | 2 | 1 | Master | UINT8 | -| align_gyro | | 0 | 8 | 0 | Master | UINT8 | -| align_acc | | 0 | 8 | 0 | Master | UINT8 | -| align_mag | | 0 | 8 | 0 | Master | UINT8 | -| align_board_roll | | -180 | 360 | 0 | Master | INT16 | -| align_board_pitch | | -180 | 360 | 0 | Master | INT16 | -| align_board_yaw | | -180 | 360 | 0 | Master | INT16 | -| max_angle_inclination | | 100 | 900 | 500 | Master | UINT16 | -| gyro_lpf | | 0 | 256 | 42 | Master | UINT16 | -| moron_threshold | | 0 | 128 | 32 | Master | UINT8 | -| gyro_cmpf_factor | | 100 | 1000 | 600 | Master | UINT16 | -| gyro_cmpfm_factor | | 100 | 1000 | 250 | Master | UINT16 | -| alt_hold_deadband | | 1 | 250 | 40 | Profile | UINT8 | -| alt_hold_fast_change | | 0 | 1 | 1 | Profile | UINT8 | -| deadband | | 0 | 32 | 0 | Profile | UINT8 | -| yaw_deadband | | 0 | 100 | 0 | Profile | UINT8 | -| throttle_correction_value | | 0 | 150 | 0 | Profile | UINT8 | -| throttle_correction_angle | | 1 | 900 | 800 | Profile | UINT16 | -| yaw_control_direction | | -1 | 1 | 1 | Master | INT8 | -| yaw_direction | | -1 | 1 | 1 | Profile | INT8 | -| tri_unarmed_servo | | 0 | 1 | 1 | Profile | INT8 | -| default_rate_profile | Default = profile number | 0 | 2 | | Profile | UINT8 | -| rc_rate | | 0 | 250 | 90 | Rate Profile | UINT8 | -| rc_expo | | 0 | 100 | 65 | Rate Profile | UINT8 | -| thr_mid | | 0 | 100 | 50 | Rate Profile | UINT8 | -| thr_expo | | 0 | 100 | 0 | Rate Profile | UINT8 | -| roll_pitch_rate | | 0 | 100 | 0 | Rate Profile | UINT8 | -| yaw_rate | | 0 | 100 | 0 | Rate Profile | UINT8 | -| tpa_rate | | 0 | 100 | 0 | Rate Profile | UINT8 | -| tpa_breakpoint | | 1000 | 2000 | 1500 | Rate Profile | UINT16 | -| failsafe_delay | | 0 | 200 | 10 | Profile | UINT8 | -| failsafe_off_delay | | 0 | 200 | 200 | Profile | UINT8 | -| failsafe_throttle | | 1000 | 2000 | 1200 | Profile | UINT16 | -| failsafe_min_usec | | 100 | 2000 | 985 | Profile | UINT16 | -| failsafe_max_usec | | 100 | 3000 | 2115 | Profile | UINT16 | -| gimbal_flags | | 0 | 255 | 1 | Profile | UINT8 | -| acc_hardware | | 0 | 9 | 0 | Master | UINT8 | -| acc_lpf_factor | | 0 | 250 | 4 | Profile | UINT8 | -| accxy_deadband | | 0 | 100 | 40 | Profile | UINT8 | -| accz_deadband | | 0 | 100 | 40 | Profile | UINT8 | -| accz_lpf_cutoff | | 1 | 20 | 5 | Profile | FLOAT | -| acc_unarmedcal | | 0 | 1 | 1 | Profile | UINT8 | -| acc_trim_pitch | | -300 | 300 | 0 | Profile | INT16 | -| acc_trim_roll | | -300 | 300 | 0 | Profile | INT16 | -| baro_tab_size | | 0 | 48 | 21 | Profile | UINT8 | -| baro_noise_lpf | | 0 | 1 | 0.6 | Profile | FLOAT | -| baro_cf_vel | | 0 | 1 | 0.985 | Profile | FLOAT | -| baro_cf_alt | | 0 | 1 | 0.965 | Profile | FLOAT | -| mag_hardware | | 0 | 3 | 0 | Master | UINT8 | -| mag_declination | | -18000 | 18000 | 0 | Profile | INT16 | -| pid_controller | | 0 | 4 | 0 | Profile | UINT8 | -| p_pitch | | 0 | 200 | 40 | Profile | UINT8 | -| i_pitch | | 0 | 200 | 30 | Profile | UINT8 | -| d_pitch | | 0 | 200 | 23 | Profile | UINT8 | -| p_roll | | 0 | 200 | 40 | Profile | UINT8 | -| i_roll | | 0 | 200 | 30 | Profile | UINT8 | -| d_roll | | 0 | 200 | 23 | Profile | UINT8 | -| p_yaw | | 0 | 200 | 85 | Profile | UINT8 | -| i_yaw | | 0 | 200 | 45 | Profile | UINT8 | -| d_yaw | | 0 | 200 | 0 | Profile | UINT8 | -| p_pitchf | | 0 | 100 | 2.5 | Profile | FLOAT | -| i_pitchf | | 0 | 100 | 0.6 | Profile | FLOAT | -| d_pitchf | | 0 | 100 | 0.06 | Profile | FLOAT | -| p_rollf | | 0 | 100 | 2.5 | Profile | FLOAT | -| i_rollf | | 0 | 100 | 0.6 | Profile | FLOAT | -| d_rollf | | 0 | 100 | 0.06 | Profile | FLOAT | -| p_yawf | | 0 | 100 | 8 | Profile | FLOAT | -| i_yawf | | 0 | 100 | 0.5 | Profile | FLOAT | -| d_yawf | | 0 | 100 | 0.05 | Profile | FLOAT | -| level_horizon | | 0 | 10 | 3 | Profile | FLOAT | -| level_angle | | 0 | 10 | 5 | Profile | FLOAT | -| sensitivity_horizon | | 0 | 250 | 75 | Profile | UINT8 | -| p_alt | | 0 | 200 | 50 | Profile | UINT8 | -| i_alt | | 0 | 200 | 0 | Profile | UINT8 | -| d_alt | | 0 | 200 | 0 | Profile | UINT8 | -| p_level | | 0 | 200 | 90 | Profile | UINT8 | -| i_level | | 0 | 200 | 10 | Profile | UINT8 | -| d_level | | 0 | 200 | 100 | Profile | UINT8 | -| p_vel | | 0 | 200 | 120 | Profile | UINT8 | -| i_vel | | 0 | 200 | 45 | Profile | UINT8 | -| d_vel | | 0 | 200 | 1 | Profile | UINT8 | -| blackbox_rate_num | | 1 | 32 | 1 | Master | UINT8 | -| blackbox_rate_denom | | 1 | 32 | 1 | Master | UINT8 | +| Variable | Description/Units | Min | Max | Default | Type | Datatype | +|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|--------|---------------|--------------|----------| +| looptime | This is the main loop time (in us). Changing this affects PID effect with some PID controllers (see PID section for details). Default of 3500us/285Hz should work for everyone. Setting it to zero does not limit loop time, so it will go as fast as possible. | 0 | 9000 | 3500 | Master | UINT16 | +| emf_avoidance | Default value is 0 for 72MHz processor speed. Setting this to 1 increases the processor speed, to move the 6th harmonic away from 432MHz. | 0 | 1 | 0 | Master | UINT8 | +| mid_rc | This is an important number to set in order to avoid trimming receiver/transmitter. Most standard receivers will have this at 1500, however Futaba transmitters will need this set to 1520. A way to find out if this needs to be changed, is to clear all trim/subtrim on transmitter, and connect to GUI. Note the value most channels idle at - this should be the number to choose. Once midrc is set, use subtrim on transmitter to make sure all channels (except throttle of course) are centered at midrc value. | 1200 | 1700 | 1500 | Master | UINT16 | +| min_check | These are min/max values (in us) which, when a channel is smaller (min) or larger (max) than the value will activate various RC commands, such as arming, or stick configuration. Normally, every RC channel should be set so that min = 1000us, max = 2000us. On most transmitters this usually means 125% endpoints. Default check values are 100us above/below this value. | 0 | 2000 | 1100 | Master | UINT16 | +| max_check | These are min/max values (in us) which, when a channel is smaller (min) or larger (max) than the value will activate various RC commands, such as arming, or stick configuration. Normally, every RC channel should be set so that min = 1000us, max = 2000us. On most transmitters this usually means 125% endpoints. Default check values are 100us above/below this value. | 0 | 2000 | 1900 | Master | UINT16 | +| rssi_channel | | 0 | 18 | 0 | Master | INT8 | +| rssi_scale | | 1 | 255 | 30 | Master | UINT8 | +| input_filtering_mode | | 0 | 1 | 0 | Master | INT8 | +| min_throttle | These are min/max values (in us) that are sent to esc when armed. Defaults of 1150/1850 are OK for everyone, for use with AfroESC, they could be set to 1064/1864. | 0 | 2000 | 1150 | Master | UINT16 | +| max_throttle | These are min/max values (in us) that are sent to esc when armed. Defaults of 1150/1850 are OK for everyone, for use with AfroESC, they could be set to 1064/1864. | 0 | 2000 | 1850 | Master | UINT16 | +| min_command | This is the PWM value sent to ESCs when they are not armed. If ESCs beep slowly when powered up, try decreasing this value. It can also be used for calibrating all ESCs at once. | 0 | 2000 | 1000 | Master | UINT16 | +| servo_center_pulse | | 0 | 2000 | 1500 | Master | UINT16 | +| 3d_deadband_low | | 0 | 2000 | 1406 | Master | UINT16 | +| 3d_deadband_high | | 0 | 2000 | 1514 | Master | UINT16 | +| 3d_neutral | | 0 | 2000 | 1460 | Master | UINT16 | +| 3d_deadband_throttle | | 0 | 2000 | 50 | Master | UINT16 | +| motor_pwm_rate | Output frequency (in Hz) for motor pins. Defaults are 400Hz for motor. If setting above 500Hz, will switch to brushed (direct drive) motors mode. For example, setting to 8000 will use brushed mode at 8kHz switching frequency. Up to 32kHz is supported. Note, that in brushed mode, minthrottle is offset to zero. Default is 16000 for boards with brushed motors. | 50 | 32000 | 400 | Master | UINT16 | +| servo_pwm_rate | Output frequency (in Hz) servo pins. Default is 50Hz. When using tricopters or gimbal with digital servo, this rate can be increased. Max of 498Hz (for 500Hz pwm period), and min of 50Hz. Most digital servos will support for example 330Hz. | 50 | 498 | 50 | Master | UINT16 | +| retarded_arm | Disabled by default, enabling (setting to 1) allows disarming by throttle low + roll. This could be useful for non-acro tricopters, where default arming by yaw could move tail servo too much. | 0 | 1 | 0 | Master | UINT8 | +| disarm_kill_switch | Enabled by default. Disarms the motors independently of throttle value. Setting to 0 reverts to the old behaviour of disarming only when the throttle is low. Only applies when arming and disarming with an AUX channel. | 0 | 1 | 1 | Master | UINT8 | +| auto_disarm_delay | | 0 | 60 | 5 | Master | UINT8 | +| small_angle | If the copter tilt angle exceed this value the copter will refuse to arm. default is 25°. | 0 | 180 | 25 | Master | UINT8 | +| flaps_speed | | 0 | 100 | 0 | Master | UINT8 | +| fixedwing_althold_dir | | -1 | 1 | 1 | Master | INT8 | +| serial_port_1_scenario | | 0 | 11 | | Master | UINT8 | +| serial_port_2_scenario | | 0 | 11 | | Master | UINT8 | +| serial_port_3_scenario | | 0 | 11 | | Master | UINT8 | +| serial_port_4_scenario | | 0 | 11 | | Master | UINT8 | +| serial_port_5_scenario | | 0 | 11 | | Master | UINT8 | +| reboot_character | | 48 | 126 | 82 | Master | UINT8 | +| msp_baudrate | | 1200 | 115200 | 115200 | Master | UINT32 | +| cli_baudrate | | 1200 | 115200 | 115200 | Master | UINT32 | +| gps_baudrate | | 0 | 115200 | 115200 | Master | UINT32 | +| gps_passthrough_baudrate | | 1200 | 115200 | 115200 | Master | UINT32 | +| gps_provider | | 0 | 1 | 0 | Master | UINT8 | +| gps_sbas_mode | | 0 | 4 | 0 | Master | UINT8 | +| gps_auto_config | | 0 | 1 | 1 | Master | UINT8 | +| gps_auto_baud | | 0 | 1 | 0 | Master | UINT8 | +| gps_pos_p | | 0 | 200 | 15 | Profile | UINT8 | +| gps_pos_i | | 0 | 200 | 0 | Profile | UINT8 | +| gps_pos_d | | 0 | 200 | 0 | Profile | UINT8 | +| gps_posr_p | | 0 | 200 | 34 | Profile | UINT8 | +| gps_posr_i | | 0 | 200 | 14 | Profile | UINT8 | +| gps_posr_d | | 0 | 200 | 53 | Profile | UINT8 | +| gps_nav_p | | 0 | 200 | 25 | Profile | UINT8 | +| gps_nav_i | | 0 | 200 | 33 | Profile | UINT8 | +| gps_nav_d | | 0 | 200 | 83 | Profile | UINT8 | +| gps_wp_radius | | 0 | 2000 | 200 | Profile | UINT16 | +| nav_controls_heading | | 0 | 1 | 1 | Profile | UINT8 | +| nav_speed_min | | 10 | 2000 | 100 | Profile | UINT16 | +| nav_speed_max | | 10 | 2000 | 300 | Profile | UINT16 | +| nav_slew_rate | | 0 | 100 | 30 | Profile | UINT8 | +| serialrx_provider | When feature SERIALRX is enabled, this allows connection to several receivers which output data via digital interface resembling serial. See RX section. | 0 | 6 | 0 | Master | UINT8 | +| spektrum_sat_bind | | 0 | 10 | 0 | Master | UINT8 | +| telemetry_provider | Choose what type of telemetry to output. See Telemetry section. | 0 | 3 | 0 | Master | UINT8 | +| telemetry_switch | Which aux channel to use to change serial output & baud rate (MSP / Telemetry). It disables automatic switching to Telemetry when armed. | 0 | 1 | 0 | Master | UINT8 | +| telemetry_inversion | | 0 | 1 | 0 | Master | UINT8 | +| frsky_default_lattitude | | -90 | 90 | 0 | Master | FLOAT | +| frsky_default_longitude | | -180 | 180 | 0 | Master | FLOAT | +| frsky_coordinates_format | | 0 | 1 | 0 | Master | UINT8 | +| frsky_unit | | 0 | 1 | 0 | Master | UINT8 | +| battery_capacity | | 0 | 20000 | 0 | Master | UINT16 | +| vbat_scale | Result is Vbatt in 0.1V steps. 3.3V = ADC Vref, 4095 = 12bit adc, 110 = 11:1 voltage divider (10k:1k) x 10 for 0.1V. Adjust this slightly if reported pack voltage is different from multimeter reading. You can get current voltage by typing "status"" in cli." | 0 | 255 | 110 | Master | UINT8 | +| vbat_max_cell_voltage | Maximum voltage per cell, used for auto-detecting battery voltage in 0.1V units, default is 43 (4.3V) | 10 | 50 | 43 | Master | UINT8 | +| vbat_min_cell_voltage | Minimum voltage per cell, this triggers battery out alarms, in 0.1V units, default is 33 (3.3V) | 10 | 50 | 33 | Master | UINT8 | +| vbat_warning_cell_voltage | | 10 | 50 | 35 | Master | UINT8 | +| current_meter_scale | This sets the output voltage to current scaling for the current sensor in 0.1 mV/A steps. 400 is 40mV/A such as the ACS756 sensor outputs. 183 is the setting for the Überdistro with a 0.25mOhm shunt. | -10000 | 10000 | 400 | Master | INT16 | +| current_meter_offset | This sets the output offset voltage of the current sensor in millivolts. | 0 | 3300 | 0 | Master | UINT16 | +| multiwii_current_meter_output | Default current output via MSP is in 0.01A steps. Setting this to 1 causes output in default multiwii scaling (1mA steps). | 0 | 1 | None defined! | Master | UINT8 | +| current_meter_type | | 0 | 2 | 1 | Master | UINT8 | +| align_gyro | When running on non-default hardware or adding support for new sensors/sensor boards, these values are used for sensor orientation. Default of zero means the driver determines alignment (and this generally means it's configured for standard hardware). Default orientation of X forward, Y right, Z up is 1. After that, the numbers are as follows, and mean sensor is rotated. CW0_DEG=1, CW90_DEG=2, CW180_DEG=3, CW270_DEG=4, CW0_DEG_FLIP=5, CW90_DEG_FLIP=6, CW180_DEG_FLIP=7, CW270_DEG_FLIP=8. This should cover all orientations. When carefully understood, these values can also be used to rotate (in 90deg steps) or flip the board. | 0 | 8 | 0 | Master | UINT8 | +| align_acc | When running on non-default hardware or adding support for new sensors/sensor boards, these values are used for sensor orientation. Default of zero means the driver determines alignment (and this generally means it's configured for standard hardware). Default orientation of X forward, Y right, Z up is 1. After that, the numbers are as follows, and mean sensor is rotated. CW0_DEG=1, CW90_DEG=2, CW180_DEG=3, CW270_DEG=4, CW0_DEG_FLIP=5, CW90_DEG_FLIP=6, CW180_DEG_FLIP=7, CW270_DEG_FLIP=8. This should cover all orientations. When carefully understood, these values can also be used to rotate (in 90deg steps) or flip the board. | 0 | 8 | 0 | Master | UINT8 | +| align_mag | When running on non-default hardware or adding support for new sensors/sensor boards, these values are used for sensor orientation. Default of zero means the driver determines alignment (and this generally means it's configured for standard hardware). Default orientation of X forward, Y right, Z up is 1. After that, the numbers are as follows, and mean sensor is rotated. CW0_DEG=1, CW90_DEG=2, CW180_DEG=3, CW270_DEG=4, CW0_DEG_FLIP=5, CW90_DEG_FLIP=6, CW180_DEG_FLIP=7, CW270_DEG_FLIP=8. This should cover all orientations. When carefully understood, these values can also be used to rotate (in 90deg steps) or flip the board. | 0 | 8 | 0 | Master | UINT8 | +| align_board_roll | Arbitrary board rotation in degrees, to allow mounting it sideways / upside down / rotated etc | -180 | 360 | 0 | Master | INT16 | +| align_board_pitch | Arbitrary board rotation in degrees, to allow mounting it sideways / upside down / rotated etc | -180 | 360 | 0 | Master | INT16 | +| align_board_yaw | Arbitrary board rotation in degrees, to allow mounting it sideways / upside down / rotated etc | -180 | 360 | 0 | Master | INT16 | +| max_angle_inclination | This setting controls max inclination (tilt) allowed in angle (level) mode. default 500 (50 degrees). | 100 | 900 | 500 | Master | UINT16 | +| gyro_lpf | Hardware lowpass filter for gyro. Allowed values depend on the driver - For example MPU6050 allows 5,10,20,42,98,188,256Hz, while MPU3050 doesn't allow 5Hz. If you have to set gyro lpf below 42Hz generally means the frame is vibrating too much, and that should be fixed first. Values outside of supported range will usually be ignored by drivers, and will configure lpf to default value of 42Hz. | 0 | 256 | 42 | Master | UINT16 | +| moron_threshold | When powering up, gyro bias is calculated. If the model is shaking/moving during this initial calibration, offsets are calculated incorrectly, and could lead to poor flying performance. This threshold (default of 32) means how much average gyro reading could differ before re-calibration is triggered. | 0 | 128 | 32 | Master | UINT8 | +| gyro_cmpf_factor | | 100 | 1000 | 600 | Master | UINT16 | +| gyro_cmpfm_factor | | 100 | 1000 | 250 | Master | UINT16 | +| alt_hold_deadband | | 1 | 250 | 40 | Profile | UINT8 | +| alt_hold_fast_change | | 0 | 1 | 1 | Profile | UINT8 | +| deadband | These are values (in us) by how much RC input can be different before it's considered valid. For transmitters with jitter on outputs, this value can be increased. Defaults are zero, but can be increased up to 10 or so if rc inputs twitch while idle. | 0 | 32 | 0 | Profile | UINT8 | +| yaw_deadband | These are values (in us) by how much RC input can be different before it's considered valid. For transmitters with jitter on outputs, this value can be increased. Defaults are zero, but can be increased up to 10 or so if rc inputs twitch while idle. | 0 | 100 | 0 | Profile | UINT8 | +| throttle_correction_value | The throttle_correction_value will be added to the throttle input. It will be maximal at the throttle_correction_angle and over, null when the copter is leveled and proportional in bewteen. The angle is set with 0.1 deg steps from 1 to 900, ie : 300 = 30.0 deg, 225 = 22.5 deg. | 0 | 150 | 0 | Profile | UINT8 | +| throttle_correction_angle | The throttle_correction_value will be added to the throttle input. It will be maximal at the throttle_correction_angle and over, null when the copter is leveled and proportional in bewteen. The angle is set with 0.1 deg steps from 1 to 900, ie : 300 = 30.0 deg, 225 = 22.5 deg. | 1 | 900 | 800 | Profile | UINT16 | +| yaw_control_direction | | -1 | 1 | 1 | Master | INT8 | +| yaw_direction | | -1 | 1 | 1 | Profile | INT8 | +| tri_unarmed_servo | On tricopter mix only, if this is set to 1, servo will always be correcting regardless of armed state. to disable this, set it to 0. | 0 | 1 | 1 | Profile | INT8 | +| default_rate_profile | Default = profile number | 0 | 2 | | Profile | UINT8 | +| rc_rate | | 0 | 250 | 90 | Rate Profile | UINT8 | +| rc_expo | | 0 | 100 | 65 | Rate Profile | UINT8 | +| thr_mid | | 0 | 100 | 50 | Rate Profile | UINT8 | +| thr_expo | | 0 | 100 | 0 | Rate Profile | UINT8 | +| roll_pitch_rate | | 0 | 100 | 0 | Rate Profile | UINT8 | +| yaw_rate | | 0 | 100 | 0 | Rate Profile | UINT8 | +| tpa_rate | | 0 | 100 | 0 | Rate Profile | UINT8 | +| tpa_breakpoint | | 1000 | 2000 | 1500 | Rate Profile | UINT16 | +| failsafe_delay | | 0 | 200 | 10 | Profile | UINT8 | +| failsafe_off_delay | | 0 | 200 | 200 | Profile | UINT8 | +| failsafe_throttle | | 1000 | 2000 | 1200 | Profile | UINT16 | +| failsafe_min_usec | | 100 | 2000 | 985 | Profile | UINT16 | +| failsafe_max_usec | | 100 | 3000 | 2115 | Profile | UINT16 | +| gimbal_flags | When feature SERVO_TILT is enabled, this can be a combination of the following numbers: 1=normal gimbal (default), 2=tiltmix gimbal, 4=in PPM (or SERIALRX) input mode, this will forward AUX1..4 RC inputs to PWM5..8 pins | 0 | 255 | 1 | Profile | UINT8 | +| acc_hardware | This is used to suggest which accelerometer driver should load, or to force no accelerometer in case gyro-only flight is needed. Default (0) will attempt to auto-detect among enabled drivers. Otherwise, to force a particular device, set it to 1 for ADXL345, 2 for MPU6050 integrated accelerometer, 3 for MMA8452, 4 for BMA280, or 5 to disable accelerometer alltogether - resulting in gyro-only operation. | 0 | 9 | 0 | Master | UINT8 | +| acc_lpf_factor | | 0 | 250 | 4 | Profile | UINT8 | +| accxy_deadband | | 0 | 100 | 40 | Profile | UINT8 | +| accz_deadband | | 0 | 100 | 40 | Profile | UINT8 | +| accz_lpf_cutoff | | 1 | 20 | 5 | Profile | FLOAT | +| acc_unarmedcal | | 0 | 1 | 1 | Profile | UINT8 | +| acc_trim_pitch | | -300 | 300 | 0 | Profile | INT16 | +| acc_trim_roll | | -300 | 300 | 0 | Profile | INT16 | +| baro_tab_size | | 0 | 48 | 21 | Profile | UINT8 | +| baro_noise_lpf | | 0 | 1 | 0.6 | Profile | FLOAT | +| baro_cf_vel | | 0 | 1 | 0.985 | Profile | FLOAT | +| baro_cf_alt | | 0 | 1 | 0.965 | Profile | FLOAT | +| mag_hardware | | 0 | 3 | 0 | Master | UINT8 | +| mag_declination | Current location magnetic declination in format. For example, -6deg 37min, = for Japan. Leading zero in ddd not required. Get your local magnetic declination here: http://magnetic-declination.com/ | -18000 | 18000 | 0 | Profile | INT16 | +| pid_controller | | 0 | 4 | 0 | Profile | UINT8 | +| p_pitch | | 0 | 200 | 40 | Profile | UINT8 | +| i_pitch | | 0 | 200 | 30 | Profile | UINT8 | +| d_pitch | | 0 | 200 | 23 | Profile | UINT8 | +| p_roll | | 0 | 200 | 40 | Profile | UINT8 | +| i_roll | | 0 | 200 | 30 | Profile | UINT8 | +| d_roll | | 0 | 200 | 23 | Profile | UINT8 | +| p_yaw | | 0 | 200 | 85 | Profile | UINT8 | +| i_yaw | | 0 | 200 | 45 | Profile | UINT8 | +| d_yaw | | 0 | 200 | 0 | Profile | UINT8 | +| p_pitchf | | 0 | 100 | 2.5 | Profile | FLOAT | +| i_pitchf | | 0 | 100 | 0.6 | Profile | FLOAT | +| d_pitchf | | 0 | 100 | 0.06 | Profile | FLOAT | +| p_rollf | | 0 | 100 | 2.5 | Profile | FLOAT | +| i_rollf | | 0 | 100 | 0.6 | Profile | FLOAT | +| d_rollf | | 0 | 100 | 0.06 | Profile | FLOAT | +| p_yawf | | 0 | 100 | 8 | Profile | FLOAT | +| i_yawf | | 0 | 100 | 0.5 | Profile | FLOAT | +| d_yawf | | 0 | 100 | 0.05 | Profile | FLOAT | +| level_horizon | | 0 | 10 | 3 | Profile | FLOAT | +| level_angle | | 0 | 10 | 5 | Profile | FLOAT | +| sensitivity_horizon | | 0 | 250 | 75 | Profile | UINT8 | +| p_alt | | 0 | 200 | 50 | Profile | UINT8 | +| i_alt | | 0 | 200 | 0 | Profile | UINT8 | +| d_alt | | 0 | 200 | 0 | Profile | UINT8 | +| p_level | | 0 | 200 | 90 | Profile | UINT8 | +| i_level | | 0 | 200 | 10 | Profile | UINT8 | +| d_level | | 0 | 200 | 100 | Profile | UINT8 | +| p_vel | | 0 | 200 | 120 | Profile | UINT8 | +| i_vel | | 0 | 200 | 45 | Profile | UINT8 | +| d_vel | | 0 | 200 | 1 | Profile | UINT8 | +| blackbox_rate_num | | 1 | 32 | 1 | Master | UINT8 | +| blackbox_rate_denom | | 1 | 32 | 1 | Master | UINT8 | From e554f73f5cef824830054c96bff1baeba6fac692 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Wed, 18 Feb 2015 19:29:47 +0000 Subject: [PATCH 49/60] Update the sensors page to show inclination, heading, estimated G and the value for small angle. The latter is to help get field reports to help with a problem where sometimes the aircraft won't arm because the FC thinks it's tilted over too much. --- src/main/flight/imu.h | 4 ++-- src/main/io/display.c | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/main/flight/imu.h b/src/main/flight/imu.h index 9d1c83110e..9a632f5705 100644 --- a/src/main/flight/imu.h +++ b/src/main/flight/imu.h @@ -21,11 +21,11 @@ extern int16_t throttleAngleCorrection; extern uint32_t accTimeSum; extern int accSumCount; extern float accVelScale; - +extern t_fp_vector EstG; extern int16_t accSmooth[XYZ_AXIS_COUNT]; extern int32_t accSum[XYZ_AXIS_COUNT]; extern int16_t gyroData[FLIGHT_DYNAMICS_INDEX_COUNT]; - +extern int16_t smallAngle; typedef struct rollAndPitchInclination_s { // absolute angle inclination in multiple of 0.1 degree 180 deg = 1800 diff --git a/src/main/io/display.c b/src/main/io/display.c index 849560f8de..0d054f4ad9 100644 --- a/src/main/io/display.c +++ b/src/main/io/display.c @@ -35,6 +35,7 @@ #include "common/printf.h" #include "common/maths.h" #include "common/axis.h" +#include "common/typeconversion.h" #ifdef DISPLAY @@ -384,20 +385,20 @@ void showBatteryPage(void) void showSensorsPage(void) { uint8_t rowIndex = PAGE_TITLE_LINE_COUNT; - static const char *format = "%c = %5d %5d %5d"; + static const char *format = "%s %5d %5d %5d"; i2c_OLED_set_line(rowIndex++); i2c_OLED_send_string(" X Y Z"); if (sensors(SENSOR_ACC)) { - tfp_sprintf(lineBuffer, format, 'A', accSmooth[X], accSmooth[Y], accSmooth[Z]); + tfp_sprintf(lineBuffer, format, "ACC", accSmooth[X], accSmooth[Y], accSmooth[Z]); padLineBuffer(); i2c_OLED_set_line(rowIndex++); i2c_OLED_send_string(lineBuffer); } if (sensors(SENSOR_GYRO)) { - tfp_sprintf(lineBuffer, format, 'G', gyroADC[X], gyroADC[Y], gyroADC[Z]); + tfp_sprintf(lineBuffer, format, "GYR", gyroADC[X], gyroADC[Y], gyroADC[Z]); padLineBuffer(); i2c_OLED_set_line(rowIndex++); i2c_OLED_send_string(lineBuffer); @@ -405,12 +406,42 @@ void showSensorsPage(void) #ifdef MAG if (sensors(SENSOR_MAG)) { - tfp_sprintf(lineBuffer, format, 'M', magADC[X], magADC[Y], magADC[Z]); + tfp_sprintf(lineBuffer, format, "MAG", magADC[X], magADC[Y], magADC[Z]); padLineBuffer(); i2c_OLED_set_line(rowIndex++); i2c_OLED_send_string(lineBuffer); } #endif + + tfp_sprintf(lineBuffer, format, "I&H", inclination.values.rollDeciDegrees, inclination.values.pitchDeciDegrees, heading); + padLineBuffer(); + i2c_OLED_set_line(rowIndex++); + i2c_OLED_send_string(lineBuffer); + + uint8_t length; + + ftoa(EstG.A[X], lineBuffer); + length = strlen(lineBuffer); + while (length < HALF_SCREEN_CHARACTER_COLUMN_COUNT) { + lineBuffer[length++] = ' '; + lineBuffer[length+1] = 0; + } + ftoa(EstG.A[Y], lineBuffer + length); + padLineBuffer(); + i2c_OLED_set_line(rowIndex++); + i2c_OLED_send_string(lineBuffer); + + ftoa(EstG.A[Z], lineBuffer); + length = strlen(lineBuffer); + while (length < HALF_SCREEN_CHARACTER_COLUMN_COUNT) { + lineBuffer[length++] = ' '; + lineBuffer[length+1] = 0; + } + ftoa(smallAngle, lineBuffer + length); + padLineBuffer(); + i2c_OLED_set_line(rowIndex++); + i2c_OLED_send_string(lineBuffer); + } #ifdef ENABLE_DEBUG_OLED_PAGE From 6c92ea8ee834be87f8f56c4f12953c5b4ecc5869 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Wed, 18 Feb 2015 22:55:05 +0100 Subject: [PATCH 50/60] Harakiri PID fix Change errorGyroI and errorAngleI from int32 to float --- src/main/flight/pid.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index fccab9ab56..0abc12eff9 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -60,6 +60,7 @@ uint8_t dynP8[3], dynI8[3], dynD8[3]; static int32_t errorGyroI[3] = { 0, 0, 0 }; static float errorGyroIf[3] = { 0.0f, 0.0f, 0.0f }; static int32_t errorAngleI[2] = { 0, 0 }; +static float errorAngleIf[2] = { 0.0f, 0.0f }; static void pidMultiWii(pidProfile_t *pidProfile, controlRateConfig_t *controlRateConfig, uint16_t max_angle_inclination, rollAndPitchTrims_t *angleTrim, rxConfig_t *rxConfig); @@ -73,6 +74,9 @@ void resetErrorAngle(void) { errorAngleI[ROLL] = 0; errorAngleI[PITCH] = 0; + + errorAngleIf[ROLL] = 0; + errorAngleIf[PITCH] = 0; } void resetErrorGyro(void) @@ -554,19 +558,19 @@ rollAndPitchTrims_t *angleTrim, rxConfig_t *rxConfig) PTermACC = error * (float)pidProfile->P8[PIDLEVEL] * 0.008f; tmp0flt = (float)pidProfile->D8[PIDLEVEL] * 5.0f; PTermACC = constrain(PTermACC, -tmp0flt, +tmp0flt); - errorAngleI[axis] = constrain(errorAngleI[axis] + error * ACCDeltaTimeINS, -30.0f, +30.0f); - ITermACC = errorAngleI[axis] * (float)pidProfile->I8[PIDLEVEL] * 0.08f; + errorAngleIf[axis] = constrain(errorAngleIf[axis] + error * ACCDeltaTimeINS, -30.0f, +30.0f); + ITermACC = errorAngleIf[axis] * (float)pidProfile->I8[PIDLEVEL] * 0.08f; } if (!FLIGHT_MODE(ANGLE_MODE)) { if (ABS((int16_t)gyroData[axis]) > 2560) { - errorGyroI[axis] = 0.0f; + errorGyroIf[axis] = 0.0f; } else { error = (rcCommandAxis * 320.0f / (float)pidProfile->P8[axis]) - gyroData[axis]; - errorGyroI[axis] = constrain(errorGyroI[axis] + error * ACCDeltaTimeINS, -192.0f, +192.0f); + errorGyroIf[axis] = constrainf(errorGyroIf[axis] + error * ACCDeltaTimeINS, -192.0f, +192.0f); } - ITermGYRO = errorGyroI[axis] * (float)pidProfile->I8[axis] * 0.01f; + ITermGYRO = errorGyroIf[axis] * (float)pidProfile->I8[axis] * 0.01f; if (FLIGHT_MODE(HORIZON_MODE)) { PTerm = PTermACC + prop * (rcCommandAxis - PTermACC); From 6548c90ca80e4c4e527fcab6bda9f5426445bc90 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Thu, 19 Feb 2015 08:30:41 +0100 Subject: [PATCH 51/60] Align Harakiri PID with Crashpilot1000 updates --- src/main/flight/pid.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 0abc12eff9..c63d858894 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -75,8 +75,8 @@ void resetErrorAngle(void) errorAngleI[ROLL] = 0; errorAngleI[PITCH] = 0; - errorAngleIf[ROLL] = 0; - errorAngleIf[PITCH] = 0; + errorAngleIf[ROLL] = 0.0f; + errorAngleIf[PITCH] = 0.0f; } void resetErrorGyro(void) @@ -85,9 +85,9 @@ void resetErrorGyro(void) errorGyroI[PITCH] = 0; errorGyroI[YAW] = 0; - errorGyroIf[ROLL] = 0; - errorGyroIf[PITCH] = 0; - errorGyroIf[YAW] = 0; + errorGyroIf[ROLL] = 0.0f; + errorGyroIf[PITCH] = 0.0f; + errorGyroIf[YAW] = 0.0f; } const angle_index_t rcAliasToAngleIndexMap[] = { AI_ROLL, AI_PITCH }; @@ -523,13 +523,14 @@ rollAndPitchTrims_t *angleTrim, rxConfig_t *rxConfig) UNUSED(rxConfig); float delta, RCfactor, rcCommandAxis, MainDptCut; - float PTerm = 0, ITerm = 0, DTerm = 0, PTermACC = 0, ITermACC = 0, ITermGYRO = 0, error = 0, prop = 0; - static float lastGyro[2] = {0, 0}, lastDTerm[2] = {0, 0}; + float PTerm = 0.0f, ITerm = 0.0f, DTerm = 0.0f, PTermACC = 0.0f, ITermACC = 0.0f, ITermGYRO = 0.0f, error = 0.0f, prop = 0.0f; + static float lastGyro[2] = { 0.0f, 0.0f }, lastDTerm[2] = { 0.0f, 0.0f }; + float gyroDataQuant[2] = { 0.0f, 0.0f }; float tmp0flt; int32_t tmp0; uint8_t axis; - float ACCDeltaTimeINS = 0; - float FLOATcycleTime = 0; + float ACCDeltaTimeINS = 0.0f; + float FLOATcycleTime = 0.0f; // MainDptCut = RCconstPI / (float)cfg.maincuthz; // Initialize Cut off frequencies for mainpid D MainDptCut = RCconstPI / MAIN_CUT_HZ; // maincuthz (default 12Hz, Range 1-50Hz), hardcoded for now @@ -542,6 +543,8 @@ rollAndPitchTrims_t *angleTrim, rxConfig_t *rxConfig) } for (axis = 0; axis < 2; axis++) { + tmp0 = (int32_t)((float)gyroData[axis] * 0.3125f); // Multiwii masks out the last 2 bits, this has the same idea + gyroDataQuant[axis] = (float)tmp0 * 3.2f; // but delivers more accuracy and also reduces jittery flight rcCommandAxis = (float)rcCommand[axis]; // Calculate common values for pid controllers if (FLIGHT_MODE(ANGLE_MODE) || FLIGHT_MODE(HORIZON_MODE)) { #ifdef GPS @@ -566,7 +569,7 @@ rollAndPitchTrims_t *angleTrim, rxConfig_t *rxConfig) if (ABS((int16_t)gyroData[axis]) > 2560) { errorGyroIf[axis] = 0.0f; } else { - error = (rcCommandAxis * 320.0f / (float)pidProfile->P8[axis]) - gyroData[axis]; + error = (rcCommandAxis * 320.0f / (float)pidProfile->P8[axis]) - gyroDataQuant[axis]; errorGyroIf[axis] = constrainf(errorGyroIf[axis] + error * ACCDeltaTimeINS, -192.0f, +192.0f); } @@ -584,10 +587,10 @@ rollAndPitchTrims_t *angleTrim, rxConfig_t *rxConfig) ITerm = ITermACC; } - PTerm -= gyroData[axis] * dynP8[axis] * 0.003f; - delta = (gyroData[axis] - lastGyro[axis]) / ACCDeltaTimeINS; + PTerm -= gyroDataQuant[axis] * dynP8[axis] * 0.003f; + delta = (gyroDataQuant[axis] - lastGyro[axis]) / ACCDeltaTimeINS; - lastGyro[axis] = gyroData[axis]; + lastGyro[axis] = gyroDataQuant[axis]; lastDTerm[axis] += RCfactor * (delta - lastDTerm[axis]); DTerm = lastDTerm[axis] * dynD8[axis] * 0.00007f; From cd94377651c8f298ae575ea825e5b3107d3e22e1 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Thu, 19 Feb 2015 09:00:20 +0100 Subject: [PATCH 52/60] Latest Crashpilot1000 update --- src/main/flight/pid.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index c63d858894..42cfe7f9cb 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -522,10 +522,9 @@ rollAndPitchTrims_t *angleTrim, rxConfig_t *rxConfig) { UNUSED(rxConfig); - float delta, RCfactor, rcCommandAxis, MainDptCut; + float delta, RCfactor, rcCommandAxis, MainDptCut, gyroDataQuant; float PTerm = 0.0f, ITerm = 0.0f, DTerm = 0.0f, PTermACC = 0.0f, ITermACC = 0.0f, ITermGYRO = 0.0f, error = 0.0f, prop = 0.0f; static float lastGyro[2] = { 0.0f, 0.0f }, lastDTerm[2] = { 0.0f, 0.0f }; - float gyroDataQuant[2] = { 0.0f, 0.0f }; float tmp0flt; int32_t tmp0; uint8_t axis; @@ -544,7 +543,7 @@ rollAndPitchTrims_t *angleTrim, rxConfig_t *rxConfig) for (axis = 0; axis < 2; axis++) { tmp0 = (int32_t)((float)gyroData[axis] * 0.3125f); // Multiwii masks out the last 2 bits, this has the same idea - gyroDataQuant[axis] = (float)tmp0 * 3.2f; // but delivers more accuracy and also reduces jittery flight + gyroDataQuant = (float)tmp0 * 3.2f; // but delivers more accuracy and also reduces jittery flight rcCommandAxis = (float)rcCommand[axis]; // Calculate common values for pid controllers if (FLIGHT_MODE(ANGLE_MODE) || FLIGHT_MODE(HORIZON_MODE)) { #ifdef GPS @@ -569,7 +568,7 @@ rollAndPitchTrims_t *angleTrim, rxConfig_t *rxConfig) if (ABS((int16_t)gyroData[axis]) > 2560) { errorGyroIf[axis] = 0.0f; } else { - error = (rcCommandAxis * 320.0f / (float)pidProfile->P8[axis]) - gyroDataQuant[axis]; + error = (rcCommandAxis * 320.0f / (float)pidProfile->P8[axis]) - gyroDataQuant; errorGyroIf[axis] = constrainf(errorGyroIf[axis] + error * ACCDeltaTimeINS, -192.0f, +192.0f); } @@ -587,10 +586,10 @@ rollAndPitchTrims_t *angleTrim, rxConfig_t *rxConfig) ITerm = ITermACC; } - PTerm -= gyroDataQuant[axis] * dynP8[axis] * 0.003f; - delta = (gyroDataQuant[axis] - lastGyro[axis]) / ACCDeltaTimeINS; + PTerm -= gyroDataQuant * dynP8[axis] * 0.003f; + delta = (gyroDataQuant - lastGyro[axis]) / ACCDeltaTimeINS; - lastGyro[axis] = gyroDataQuant[axis]; + lastGyro[axis] = gyroDataQuant; lastDTerm[axis] += RCfactor * (delta - lastDTerm[axis]); DTerm = lastDTerm[axis] * dynD8[axis] * 0.00007f; From 77e5be5002da846c642c7159b137bf449a940f6e Mon Sep 17 00:00:00 2001 From: Konstantin Sharlaimov Date: Thu, 19 Feb 2015 15:25:32 +1000 Subject: [PATCH 53/60] Fixed external barometer & magnetometer detection --- src/main/sensors/initialisation.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/sensors/initialisation.c b/src/main/sensors/initialisation.c index f278893e7b..ee6f3913cd 100644 --- a/src/main/sensors/initialisation.c +++ b/src/main/sensors/initialisation.c @@ -381,12 +381,14 @@ static void detectBaro() #ifdef USE_BARO_MS5611 if (ms5611Detect(&baro)) { + sensorsSet(SENSOR_BARO); return; } #endif #ifdef USE_BARO_BMP085 if (bmp085Detect(bmp085Config, &baro)) { + sensorsSet(SENSOR_BARO); return; } #endif @@ -440,6 +442,7 @@ retry: #ifdef USE_MAG_HMC5883 case MAG_HMC5883: if (hmc5883lDetect(&mag, hmc5883Config)) { + sensorsSet(SENSOR_MAG); #ifdef MAG_HMC5883_ALIGN magAlign = MAG_HMC5883_ALIGN; #endif @@ -455,6 +458,7 @@ retry: case MAG_AK8975: if (ak8975detect(&mag)) { + sensorsSet(SENSOR_MAG); #ifdef MAG_AK8975_ALIGN magAlign = MAG_AK8975_ALIGN; #endif From c45efac8122d9f668ff4e80c8594c14e61736bc3 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Thu, 19 Feb 2015 16:15:14 +0000 Subject: [PATCH 54/60] Cleanup sensor detection. Less code required and a similar pattern is used for each type of sensor. --- src/main/main.c | 3 - src/main/sensors/acceleration.c | 2 +- src/main/sensors/acceleration.h | 4 +- src/main/sensors/barometer.c | 1 + src/main/sensors/barometer.h | 9 +++ src/main/sensors/compass.c | 2 +- src/main/sensors/compass.h | 2 +- src/main/sensors/initialisation.c | 97 +++++++++++++---------- src/main/target/ALIENWIIF3/target.h | 3 - src/main/target/CC3D/target.h | 2 - src/main/target/CHEBUZZF3/target.h | 3 - src/main/target/CJMCU/target.h | 2 - src/main/target/EUSTM32F103RC/target.h | 2 - src/main/target/NAZE/target.h | 2 - src/main/target/NAZE32PRO/target.h | 2 - src/main/target/OLIMEXINO/target.h | 3 - src/main/target/PORT103R/target.h | 2 - src/main/target/SPARKY/target.h | 3 - src/main/target/SPRACINGF3/target.h | 2 - src/main/target/STM32F3DISCOVERY/target.h | 2 - 20 files changed, 70 insertions(+), 78 deletions(-) diff --git a/src/main/main.c b/src/main/main.c index f83d5e23f2..1cc6a18781 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -294,9 +294,6 @@ void init(void) } #endif - // We have these sensors; SENSORS_SET defined in board.h depending on hardware platform - sensorsSet(SENSORS_SET); - // drop out any sensors that don't seem to work, init all the others. halt if gyro is dead. sensorsOK = sensorsAutodetect(&masterConfig.sensorAlignmentConfig, masterConfig.gyro_lpf, masterConfig.acc_hardware, masterConfig.mag_hardware, currentProfile->mag_declination); // if gyro was not detected due to whatever reason, we give up now. diff --git a/src/main/sensors/acceleration.c b/src/main/sensors/acceleration.c index f02e0e992e..b43711f0bd 100644 --- a/src/main/sensors/acceleration.c +++ b/src/main/sensors/acceleration.c @@ -37,7 +37,7 @@ int16_t accADC[XYZ_AXIS_COUNT]; acc_t acc; // acc access functions -uint8_t accHardware = ACC_DEFAULT; // which accel chip is used/detected +accelerationSensor_e accHardware = ACC_DEFAULT; // which accel chip is used/detected sensor_align_e accAlign = 0; uint16_t acc_1G = 256; // this is the 1G measured acceleration. diff --git a/src/main/sensors/acceleration.h b/src/main/sensors/acceleration.h index 159393aa15..709f4415a2 100644 --- a/src/main/sensors/acceleration.h +++ b/src/main/sensors/acceleration.h @@ -18,7 +18,7 @@ #pragma once // Type of accelerometer used/detected -typedef enum AccelSensors { +typedef enum { ACC_DEFAULT = 0, ACC_ADXL345 = 1, ACC_MPU6050 = 2, @@ -29,7 +29,7 @@ typedef enum AccelSensors { ACC_SPI_MPU6500 = 7, ACC_FAKE = 8, ACC_NONE = 9 -} accelSensor_e; +} accelerationSensor_e; extern uint8_t accHardware; extern sensor_align_e accAlign; diff --git a/src/main/sensors/barometer.c b/src/main/sensors/barometer.c index f019dd628c..719c83eed7 100644 --- a/src/main/sensors/barometer.c +++ b/src/main/sensors/barometer.c @@ -41,6 +41,7 @@ static int32_t baroGroundPressure = 0; static uint32_t baroPressureSum = 0; barometerConfig_t *barometerConfig; +baroSensor_e baroHardware; void useBarometerConfig(barometerConfig_t *barometerConfigToUse) { diff --git a/src/main/sensors/barometer.h b/src/main/sensors/barometer.h index 9edd7c6a57..fed38d0aab 100644 --- a/src/main/sensors/barometer.h +++ b/src/main/sensors/barometer.h @@ -17,6 +17,15 @@ #pragma once +typedef enum { + BARO_NONE = 0, + BARO_DEFAULT = 1, + BARO_BMP085 = 2, + BARO_MS5611 = 3 +} baroSensor_e; + +extern baroSensor_e baroHardware; + #define BARO_SAMPLE_COUNT_MAX 48 typedef struct barometerConfig_s { diff --git a/src/main/sensors/compass.c b/src/main/sensors/compass.c index e3c18036ad..7c5f11f6a7 100644 --- a/src/main/sensors/compass.c +++ b/src/main/sensors/compass.c @@ -40,7 +40,7 @@ #endif mag_t mag; // mag access functions -uint8_t magHardware = MAG_DEFAULT; +magSensor_e magHardware = MAG_DEFAULT; extern uint32_t currentTime; // FIXME dependency on global variable, pass it in instead. diff --git a/src/main/sensors/compass.h b/src/main/sensors/compass.h index 374cac1851..2effbabc95 100644 --- a/src/main/sensors/compass.h +++ b/src/main/sensors/compass.h @@ -18,7 +18,7 @@ #pragma once // Type of accelerometer used/detected -typedef enum MagSensors { +typedef enum { MAG_DEFAULT = 0, MAG_HMC5883 = 1, MAG_AK8975 = 2, diff --git a/src/main/sensors/initialisation.c b/src/main/sensors/initialisation.c index ee6f3913cd..883c253f19 100644 --- a/src/main/sensors/initialisation.c +++ b/src/main/sensors/initialisation.c @@ -233,11 +233,10 @@ retry: } #endif case ACC_NONE: // disable ACC - sensorsClear(SENSOR_ACC); break; case ACC_DEFAULT: // autodetect -#ifdef USE_ACC_ADXL345 case ACC_ADXL345: // ADXL345 +#ifdef USE_ACC_ADXL345 acc_params.useFifo = false; acc_params.dataRate = 800; // unused currently #ifdef NAZE @@ -252,10 +251,10 @@ retry: if (accHardwareToUse == ACC_ADXL345) break; } - ; // fallthrough #endif -#ifdef USE_ACC_LSM303DLHC + ; // fallthrough case ACC_LSM303DLHC: +#ifdef USE_ACC_LSM303DLHC if (lsm303dlhcAccDetect(&acc)) { #ifdef ACC_LSM303DLHC_ALIGN accAlign = ACC_LSM303DLHC_ALIGN; @@ -264,10 +263,10 @@ retry: if (accHardwareToUse == ACC_LSM303DLHC) break; } - ; // fallthrough #endif -#ifdef USE_ACC_MPU6050 + ; // fallthrough case ACC_MPU6050: // MPU6050 +#ifdef USE_ACC_MPU6050 if (mpu6050AccDetect(selectMPU6050Config(), &acc)) { #ifdef ACC_MPU6050_ALIGN accAlign = ACC_MPU6050_ALIGN; @@ -276,10 +275,10 @@ retry: if (accHardwareToUse == ACC_MPU6050) break; } - ; // fallthrough #endif -#ifdef USE_ACC_MMA8452 + ; // fallthrough case ACC_MMA8452: // MMA8452 +#ifdef USE_ACC_MMA8452 #ifdef NAZE // Not supported with this frequency if (hardwareRevision < NAZE32_REV5 && mma8452Detect(&acc)) { @@ -293,10 +292,10 @@ retry: if (accHardwareToUse == ACC_MMA8452) break; } - ; // fallthrough #endif -#ifdef USE_ACC_BMA280 + ; // fallthrough case ACC_BMA280: // BMA280 +#ifdef USE_ACC_BMA280 if (bma280Detect(&acc)) { #ifdef ACC_BMA280_ALIGN accAlign = ACC_BMA280_ALIGN; @@ -305,10 +304,10 @@ retry: if (accHardwareToUse == ACC_BMA280) break; } - ; // fallthrough #endif -#ifdef USE_ACC_SPI_MPU6000 + ; // fallthrough case ACC_SPI_MPU6000: +#ifdef USE_ACC_SPI_MPU6000 if (mpu6000SpiAccDetect(&acc)) { #ifdef ACC_SPI_MPU6000_ALIGN accAlign = ACC_SPI_MPU6000_ALIGN; @@ -317,10 +316,10 @@ retry: if (accHardwareToUse == ACC_SPI_MPU6000) break; } - ; // fallthrough #endif -#ifdef USE_ACC_SPI_MPU6500 + ; // fallthrough case ACC_SPI_MPU6500: +#ifdef USE_ACC_SPI_MPU6500 #ifdef NAZE if (hardwareRevision == NAZE32_SP && mpu6500SpiAccDetect(&acc)) { #else @@ -333,9 +332,8 @@ retry: if (accHardwareToUse == ACC_SPI_MPU6500) break; } - ; // fallthrough #endif - ; // prevent compiler error + ; // fallthrough } // Found anything? Check if error or ACC is really missing. @@ -344,18 +342,21 @@ retry: // Nothing was found and we have a forced sensor that isn't present. accHardwareToUse = ACC_DEFAULT; goto retry; - } else { - // No ACC was detected - sensorsClear(SENSOR_ACC); } } + + if (accHardware != ACC_NONE) { + sensorsSet(SENSOR_ACC); + } } static void detectBaro() { +#ifdef BARO // Detect what pressure sensors are available. baro->update() is set to sensor-specific update function - #ifdef BARO + baroHardware = BARO_DEFAULT; + #ifdef USE_BARO_BMP085 const bmp085Config_t *bmp085Config = NULL; @@ -379,24 +380,37 @@ static void detectBaro() #endif -#ifdef USE_BARO_MS5611 - if (ms5611Detect(&baro)) { - sensorsSet(SENSOR_BARO); - return; - } -#endif + switch (baroHardware) { + case BARO_DEFAULT: + ; // fallthough + case BARO_MS5611: +#ifdef USE_BARO_MS5611 + if (ms5611Detect(&baro)) { + baroHardware = BARO_MS5611; + break; + } +#endif + ; // fallthough + case BARO_BMP085: #ifdef USE_BARO_BMP085 - if (bmp085Detect(bmp085Config, &baro)) { - sensorsSet(SENSOR_BARO); - return; + if (bmp085Detect(bmp085Config, &baro)) { + baroHardware = BARO_BMP085; + break; + } +#endif + baroHardware = BARO_NONE; // nothing detected or enabled. + case BARO_NONE: + break; } -#endif -#endif - sensorsClear(SENSOR_BARO); + + if (baroHardware != BARO_NONE) { + sensorsSet(SENSOR_BARO); + } + #endif } -static void detectMag(uint8_t magHardwareToUse) +static void detectMag(magSensor_e magHardwareToUse) { #ifdef USE_MAG_HMC5883 static hmc5883Config_t *hmc5883Config = 0; @@ -435,12 +449,11 @@ retry: switch(magHardwareToUse) { case MAG_NONE: // disable MAG - sensorsClear(SENSOR_MAG); break; case MAG_DEFAULT: // autodetect -#ifdef USE_MAG_HMC5883 case MAG_HMC5883: +#ifdef USE_MAG_HMC5883 if (hmc5883lDetect(&mag, hmc5883Config)) { sensorsSet(SENSOR_MAG); #ifdef MAG_HMC5883_ALIGN @@ -451,11 +464,11 @@ retry: break; } - ; // fallthrough #endif + ; // fallthrough -#ifdef USE_MAG_AK8975 case MAG_AK8975: +#ifdef USE_MAG_AK8975 if (ak8975detect(&mag)) { sensorsSet(SENSOR_MAG); @@ -466,9 +479,8 @@ retry: if (magHardwareToUse == MAG_AK8975) break; } - ; // fallthrough #endif - ; // prevent compiler error. + ; // fallthrough } if (magHardware == MAG_DEFAULT) { @@ -476,12 +488,13 @@ retry: // Nothing was found and we have a forced sensor that isn't present. magHardwareToUse = MAG_DEFAULT; goto retry; - } else { - // No MAG was detected - sensorsClear(SENSOR_MAG); } } + if (magHardware != MAG_NONE) { + sensorsSet(SENSOR_MAG); + } + } void reconfigureAlignment(sensorAlignmentConfig_t *sensorAlignmentConfig) diff --git a/src/main/target/ALIENWIIF3/target.h b/src/main/target/ALIENWIIF3/target.h index 009782a697..924a9306f1 100644 --- a/src/main/target/ALIENWIIF3/target.h +++ b/src/main/target/ALIENWIIF3/target.h @@ -86,9 +86,6 @@ #define I2C2_SDA_PIN_SOURCE GPIO_PinSource10 #define I2C2_SDA_CLK_SOURCE RCC_AHBPeriph_GPIOA - -#define SENSORS_SET (SENSOR_ACC | SENSOR_BARO | SENSOR_MAG) - #define BLACKBOX #define SERIAL_RX #define GPS diff --git a/src/main/target/CC3D/target.h b/src/main/target/CC3D/target.h index a06d3540a6..b0e1a2f7a2 100644 --- a/src/main/target/CC3D/target.h +++ b/src/main/target/CC3D/target.h @@ -98,8 +98,6 @@ #define RSSI_ADC_CHANNEL ADC_Channel_1 -#define SENSORS_SET (SENSOR_ACC) - #define GPS #define LED_STRIP #define LED_STRIP_TIMER TIM3 diff --git a/src/main/target/CHEBUZZF3/target.h b/src/main/target/CHEBUZZF3/target.h index e27951b9fd..d8a0f704a5 100644 --- a/src/main/target/CHEBUZZF3/target.h +++ b/src/main/target/CHEBUZZF3/target.h @@ -90,9 +90,6 @@ #define EXTERNAL1_ADC_GPIO_PIN GPIO_Pin_3 #define EXTERNAL1_ADC_CHANNEL ADC_Channel_9 - -#define SENSORS_SET (SENSOR_ACC | SENSOR_BARO | SENSOR_MAG) - #define GPS #define LED_STRIP #if 1 diff --git a/src/main/target/CJMCU/target.h b/src/main/target/CJMCU/target.h index 2bdabd78e3..ac4088e083 100644 --- a/src/main/target/CJMCU/target.h +++ b/src/main/target/CJMCU/target.h @@ -60,8 +60,6 @@ // #define SOFT_I2C_PB1011 // If SOFT_I2C is enabled above, need to define pinout as well (I2C1 = PB67, I2C2 = PB1011) // #define SOFT_I2C_PB67 -#define SENSORS_SET (SENSOR_ACC | SENSOR_MAG) - #define SERIAL_RX #define SPEKTRUM_BIND diff --git a/src/main/target/EUSTM32F103RC/target.h b/src/main/target/EUSTM32F103RC/target.h index ccc9bebaa3..48ac2fd273 100644 --- a/src/main/target/EUSTM32F103RC/target.h +++ b/src/main/target/EUSTM32F103RC/target.h @@ -116,8 +116,6 @@ #define EXTERNAL1_ADC_GPIO_PIN GPIO_Pin_5 #define EXTERNAL1_ADC_CHANNEL ADC_Channel_5 -#define SENSORS_SET (SENSOR_ACC | SENSOR_BARO | SENSOR_MAG) - #define GPS #define LED_STRIP #define LED_STRIP_TIMER TIM3 diff --git a/src/main/target/NAZE/target.h b/src/main/target/NAZE/target.h index c2109e5c21..7d53b0c4e3 100644 --- a/src/main/target/NAZE/target.h +++ b/src/main/target/NAZE/target.h @@ -135,8 +135,6 @@ #define EXTERNAL1_ADC_GPIO_PIN GPIO_Pin_5 #define EXTERNAL1_ADC_CHANNEL ADC_Channel_5 -#define SENSORS_SET (SENSOR_ACC | SENSOR_BARO | SENSOR_MAG) - #define GPS #define LED_STRIP diff --git a/src/main/target/NAZE32PRO/target.h b/src/main/target/NAZE32PRO/target.h index 19f806d71c..7435a8e991 100644 --- a/src/main/target/NAZE32PRO/target.h +++ b/src/main/target/NAZE32PRO/target.h @@ -40,8 +40,6 @@ #define USE_I2C #define I2C_DEVICE (I2CDEV_1) -#define SENSORS_SET (SENSOR_ACC) - #define GPS #define BLACKBOX #define TELEMETRY diff --git a/src/main/target/OLIMEXINO/target.h b/src/main/target/OLIMEXINO/target.h index 87dd9aadd6..6288c6b40b 100644 --- a/src/main/target/OLIMEXINO/target.h +++ b/src/main/target/OLIMEXINO/target.h @@ -103,9 +103,6 @@ #define EXTERNAL1_ADC_GPIO_PIN GPIO_Pin_5 #define EXTERNAL1_ADC_CHANNEL ADC_Channel_5 - -#define SENSORS_SET (SENSOR_ACC | SENSOR_BARO | SENSOR_MAG) - #define GPS #define LED_STRIP #define LED_STRIP_TIMER TIM3 diff --git a/src/main/target/PORT103R/target.h b/src/main/target/PORT103R/target.h index 0f4aa39046..f3af089d0a 100644 --- a/src/main/target/PORT103R/target.h +++ b/src/main/target/PORT103R/target.h @@ -126,8 +126,6 @@ #define EXTERNAL1_ADC_GPIO_PIN GPIO_Pin_5 #define EXTERNAL1_ADC_CHANNEL ADC_Channel_5 -#define SENSORS_SET (SENSOR_ACC | SENSOR_BARO | SENSOR_MAG) - #define LED0 #define GPS #define LED_STRIP diff --git a/src/main/target/SPARKY/target.h b/src/main/target/SPARKY/target.h index d9bfe31e3d..2c6101d7cf 100644 --- a/src/main/target/SPARKY/target.h +++ b/src/main/target/SPARKY/target.h @@ -86,9 +86,6 @@ #define I2C2_SDA_PIN_SOURCE GPIO_PinSource10 #define I2C2_SDA_CLK_SOURCE RCC_AHBPeriph_GPIOA - -#define SENSORS_SET (SENSOR_ACC | SENSOR_BARO | SENSOR_MAG) - #define BLACKBOX #define SERIAL_RX #define GPS diff --git a/src/main/target/SPRACINGF3/target.h b/src/main/target/SPRACINGF3/target.h index ae1feff44c..4af92665a3 100644 --- a/src/main/target/SPRACINGF3/target.h +++ b/src/main/target/SPRACINGF3/target.h @@ -120,8 +120,6 @@ #define WS2811_DMA_CHANNEL DMA1_Channel2 #define WS2811_IRQ DMA1_Channel2_IRQn -#define SENSORS_SET (SENSOR_ACC | SENSOR_BARO | SENSOR_MAG) - #define GPS #define BLACKBOX #define TELEMETRY diff --git a/src/main/target/STM32F3DISCOVERY/target.h b/src/main/target/STM32F3DISCOVERY/target.h index 29f5f39e82..a98f03d84e 100644 --- a/src/main/target/STM32F3DISCOVERY/target.h +++ b/src/main/target/STM32F3DISCOVERY/target.h @@ -81,8 +81,6 @@ #define EXTERNAL1_ADC_GPIO_PIN GPIO_Pin_3 #define EXTERNAL1_ADC_CHANNEL ADC_Channel_9 -#define SENSORS_SET (SENSOR_ACC | SENSOR_MAG) - #define BLACKBOX #define GPS #define LED_STRIP From 257c7e092e3a3554a59323e09c4b4453269c1900 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Thu, 19 Feb 2015 21:28:26 +0100 Subject: [PATCH 55/60] Harakiri PID controller variables cleanup Flight tested --- src/main/flight/pid.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 42cfe7f9cb..d123250484 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -523,13 +523,10 @@ rollAndPitchTrims_t *angleTrim, rxConfig_t *rxConfig) UNUSED(rxConfig); float delta, RCfactor, rcCommandAxis, MainDptCut, gyroDataQuant; - float PTerm = 0.0f, ITerm = 0.0f, DTerm = 0.0f, PTermACC = 0.0f, ITermACC = 0.0f, ITermGYRO = 0.0f, error = 0.0f, prop = 0.0f; + float PTerm, ITerm, DTerm, PTermACC = 0.0f, ITermACC = 0.0f, ITermGYRO, error, prop = 0.0f; static float lastGyro[2] = { 0.0f, 0.0f }, lastDTerm[2] = { 0.0f, 0.0f }; - float tmp0flt; - int32_t tmp0; uint8_t axis; - float ACCDeltaTimeINS = 0.0f; - float FLOATcycleTime = 0.0f; + float ACCDeltaTimeINS, FLOATcycleTime, Mwii3msTimescale; // MainDptCut = RCconstPI / (float)cfg.maincuthz; // Initialize Cut off frequencies for mainpid D MainDptCut = RCconstPI / MAIN_CUT_HZ; // maincuthz (default 12Hz, Range 1-50Hz), hardcoded for now @@ -542,8 +539,8 @@ rollAndPitchTrims_t *angleTrim, rxConfig_t *rxConfig) } for (axis = 0; axis < 2; axis++) { - tmp0 = (int32_t)((float)gyroData[axis] * 0.3125f); // Multiwii masks out the last 2 bits, this has the same idea - gyroDataQuant = (float)tmp0 * 3.2f; // but delivers more accuracy and also reduces jittery flight + int32_t tmp = (int32_t)((float)gyroData[axis] * 0.3125f); // Multiwii masks out the last 2 bits, this has the same idea + gyroDataQuant = (float)tmp * 3.2f; // but delivers more accuracy and also reduces jittery flight rcCommandAxis = (float)rcCommand[axis]; // Calculate common values for pid controllers if (FLIGHT_MODE(ANGLE_MODE) || FLIGHT_MODE(HORIZON_MODE)) { #ifdef GPS @@ -558,8 +555,8 @@ rollAndPitchTrims_t *angleTrim, rxConfig_t *rxConfig) } #endif PTermACC = error * (float)pidProfile->P8[PIDLEVEL] * 0.008f; - tmp0flt = (float)pidProfile->D8[PIDLEVEL] * 5.0f; - PTermACC = constrain(PTermACC, -tmp0flt, +tmp0flt); + float limitf = (float)pidProfile->D8[PIDLEVEL] * 5.0f; + PTermACC = constrain(PTermACC, -limitf, +limitf); errorAngleIf[axis] = constrain(errorAngleIf[axis] + error * ACCDeltaTimeINS, -30.0f, +30.0f); ITermACC = errorAngleIf[axis] * (float)pidProfile->I8[PIDLEVEL] * 0.08f; } @@ -602,37 +599,37 @@ rollAndPitchTrims_t *angleTrim, rxConfig_t *rxConfig) #endif } - tmp0flt = (int32_t)FLOATcycleTime & (int32_t)~3; // Filter last 2 bit jitter - tmp0flt /= 3000.0f; + Mwii3msTimescale = (int32_t)FLOATcycleTime & (int32_t)~3; // Filter last 2 bit jitter + Mwii3msTimescale /= 3000.0f; if (OLD_YAW) { // [0/1] 0 = multiwii 2.3 yaw, 1 = older yaw. hardcoded for now PTerm = ((int32_t)pidProfile->P8[FD_YAW] * (100 - (int32_t)controlRateConfig->yawRate * (int32_t)ABS(rcCommand[FD_YAW]) / 500)) / 100; - tmp0 = lrintf(gyroData[FD_YAW] * 0.25f); - PTerm = rcCommand[FD_YAW] - tmp0 * PTerm / 80; - if ((ABS(tmp0) > 640) || (ABS(rcCommand[FD_YAW]) > 100)) { + int32_t tmp = lrintf(gyroData[FD_YAW] * 0.25f); + PTerm = rcCommand[FD_YAW] - tmp * PTerm / 80; + if ((ABS(tmp) > 640) || (ABS(rcCommand[FD_YAW]) > 100)) { errorGyroI[FD_YAW] = 0; } else { - error = ((int32_t)rcCommand[FD_YAW] * 80 / (int32_t)pidProfile->P8[FD_YAW]) - tmp0; - errorGyroI[FD_YAW] = constrain(errorGyroI[FD_YAW] + (int32_t)(error * tmp0flt), -16000, +16000); // WindUp + error = ((int32_t)rcCommand[FD_YAW] * 80 / (int32_t)pidProfile->P8[FD_YAW]) - tmp; + errorGyroI[FD_YAW] = constrain(errorGyroI[FD_YAW] + (int32_t)(error * Mwii3msTimescale), -16000, +16000); // WindUp ITerm = (errorGyroI[FD_YAW] / 125 * pidProfile->I8[FD_YAW]) >> 6; } } else { - tmp0 = ((int32_t)rcCommand[FD_YAW] * (((int32_t)controlRateConfig->yawRate << 1) + 40)) >> 5; - error = tmp0 - lrintf(gyroData[FD_YAW] * 0.25f); // Less Gyrojitter works actually better + int32_t tmp = ((int32_t)rcCommand[FD_YAW] * (((int32_t)controlRateConfig->yawRate << 1) + 40)) >> 5; + error = tmp - lrintf(gyroData[FD_YAW] * 0.25f); // Less Gyrojitter works actually better - if (ABS(tmp0) > 50) { + if (ABS(tmp) > 50) { errorGyroI[FD_YAW] = 0; } else { - errorGyroI[FD_YAW] = constrain(errorGyroI[FD_YAW] + (int32_t)(error * (float)pidProfile->I8[FD_YAW] * tmp0flt), -268435454, +268435454); + errorGyroI[FD_YAW] = constrain(errorGyroI[FD_YAW] + (int32_t)(error * (float)pidProfile->I8[FD_YAW] * Mwii3msTimescale), -268435454, +268435454); } ITerm = constrain(errorGyroI[FD_YAW] >> 13, -GYRO_I_MAX, +GYRO_I_MAX); PTerm = ((int32_t)error * (int32_t)pidProfile->P8[FD_YAW]) >> 6; if (motorCount >= 4) { // Constrain FD_YAW by D value if not servo driven in that case servolimits apply - tmp0 = 300; - if (pidProfile->D8[FD_YAW]) tmp0 -= (int32_t)pidProfile->D8[FD_YAW]; - PTerm = constrain(PTerm, -tmp0, tmp0); + int32_t limit = 300; + if (pidProfile->D8[FD_YAW]) limit -= (int32_t)pidProfile->D8[FD_YAW]; + PTerm = constrain(PTerm, -limit, limit); } } axisPID[FD_YAW] = PTerm + ITerm; From 1de72b11ce770f4437cee789cf0ac1b08f88d09a Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Thu, 19 Feb 2015 21:04:06 +0000 Subject: [PATCH 56/60] Update the cli `status` command to show all detected sensors (Except on CJMCU). Further cleanup of sensor initialisation. --- src/main/io/serial_cli.c | 52 ++++--- src/main/sensors/acceleration.c | 1 - src/main/sensors/acceleration.h | 1 - src/main/sensors/barometer.c | 1 - src/main/sensors/barometer.h | 2 - src/main/sensors/compass.c | 1 - src/main/sensors/compass.h | 7 +- src/main/sensors/gyro.h | 12 ++ src/main/sensors/initialisation.c | 217 ++++++++++++++++++------------ src/main/sensors/sensors.h | 10 ++ 10 files changed, 190 insertions(+), 114 deletions(-) diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index 276c9310a1..7098e06104 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -146,14 +146,23 @@ static const char * const featureNames[] = { "BLACKBOX", NULL }; +#ifndef CJMCU // sync this with sensors_e -static const char * const sensorNames[] = { +static const char * const sensorTypeNames[] = { "GYRO", "ACC", "BARO", "MAG", "SONAR", "GPS", "GPS+MAG", NULL }; -static const char * const accNames[] = { - "", "ADXL345", "MPU6050", "MMA845x", "BMA280", "LSM303DLHC", "MPU6000", "MPU6500", "FAKE", "None", NULL +// FIXME the next time the EEPROM is bumped change the order of acc and gyro names so that "None" is second. + +#define SENSOR_NAMES_MASK (SENSOR_GYRO | SENSOR_ACC | SENSOR_BARO | SENSOR_MAG) + +static const char * const sensorHardwareNames[4][11] = { + { "", "None", "MPU6050", "L3G4200D", "MPU3050", "L3GD20", "MPU6000", "MPU6500", "FAKE", NULL }, + { "", "ADXL345", "MPU6050", "MMA845x", "BMA280", "LSM303DLHC", "MPU6000", "MPU6500", "FAKE", "None", NULL }, + { "", "None", "BMP085", "MS5611", NULL }, + { "", "None", "HMC5883", "AK8975", NULL } }; +#endif typedef struct { const char *name; @@ -1357,27 +1366,38 @@ static void cliGet(char *cmdline) static void cliStatus(char *cmdline) { - uint8_t i; - uint32_t mask; - UNUSED(cmdline); printf("System Uptime: %d seconds, Voltage: %d * 0.1V (%dS battery)\r\n", millis() / 1000, vbat, batteryCellCount); - mask = sensorsMask(); - printf("CPU %dMHz, detected sensors: ", (SystemCoreClock / 1000000)); + + printf("CPU Clock=%dMHz", (SystemCoreClock / 1000000)); + +#ifndef CJMCU + uint8_t i; + uint32_t mask; + uint32_t detectedSensorsMask = sensorsMask(); + for (i = 0; ; i++) { - if (sensorNames[i] == NULL) + + if (sensorTypeNames[i] == NULL) break; - if (mask & (1 << i)) - printf("%s ", sensorNames[i]); - } - if (sensors(SENSOR_ACC)) { - printf("ACCHW: %s", accNames[accHardware]); - if (acc.revisionCode) - printf(".%c", acc.revisionCode); + + mask = (1 << i); + if ((detectedSensorsMask & mask) && (mask & SENSOR_NAMES_MASK)) { + const char *sensorHardware; + uint8_t sensorHardwareIndex = detectedSensors[i]; + sensorHardware = sensorHardwareNames[i][sensorHardwareIndex]; + + printf(", %s=%s", sensorTypeNames[i], sensorHardware); + + if (mask == SENSOR_ACC && acc.revisionCode) { + printf(".%c", acc.revisionCode); + } + } } +#endif cliPrint("\r\n"); #ifdef USE_I2C diff --git a/src/main/sensors/acceleration.c b/src/main/sensors/acceleration.c index b43711f0bd..c265b7595d 100644 --- a/src/main/sensors/acceleration.c +++ b/src/main/sensors/acceleration.c @@ -37,7 +37,6 @@ int16_t accADC[XYZ_AXIS_COUNT]; acc_t acc; // acc access functions -accelerationSensor_e accHardware = ACC_DEFAULT; // which accel chip is used/detected sensor_align_e accAlign = 0; uint16_t acc_1G = 256; // this is the 1G measured acceleration. diff --git a/src/main/sensors/acceleration.h b/src/main/sensors/acceleration.h index 709f4415a2..5b925b01d4 100644 --- a/src/main/sensors/acceleration.h +++ b/src/main/sensors/acceleration.h @@ -31,7 +31,6 @@ typedef enum { ACC_NONE = 9 } accelerationSensor_e; -extern uint8_t accHardware; extern sensor_align_e accAlign; extern acc_t acc; extern uint16_t acc_1G; diff --git a/src/main/sensors/barometer.c b/src/main/sensors/barometer.c index 719c83eed7..f019dd628c 100644 --- a/src/main/sensors/barometer.c +++ b/src/main/sensors/barometer.c @@ -41,7 +41,6 @@ static int32_t baroGroundPressure = 0; static uint32_t baroPressureSum = 0; barometerConfig_t *barometerConfig; -baroSensor_e baroHardware; void useBarometerConfig(barometerConfig_t *barometerConfigToUse) { diff --git a/src/main/sensors/barometer.h b/src/main/sensors/barometer.h index fed38d0aab..685f6b8434 100644 --- a/src/main/sensors/barometer.h +++ b/src/main/sensors/barometer.h @@ -24,8 +24,6 @@ typedef enum { BARO_MS5611 = 3 } baroSensor_e; -extern baroSensor_e baroHardware; - #define BARO_SAMPLE_COUNT_MAX 48 typedef struct barometerConfig_s { diff --git a/src/main/sensors/compass.c b/src/main/sensors/compass.c index 7c5f11f6a7..31d7688c6c 100644 --- a/src/main/sensors/compass.c +++ b/src/main/sensors/compass.c @@ -40,7 +40,6 @@ #endif mag_t mag; // mag access functions -magSensor_e magHardware = MAG_DEFAULT; extern uint32_t currentTime; // FIXME dependency on global variable, pass it in instead. diff --git a/src/main/sensors/compass.h b/src/main/sensors/compass.h index 2effbabc95..502c187285 100644 --- a/src/main/sensors/compass.h +++ b/src/main/sensors/compass.h @@ -20,9 +20,9 @@ // Type of accelerometer used/detected typedef enum { MAG_DEFAULT = 0, - MAG_HMC5883 = 1, - MAG_AK8975 = 2, - MAG_NONE = 3 + MAG_NONE = 1, + MAG_HMC5883 = 2, + MAG_AK8975 = 3, } magSensor_e; #ifdef MAG @@ -32,6 +32,5 @@ void updateCompass(flightDynamicsTrims_t *magZero); extern int16_t magADC[XYZ_AXIS_COUNT]; -extern uint8_t magHardware; extern sensor_align_e magAlign; extern mag_t mag; diff --git a/src/main/sensors/gyro.h b/src/main/sensors/gyro.h index caa34281d5..f09e2af5e2 100644 --- a/src/main/sensors/gyro.h +++ b/src/main/sensors/gyro.h @@ -17,6 +17,18 @@ #pragma once +typedef enum { + GYRO_NONE = 0, + GYRO_DEFAULT, + GYRO_MPU6050, + GYRO_L3G4200D, + GYRO_MPU3050, + GYRO_L3GD20, + GYRO_SPI_MPU6000, + GYRO_SPI_MPU6500, + GYRO_FAKE +} gyroSensor_e; + extern gyro_t gyro; extern sensor_align_e gyroAlign; diff --git a/src/main/sensors/initialisation.c b/src/main/sensors/initialisation.c index 883c253f19..cd90c28f36 100644 --- a/src/main/sensors/initialisation.c +++ b/src/main/sensors/initialisation.c @@ -71,6 +71,8 @@ extern gyro_t gyro; extern baro_t baro; extern acc_t acc; +uint8_t detectedSensors[MAX_SENSORS_TO_DETECT] = { GYRO_NONE, ACC_NONE, BARO_NONE, MAG_NONE }; + const mpu6050Config_t *selectMPU6050Config(void) { #ifdef NAZE @@ -141,82 +143,121 @@ bool fakeAccDetect(acc_t *acc) bool detectGyro(uint16_t gyroLpf) { + gyroSensor_e gyroHardware = GYRO_DEFAULT; + gyroAlign = ALIGN_DEFAULT; + switch(gyroHardware) { + case GYRO_DEFAULT: + ; // fallthrough + case GYRO_MPU6050: #ifdef USE_GYRO_MPU6050 - if (mpu6050GyroDetect(selectMPU6050Config(), &gyro, gyroLpf)) { + if (mpu6050GyroDetect(selectMPU6050Config(), &gyro, gyroLpf)) { #ifdef GYRO_MPU6050_ALIGN - gyroAlign = GYRO_MPU6050_ALIGN; + gyroHardware = GYRO_MPU6050; + gyroAlign = GYRO_MPU6050_ALIGN; #endif - return true; - } + break; + } #endif - + ; // fallthrough + case GYRO_L3G4200D: #ifdef USE_GYRO_L3G4200D - if (l3g4200dDetect(&gyro, gyroLpf)) { + if (l3g4200dDetect(&gyro, gyroLpf)) { #ifdef GYRO_L3G4200D_ALIGN - gyroAlign = GYRO_L3G4200D_ALIGN; + gyroHardware = GYRO_L3G4200D; + gyroAlign = GYRO_L3G4200D_ALIGN; #endif - return true; - } + break; + } #endif + ; // fallthrough + case GYRO_MPU3050: #ifdef USE_GYRO_MPU3050 - if (mpu3050Detect(&gyro, gyroLpf)) { + if (mpu3050Detect(&gyro, gyroLpf)) { #ifdef GYRO_MPU3050_ALIGN - gyroAlign = GYRO_MPU3050_ALIGN; + gyroHardware = GYRO_MPU3050; + gyroAlign = GYRO_MPU3050_ALIGN; #endif - return true; - } + break; + } #endif + ; // fallthrough + case GYRO_L3GD20: #ifdef USE_GYRO_L3GD20 - if (l3gd20Detect(&gyro, gyroLpf)) { + if (l3gd20Detect(&gyro, gyroLpf)) { #ifdef GYRO_L3GD20_ALIGN - gyroAlign = GYRO_L3GD20_ALIGN; + gyroHardware = GYRO_L3GD20; + gyroAlign = GYRO_L3GD20_ALIGN; #endif - return true; - } + break; + } #endif + ; // fallthrough + case GYRO_SPI_MPU6000: #ifdef USE_GYRO_SPI_MPU6000 - if (mpu6000SpiGyroDetect(&gyro, gyroLpf)) { + if (mpu6000SpiGyroDetect(&gyro, gyroLpf)) { #ifdef GYRO_SPI_MPU6000_ALIGN - gyroAlign = GYRO_SPI_MPU6000_ALIGN; + gyroHardware = GYRO_SPI_MPU6000; + gyroAlign = GYRO_SPI_MPU6000_ALIGN; #endif - return true; - } + break; + } #endif + ; // fallthrough + case GYRO_SPI_MPU6500: #ifdef USE_GYRO_SPI_MPU6500 #ifdef NAZE - if (hardwareRevision == NAZE32_SP && mpu6500SpiGyroDetect(&gyro, gyroLpf)) { + if (hardwareRevision == NAZE32_SP && mpu6500SpiGyroDetect(&gyro, gyroLpf)) { #ifdef GYRO_SPI_MPU6500_ALIGN - gyroAlign = GYRO_SPI_MPU6500_ALIGN; + gyroHardware = GYRO_SPI_MPU6500; + gyroAlign = GYRO_SPI_MPU6500_ALIGN; #endif - return true; - } + break; + } #else - if (mpu6500SpiGyroDetect(&gyro, gyroLpf)) { + if (mpu6500SpiGyroDetect(&gyro, gyroLpf)) { #ifdef GYRO_SPI_MPU6500_ALIGN - gyroAlign = GYRO_SPI_MPU6500_ALIGN; + gyroHardware = GYRO_SPI_MPU6500; + gyroAlign = GYRO_SPI_MPU6500_ALIGN; #endif - return true; - } + break; + } #endif #endif + ; // fallthrough + case GYRO_FAKE: #ifdef USE_FAKE_GYRO - if (fakeGyroDetect(&gyro, gyroLpf)) { - return true; - } + if (fakeGyroDetect(&gyro, gyroLpf)) { + gyroHardware = GYRO_FAKE; + break; + } #endif - return false; + ; // fallthrough + case GYRO_NONE: + gyroHardware = GYRO_NONE; + } + + if (gyroHardware == GYRO_NONE) { + return false; + } + + detectedSensors[SENSOR_INDEX_GYRO] = gyroHardware; + sensorsSet(SENSOR_GYRO); + + return true; } -static void detectAcc(uint8_t accHardwareToUse) +static void detectAcc(accelerationSensor_e accHardwareToUse) { -#ifdef USE_ACC_ADXL345 + accelerationSensor_e accHardware; + + #ifdef USE_ACC_ADXL345 drv_adxl345_config_t acc_params; #endif @@ -224,17 +265,16 @@ retry: accAlign = ALIGN_DEFAULT; switch (accHardwareToUse) { + case ACC_DEFAULT: + ; // fallthrough + case ACC_FAKE: #ifdef USE_FAKE_ACC - default: if (fakeAccDetect(&acc)) { accHardware = ACC_FAKE; - if (accHardwareToUse == ACC_FAKE) - break; + break; } #endif - case ACC_NONE: // disable ACC - break; - case ACC_DEFAULT: // autodetect + ; // fallthrough case ACC_ADXL345: // ADXL345 #ifdef USE_ACC_ADXL345 acc_params.useFifo = false; @@ -248,8 +288,7 @@ retry: accAlign = ACC_ADXL345_ALIGN; #endif accHardware = ACC_ADXL345; - if (accHardwareToUse == ACC_ADXL345) - break; + break; } #endif ; // fallthrough @@ -260,8 +299,7 @@ retry: accAlign = ACC_LSM303DLHC_ALIGN; #endif accHardware = ACC_LSM303DLHC; - if (accHardwareToUse == ACC_LSM303DLHC) - break; + break; } #endif ; // fallthrough @@ -272,8 +310,7 @@ retry: accAlign = ACC_MPU6050_ALIGN; #endif accHardware = ACC_MPU6050; - if (accHardwareToUse == ACC_MPU6050) - break; + break; } #endif ; // fallthrough @@ -289,8 +326,7 @@ retry: accAlign = ACC_MMA8452_ALIGN; #endif accHardware = ACC_MMA8452; - if (accHardwareToUse == ACC_MMA8452) - break; + break; } #endif ; // fallthrough @@ -301,8 +337,7 @@ retry: accAlign = ACC_BMA280_ALIGN; #endif accHardware = ACC_BMA280; - if (accHardwareToUse == ACC_BMA280) - break; + break; } #endif ; // fallthrough @@ -313,8 +348,7 @@ retry: accAlign = ACC_SPI_MPU6000_ALIGN; #endif accHardware = ACC_SPI_MPU6000; - if (accHardwareToUse == ACC_SPI_MPU6000) - break; + break; } #endif ; // fallthrough @@ -329,25 +363,30 @@ retry: accAlign = ACC_SPI_MPU6500_ALIGN; #endif accHardware = ACC_SPI_MPU6500; - if (accHardwareToUse == ACC_SPI_MPU6500) - break; + break; } #endif ; // fallthrough + case ACC_NONE: // disable ACC + accHardware = ACC_NONE; + break; + } // Found anything? Check if error or ACC is really missing. - if (accHardware == ACC_DEFAULT) { - if (accHardwareToUse > ACC_DEFAULT && accHardwareToUse < ACC_NONE) { - // Nothing was found and we have a forced sensor that isn't present. - accHardwareToUse = ACC_DEFAULT; - goto retry; - } + if (accHardwareToUse != ACC_DEFAULT && accHardware == ACC_NONE) { + // Nothing was found and we have a forced sensor that isn't present. + accHardwareToUse = ACC_DEFAULT; + goto retry; } - if (accHardware != ACC_NONE) { - sensorsSet(SENSOR_ACC); + + if (accHardware == ACC_NONE) { + return; } + + detectedSensors[SENSOR_INDEX_ACC] = accHardware; + sensorsSet(SENSOR_ACC); } static void detectBaro() @@ -355,7 +394,7 @@ static void detectBaro() #ifdef BARO // Detect what pressure sensors are available. baro->update() is set to sensor-specific update function - baroHardware = BARO_DEFAULT; + baroSensor_e baroHardware = BARO_DEFAULT; #ifdef USE_BARO_BMP085 @@ -399,19 +438,24 @@ static void detectBaro() break; } #endif - baroHardware = BARO_NONE; // nothing detected or enabled. case BARO_NONE: + baroHardware = BARO_NONE; break; } - if (baroHardware != BARO_NONE) { - sensorsSet(SENSOR_BARO); + if (baroHardware == BARO_NONE) { + return; } - #endif + + detectedSensors[SENSOR_INDEX_BARO] = baroHardware; + sensorsSet(SENSOR_BARO); +#endif } static void detectMag(magSensor_e magHardwareToUse) { + magSensor_e magHardware; + #ifdef USE_MAG_HMC5883 static hmc5883Config_t *hmc5883Config = 0; @@ -448,21 +492,17 @@ retry: magAlign = ALIGN_DEFAULT; switch(magHardwareToUse) { - case MAG_NONE: // disable MAG - break; - case MAG_DEFAULT: // autodetect + case MAG_DEFAULT: + ; // fallthrough case MAG_HMC5883: #ifdef USE_MAG_HMC5883 if (hmc5883lDetect(&mag, hmc5883Config)) { - sensorsSet(SENSOR_MAG); #ifdef MAG_HMC5883_ALIGN magAlign = MAG_HMC5883_ALIGN; #endif magHardware = MAG_HMC5883; - if (magHardwareToUse == MAG_HMC5883) - break; - + break; } #endif ; // fallthrough @@ -470,31 +510,32 @@ retry: case MAG_AK8975: #ifdef USE_MAG_AK8975 if (ak8975detect(&mag)) { - - sensorsSet(SENSOR_MAG); #ifdef MAG_AK8975_ALIGN magAlign = MAG_AK8975_ALIGN; #endif magHardware = MAG_AK8975; - if (magHardwareToUse == MAG_AK8975) - break; + break; } #endif ; // fallthrough + + case MAG_NONE: + magHardware = MAG_NONE; + break; } - if (magHardware == MAG_DEFAULT) { - if (magHardwareToUse > MAG_DEFAULT && magHardwareToUse < MAG_NONE) { - // Nothing was found and we have a forced sensor that isn't present. - magHardwareToUse = MAG_DEFAULT; - goto retry; - } + if (magHardwareToUse != MAG_DEFAULT && magHardware == MAG_NONE) { + // Nothing was found and we have a forced sensor that isn't present. + magHardwareToUse = MAG_DEFAULT; + goto retry; } - if (magHardware != MAG_NONE) { - sensorsSet(SENSOR_MAG); + if (magHardware == MAG_NONE) { + return; } + detectedSensors[SENSOR_INDEX_MAG] = magHardware; + sensorsSet(SENSOR_MAG); } void reconfigureAlignment(sensorAlignmentConfig_t *sensorAlignmentConfig) @@ -513,13 +554,13 @@ void reconfigureAlignment(sensorAlignmentConfig_t *sensorAlignmentConfig) bool sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t gyroLpf, uint8_t accHardwareToUse, uint8_t magHardwareToUse, int16_t magDeclinationFromConfig) { int16_t deg, min; + memset(&acc, sizeof(acc), 0); memset(&gyro, sizeof(gyro), 0); if (!detectGyro(gyroLpf)) { return false; } - sensorsSet(SENSOR_GYRO); detectAcc(accHardwareToUse); detectBaro(); diff --git a/src/main/sensors/sensors.h b/src/main/sensors/sensors.h index 805043d5ce..78c452f46d 100644 --- a/src/main/sensors/sensors.h +++ b/src/main/sensors/sensors.h @@ -17,6 +17,16 @@ #pragma once +typedef enum { + SENSOR_INDEX_GYRO = 0, + SENSOR_INDEX_ACC, + SENSOR_INDEX_BARO, + SENSOR_INDEX_MAG +} sensorIndex_e; + +#define MAX_SENSORS_TO_DETECT (SENSOR_INDEX_MAG + 1) + +extern uint8_t detectedSensors[MAX_SENSORS_TO_DETECT]; typedef struct int16_flightDynamicsTrims_s { int16_t roll; From 91b4cafbfa9383b93bf693c249b24e89662d683b Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Sat, 14 Feb 2015 12:16:14 +0100 Subject: [PATCH 57/60] ALIENWII F3/F1 target cleanup and documentation update --- docs/Board - AlienWii32.md | 6 +++ src/main/target/ALIENWIIF3/target.h | 66 ++++++++--------------------- src/main/target/NAZE/target.h | 2 +- 3 files changed, 24 insertions(+), 50 deletions(-) diff --git a/docs/Board - AlienWii32.md b/docs/Board - AlienWii32.md index f442edcef2..6c35f617b2 100644 --- a/docs/Board - AlienWii32.md +++ b/docs/Board - AlienWii32.md @@ -24,3 +24,9 @@ Here are the hardware specifications: Deltang receivers in serial mode will work like any other Spektrum satellite receiver (10bit, 22ms) only the bind process will be different. The pin layout for the ALIENWIIF1 is very similar to NAZE32 or the related clones (MW32, Flip32, etc.). The hardware bind pin is connected to pin 41 (PB5). The pin layout for the ALIENWIIF3 is similar to Sparky. The hardware bind pin is connected to pin 25 (PB12). The AlienWii32 firmware will be built as target ALIENWIIF1 or ALIENWIIF3. The firmware image will come with alternative default settings which will give the user a plug and play experience. There is no computer needed to get this into the air with an small Quadcopter. An preconfigured custom mixer for an Octocopter is part of the default settings to allow clean straight wiring with the AlienWii32. The mixer can be activated with "mixer custom" in the CLI. To use the AlienWii32 in an Hexa- or Octocopter or to do some more tuning additional configuration changes can be done as usual in the CLI or the Cleanflight configurator. + +## Flashing the firmware + +The AlienWii32 F1 board can be flashed like the Naze board or the related clones. All the different methods will work in the same way. + +The AlienWii32 F3 board needs to be flashed via the USB port in DFU mode. Flashing via the Cleanflight GUI is not possible yet. The DFU mode can be activated via setting the BOOT0 jumper during power on of the board. The second method is to connect with an terminal program (i.e. Putty) to the board and enter the character "R" immediately after connecting. Details about the flashing process can be found in the related section of the Sparky documentation. The BOOT0 jumper should be removed and the board needs to be repowerd after firmware flashing. Please be aware, during reboot of the AlienWii F3 board, the GUI will disconnect and an manual reconnect is required. \ No newline at end of file diff --git a/src/main/target/ALIENWIIF3/target.h b/src/main/target/ALIENWIIF3/target.h index 924a9306f1..fbd7ac2990 100644 --- a/src/main/target/ALIENWIIF3/target.h +++ b/src/main/target/ALIENWIIF3/target.h @@ -28,7 +28,7 @@ #define USABLE_TIMER_CHANNEL_COUNT 11 -// MPU 9150 INT connected to PA15, pulled up to VCC by 10K Resistor, contains MPU6050 and AK8975 in single component. +// Using MPU6050 for the moment. #define GYRO #define USE_GYRO_MPU6050 @@ -39,11 +39,13 @@ #define ACC_MPU6050_ALIGN CW270_DEG +// No baro support. //#define BARO //#define USE_BARO_MS5611 -#define MAG -#define USE_MAG_AK8975 +// No mag support for now (option to use MPU9150 in the future). +//#define MAG +//#define USE_MAG_AK8975 #define MAG_AK8975_ALIGN CW0_DEG_FLIP @@ -51,9 +53,9 @@ #define LED1 #define USE_VCP -#define USE_USART1 // Conn 1 - TX (PB6) RX PB7 (AF7) -#define USE_USART2 // Input - RX (PA3) -#define USE_USART3 // Servo out - 10/RX (PB11) 11/TX (PB10) +#define USE_USART1 // Not connected - TX (PB6) RX PB7 (AF7) +#define USE_USART2 // Receiver - RX (PA3) +#define USE_USART3 // Not connected - 10/RX (PB11) 11/TX (PB10) #define SERIAL_PORT_COUNT 4 #define UART1_TX_PIN GPIO_Pin_6 // PB6 @@ -63,14 +65,13 @@ #define UART1_TX_PINSOURCE GPIO_PinSource6 #define UART1_RX_PINSOURCE GPIO_PinSource7 -#define UART2_TX_PIN GPIO_Pin_2 // PA2 - Clashes with PWM6 input. +#define UART2_TX_PIN GPIO_Pin_2 // PA2 #define UART2_RX_PIN GPIO_Pin_3 // PA3 #define UART2_GPIO GPIOA #define UART2_GPIO_AF GPIO_AF_7 #define UART2_TX_PINSOURCE GPIO_PinSource2 #define UART2_RX_PINSOURCE GPIO_PinSource3 -// Note: PA5 and PA0 are N/C on the sparky - potentially use for ADC or LED STRIP? #define USE_I2C #define I2C_DEVICE (I2CDEV_2) // SDA (PA10/AF4), SCL (PA9/AF4) @@ -89,53 +90,20 @@ #define BLACKBOX #define SERIAL_RX #define GPS -#define DISPLAY - -#define LED_STRIP -#if 1 -// LED strip configuration using PWM motor output pin 5. -#define LED_STRIP_TIMER TIM16 - -#define USE_LED_STRIP_ON_DMA1_CHANNEL3 -#define WS2811_GPIO GPIOA -#define WS2811_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA -#define WS2811_GPIO_AF GPIO_AF_1 -#define WS2811_PIN GPIO_Pin_6 // TIM16_CH1 -#define WS2811_PIN_SOURCE GPIO_PinSource6 -#define WS2811_TIMER TIM16 -#define WS2811_TIMER_APB2_PERIPHERAL RCC_APB2Periph_TIM16 -#define WS2811_DMA_CHANNEL DMA1_Channel3 -#define WS2811_IRQ DMA1_Channel3_IRQn -#endif - -#if 0 -// Alternate LED strip pin -// FIXME DMA IRQ Transfer Complete is never called because the TIM17_DMA_RMP needs to be set in SYSCFG_CFGR1 -#define LED_STRIP_TIMER TIM17 - -#define USE_LED_STRIP_ON_DMA1_CHANNEL7 -#define WS2811_GPIO GPIOA -#define WS2811_GPIO_AHB_PERIPHERAL RCC_AHBPeriph_GPIOA -#define WS2811_GPIO_AF GPIO_AF_1 -#define WS2811_PIN GPIO_Pin_7 // TIM17_CH1 -#define WS2811_PIN_SOURCE GPIO_PinSource7 -#define WS2811_TIMER TIM17 -#define WS2811_TIMER_APB2_PERIPHERAL RCC_APB2Periph_TIM17 -#define WS2811_DMA_CHANNEL DMA1_Channel7 -#define WS2811_IRQ DMA1_Channel7_IRQn -#endif +//#define DISPLAY +#define AUTOTUNE #define SPEKTRUM_BIND // USART2, PA3 -#define BIND_PORT GPIOA -#define BIND_PIN Pin_3 +#define BIND_PORT GPIOA +#define BIND_PIN Pin_3 + +// alternative defaults for AlienWii32 F3 target +#define ALIENWII32 +#define HARDWARE_BIND_PLUG // Hardware bind plug at PB12 (Pin 25) #define BINDPLUG_PORT GPIOB #define BINDPLUG_PIN Pin_12 -// alternative defaults for AlienWii32 F3 target -#define ALIENWII32 -#define BRUSHED_MOTORS -#define HARDWARE_BIND_PLUG diff --git a/src/main/target/NAZE/target.h b/src/main/target/NAZE/target.h index 7d53b0c4e3..1e1fe772d8 100644 --- a/src/main/target/NAZE/target.h +++ b/src/main/target/NAZE/target.h @@ -154,8 +154,8 @@ #ifdef ALIENWII32 #undef TARGET_BOARD_IDENTIFIER #define TARGET_BOARD_IDENTIFIER "AWF1" // AlienWii32 F1. -#define BRUSHED_MOTORS #define HARDWARE_BIND_PLUG + // Hardware bind plug at PB5 (Pin 41) #define BINDPLUG_PORT GPIOB #define BINDPLUG_PIN Pin_5 From ae8be396d64e15ff37db3b7c2fd81184aa1f9120 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 20 Feb 2015 14:30:35 +0000 Subject: [PATCH 58/60] Correct markdown formatting on Oneshot.md. --- docs/Oneshot.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/docs/Oneshot.md b/docs/Oneshot.md index cd6ca5ddb2..76f3ad4481 100644 --- a/docs/Oneshot.md +++ b/docs/Oneshot.md @@ -5,8 +5,7 @@ Oneshot allows faster communication between the Flight Controller and the ESCs t It does this in two ways: 1. Use a signal that varies between 125 µs and 250 µs (instead of the normal PWM timing of 1000µs to 2000µs) - -2. Only send a 'shot' once per flight controller loop, and do this as soon as the flight controller has calculated the required speed of the motors. +1. Only send a 'shot' once per flight controller loop, and do this as soon as the flight controller has calculated the required speed of the motors. ## Supported ESCs @@ -43,20 +42,13 @@ Then you can safely power up your ESCs again. The process for calibrating oneshot ESCs is the same as any other ESC. 1. Ensure that your ESCs are not powered up. - 1. Connect to the board using a USB cable, and change to the motor test page. - 1. Set the motor speed to maximum using the main slider. - 1. Connect power to your ESCs. They will beep. - 1. Click on the slider to bring the motor speed down to zero. The ESCs will beep again, usually a couple of times. - 1. Disconnect the power from your ESCs. - 1. Re-connect power to your ESCs, and verify that moving the motor slider makes your motors spin up normally. - ## References * FlyDuino (http://flyduino.net/) From 4aded2a0b90a4ae89b00eac1820168d70905b6d7 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 20 Feb 2015 14:31:09 +0000 Subject: [PATCH 59/60] Use same casing in Readme.md for 'Oneshot' as found elsewhere in the documentation. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ad931ae0a..7553015750 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The MultiWii software, from which baseflight originated, violates many good soft Cleanflight also has additional features not found in baseflight. * Multi-color RGB LED Strip support (each LED can be a different color using variable length WS2811 Addressable RGB strips - use for Orientation Indicators, Low Battery Warning, Flight Mode Status, etc) -* OneShot ESC support. +* Oneshot ESC support. * Support for additional targets that use the STM32F3 processors (baseflight only supports STM32F1). * Support for the TauLabs Sparky board (~$35 STM32F303 I2C sensors, based board with acc/gyro/compass and baro!) * Support for the OpenPilot CC3D board. (~$20 STM32F103 board, SPI acc/gyro) From f6408cd355c57e54b90440c5c3da7c93cf88a722 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 20 Feb 2015 18:51:50 +0000 Subject: [PATCH 60/60] CJMCU disable cli servos command to save flash space. At some point in the future it might be an idea to use a define for USE_SERVOS so that more code could be excluded. (Servo tilt, etc). --- src/main/io/serial_cli.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index 42dd1166e5..338ae295e0 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -199,7 +199,9 @@ const clicmd_t cmdTable[] = { { "profile", "index (0 to 2)", cliProfile }, { "rateprofile", "index (0 to 2)", cliRateProfile }, { "save", "save and reboot", cliSave }, +#ifndef CJMCU { "servo", "servo config", cliServo }, +#endif { "set", "name=value or blank or * for list", cliSet }, { "status", "show system status", cliStatus }, { "version", "", cliVersion }, @@ -748,6 +750,9 @@ static void cliColor(char *cmdline) static void cliServo(char *cmdline) { +#ifdef CJMCU + UNUSED(cmdline); +#else enum { SERVO_ARGUMENT_COUNT = 6 }; int16_t arguments[SERVO_ARGUMENT_COUNT]; @@ -812,6 +817,7 @@ static void cliServo(char *cmdline) servo->rate = arguments[4]; servo->forwardFromChannel = arguments[5]; } +#endif } static void dumpValues(uint16_t mask)