Subversion Repositories FlightCtrl

Rev

Rev 1221 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1221 Rev 1223
Line 92... Line 92...
92
 
92
 
93
uint8_t dsl_RSSI = 0;
93
uint8_t dsl_RSSI = 0;
94
uint8_t dsl_Battery = 0;
94
uint8_t dsl_Battery = 0;
95
uint8_t dsl_Allocation = 0;
95
uint8_t dsl_Allocation = 0;
96
uint8_t PacketBuffer[6];
96
uint8_t PacketBuffer[6];
Line 97... Line 97...
97
uint8_t Jitter = 0; // same measurement as RC_Quality in rc.c
97
//uint8_t Jitter = 0; // same measurement as RC_Quality in rc.c
98
 
98
 
99
typedef union
99
typedef union
100
{
100
{
Line 111... Line 111...
111
void dsl_new_signal(uint8_t channel, int16_t signal)
111
void dsl_new_signal(uint8_t channel, int16_t signal)
112
{
112
{
113
    int16_t tmp;
113
    int16_t tmp;
114
    uint8_t index = channel + 1; // mk channels start with 1
114
    uint8_t index = channel + 1; // mk channels start with 1
Line 115... Line 115...
115
 
115
 
116
        RC_Quality      = (212 * (uint16_t)dsl_RSSI) / 128; // have to be scaled approx. by a factor of 1.66 to get 200 at full level
116
        //RC_Quality    = (212 * (uint16_t)dsl_RSSI) / 128; // have to be scaled approx. by a factor of 1.66 to get 200 at full level
Line 117... Line 117...
117
        if(RC_Quality > 255) RC_Quality = 255;
117
        //if(RC_Quality > 255) RC_Quality = 255;
118
 
118
 
119
    // signal from  DSL-receiver is between 7373 (1ms) und 14745 (2ms).
119
    // signal from  DSL-receiver is between 7373 (1ms) und 14745 (2ms).
Line 120... Line 120...
120
    signal-= 11059;     // shift to neutral
120
    signal-= 11059;     // shift to neutral
121
    signal/= 24;        // scale to mk rc resolution
121
    signal/= 24;        // scale to mk rc resolution
122
 
122
 
123
        if(abs(signal-PPM_in[index]) < 6)
123
        if(abs(signal-PPM_in[index]) < 6)
124
        {
124
        {
Line 125... Line 125...
125
                if(Jitter < 200) Jitter +=10;
125
                if(RC_Quality < 200) RC_Quality +=10;
126
                else Jitter = 200;
126
                else RC_Quality = 200;
127
        }
127
        }
128
 
128
 
129
        // calculate exponential history for signal
129
        // calculate exponential history for signal
130
        tmp = (3 * (PPM_in[index]) + signal) / 4;
130
        tmp = (3 * (PPM_in[index]) + signal) / 4;
131
        if(tmp > signal+1) tmp--; else
131
        if(tmp > signal+1) tmp--; else
132
        if(tmp < signal-1) tmp++;
132
        if(tmp < signal-1) tmp++;
Line 133... Line 133...
133
        // calculate signal difference on good signal level
133
        // calculate signal difference on good signal level
134
        if(Jitter >= 195)  PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; // cut off lower 3 bit for noise reduction
134
        if(RC_Quality >= 195)  PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; // cut off lower 3 bit for noise reduction
Line 157... Line 157...
157
                        dsl_RSSI                = PacketBuffer[3]; // Get signal quality
157
                        dsl_RSSI                = PacketBuffer[3]; // Get signal quality
158
                        dsl_Battery     = PacketBuffer[4]; // Get voltage of battery supply
158
                        dsl_Battery     = PacketBuffer[4]; // Get voltage of battery supply
159
                        // ??                   = PacketBuffer[5];
159
                        // ??                   = PacketBuffer[5];
160
                        if(dsl_RSSI == 0)
160
                        if(dsl_RSSI == 0)
161
                        {
161
                        {
-
 
162
                                RC_Quality = 0;
162
                                for (i = 0; i<5; i++)
163
                                for (i = 0; i<5; i++)
163
                                {
164
                                {
164
                                        PPM_diff[i] = 0;
165
                                        PPM_diff[i] = 0;
165
                                        PPM_in[i] = 0;
166
                                        PPM_in[i] = 0;
166
                                }
167
                                }