So... ich hab jetzt versucht ein anderes Programm aufzuziehen.
Es ist stark angelehnt an dieses hier https://www.roboternetz.de/wissen/in..._an_RN-Control
meins sieht wie folgt aus:
Code:'############################################################################### '# # '# entfernung_1.bas # '# # '# Aufgabe: Messen von Entfernungen via SRF08 # '# # '############################################################################### Declare Function Srf08_firmware(byval Srf08_adr_0 As Byte) As Byte Declare Sub Srf08_reichweite(byval Srf08_adr_0 As Byte , Byval Reichweite As Word) Declare Sub Srf08_verstaerkung(byval Srf08_adr_0 As Byte , Byval Verstaerkung As Byte) Declare Function Srf08_entfernung(byval Srf_adr_0 As Byte) As Byte $regfile = "m32def.dat" $crystal = 16000000 $baud = 9600 Config Scl = Portc.0 'Port fuer IIC-Bus Config Sda = Portc.1 'Port fuer IIC-Bus Dim Entfernung As Integer '############################################################################### '# Main # '############################################################################### Wait 3 I2cinit Print "**********************************" Print "*US Messuns via SRF08 by stiffler*" Print "**********************************" Print "\n" Print "SRF 08 Firmware Version: " ; Srf08_firmware(&He0) Srf08_reichweite &HE0 , 100 'Reichweite für die Messung festlegen Srf08_verstaerkung &HE0 , 1 'Lichtverstärkungsfaktor Do Entfernung = Srf08_entfernung(&He0) Print "Entfernung: " ; Entfernung ; "cm" Wait 1 Loop End '############################################################################### '# Reichweite setzen # '############################################################################### Sub Srf08_reichweite(byval Srf08_adr_0 As Byte , Byval Reichweite As Word) I2cstart I2cwbyte Srf08_adr_0 I2cwbyte 2 I2cwbyte Reichweite I2cstop End Sub '############################################################################### '# Verstärkung setzten # '############################################################################### Sub Srf08_verstaerkung(byval Srf08_adr_0 As Byte , Byval Verstaerkung As Word) I2cstart I2cwbyte Srf08_adr_0 I2cwbyte 1 I2cwbyte Verstaerkung I2cstop End Sub '############################################################################### '# Firmware-Vers. prüfen (wenn Byte 255 anzeigt wird noch gemessen)# '############################################################################### Function Srf08_firmware(byval Srf08_adr_0 As Byte) Local Srf08_adr_read As Byte Local Firmware As Byte Srf08_adr_read = Srf08_adr_0 + 1 I2cstart I2cwbyte Srf08_adr_0 I2cwbyte 0 I2cstop I2cstart I2cwbyte Srf08_adr_read I2crbyte Firmware , Nack I2cstop Srf08_firmware = Firmware End Function '############################################################################### '# Entfernung bestimmen # '############################################################################### Function Srf08_entfernung(byval Srf08_adr_0 As Byte) Local Firmware As Byte Local Srf08_adr_read As Byte Local Hib As Byte Local Lob As Byte Srf08_adr_read = &HE1 'Messung starten: I2cstart I2cwbyte Srf_adr_0 I2cwbyte 0 I2cwbyte 81 I2cstop Warteaufmessung: Waitms 1 Firmware = Srf08_firmware(&He0) If Firmware = 255 Then Goto Warteaufmessung I2cstart I2cwbyte Srf08_adr_0 I2cwbyte 2 I2cstop I2cstart I2cwbyte Srf08_adr_read I2crbyte Hib , Ack I2crbyte Lob , Nack I2cstop Srf08_entfernung = Makeint(lob , Hib) End Function
ich bekomme hierbei nun 3 errors nicht weg und zwar in dieser zeile:
an der Stelle von Funktion "Srf08_entfernung(byval Srf08_adr_0 As Byte)"Code:I2cwbyte Srf08_adr_0
Als error sagt er mir "invalid datatype" und als 2. "variable not dimensioned"
das habe ich aber doch schon im funktionsaufruf gemacht, oder nicht?!?
und der 3. fehler ist in dieser zeile im hauptprogramm:
da sagt Bascom mir: "different parameter type passed then declared"Code:Entfernung = Srf08_entfernung(&He0)





Zitieren

Lesezeichen