Forum: Mikrocontroller und Digitale Elektronik Unterprogramm mit 2 Variabeln und debounce Befehl aufrufen


von kemal y. (sauerland2010)


Lesenswert?

Hallo liebe Forumgemeinde,

habe ein Programm geschrieben, wo ich beim Schrittmotor mit 2 Tastern 3 
Geschwindigkeiten steuere.
Tempo 1 wird mit Taster 1, Tempo 2 mit Taster 2 & Tempo 3 mit Taster 1 & 
Taster 2, aktiviert.

Mein Problem: Ich kann das Unterprogramm Tempo 3 nicht aufrufen!!

Const Pause1 = 800
 Const Pause2 = 400
 Const Pause3 = 50

Declare Sub Tempo1
 Declare Sub Tempo2
 Declare Sub Tempo3

'---Initialisierungen--------------------
 Config Pinb.1 = Input
 Portb.1 = 1
 Config Pinb.2 = Input
 Portb.2 = 1

Config Portc = Output

S1 Alias Pinb.1
 S2 Alias Pinb.2

'---Hauptprogramm-------------------------
 Do

Debounce S1 , 0 , Tempo1 , Sub
 Debounce S2 , 0 , Tempo2 , Sub
 Debounce ?? , 0 , Tempo3 , Sub <---- hier brauche ich eine Lösung zum 
Aufrufen des Unterprogramms
 Loop

'---Ende Hauptprogramm--------------------
 '---Unterprogramm-------------------------

Sub Tempo1
 Do
 Portc.2 = 0
 Portc.3 = 1
 Portc.4 = 0
 Portc.5 = 1
 Waitms Pause1
 Portc.2 = 1
 Portc.3 = 0
 Portc.4 = 0
 Portc.5 = 1
 Waitms Pause1
 Portc.2 = 1
 Portc.3 = 0
 Portc.4 = 1
 Portc.5 = 0
 Waitms Pause1
 Portc.2 = 0
 Portc.3 = 1
 Portc.4 = 1
 Portc.5 = 0
 Waitms Pause1
 Loop Until Merker1 = 0
 End Sub

Sub Tempo2
 Do
 Portc.2 = 1
 Portc.3 = 0
 Portc.4 = 1
 Portc.5 = 0
 Waitms Pause2
 Portc.2 = 0
 Portc.3 = 1
 Portc.4 = 1
 Portc.5 = 0
 Waitms Pause2
 Portc.2 = 0
 Portc.3 = 1
 Portc.4 = 0
 Portc.5 = 1
 Waitms Pause2
 Portc.2 = 1
 Portc.3 = 0
 Portc.4 = 0
 Portc.5 = 1
 Waitms Pause2
 Loop Until Merker2 = 0
 End Sub

Sub Tempo3
 Do
 Portc.2 = 1
 Portc.3 = 0
 Portc.4 = 1
 Portc.5 = 0
 Waitms Pause3
 Portc.2 = 0
 Portc.3 = 1
 Portc.4 = 1
 Portc.5 = 0
 Waitms Pause3
 Portc.2 = 0
 Portc.3 = 1
 Portc.4 = 0
 Portc.5 = 1
 Waitms Pause3
 Portc.2 = 1
 Portc.3 = 0
 Portc.4 = 0
 Portc.5 = 1
 Waitms Pause3
 Loop Until Merker3 = 0
 End Sub

'---Ende Unterprogramm-----------------

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.