@raggy:

Du bist mein Retter. es fehlte natürlich das ;

habe noch ne kleine andere Frage. Ich werte einen SRF02 Ultraschall Sensor aus. Den SRF02 lese ich folgendermaßen aus :



Code:
'------------------------ CPU Config -------------------------
$regfile = "m8def.dat"
$crystal = 1000000
$baud = 1200
$framesize = 42
$swstack = 42
$hwstack = 42
'------------------------ Port Config --------------------------
Config Portb = Output
Config Portd.2 = Output
Config Scl = Portc.5
Config Sda = Portc.4
Const Srf02_slaveid = &HE0
'------------------------ Alias ----------------------------------
Led1 Alias Portb.0
Led2 Alias Portb.1
Led3 Alias Portb.2
Led4 Alias Portb.3
Rs485 Alias Portd.2
'-------------------------- Subs -------------------------------

'--------------------------- RS485 -------------------------------
Rs485 = 0
Enable Interrupts
'----------------------------- Dims ------------------------------
Dim Entfernung As Integer
Dim V As Byte
'----------------------- Funcitons -------------------------
Declare Function Srf02_firmware(byval Slaveid As Byte) As Byte
Declare Function Srf02_entfernung(byval Slaveid As Byte) As Integer
'------------------------- Boot ---------------------------------
Wait 1
I2cinit
V = 1
Waitms 100
'---------------------------------- Mainprogramm ------------------
Main:
Entfernung = Srf02_entfernung(srf02_slaveid)
Waitms 100
Rs485 = 1

         Print Entfernung ;
         Do
         Loop Until Ucsra.txc = 1
         Set Ucsra.txc



Rs485 = 0

Wait 2

Goto Main
'--------------------------------- SRF_02 ------------------------------------------
Function Srf02_firmware(byval Slaveid As Byte) As Byte
Local Firmware As Byte
Local Slaveid_read As Byte

   Slaveid_read = Slaveid + 1

   I2cstart
   I2cwbyte Slaveid
   I2cwbyte 0                                               'Leseregister festlegen
   I2cstop

   I2cstart
   I2cwbyte Slaveid_read
   I2crbyte Firmware , Nack
   I2cstop

   Srf02_firmware = Firmware
End Function



Function Srf02_entfernung(byval Slaveid As Byte) As Integer
Local Lob As Byte
Local Hib As Byte
Local Firmware As Byte
Local Temp As Byte
Local Slaveid_read As Byte

   Slaveid_read = Slaveid + 1

   'Messvorgang in starten
   I2cstart
   I2cwbyte Slaveid
   I2cwbyte 0
   I2cwbyte 81                                              'in Zentimetern messen
   I2cstop


Warteaufmessung:
   Waitms 1
   Firmware = Srf02_firmware(slaveid)
   If Firmware = 255 Then Goto Warteaufmessung

   I2cstart
   I2cwbyte Slaveid
   I2cwbyte 2                                               'Leseregister festlegen
   I2cstop


   I2cstart
   I2cwbyte Slaveid_read
   I2crbyte Hib , Ack
   I2crbyte Lob , Nack
   I2cstop


   Srf02_entfernung = Makeint(lob , Hib)
End Function
ich übertrage ja den integerwert. auf der Empfängerseite wird mir aber nicht die cm angezeigt sondern wieder wirres Zeug. Kann ich denn von Integer nach String wandeln um es zu übertragen ?

mfg Kay