Bipolar Stepper motors - Atmega8 - Bascom

View previous topic View next topic Go down

Bipolar Stepper motors - Atmega8 - Bascom

Post  abed.oubari on Mon Sep 17, 2012 2:28 am

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

abed.oubari
Admin

Posts: 76
Join date: 2010-02-25
Age: 35
Location: Morocco

http://gft2009.forumactif.com

Back to top Go down

View previous topic View next topic Back to top


Permissions in this forum:
You cannot reply to topics in this forum