$regfile = "m8def.dat" $crystal = 12000000 Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.2 , _ Db7 = Portb.3 , E = Portb.1 , Rs = Portb.0 Config Lcd = 16 * 2 Cursor Off Cls Waitms 10 Config Adc = Single , Prescaler = Auto , Reference = Avcc Config Portc.2 = Output Config Portc.0 = Output Config Portd.4 = Output Config Portd.5 = Output Config Portd.6 = Output Config Portd.7 = Output Config Portd.3 = Input Portd.3 = 1 Config Portd.2 = Input Portd.2 = 1 Config Portd.1 = Input Portd.1 = 1 Config Portd.0 = Input Portd.0 = 1 Wicklung1 Alias Portd.4 Wicklung2 Alias Portd.5 Wicklung3 Alias Portd.6 Wicklung4 Alias Portd.7 Taster1 Alias Pind.3 Taster2 Alias Pind.2 Endschalterrechts Alias Pind.1 Endschalterlinks Alias Pind.0 Ausloeser Alias Portc.2 Beleuchtung Alias Portc.0 Dim Strecke As Single Dim Adcwert As Word Dim Wartezeit As Word Dim Fotos As Word Dim Durchlauf As Word Dim Zyklus As Word Dim Richtung As Bit Dim Anzeigewert As String * 5 Dim Anzeigewert1 As String * 5 Dim Rechnen1 As Integer Dim Rechnen2 As Integer Dim Manuell As Bit Locate 1 , 5 Lcd "Slow-Cam" Locate 2 , 6 Lcd "T W O" Beleuchtung = 1 Wait 1 Beleuchtung = 0 Wait 1 Beleuchtung = 1 Wait 1 Locate 1 , 5 Lcd "copyright" Locate 2 , 3 Lcd "Martin Goerke" Wait 4 Cls Ausloeser = 1 Waitms 500 Ausloeser = 0 Anfang: Do Locate 1 , 1 Lcd "Taster 1 Autom." Locate 2 , 1 Lcd "Taster 2 Manuell" If Taster1 = 0 Then Goto Anfang1 If Taster2 = 0 Then Goto Anfang2 Waitms 10 Loop Anfang1: Waitms 500 Cls Manuell = 0 Do Locate 1 , 1 Lcd "Geschwindigkeit" Locate 2 , 8 Lcd "T1 weiter" Gosub Berechnen Locate 2 , 1 Lcd " %" Locate 2 , 1 Lcd Rechnen2 Waitms 10 If Taster1 = 0 Then Goto Warten1: Loop Anfang2: Waitms 500 Cls Richtung = 0 Do Locate 1 , 1 Lcd "T1 Start" Locate 2 , 1 Lcd "T2 Re/Li" Locate 2 , 11 Lcd "Rechts" Gosub Berechnen Locate 1 , 12 Lcd " %" Locate 1 , 12 Lcd Rechnen2 Waitms 10 If Taster2 = 0 Then Goto Anfang3 If Taster1 = 0 Then Goto Fahren Waitms 10 Loop Anfang3: Richtung = 1 Waitms 500 Cls Do Locate 1 , 1 Lcd "T1 Start" Locate 2 , 1 Lcd "T2 Re/Li" Locate 2 , 11 Lcd "Links" Gosub Berechnen Locate 1 , 12 Lcd " %" Locate 1 , 12 Lcd Rechnen2 Waitms 10 If Taster2 = 0 Then Goto Anfang2 If Taster1 = 0 Then Goto Fahren Loop Warten1: Waitms 500 Goto Unterprogramm1 Unterprogramm1: Cls Do Locate 1 , 1 Lcd "Richtung mit T2 " Locate 2 , 8 Lcd "T1 weiter" Locate 2 , 1 Lcd "Rechts" Richtung = 0 If Taster1 = 0 Then Goto Unterprogramm3 If Taster2 = 0 Then Goto Unterprogramm2 Waitms 10 Loop Unterprogramm2: Waitms 500 Do Locate 2 , 1 Lcd "Links " Richtung = 1 If Taster1 = 0 Then Goto Unterprogramm3 If Taster2 = 0 Then Goto Warten1 Loop Unterprogramm3: Waitms 500 Cls Do Locate 1 , 1 Lcd "Ausloesen einst." Locate 2 , 8 Lcd "T1 weiter" Adcwert = Getadc(1) Adcwert = Adcwert * 2 Zyklus = Adcwert Anzeigewert = Str(adcwert) Anzeigewert1 = Format(anzeigewert , "    0" ) Locate 2 , 1 Lcd Anzeigewert1 Waitms 10 If Taster1 = 0 Then Goto Warten2: Loop Fahren: Do Gosub Berechnen Loop Warten2: Cls Locate 1 , 2 Lcd "Vorgang laeuft" Locate 2 , 1 Lcd "Fotos / T1 STOP" Wait 1 If Richtung = 0 Then Goto Rechts If Richtung = 1 Then Goto Links Links: Do Durchlauf = Durchlauf + 1 Wicklung1 = 1 Waitms Wartezeit Wicklung1 = 0 Waitus 1 Wicklung2 = 1 Waitms Wartezeit Wicklung2 = 0 Waitus 1 Wicklung3 = 1 Waitms Wartezeit Wicklung3 = 0 Waitus 1 Wicklung4 = 1 Waitms Wartezeit Wicklung4 = 0 Waitus 1 If Manuell = 1 Then Return If Endschalterrechts = 0 Then Goto Rechts If Taster1 = 0 Then Gosub Halt If Durchlauf = Zyklus Then Gosub Ausloesen Loop Rechts: Do Durchlauf = Durchlauf + 1 Wicklung4 = 1 Waitms Wartezeit Wicklung4 = 0 Waitus 1 Wicklung3 = 1 Waitms Wartezeit Wicklung3 = 0 Waitus 1 Wicklung2 = 1 Waitms Wartezeit Wicklung2 = 0 Waitus 1 Wicklung1 = 1 Waitms Wartezeit Wicklung1 = 0 Waitus 1 If Manuell = 1 Then Return If Endschalterlinks = 0 Then Goto Links If Taster1 = 0 Then Gosub Halt If Durchlauf = Zyklus Then Gosub Ausloesen Loop Ausloesen: Fotos = Fotos + 1 Locate 2 , 8 Lcd Fotos Waitms 200 Ausloeser = 1 Waitms 100 Ausloeser = 0 Durchlauf = 0 Return Halt: Locate 1 , 1 Lcd "Slow-Cam 2 Stop!" Wait 1 Do If Taster1 = 0 Then Goto Warten4 Waitms 100 Loop Warten4: Cls Waitms 500 Goto Anfang Berechnen: Adcwert = Getadc(1) Rechnen1 = Adcwert Adcwert = Adcwert / 7 If Adcwert < 4 Then Adcwert = 4 Wartezeit = Adcwert Rechnen1 = Rechnen1 / 10.23 Rechnen1 = Rechnen1 - 2 If Rechnen1 < 0 Then Rechnen1 = 0 Rechnen2 = Rechnen1 - 100 Rechnen2 = Abs(rechnen2) Return End