Doch, eine Buchse ist da. Sehe ich jetzt erst. Die Dateinamen der Bilder ist die Auflösung.
Sorry wegen dem Code. Hier nochmal komplett:
Display All
Sorry wegen dem Code. Hier nochmal komplett:
BASCOM Source Code
- ' Empfänger VPW von Pac-Man modifiziert
- ' Nicht vollständig (Timer-ISR)
- $regfile = "m328pdef.dat"
- $crystal = 8000000
- $hwstack = 60
- $swstack = 60
- $framesize = 100
- $baud = 38400
- 'Dim Myframe , Dummyframe As String * 24 'Frame und Dummy für berechnung
- '
- Dim Mybyte As Byte 'erkannte Bits als byte
- Dim Bitcounter As Byte 'zähler für die Bits
- Dim Timerwert As Byte 'wert des Zählers
- Dim Myframe(8) As Byte
- 'Dim Bytewert(8) As Byte
- Dim Bytecounter , Dummybytecounter As Byte
- Dim I As Byte 'schleifenzähler
- 'Flags
- 'Dim Byte_da As Byte
- Dim Frame_da As Byte
- Declare Sub Frame_bearbeiten
- Led_gruen Alias Portc.0 : Config Led_gruen = Output
- Led_rot Alias Portc.1 : Config Led_rot = Output
- '############################################# serielle
- Const Pc = 1
- Open "COM1:" For Binary As #pc
- '########################################################### Timer
- 'OCR0 = f_cpu / (1024 * f_timer)
- Config Timer0 = Timer , Prescale = 8 , Clear Timer = 1 , Compare A = Disconnect '1uS
- Ocr0a = 240
- Enable Oc0a
- On Oc0a Timer_0
- '########################################################### PC-Interrupt
- Bus_in Alias Pinb.0 : Config Bus_in = Input : Portb.0 = 1
- Pcmsk0 = &B00000001 'Pcmsk0=pcint(0-7) Pcmsk1=pcint(8-14) ...
- Enable Pcint0
- On Pcint0 Read_bit 'bit einlesen
- '####################################################################################################
- Led_rot = 1 : Led_gruen = 1 : Wait 2 : Led_rot = 0 : Led_gruen = 0 'reset erkennen
- Enable Interrupts
- Do
- If Frame_da = 1 Then
- Frame_da = 0
- Frame_bearbeiten
- End If
- Loop
- End
- '########################################################## Subs
- Sub Frame_bearbeiten
- Local Header As String * 4 'zwei ersten headerbytes zur identifikation vom frame
- Local Result As Word : Result = 0 'ergebnis berechnung
- Header = Hex(myframe(1)) + Hex(myframe(2))
- Select Case Header
- Case "281B" 'RPM
- Result = Makeint(myframe(6) , Myframe(5))
- Result = Result / 4
- Print #pc , "RPM " ; Result
- Case "4829" 'Speed
- Result = Makeint(myframe(6) , Myframe(5))
- Result = Result / 128
- Print #pc , "Speed " ; Result
- Case "A849" 'temp
- Result = Myframe(5) - 40
- Print #pc , "TEMP " ; Result
- End Select
- End Sub
- Read_bit:
- Timerwert = Timer0
- Timer0 = 6
- Start Timer0
- '64uS "H" oder 128uS "L" => Bit=1
- '64uS "L" oder 128uS "H" => Bit=0
- 'SOF 200uS "H"
- 'EOD 200uS "L"
- 'EOF 280uS "L"
- Select Case Timerwert
- Case Is < 40
- 'Start Timer0
- ' Kurzer Bit-Inpuls
- Case 34 To 96 ' 34µs bis 96µs (nominell 64µs)
- If Bus_in = 1 Then ' Bitwert 0
- Mybyte = Mybyte * 2
- Else ' Nitwert 1
- Mybyte = Mybyte * 2
- Incr Mybyte ' +1 rechnen
- End If
- Incr Bitcounter ' Bit zählen, wenn es hinzugefügt wird
- ' Langer Bit-Impuls
- Case 96 To 163 ' 96µs bis 163µs (nominell 128µs)
- If Bus_in = 1 Then ' Bitwert 1
- Mybyte = Mybyte * 2
- Incr Mybyte ' +1 rechnen
- Else ' Bitwert 0
- Mybyte = Mybyte * 2
- End If
- Incr Bitcounter ' Bit zählen, wenn es hinzugefügt wird
- ' SOF-Inpuls
- Case 163 To 239 ' 163µs bis 239µs
- If Bus_in = 0 Then ' Pegel ist Low nach SOF-Impuls
- Bitcounter = 0
- Mybyte = 0
- End If
- End Select
- If Bitcounter = 8 Then
- Bitcounter = 0
- Incr Bytecounter
- Myframe(bytecounter) = Mybyte
- End If
- Return
- Timer_0:
- Stop Timer0
- Dummybytecounter = Bytecounter
- Bytecounter = 0
- Frame_da = 1 'frame empfangen
- 'Toggle Led_gruen
- Return