PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : seltsamer ueberlauf ??



goara
03.02.2008, 19:14
hallo habe folgenden code:


If Motor_send_v > Motorbegrenzung Then
Motor_send_v = Motorbegrenzung
Elseif Motor_send_v < 10 Then
Motor_send_v = 10
End If

Motor_sed_v is nen integer
Motorbegrenzung constant
wenn jetz motor_send_v immer kleiner wird, ( so maximal -100 ) wird es auf einamal auf motorbegrundzun (150) gesetzt... aber nen int hat da doch noch keinen ueberlauf.. oder was is hier falsch

PicNick
03.02.2008, 19:39
Motor_Send_v sollte eigentlich nicht kleiner als 10 werden können.
Da hat es was mit den DIM's (vorzeichen) würde ich mal raten.

Da müßt man mehr Code sehen, sorry

goara
03.02.2008, 20:09
kleienr als 10 wirds ja nicht.. es bleibt wenns kleier wird auf 10 und springt dann auf 130... wie wenns nen überrlauf gäbe.. nur das der nich bei minus 100 liegen kann sondern bei -32000 dachte ich ??


'---------Variablen-------------
Dim X As Word
Dim Y As Word
Dim Temp As Word
Dim Ledloop As Word
Dim Motor_soll_v As Integer
Dim Motor_soll_r As Integer
Dim Motor_soll_l As Integer
Dim Motor_soll_h As Integer
Dim Motor_send_v As Word
Dim Motor_send_r As Word
Dim Motor_send_l As Word
Dim Motor_send_h As Word
Dim Gyro_nick As Integer
Dim Gyro_roll As Integer
Dim Gyro_yaw As Integer
Dim Besch_x As Integer
Dim Besch_y As Integer
Dim Besch_z As Integer
Dim Gyro_nick_init As Integer
Dim Gyro_roll_init As Integer
Dim Gyro_yaw_init As Integer
Dim Besch_x_init As Integer
Dim Besch_y_init As Integer
Dim Besch_z_init As Integer
Dim Kanal_nick As Integer
Dim Kanal_roll As Integer
Dim Kanal_yaw As Integer
Dim Kanal_pitch As Integer
Dim Kanal_nick_init As Integer
Dim Kanal_roll_init As Integer
Dim Kanal_yaw_init As Integer
Dim Kanal_pitch_init As Integer
Dim Puls(8) As Integer
Dim Kanal As Byte
Dim Empfaenger_ok(4) As Byte
Dim Ok_flag As Byte
Dim Startflag As Bit
'----------Konstanten-----------
Const Mot_v = &H58 'I2C-Adressen der Motoren
Const Mot_r = &H52
Const Mot_h = &H56
Const Mot_l = &H54
Const Steuerempfindlichkeit = 50
Const Accempfindlichkeit = 1
Const Gyroempfindlichkeit = 0.5
Const Motorbegrenzung = 130

........


Sub Mixer

If Kanal_pitch < -60 Then
Startflag = 1
If Kanal_yaw < -15 Then
Startflag = 0
End If
End If
Motor_soll_v = Kanal_pitch + 100 'pitch
Motor_soll_r = Kanal_pitch + 100
Motor_soll_h = Kanal_pitch + 100
Motor_soll_l = Kanal_pitch + 100

Motor_soll_v = Motor_soll_v - Kanal_nick 'nick
Motor_soll_h = Motor_soll_h + Kanal_nick
Motor_soll_v = Motor_soll_v + Gyro_nick 'gyro nick
Motor_soll_h = Motor_soll_h - Gyro_nick
Motor_soll_v = Motor_soll_v + Besch_x 'acc nick
Motor_soll_h = Motor_soll_h - Besch_x

Motor_soll_r = Motor_soll_r - Kanal_roll 'roll
Motor_soll_l = Motor_soll_l + Kanal_roll
Motor_soll_r = Motor_soll_r + Gyro_roll 'gyro roll
Motor_soll_l = Motor_soll_l - Gyro_roll
Motor_soll_r = Motor_soll_r + Besch_y 'acc roll
Motor_soll_l = Motor_soll_l - Besch_y

Motor_soll_v = Motor_soll_v - Kanal_yaw 'yaw
Motor_soll_l = Motor_soll_l + Kanal_yaw
Motor_soll_r = Motor_soll_r + Kanal_yaw
Motor_soll_h = Motor_soll_h - Kanal_yaw

Motor_send_v = Motor_soll_v
Motor_send_r = Motor_soll_r
Motor_send_h = Motor_soll_h
Motor_send_l = Motor_soll_l

If Motor_send_v > Motorbegrenzung Then
Motor_send_v = Motorbegrenzung
Elseif Motor_send_v < 10 Then
Motor_send_v = 10
End If

If Motor_send_r > Motorbegrenzung Then
Motor_send_r = Motorbegrenzung
Elseif Motor_send_r < 10 Then
Motor_send_r = 10
End If

If Motor_send_h > Motorbegrenzung Then
Motor_send_h = Motorbegrenzung
Elseif Motor_send_h < 10 Then
Motor_send_h = 10
End If

If Motor_send_l > Motorbegrenzung Then
Motor_send_l = Motorbegrenzung
Elseif Motor_send_l < 10 Then
Motor_send_l = 10
End If


End Sub

Michael
03.02.2008, 20:27
Hallo goara,


PicNick schrieb:
Da hat es was mit den DIM's (vorzeichen) würde ich mal raten.

Bingo ;)


Motor_sed_v is nen integer

Dim Motor_send_v As Word

Gruß, Michael

goara
03.02.2008, 22:26
ui ok,... ich blindfisch... danke..