PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Fehler bei berechnung; warum?



Toxic
10.04.2007, 20:37
Hi,
habe n kleines Problem!

dieser Code Funtzt:


' Define´s
'Variablen
Define Vi Byte
Define VRemote3 Byte

Define VLgt1Bt Bit[185]
Define VLgt2Bt Bit[186]
Define VLgt3Bt Bit[187]
Define VAirBt Bit[188]
Define VHydBt Bit[189]
Define VDeHydBt Bit[190]
Define VHeatBt Bit[191]
Define VCoolBt Bit[192]
Define y byte

' Prog
gosub Initialization

Print "Start"
Print
Print "+--------------------+"
Print "| Byte->Binärtabelle |"
Print "+-------+------------|"
Print "| Byte: | Binärzahl: |"
Print "+-------+------------+"

#Main
for Vi = 0 to 255
VRemote3 = Vi
gosub DeCodeRcRelaisData
Print Vi; " = "; VLgt1Bt; VLgt2Bt; VLgt3Bt; VAirBt; VHydBt; VDeHydBt; VHeatBt; VCoolBt
Print "+-------+------------+"
next
Print "End"
end


#DeCodeRcRelaisData
y = ((VRemote3 SHR 7) MOD 2)
VLgt1Bt = y

y = ((VRemote3 SHR 6) MOD 2)
VLgt2Bt = y

y = ((VRemote3 SHR 5) MOD 2)
VLgt3Bt = y

y = ((VRemote3 SHR 4) MOD 2)
VAirBt = y

y = ((VRemote3 SHR 3) MOD 2)
VHydBt = y

y = ((VRemote3 SHR 2) MOD 2)
VDeHydBt = y

y = ((VRemote3 SHR 1) MOD 2)
VHeatBt = y

y = (VRemote3 MOD 2)
VCoolBt = y

return

#Initialization
Print "Initialization"

' Alle Vars (Vxxxxxxx) = 0
Vi = 0
VRemote3 = 0
VLgt1Bt = 0
VLgt2Bt = 0
VLgt3Bt = 0
VAirBt = 0
VHydBt = 0
VDeHydBt = 0
VHeatBt = 0
VCoolBt = 0
y = 0
return


dieser nicht:


' Define´s
'Variablen
Define Vi Byte
Define VRemote3 Byte

Define VLgt1Bt Bit[185]
Define VLgt2Bt Bit[186]
Define VLgt3Bt Bit[187]
Define VAirBt Bit[188]
Define VHydBt Bit[189]
Define VDeHydBt Bit[190]
Define VHeatBt Bit[191]
Define VCoolBt Bit[192]
Define y byte

' Prog
gosub Initialization

Print "Start"
Print
Print "+--------------------+"
Print "| Byte->Binärtabelle |"
Print "+-------+------------|"
Print "| Byte: | Binärzahl: |"
Print "+-------+------------+"

#Main
for Vi = 0 to 255
VRemote3 = Vi
gosub DeCodeRcRelaisData
Print Vi; " = "; VLgt1Bt; VLgt2Bt; VLgt3Bt; VAirBt; VHydBt; VDeHydBt; VHeatBt; VCoolBt
Print "+-------+------------+"
next
Print "End"
end


#DeCodeRcRelaisData
VRemote3 = ((VRemote3 SHR 7) MOD 2)
VLgt1Bt = VRemote3

VRemote3 = ((VRemote3 SHR 6) MOD 2)
VLgt2Bt = VRemote3

VRemote3 = ((VRemote3 SHR 5) MOD 2)
VLgt3Bt = VRemote3

VRemote3 = ((VRemote3 SHR 4) MOD 2)
VAirBt = VRemote3

VRemote3 = ((VRemote3 SHR 3) MOD 2)
VHydBt = VRemote3

VRemote3 = ((VRemote3 SHR 2) MOD 2)
VDeHydBt = VRemote3

VRemote3 = ((VRemote3 SHR 1) MOD 2)
VHeatBt = VRemote3

VRemote3 = (VRemote3 MOD 2)
VCoolBt = VRemote3

return

#Initialization
Print "Initialization"

' Alle Vars (Vxxxxxxx) = 0
Vi = 0
VRemote3 = 0
VLgt1Bt = 0
VLgt2Bt = 0
VLgt3Bt = 0
VAirBt = 0
VHydBt = 0
VDeHydBt = 0
VHeatBt = 0
VCoolBt = 0
y = 0
return


Kann mir wer sagen Warum?
Will mir unbedingt die "y"-Variable sparen; Ist das möglich?
Is Dringend und echt wichtig!

Toxic

matlxxx
17.04.2007, 12:09
hallo toxic!
bin spät dran, aber besser spät als nie!

schau dir das mal an:


#DeCodeRcRelaisData
VRemote3 = ((VRemote3 SHR 7) MOD 2)
VLgt1Bt = VRemote3

VRemote3 = ((VRemote3 SHR 6) MOD 2)
VLgt2Bt = VRemote3

VRemote3 = ((VRemote3 SHR 5) MOD 2)
VLgt3Bt = VRemote3

VRemote3 = ((VRemote3 SHR 4) MOD 2)
VAirBt = VRemote3

VRemote3 = ((VRemote3 SHR 3) MOD 2)
VHydBt = VRemote3

VRemote3 = ((VRemote3 SHR 2) MOD 2)
VDeHydBt = VRemote3

VRemote3 = ((VRemote3 SHR 1) MOD 2)
VHeatBt = VRemote3

VRemote3 = (VRemote3 MOD 2)
VCoolBt = VRemote3

return

du machst hier folgendes:
Vremote3 7 stellen nach rechts schieben.==>das ergebnis dann in die Variable Vremote3 Schreiben
du hast jetzt Vremote3 verändert! bei der zweiten berechnung rechnest du dann wieder mit der veränderten variable Vremote3!

probier es mal so:



#DeCodeRcRelaisData
VLgt1Bt = ((VRemote3 SHR 7) MOD 2)

VLgt2Bt = ((VRemote3 SHR 6) MOD 2)

VLgt3Bt =((VRemote3 SHR 5) MOD 2)

VAirBt = ((VRemote3 SHR 4) MOD 2)

VHydBt =(VRemote3 SHR 3) MOD 2)

VDeHydBt = ((VRemote3 SHR 2) MOD 2)

VHeatBt = ((VRemote3 SHR 1) MOD 2)

VCoolBt = (VRemote3 MOD 2)
return


hoffe ich liege richtig,
gruß martin