Bipolar Stepper motors - Atmega8 - Bascom
Page 1 of 1
Bipolar Stepper motors - Atmega8 - Bascom
This is a small program in Bascom, to drive a bipolar stepper motor using Atmega8 Controller and L298N:
[img][/img]
Bascom Program:
'------------------------------------------------------------------------------
'name : BIPOLAR STEPPER MOTOR - L298N
'copyright : (c) 2012 - CNESTEN - MOROCCO
'purpose : 2 directions driving bipolar steper motor
'micro : AtMega8
'
' By Abed OUBARI
'------------------------------------------------------------------------------
$regfile = "m8def.dat" ' we use the M48
$crystal = 16000000
$baud = 9600
'define pins of Port D and C
Config Portd = Output
Config Pind.2 = Input
Config Pind.3 = Input
Dim I As Byte
Begin:
For I = 0 To 20
Set Portd.4
Set Portd.5
Reset Portd.6
Reset Portd.7
Waitms 7
Reset Portd.4
Set Portd.5
Set Portd.6
Reset Portd.7
Waitms 7
Reset Portd.4
Reset Portd.5
Set Portd.6
Set Portd.7
Waitms 7
Set Portd.4
Reset Portd.5
Reset Portd.6
Set Portd.7
Waitms 7
Next I
For I = 0 To 20
Set Portd.4
Reset Portd.5
Reset Portd.6
Set Portd.7
Waitms 7
Reset Portd.4
Reset Portd.5
Set Portd.6
Set Portd.7
Waitms 7
Reset Portd.4
Set Portd.5
Set Portd.6
Reset Portd.7
Waitms 7
Set Portd.4
Set Portd.5
Reset Portd.6
Reset Portd.7
Waitms 7
Next I
Wait 3
Goto Begin
End
[img][/img]
Bascom Program:
'------------------------------------------------------------------------------
'name : BIPOLAR STEPPER MOTOR - L298N
'copyright : (c) 2012 - CNESTEN - MOROCCO
'purpose : 2 directions driving bipolar steper motor
'micro : AtMega8
'
' By Abed OUBARI
'------------------------------------------------------------------------------
$regfile = "m8def.dat" ' we use the M48
$crystal = 16000000
$baud = 9600
'define pins of Port D and C
Config Portd = Output
Config Pind.2 = Input
Config Pind.3 = Input
Dim I As Byte
Begin:
For I = 0 To 20
Set Portd.4
Set Portd.5
Reset Portd.6
Reset Portd.7
Waitms 7
Reset Portd.4
Set Portd.5
Set Portd.6
Reset Portd.7
Waitms 7
Reset Portd.4
Reset Portd.5
Set Portd.6
Set Portd.7
Waitms 7
Set Portd.4
Reset Portd.5
Reset Portd.6
Set Portd.7
Waitms 7
Next I
For I = 0 To 20
Set Portd.4
Reset Portd.5
Reset Portd.6
Set Portd.7
Waitms 7
Reset Portd.4
Reset Portd.5
Set Portd.6
Set Portd.7
Waitms 7
Reset Portd.4
Set Portd.5
Set Portd.6
Reset Portd.7
Waitms 7
Set Portd.4
Set Portd.5
Reset Portd.6
Reset Portd.7
Waitms 7
Next I
Wait 3
Goto Begin
End
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|