/branches/V0.82b-Arthur-P/fc.c |
---|
1,3 → 1,20 |
/****************************************************************************************************************** |
V0.82b-Arthur-P 2010-12-18 |
------------------------------------------------------------------------------------------------------------------ |
Version includes only support for external HEF4017 for FC1.x hardware, NOT for Twi2Ppm converters for ESCs. |
2010-12-18 Transferred changes to v.0.82b-Arthur-P. Remarked out variable i in Mittelwert() as this |
variable is not used. |
20100917: Transferred changes to v0.80g-Arthur-Px. |
20100804: Arthur P.: Modified to use user parameter 7 to determine downstep for motorsmoothing |
with 0 or 1 defaulting to the default -150% first step followed by upsmoothing and |
values beyond that resulting in 50% (2), 75% (4), 90% (10), 95% (20), 97.5% (40), 99% (100) |
downsteps. |
Within timer0.c user paramater 8 is used to activate an external HEF4017 on FC 1.x hardware, |
and/or to set the shutter interval timer in steps of 0.1sec (minimum = 1 sec), by using |
bit 8 (128) as on/off switch, and bits 7 (0..127) for the timer counter. |
******************************************************************************************************************/ |
/*####################################################################################### |
Flight Control |
#######################################################################################*/ |
368,7 → 385,13 |
static signed long tmpl,tmpl2,tmpl3,tmpl4; |
static signed int oldNick, oldRoll, d2Roll, d2Nick; |
signed long winkel_nick, winkel_roll; |
unsigned char i; |
/*********************************************************************************************************** |
Arthur P: Disabbled unsinged char i as this variable is not used. |
***********************************************************************************************************/ |
// unsigned char i; |
/*********************************************************************************************************** |
Arthur P: End of change. |
***********************************************************************************************************/ |
MesswertGier = (signed int) AdNeutralGier - AdWertGier; |
MesswertNick = (signed int) AdWertNickFilter / 8; |
MesswertRoll = (signed int) AdWertRollFilter / 8; |
1715,8 → 1738,42 |
else if(Mixer.Motor[i][3] == -64) tmp_int -= GierMischanteil; |
else tmp_int += ((long)GierMischanteil * Mixer.Motor[i][3]) / 64L; |
/****************************************************************************************************************** |
Arthur P: the original code allowed the motor value to drop to 0 or negative values |
straight off, i.e. could amplify an intended decrease excessively while upregulation |
is dampened. The modification would still allow immediate drop below intended value |
but would dampen this. This would still allow for airbraking of the prop to have effect |
but it might lead to less sudden excessive drops in rpm with only gradual recovery. |
090807 Arthur P: Due to problems with uart.c which still refers to user parameter 1 and 2 and |
possible timing issues with the shutter interval load, removed the shutter interval functions |
and switched to use of userparam6 for the motor smoothing. |
091114 Inserted modification into 0.76g source code. |
20100804 Modified v.0.80d code where motorsmoothing is no longer a separate function. |
Downsmoothing either uses default v.0.7x+ 150% downstep (user para 7 == 0), |
50% downstep (user para 7 == 1 or 2), or downsteps of x% (userpara7 ==): |
66.6% (3), 75% (4), 80% (5), 90% (10), 95% (20), 97.5% (40), 98% (50), 99% (100). |
******************************************************************************************************************/ |
if(tmp_int > tmp_motorwert[i]) tmp_int = (tmp_motorwert[i] + tmp_int) / 2; // MotorSmoothing |
else tmp_int = 2 * tmp_int - tmp_motorwert[i]; // MotorSmoothing |
/****************************************************************************************************************** |
Arthur P: Start of changes in fc.c. Next line is disabled and replaced by modified routine. |
******************************************************************************************************************/ |
// else tmp_int = 2 * tmp_int - tmp_motorwert[i]; // MotorSmoothing |
else |
{ |
if(Parameter_UserParam7 < 2) |
{ // Original function |
tmp_int = 2 * tmp_int - tmp_motorwert[i]; |
} |
else |
{ |
// If userpara7 >= 2 then allow >= 50% of the intended step down to rapidly reach the intended value. |
tmp_int = tmp_int + ((tmp_motorwert[i] - tmp_int)/Parameter_UserParam7); |
} |
} |
/****************************************************************************************************************** |
Arthur P: End of changes in fc.c. |
******************************************************************************************************************/ |
LIMIT_MIN_MAX(tmp_int,(int) MIN_GAS * 4,(int) MAX_GAS * 4); |
Motor[i].SetPoint = tmp_int / 4; |
/branches/V0.82b-Arthur-P/main.c |
---|
1,3 → 1,18 |
/****************************************************************************************************************** |
V0.82b-Arthur-P 2010-12-18 |
------------------------------------------------------------------------------------------------------------------ |
Version includes only support for external HEF4017 for FC1.x hardware, NOT for Twi2Ppm converters for ESCs. |
------------------------------------------------------------------------------------------------------------------ |
Besides adding this header. The following files have been modified: |
* main.c: Remark header added with summary of changes to other files. Also remarked out variable i from function |
Mittelwert as this variable is not used. No other changes. |
* menu.c: Modifed text to show branch name in MKTool window. |
* fc.c: Modified motor smoothing routine. |
* timer0.c: Added several variables and modified the servo control routines to allow control to be activated |
* through a parameter, and to allow different shutter servo control. |
* makefile: Modified to correctly name output file to reflect branch name. |
All changes are clearly marked similar to this change. |
******************************************************************************************************************/ |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Copyright (c) Holger Buss, Ingo Busker |
// + Nur für den privaten Gebrauch / NON-COMMERCIAL USE ONLY |
/branches/V0.82b-Arthur-P/makefile |
---|
1,3 → 1,6 |
#v0.82b-Arthur-P 2010-12-18 |
#Modified the output line to correctly reflect the branch name. |
# |
#-------------------------------------------------------------------- |
# MCU name |
#MCU = atmega1284p |
42,10 → 45,13 |
# Target file name (without extension). |
ifeq ($(VERSION_PATCH), 0) |
#Arthur P: Following line modified. |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)a_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 1) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b_SVN$(REV) |
#TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b_SVN$(REV) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b_Arthur-P1_SVN$(REV) |
#Arthur P: End of modification. |
endif |
ifeq ($(VERSION_PATCH), 2) |
TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)c_SVN$(REV) |
/branches/V0.82b-Arthur-P/menu.c |
---|
1,3 → 1,9 |
/****************************************************************************************************************** |
V0.80b-Arthur-P 2010-12-18 |
------------------------------------------------------------------------------------------------------------------ |
Version includes only support for external HEF4017 for FC1.x hardware, NOT for Twi2Ppm converters for ESCs. |
2010-12-18 Modified to show branch version in MKTool window. |
******************************************************************************************************************/ |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Copyright (c) Holger Buss, Ingo Busker |
// + only for non-profit use |
45,7 → 51,13 |
{ |
case 0: |
LCD_printfxy(0,0,"+ MikroKopter +"); |
LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c",PlatinenVersion/10,PlatinenVersion%10, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH +'a'); |
/****************************************************************************************************************** |
Arthur P: Modified next line to show branch version name in MKTool window. |
******************************************************************************************************************/ |
LCD_printfxy(0,1,"HW:V%d.%d SW:%d.%d%c-Arthur-P",PlatinenVersion/10,PlatinenVersion%10, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH +'a'); |
/****************************************************************************************************************** |
Arthur P: End of changes to menu.c. |
******************************************************************************************************************/ |
LCD_printfxy(0,2,"Setting:%d %s", GetActiveParamSet(),Mixer.Name); |
if(VersionInfo.HardwareError[0]) LCD_printfxy(0,3,"Hardware Error 1:%d !!",VersionInfo.HardwareError[0]) |
else |
/branches/V0.82b-Arthur-P/timer0.c |
---|
1,3 → 1,21 |
/****************************************************************************************************************** |
V0.82b-Arthur-P 2010-12-18 |
------------------------------------------------------------------------------------------------------------------ |
Version includes only support for external HEF4017 for FC1.x hardware, NOT for Twi2Ppm converters for ESCs. |
2010-12-18 Transferred changes to v.0.82b-Arthur-P |
20100917: Transferred changes to v0.80g-Arthur-P. |
Arthur P. Modified to use several parameters for servo control: |
User_Parameter4: |
User_Parameter5: |
User_Parameter6: |
User_Parameter7: |
User_Parameter8: Use external HEF4017 if bit 8 is set (>127). The remaining 7 bits are used |
for the shutter cycle counter: the value is multiplied by 5 programmatically, |
resulting in steps of approx. 0.1sec. Minimum value to start using the |
interval timer is 10 (approx. 1 sec, or countervalue of 50). Note that this |
was originally done through user para 6. |
******************************************************************************************************************/ |
#include "main.h" |
#define MULTIPLYER 4 |
16,7 → 34,24 |
volatile int16_t ServoNickValue = 0; |
volatile int16_t ServoRollValue = 0; |
/****************************************************************************************************************** |
Arthur P: Added two variables for control of the shutter servo cycle. |
091114 Inserted same changes into v.0.76g code. |
091114 Inactivated the following two lines as the shutter interval funtion is not |
used at the moment. |
20100804 Reactivated to be able to choose slower shutter rate than normal for |
Panasonic FX150 in continuous mode. |
******************************************************************************************************************/ |
volatile static unsigned int CameraShutterCycleCounter = 0; |
volatile static unsigned int CameraShutterCycle = 0; |
volatile static unsigned int CameraShutterCycleOnCount = 20; // Leave the shutter on for at least |
// 20 cycles or approx. 0.2 seconds. |
/****************************************************************************************************************** |
Arthur P: End of changes to variables section of timer0.c. |
******************************************************************************************************************/ |
enum { |
STOP = 0, |
CK = 1, |
130,6 → 165,23 |
{ |
uint8_t sreg = SREG; |
/****************************************************************************************************************** |
Arthur P: Added initialization of the CameraShutterCycle value here as this routine is only |
called once. This retains all code changes in timer0.c. If (parameter 8 & 127) > 0 then the user |
has set a value for the cycle. CameraShuytterCycle == 5x (Para8 & 127) to get approx 0.1sec increments. |
090807: Arthur P.: Removed the shutter cycle parts as they may be impacting timing loops. |
20100804 Arthur P.: Reactivate shutter cycle counters. Modified to use the lower 7 bits of |
user parameter 8 (bit 8 is used for enabling the external HEF4017). |
CameraShutterCycle = Parameter_UserParam6; |
******************************************************************************************************************/ |
CameraShutterCycle = 5 * (Parameter_UserParam8 & 127); |
/****************************************************************************************************************** |
Arthur P: End of changes to Timer2 function. |
******************************************************************************************************************/ |
// disable all interrupts before reconfiguration |
cli(); |
271,7 → 323,21 |
static uint8_t ServoIndex = 0; |
if(PlatinenVersion < 20) |
/****************************************************************************************************************** |
Arthur P: Modified the code to check the value of parameter 8. If 128 or higher then a HEF4017 is |
expected and will be used. Else J7 and J9 are seen as separate normal outputs. |
if((PlatinenVersion < 20) |
091114. Inserted same changes into v.0.76g code. |
20100802 Inserted same changes into v.0.80d code. |
******************************************************************************************************************/ |
// if(PlatinenVersion < 20) |
if((PlatinenVersion < 20) && (Parameter_UserParam8 < 128 )) |
/****************************************************************************************************************** |
Arthur P: End of modification ot if statement. |
******************************************************************************************************************/ |
{ |
//--------------------------- |
// Nick servo state machine |
327,9 → 393,70 |
case 2: // Roll Compensation Servo |
RemainingPulse += ServoRollValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
break; |
/****************************************************************************************************************** |
Arthur P: Shutter Servo including interval control over parameter 5 and 6. |
091114 Inserted same modification into v.0.76g code, removing previously REM-ed out modified parts. |
20100802 Inserted same modification into v.0.76g code, removing previously REM-ed out modified parts. |
Modified to use lower 7 bits of user parameter 7. |
******************************************************************************************************************/ |
case 3: |
RemainingPulse += ((int16_t)Parameter_Servo3 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
// RemainingPulse += ((int16_t)Parameter_Servo3 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
// break; |
if(PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] < -32) |
{ |
// Set servo to null position, turning camera off. |
RemainingPulse = MINSERVOPULSE; |
} |
else |
{ |
// 090807: Arthur P.: Removed the shutter cycle parts as they may be impacting timing loops. |
// 20100804 Reactived shutter interval timer capability. |
if(PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] > 32) |
// Top position on a 3 position switch which runs from -127 to +127 |
{ |
RemainingPulse = MINSERVOPULSE + SERVORANGE; |
} |
else |
{ |
// Cycle shutter servo between 50% on and off depending upon CameraShutterCycleCounter |
// If CameraShutterCylce < 50 then default to continuous shoot. |
if(CameraShutterCycle < 50 ) // == 5x the minimum value of userpara8 lower 7 bits |
{ |
RemainingPulse = MINSERVOPULSE + SERVORANGE/2; |
} |
else |
{ |
if(CameraShutterCycleCounter == CameraShutterCycle) |
{ |
// Shutter on |
CameraShutterCycleCounter = 0; |
RemainingPulse = MINSERVOPULSE + SERVORANGE/2; |
} |
else |
{ |
// Leave on for at least 20 cycles or 0.2 seconds to allow |
// the camera to properly trigger, turn off if past 0.2 sec. |
// For now this is actually set via para5 to allow for a long enough |
// shutter pulse for different cameras. Once it is clear what value |
// works, this can be changed to a hardcoded value. |
CameraShutterCycleCounter++; |
if(CameraShutterCycleCounter == CameraShutterCycleOnCount) |
{ |
// Shutter off |
RemainingPulse = MINSERVOPULSE; |
} |
} |
} |
} |
} |
break; |
/****************************************************************************************************************** |
Arthur P: End of modified shutter servo control (via HEF4017) and of modifications to timer0.c. |
******************************************************************************************************************/ |
case 4: |
RemainingPulse += ((int16_t)Parameter_Servo4 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
break; |