PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Schrittmotor Amsteuerung mit BASCOM



janboe
08.06.2010, 18:48
Hallo Leute!

Habe ein Problem mit meinem Programm!

zur nächst mal zum eigentlichen Projekt:

Es soll eine Spulenwickelmaschine mittel 2 Schrittmotoren gebaut werden. Es soll eine Eingabe mittels Taster erfolgen für z.B. Hand-Modus und die einzelnen Spulenprogramme. Die Hardware steht soweit jetzt hab ich nur noch das Problem das ich a) die Taster nicht vernünftig ausgewertet bekomme b) Nicht das gewünschte auf dem LCD Display angezeigt bekomme c) der 2. Motor total heiß wird und jetzt zuguter letzt der ATMEGA32 garnicht mehr erkannt wird.

hier mal das Programm:


'---------------- Deklaration des Mikrokontrollers ------------
$regfile = "M32def.dat"
$framesize = 32
$swstack = 32
$hwstack = 64
$crystal = 1600000

Cursor Off Noblink


Declare Sub Keypressed
Declare Sub Enable1
Declare Sub Enable2
Declare Sub Rechts
Declare Sub Links
Declare Sub Ok
Declare Sub Dreh1
Declare Sub Prog1

'--------------------------------------------------------------
'---------------- Deklaration der Aus und Eingänge ------------

Ddrb = &B00110011
Portb = &B11001100

Ddrc = &B00000000
Portc = &B11111111

Ddrd = &B00110011
Portd = &B11001100

'----------------- Deklaration der Motor Variablen ------------

Motor1_clock Alias Portb.0 'Deklaration des Ausganges PortB.0 als Motor1_clock
Motor1_cw Alias Portb.1 'Deklaration des Ausganges PortB.1 als Motor1_cw
Motor1_enable Alias Portb.5 'Deklaration des Ausganges PortB.6 als Motor1_enable

Motor2_clock Alias Portd.0 'Deklaration des Ausganges PortD.0 als Motor2_clock
Motor2_cw Alias Portd.1 'Deklaration des Ausganges PortD.1 als Motor2_cw
Motor2_enable Alias Portd.5 'Deklaration des Ausganges PortD.6 als Motor2_enable

'--------------------------------------------------------------

Dim A As Word
Dim I As Word
Dim X As Word
Dim Z As Word

'--------------------------------------------------------------
'-------------------- Hauptprogramm -------------------------
Cls
Locate 1 , 5
Lcd "NBSS TEC"
Locate 2 , 2
Lcd "Spulenmaschine"

Main:
Do
'Debounce Pinc.1 , 0 , Enable1 , Sub
Debounce Pinc.0 , 0 , Links , Sub
Debounce Pinc.2 , 0 , Rechts , Sub
'Debounce Pinc.3 , 0 , Ok , Sub
'Debounce Pinc.4 , 0 , Prog2 , Sub
Debounce Pinc.5 , 0 , Prog1 , Sub
'Debounce Pinc.7 , 0 , Prog3 , Sub
Loop

Sub Enable1:
Do

Loop
Goto Main
End Sub

Sub Links:
Cls
Locate 1 , 5
Lcd "NBSS TEC"
Locate 2 , 3
Lcd "Hand - Modus"

Portb.5 = 1

Do
If Pinc.0 = 0 Then
Portb.0 = 1
Waitus 800
Portb.0 = 0
End If

Loop
Goto Main
End Sub


Sub Rechts:
Cls
Locate 1 , 5
Lcd "NBSS TEC"
Locate 2 , 3
Lcd "Hand - Modus"


Do
If Pinc.2 = 0 Then
Portb.0 = 1
Waitus 800
Portb.0 = 0
End If

Loop
Goto Main
End Sub


Sub Prog1:
Do
If Pinc.5 = 0 Then
Gosub Enable1
End If

If I = 7400 Then
Gosub Dreh1
End If

If I = 7400 Then
Incr A
End If

If A = 4 Then
Gosub Enable2
End If

If Z = 74000 Then
Gosub Enable2
End If

Incr I

Incr Z

Portb.0 = 1
Waitus 800
Portb.0 = 0

Portd.0 = 1
Waitus 800
Portd.0 = 0

Loop
End Sub

Sub Dreh1:
Do
Toggle Portb.1
I = 0
'waitms 80
Goto Prog1
Loop
End Sub



Sub Enable2:
Do
Toggle Motor1_enable
Toggle Motor2_enable
Loop
End Sub



End

Vielleicht hat jemand ja auch ne idee das ganze ganz anders zu realisieren.

Ich hoffe es kann mir jemand helfen!!

VIELEN VIELEN DANK IM VORRAUS!!

Gruß Jan

Maxtronik
08.06.2010, 19:01
Hi,

Muss der $hwstack nich auch 32 sein?!(ich galaube ja)
Und wo hast du das LCD dekliniert?

MfG Maxtronik

janboe
08.06.2010, 19:06
Hey Maxtronik!

danke für die schnelle Antwort.

$hwstack habe ich jetzt mal geändert! weiß aber jetzt auch nich ob das zu den problemen geührt hat! bis jetzt hat sich aber nichts geändert!

Das LCD display habe ich in BASCOM selbst deklariert! Muß das dann nochmal im eigentlichen Programm definiert werden?

MFG Jan