Code:
$regfile = "m32def.dat"
$framesize = 32
$swstack = 32
$hwstack = 32
$crystal = 16000000
$baud = 9600
Config Timer1 = Timer , Prescale = 8 'Konfiguriere Timer0
Disable Timer1 'schalte Den Timer0 Overflow -interrupt Ein
On Timer1 Schritt
Enable Interrupts
Config Pind.5 = Output 'LEDs
Config Pind.6 = Output
Led1 Alias Portd.5
Led2 Alias Portd.6
Config Pina.0 = Output 'Motorx pins
Config Pina.1 = Output
Config Pina.2 = Output
Config Pina.3 = Output
X1 Alias Porta.0
X2 Alias Porta.1
X3 Alias Porta.2
X4 Alias Porta.3
Dim Empfangen As String * 8
Dim Modus As Byte
Modus=0
Dim Befehlsarray(20) As Integer
Dim Befehlsindex as Integer
Dim i as Integer
Dim Schrittarray(8) As Byte
Schrittarray(1).1 = 0 '##### Tabelle mit dem Steuermuster #####
Schrittarray(1).2 = 1
Schrittarray(1).3 = 0
Schrittarray(1).4 = 1
Schrittarray(2).1 = 0
Schrittarray(2).2 = 1
Schrittarray(2).3 = 0
Schrittarray(2).4 = 0
Schrittarray(3).1 = 0
Schrittarray(3).2 = 1
Schrittarray(3).3 = 1
Schrittarray(3).4 = 0
Schrittarray(4).1 = 0
Schrittarray(4).2 = 0
Schrittarray(4).3 = 1
Schrittarray(4).4 = 0
Schrittarray(5).1 = 1
Schrittarray(5).2 = 0
Schrittarray(5).3 = 1
Schrittarray(5).4 = 0
Schrittarray(6).1 = 1
Schrittarray(6).2 = 0
Schrittarray(6).3 = 0
Schrittarray(6).4 = 0
Schrittarray(7).1 = 1
Schrittarray(7).2 = 0
Schrittarray(7).3 = 0
Schrittarray(7).4 = 1
Schrittarray(8).1 = 0
Schrittarray(8).2 = 0
Schrittarray(8).3 = 0
Schrittarray(8).4 = 1
Print "gestartet"
Declare Sub run
Do
Input Empfangen
If Modus=1 Then 'array befüllen
If Empfangen<> "-32768" Then 'Befehl, das array fertig
print "anders als 68"
Incr Befehlsindex
Befehlsarray(Befehlsindex)=Val(Empfangen)
Else
Modus=2
i=0
while i< Befehlsindex
incr i
Print Befehlsarray(i)
Wend
End If
ElseIf Modus=2 Then
If Empfangen="-32767" Then 'Befehl, Programm starten
gosub run
End If
ElseIf Modus=0 Then
If Empfangen="-32766" Then 'Befehl, das array zu befüllen
Modus=1
Befehlsindex=0
print "66 erkannt"
End If
End If
Loop
sub run
print "run"
End sub
Schritt:
print "schritt"
Return
Lesezeichen