Hier sind die Berechnungen im Code:
Code:
'--Noise filter--
For I = 1 To 5
Meanrx(i) = Meanrx(i) * 3
Meanrx(i) = Meanrx(i) + Empf(i) '"lowpass filter" of the RC signal
Shift Meanrx(i) , Right , 2 ' (=divide by 4)
Aempfh(i) = Meanrx(i) + 17 'upper acceptable fluctuation
Aempfl(i) = Meanrx(i) - 17 'lower acceptable fluctuation
If Empf(i) > Aempfh(i) Or Empf(i) < Aempfl(i) Then 'compare allowed fluctuation with current rc reading
Empf(i) = Meanrx(i) 'if fluctuation was too high -> replace with averaged value
Print "Error reading channel: " ; I 'handy to check for RC problems
End If
Next
'Empf(X) are filled in "getreceiver". They usually contain values ranging from 63 - 137.
'Empf(throttlechannel) is the throttle stick. it will be rescaled differently.
If Empf(throttlechannel) > 61 And Empf(throttlechannel) < 139 Then 'don't process values that can't be correct
Sempf(throttlechannel) = Empf(throttlechannel) - 61
Sempf(throttlechannel) = Sempf(throttlechannel) * 3 '==> values ranging from 3 (stick at bottom) to 228 (full throttle)
End If
'Now nick, roll, yaw and idle up switch
If Empf(nickchannel) > 61 And Empf(nickchannel) < 139 Then 'don't process values that can't be correct
Sempf(nickchannel) = Empf(nickchannel) - 100 'convert to values ranging from -37 to +37
End If
If Empf(rollchannel) > 61 And Empf(rollchannel) < 139 Then 'don't process values that can't be correct
Sempf(rollchannel) = Empf(rollchannel) - 100 'convert to values ranging from -37 to +37
End If
If Empf(yawchannel) > 61 And Empf(yawchannel) < 139 Then 'don't process values that can't be correct
Sempf(yawchannel) = Empf(yawchannel) - 100 'convert to values ranging from -37 to +37
End If
If Empf(5) > 61 And Empf(5) < 139 Then 'don't process values that can't be correct
Sempf(5) = Empf(5) - 100 'convert to values ranging from -37 to +37
End If
Eigentlich findet alles nicht im Array statt, trotzdem gehts nicht als Byte. Vielleicht liegt das daran, dass bei Fehlerhaftem Signal die Variable Meanrx in Empf geschrieben wird. Sicher bin ich mir da aber nicht. Vielleicht hast du eine Erklärung?
Gruß
Chris
Lesezeichen