100% found this document useful (2 votes)
520 views4 pages

Stepper Motor Control With Atmega16

This document describes an AVR microcontroller project to control a unipolar stepper motor. A 4x4 keypad is used to enter the speed and select the direction of the motor. The Bascom code controls the direction and speed of the stepper motor based on inputs from the keypad. It displays the speed and direction on an LCD. The circuit diagram and Bascom code are provided to allow prototyping and simulation of the project.

Uploaded by

sifnsjdnfj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
520 views4 pages

Stepper Motor Control With Atmega16

This document describes an AVR microcontroller project to control a unipolar stepper motor. A 4x4 keypad is used to enter the speed and select the direction of the motor. The Bascom code controls the direction and speed of the stepper motor based on inputs from the keypad. It displays the speed and direction on an LCD. The circuit diagram and Bascom code are provided to allow prototyping and simulation of the project.

Uploaded by

sifnsjdnfj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

AVR microcontroller projects

Home
AVR projects
AVR Interfacing
AVR Tutorials
AVR Tools
Guest Book
Contact Me

Stepper motor Control with Atmega16


With this project you can control a unipolar stepper motor. You can control
both the speed and the direction of the motor.
The speed and direction and can changed with help of the keypad. The data's are
displayed over the LCD display.
A 4x4 keypad is used for entering the speed and selecting the direction.
Load the hex file into the chip, dont forget to select the internal oscillator at 10Mhz.
Then switch on the circuit and select the direction by pressing the corresponding key
(Left or Right). Then enter the speed through the numeric keys and press the Enter key
to start the operation. To switch off the motor press the separate switch which is
connected to the port A.0
Proteus simulation file is also added with the download file, so that you can run the
program on your desktop.

Circuit Diagram

Bascom Code
$regfile="m16def.dat"
$crystal=1000000
ConfigKbd=Portb
ConfigLcd=16*2
ConfigLcdpin=Pin,Db4=Portc.4,Db5=Portc.5,Db6=Portc.6,Db7=Portc.7,Rs=
Portc.0,E=Portc.1
ConfigPortd=Output
ConfigPorta=Input
DimAAsByte,BAsByte,KeyAsByte,CAsByte,DAsByte,EAsByte
Cls
CursorOff
B=0
D=1
Q:
Locate1,1
Lcd"Direction:"
Locate2,1
Lcd"Speed:"
Do
'************ReadKeyboard
A=Getkbd()
IfA>15Then
GotoQ
Else
Key=Lookup(a,Dta)
IfKey<=9Then
B=B*10
B=B+Key
'*************Direction
IfD=0ThenLcdB
Waitms270
ElseifKey=10Then
Locate1,11
Lcd"Left"
C=1
D=0
B=0
ElseifKey=11Then
Locate1,11
Lcd"Right"
C=2
D=0
B=0
'****************reset
ElseifKey=13Then
Cls
D=1
B=0
Portd.0=0
Portd.1=0
Waitms50
GotoQ
'****************Enterkey
ElseifKey=14Then
IfD=0Then
SelectCaseC
Case1:GosubR
Case2:GosubT

EndSelect
EndIf
EndIf
EndIf
Wait1
Loop
End
Dta:
Data7,8,9,10,4,5,6,11,1,2,3,12,13,0,14,15
R:
Do
Portd=&B00000001:WaitmsB
Portd=&B00000011:WaitmsB
Portd=&B00000010:WaitmsB
Portd=&B00000110:WaitmsB
Portd=&B00000100:WaitmsB
Portd=&B00001100:WaitmsB
Portd=&B00001000:WaitmsB
Portd=&B00001001:WaitmsB
IfPina.0=1Then
Locate2,1
Lcd"Speed:"
B=0
LcdB;""
Return
EndIf
Loop
T:
Do
Portd=&B00001001:WaitmsB
Portd=&B00001000:WaitmsB
Portd=&B00001100:WaitmsB
Portd=&B00000100:WaitmsB
Portd=&B00000110:WaitmsB
Portd=&B00000010:WaitmsB
Portd=&B00000011:WaitmsB
Portd=&B00000001:WaitmsB
IfPina.0=1Then
Locate2,1
Lcd"Speed:"
B=0
LcdB;""
Return
EndIf
Loop

Download
Bascom code & Proteus simulation file

Similar Posts

1. Simple calculator using avr microcontroller


2. Measure negative temperature with Lm35
3. Connect 2 microcontrollers through serial port

You might also like