Hier die Programme vom Sender:
Code:
$regfile = "m8def.dat"
$crystal = 8000000
Baud = 9600

Dim I As Byte
Dim T0ov As Byte
Dim Akth As Word At &H70
Dim Diffh As Integer At &H72
Dim Akthlow As Byte At &H70 Overlay
Dim Akthhigh As Byte At &H71 Overlay
Dim Diffhlow As Byte At &H72 Overlay
Dim Diffhhigh As Byte At &H73 Overlay
Dim Lasth As Word
Dim Temph As Word
'Dim Zeroh As Word
'Zeroh = 0

Enable Interrupts
'Enable Int1                                                 'Interrupt durch Taster zur Abfrage
'On Int1 _interr1                                                     'der Nullpunkthöhe über Normalnull

Ddrb.0 = 1
Ddrb.1 = 1
Portb.1 = 1

Config Adc = Single , Prescaler = Auto , Reference = Avcc   'Konfig. des AD-Wandlers
Start Adc
'On Adc _adc Nosave

Config Timer0 = Timer , Prescale = 1024                     'Timer0 für Durchlaufzeit der Hauptschleife
Enable Timer0
On Timer0 _t0
Start Timer0


' *** Hauptschleife ***
Do
Toggle Portb.0
Toggle Portb.1
  T0ov = 0                                                  'Überlaufzähler Timer0 rücksetzen
  Lasth = Akth                                              'Den Wert der letzten Messung sichern
  Akth = 0                                                  'Variable löschen
  For I = 1 To 16                                           '16 Meßwerte aufnehmen für Mittelwertbildung
    Temph = Getadc(0)                                       'Drucksensor am ADC0
    Akth = Akth + Temph
  Next
  Shift Akth , Right , 4                                    'Ergebnis /16 teilen
  'Akth = Akth - Zeroh                                       'Nullhöhe abziehen
  Diffh = Akth - Lasth                                      'Differenz zw. letzter und aktueller Messung
  Print 1                                                   '&B00000001
  Waitms 50
  Print Akthlow
  Waitms 50
  Print Akthhigh
  Waitms 50
  Print Diffhlow
  Waitms 50
  Print Diffhhigh


  Do                                                        'warten bis Timer0 10 mal übergelaufen ist,
  Loop Until T0ov = 10                                      'dann beginnt nächster Messzyklus

Loop

End

' *** Interruptroutinen ***

'_adc:
' Return

_t0:
 Incr T0ov
 Timer0 = 15
 Return

'_interr1:
'Zeroh = Getadc(0)                                           'Nullpunkt setzen
'Return
und Empfänger:
Code:
$regfile = "m8def.dat"                                      'Mega8
$crystal = 8000000
$baud = 9600

Declare Sub Lcdinit
Declare Sub Lcdwrite(byval Zeichen As Byte)

Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.2 , Rs = Portd.3
Config Lcd = 20 * 4a
Waitms 100
'Initlcd
Call Lcdinit
Cls

Ddrb.0 = 1

Dim Akth As Word At &H71
Dim Diffh As Integer At &H73
Dim Buffer(6) As Byte At &H70 Overlay
Dim I As Byte
Dim P As Byte
Dim A As Word
Dim D As Integer

On Urxc _onrxc
Enable Urxc
Enable Interrupts
I = 0

Do
If I > 5 Then
  A = Akth
  D = Diffh
  End If
Locate 1 , 1
Lcd A ; "    "
Locate 2 , 1
Lcd D ; "    "
Locate 3 , 1
Lcd P ; "     "
Locate 4 , 1
Lcd I
Loop





  _onrxc:
  P = Udr
  If P = 1 And I = 6 Then
    I = 1
    End If
  If I < 6 Then
    Buffer(i) = P
    Incr I
    End If
  Toggle Portb.0
  Return


  Sub Lcdinit
     Call Lcdwrite(&B00101100)
     Call Lcdwrite(&B00001001)
     Call Lcdwrite(&B00101000)
     Call Lcdwrite(&B00000110)
     Call Lcdwrite(&B00001100)
   End Sub


   Sub Lcdwrite(byval Zeichen As Byte)

     ' Höherwertiges Nibble setzen
     If Zeichen.4 = 1 Then Portd.4 = 1 Else Portd.4 = 0
     If Zeichen.5 = 1 Then Portd.5 = 1 Else Portd.5 = 0
     If Zeichen.6 = 1 Then Portd.6 = 1 Else Portd.6 = 0
     If Zeichen.7 = 1 Then Portd.7 = 1 Else Portd.7 = 0
     ' Höherwertiges Nibble übertragen
     Portd.2 = 1
     Waitms 1
     Portd.2 = 0
     Waitms 1

     ' Niederwertiges Nibble setzen
     If Zeichen.0 = 1 Then Portd.4 = 1 Else Portd.4 = 0
     If Zeichen.1 = 1 Then Portd.5 = 1 Else Portd.5 = 0
     If Zeichen.2 = 1 Then Portd.6 = 1 Else Portd.6 = 0
     If Zeichen.3 = 1 Then Portd.7 = 1 Else Portd.7 = 0
     ' Niederwertiges Nibble übertragen
     Portd.2 = 1
     Waitms 1
     Portd.2 = 0
     Waitms 1

   End Sub