Anda di halaman 1dari 17

06/10/2016

StepperMotorController

STEPPER
MOTOR
CONTROLLER
Home
Kits are availableforthisprojectfrom
TalkingElectronicsfor$25.00pluspostage.
SeemoreprojectsusingPICmicros:
Elektor,EPE,SiliconChip
"PickAPIC."

Thisprojectcontrolsasteppermotorinfullandhalfstepincrements.

http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

1/17

06/10/2016

StepperMotorController

StepperMotorControllerbuiltonExperimenterPCboard

THESTEPPERMOTOR
Thereareanumberofsteppermotorsonthemarketandittakesalittlebitofunderstanding
toknowhowtheywork.Themaindifferenceisthenumberofcoilsandthewaytheyare
connectedbuttherearealsopointstoknowtogetthemaximumtorque.

ASTEPPERMOTOR
Asteppermotorconsistsofanumberofstationarycoilsandtheseareturnedonandpulla
rotarymagnettowardsthecoil.Thisactionturnsashaft.
Butyoumustturnthecoilsonandoffattherightmomenttocreaterotarymovement.
Thisrequiresanexternalcircuitconsistingofpulsesandthesepulsesmustcontainvoltage
andcurrenttodeliverenergytothesteppermotor.
Tounderstandhowasteppermotorworks,youjustneedtoknowthefactthatacoilwill
attractamagnetwhenacurrentflowsanditwillrepelthemagnetwhenthecurrentflowsin
theoppositedirection.
Inthefollowinganimationyoucanseeanarmature(rotor)beingpulledaroundbyturningon
oneormorecoils.

Notethat8stepscanbecreatedwith4coilsbyturningthemonindividuallyorinpairs:

http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

2/17

06/10/2016

StepperMotorController

Hereisanotherdiagramtoshowhowtherotorismovedbyhalfstepintervals:

UNIPOLARANIMATION
Thefollowinganimationshowsa6wiresteppermotor.Itcanbeconvertedtoa5wire
steppermotorbyconnectingthetwocentretapstogethertothepositivesupply.Thetwo
endsofeachwindingarealternatelygroundedtoreversethedirectionofthefieldprovided
bythatwinding.
Thecrosssectionshownisa30degreeperstepmotor.Motorwindingnumber1is
distributedbetweenthetopandbottomstatorpole,whilemotorwindingnumber2is
distributedbetweentheleftandrightmotorpoles.Therotorisapermanentmagnetwith6
poles,3southand3north,arrangedarounditscircumference.
Asshowninthefigure,thecurrentflowingfromthecentertapofwinding1toterminal"a"
causesthetopstatorpoletobeanorthpolewhilethebottomstatorpoleisasouthpole.
Thisattractstherotorintothepositionshown.Ifthepowertowinding1isremovedand
winding2isenergised,therotorwillturn30degrees,oronestep.
Byturningontwowindingsduringpartofthecycle,ahalfstepcanbeintroduced.Thisis
shownintheanimation.
Ittakesthreecompletecyclesofthecontrolsystemtoturnthis6polerotoronerevolution.

HALFSTEPPING
Withhalfstepping,thedrivealternatesbetweentwophasesONandasinglephaseON.
Thisincreasestheangularresolution,butthemotoralsohaslesstorque(approx70%)at
thehalfstepposition(whereonlyasinglephaseison).Thiscanbeincreasedbyincreasing
thecurrentintheactivewinding.Halfsteppingincreasestheaccuracyoftheoutput.Thisis
whatwehavedoneinthisproject.
Tokeepthetheorysimple,wearenotgoingintothewaveformsneededtoproducerotation,
howeverweneedtoexplainhowthecoilsareconnectedassomemotorshave5,6or8
leads(wires).
http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

3/17

06/10/2016

StepperMotorController

4wiresteppermotors:

Thistypeofmotorhasonlyonewindingperstatorpole.ThisiscalledaUnifilarwinding(uni
meaningone).Aswementionedabove,thewindingmustseereversevoltagetoproduce
rotationandthistypeofmotorisnotcoveredinthisproject.
6wiresteppermotors:

6wiresteppermotorshavetwoidenticalsetsofwindingsoneachstatorpole.Thisiscalled
bifilarwindingandthistypeofwindingconfigurationsimplifiesoperationinthatdelivering
currentfromonecoilthenanother,woundintheoppositedirection,willreversetherotation
ofthemotorshaft.Whereas,inaunifilarapplication,tochangedirectionrequiresreversing
thecurrentinthesamewinding,asmentionedabove.
5wiresteppermotors:

5wiresteppermotorssimplyhavethecentretapofeachwindingconnectedinsidethe
motororonaterminalblock.
8wiresteppermotors:

8wiresteppermotorssimplyhavethewiresfromthetwocoilsbroughtoutseparately.This
arrangementofferstheflexibilityofeitheraseriesorparallelconnection.Butthiswillbringit
toa4wiredeviceandrequirevoltagereversaltoproducerotation.
Youcanalsosearchthewebfordetailsonconnectingthewindingsforhightorquebutthis
isbeyondthescopeofthisarticle.
Thetypeofsteppermotorwewillbecoveringare5,6or8leadUnipolarsteppermotors.
http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

4/17

06/10/2016

StepperMotorController

UNIPOLARANDBIPOLARSTEPPERMOTORS
AUnipolarStepperMotorhastwowindingsperphase,oneforeachdirectionof
magneticfield.Youcanremembertheword"Uni"meansonlyonedirectionofcurrentis
neededforthistypeofmotor.Thisisthetypeweuseinthisproject.
ABipolarStepperMotorhasasinglewindingperphase.Thecurrentinawinding
needstobereversed(thustheprefix"Bi")inordertoreverseamagneticpole,sothe
drivingcircuitmustbemorecomplicated,typicallywithanHbridgearrangement.
Thefollowingdiagramsshowhowtoconnectthesesteppermotors:

BIFILARSTEPPERMOTORS
Bifilarwindingsonasteppermotorareappliedtothesamerotorandstatorgeometryasa
bipolarmotor,butinsteadofwindingeachcoilinthestatorwithasinglewire,twowiresare
woundinparallelwitheachother.Asaresult,themotorhas8wires,notfour.
Inpractice,motorswithbifilarwindingsarealwayspoweredaseitherunipolarorbipolar
motors.

Notethealignmentofthepolesontherotor
Touseabifilarmotorasaunipolarmotor,thetwowiresofeachwindingareconnectedin
seriesandthepointofconnectionisusedasacentertap.
Touseabifilarmotorasabipolarmotor,thetwowiresofeachwindingareconnectedeither
inparallelorinseries.Withparallelconnection,thisallowslowvoltagehighcurrent
operation.Withseriesconnection,ifthecentertapisignored,thisallowsoperationata
highervoltageandlowercurrentthanwouldbeusedwiththewindingsinparallel.
Essentiallyall6wiremotorssoldforbipolaruseareactuallywoundusingbifilarwindings.
Anyunipolarmotormaybeusedasabipolarmotorattwicetheratedvoltageandhalfthe
ratedcurrentonthenameplate.

IDENTIFYINGSTEPPERMOTORWIRES
Moststeppermotorshave6wires,howevertherearesomewith4,5,or8wires.Eachof
thefourcoilsismadeupofonelengthofwirewithtwoends.Oneendiscalledliveandthe
otherendiscalledcommon.Inafivewiresteppermotorallfourcommonsarejoined
together,inasixwiresteppermotortwopairsofcommonwiresarejoinedtogether,andin
aneightwiresteppermotornoneofthefourcommonwiresarejoinedtogether.The
followingdiagramsshowhowthecoilsareconnected:
http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

5/17

06/10/2016

StepperMotorController

Ifyoudonothaveaschematicdiagramforyoursteppermotorforexampleifitwas
salvagedfromanoldprinteritisveryeasytoworkoutthewiring.
Useamultimetertomeasuretheresistanceofeachcoil.Allfourcoilswillhaveidentical
resistance.Iftheydidnot,themotorwouldnotfunctionproperly.Theresistancemaybe
100ohms.Ifapairofwiresmeasures200ohms,youaremeasuringbetweentwoliveends.
Inotherwords,youaremeasuringtheresistanceofTWOCOILS.
Ifyouhavea5wiresteppermotor,itwillbeveryeasytofindthecommonwireasevery
otherwireswillhavearesistanceof100ohms.
Forthe6wiresteppermotor,youwillhave3wireswithresistancevaluesandanother3
wireswithresistancevalues.Thetwowireswith200ohmsresistancebetweenthem,are
"live,"sotheotherwireis"common."
Onceyouhaveidentifiedthe"common"wire(s),youneedtofindthecorrect"phases."This
isanotherwayofsayingthecorrectwaytoconnectthemotorsothatitrotatesclockwiseof
anticlockwise.
Youcannotsimplyconnectthe"live"wirestotheprojectinanyorder.
Theymustbeconnectedsothatthepulseswillcreatearotatingmagneticfield.
Thereisnowaytodeterminethecorrectwaytoconnectasteppermotorotherthanviewing
theoutputona4inputCRO.
So,wehavetodoitbytrialanderror.
Connectthesteppermotorinanyarrangementtotheprojectbutmakesurethecommon
goestothepositiverail,aswehavealreadyidentifiedthiswire.
Turnontheprojectandseeifthesteppermotorrotates.
Ifnot,donottouchthefirstwire.Simplyswapthelasttwowires.Ifthisdoesnotwork,
swapthe2ndandfourthwires.Thenthesecondandthirdwires.
Themotorwillnotbedamagedduringthisprocessasitdoesnottakeanymorecurrent
whenoscillatingbackandforthorwhenrotating.
keepswappingthelastthreewiresuntilthemotorrotates.

PWM
TomakeasteppermotorrotateatthefastestRPM,wedeliverapulseofveryshort
duration,toeachofthepolesandtheorderofdeliveringthesepulsesmustbecorrect.
IfwetrytoincreasetheRPM,weneedtomakethepulseshorterindurationandapointwill
comewhenthesteppermotorHALTSorSTOPSorFREEZES.
WenowknowthemaximumRPM.
TodecreasetheRPM,weincreasethelengthofeachpulseandthisproduceslesspulses
persecond.TheRPMdecreases.
Inallofthisaction,thesteppermotoristakingalmostthesamecurrentasthevoltageis
beingsuppliedalmostconstantly,theonlydifferenceisthepulsesarelongerorshorter.
Butsupposeyouwanttosupplylesscurrentorsupplythesteppermotorwithahigher
voltage.
Thiscanbedonebydeliveringashortpulsethenturningoffthesupplyforashortperiodof
timebetweenpulses.
ThiswillnotaltertheRPMunderthefollowingconditions:Supposetheminimumpulsewidth
is5mS.Supposethepulsewidthispresently25mS.Ifthepulsewidthisreducedto5mS
andanoffperiodof20mS,thesteppermotorwillretainthesameRPMbutconsumeless
current.
Thetorquewillalsobereducedandthiswillhavebecheckedtoseeifthemotorstalls
underload.
http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

6/17

06/10/2016

StepperMotorController

Thisactioniscalled"reducingthepulsewidth"andiscommonlycalledPULSEWIDTH
MODULATION.
Thisiscalled"drivingthemotorwithPWM."
YoucanalsousePWMtodrivea12vsteppermotorfrom24vor36v.
Byusingtheexampleabove,thesteppermotorisonlygettingapulseofenergyfor20%of
thetime,sothatdeliveringavoltagesuchas24vor36v,willresultinanaveragecurrent
thatislessthandrivingitwithoutPWMon12v.
ThesearethemainreasonsforusingPWM.ItisnotusedtocontroltheRPM.

STEPPERMOTORVOLTAGE
Youcanfindsteppermotorsinalltypesofconsumerelectronics,includingprinters,video
players,plottersandtheheadpositioningmotorsfromolddiskettedrives.
Mostofthesesteppermotorsare12v.
Howeverfewofthemareidentifiedwiththeoperatingvoltageandthesimplestwaytotest
themistoconnectto12vandreadthecurrent.
Currentconsumptionfrom50mAto300mAisquitecommonandsincetheyaregenerally
usedforveryshortperiodsoftime,theywillnotgethotorevenwarm.
Ifyouwanttousethemonahighervoltage,suchas24vor36v,youwillneedtodrivethem
withveryshortpulsesandprovideanoffperiodinthewaveformsothattheoverallcurrent
isnotaboveabout300mA.
ThisinvolvesapulsewidthtechniquecalledPWM,mentionedabove.
Thiscanbeincorporatedintotheprojectbymodifyingtheprogram.

INSTRUCTIONSFORUSE
TurntheprojectONandpushtheleftbuttonveryquickly.Thestepper
motorwillincrementahalfstep.Keepthebuttonpressedandthestepper
motorwillrotateclockwise.
Pushtherightbuttonveryquickly.Thesteppermotorwillincrementahalf
step.Keepthebuttonpressedandthesteppermotorwillrotateanti
clockwise.
Pushthetopbutton.Theprojectnowgoestofullstepmode.
Pushtheleftbuttonandthesteppermotorrotatesclockwiseinfullstep
mode.TurnthepottoincreaseordecreaseRPM.
Turntheprojectoff.
Pushthetopbutton.Theprojectnowgoestofullstepmode.
Pushtherightbuttonandthesteppermotorrotatesanticlockwiseinfull
stepmode.TurnthepottoincreaseordecreaseRPM.
CONSTRUCTION
YoucanbuildthecircuitonanytypeofProtoboard.Wehavechosenoursurfacemount
boardasitmakesaneatprojectandyoucanseeallthewiringatthesametime.
ThePROGRAM
Ifyouwanttomodifytheprogramyouwillneedaprogrammer,aboardtoholdthe8pinchip
duringprogrammingandanadaptertoconnectbetweentheprogrammerandPCboard.
Thesearecoveredinourarticle"PickAPIC."
Herearethefilesyouwillneedfor"burning"yourchipand/ormodifyingtheprogram:
Step.asm
Step.txt
Step.hex
Thefollowingprogramisforviewing.Itmaycontainspacesorhiddencharactersthatwill
notcompilecorrectlytoproducea.hexfile.Usethe.hexfileabovetoburnyourchiporthe
.asmfiletomodifytheprogram.

;*******************************
;Stepper.asm
drivesaSteppermotorforwardandreverse
;13112010
;*******************************

list

p=12F629

http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

7/17

06/10/2016

StepperMotorController

radix dec
include"p12f629.inc"
errorlevel302;Don'tcomplainaboutBANK1registers

__CONFIG
_MCLRE_OFF&_CP_OFF
&_WDT_OFF&_INTRC_OSC_NOCLKOUT;Internalosc.
;_MCLRE_OFFmasterclearmustbeoffforgp3asinputpin
;******************************
;variablesnamesandfiles
;*****************************
temp1
temp2

equ20h;
equ21h;

Sw_Flagequ25h;switchflagfor"inching"
loops equ26h;loopsforfullstepping
count equ27h;loopsofdischargetimefor100n
PotValueequ28h;valueofpot
look
equ29h;lookforpotvalueevery100loops
;***************************
;Equates
;***************************
status equ
0x03
rp1
equ
0x06
rp0
equ
0x05
GPIO equ0x05

status
option_reg

equ
03h
equ81h

pin7
pin6
pin5
pin4
pin3
pin2

equ
equ
equ
equ
equ
equ

;bitsonGPIO

0
;GP0100kspeedpot
1
;GP1output1tosteppermotor
2
;GP2output2tosteppermotor
3
;GP3Inputfrombuttons
4
;GP4output3tosteppermotor
5
;GP5output4tosteppermotor

rp0

equ

;bits

;bit5ofthestatusregister

;**********************
;Beginningofprogram
;**********************

org
0x00

nop

nop

nop

nop

nop

SetUp bsf
status,rp0
movlw b'11001000'

movwf TRISIO

bcf
status,rp0

movlw07h
movwfCMCON
clrf GPIO
clrf
Sw_Flag
incf
Sw_Flag,1

goto Main

;Bank1

;SetTRISGP1,2,4,5outGP3input

;bank0
;turnoffComparatorports
;mustbeplacedinbank0
;ClearGPIOofjunk

;putabitontoSw_Flag

http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

8/17

06/10/2016

StepperMotorController

;****************
;delays
*
;****************
_uS

acw

_1mS

_5mS

movlw 08Ch
movwf temp1
decfsztemp1,f
goto $1
retlw 00

;delayforpulsingservoanticlockwise

_10mS

_15mS

_18mS

_50mS

movlw 0Ah
movwf temp2
nop
decfsztemp1,f
goto $2
decfsztemp2,f
goto $4
retlw 00

movlw .15
movwf temp2
nop
decfsztemp1,f
goto $2
decfsztemp2,f
goto $4
retlw 00

movlw .18
movwf temp2
nop
decfsztemp1,f
goto $2
decfsztemp2,f
goto $4
retlw 00

movlw .50
movwf temp2
nop

movlw 60h
movwf temp1
decfsztemp1,f
goto $1
retlw 00

nop
decfsztemp1,f
goto _1mS
retlw 00

movlw .5
movwf temp2
nop
decfsztemp1,f
goto $2
decfsztemp2,f
goto $4
retlw 00

http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

9/17

06/10/2016

StepperMotorController

decfsztemp1,f

goto $2

decfsztemp2,f

goto $4

retlw 00

_100mS movlw .100

movwf temp2

nop

decfsztemp1,f

goto $2

decfsztemp2,f

goto $4

retlw 00

_200mS movlw .200

movwf temp2

nop

decfsztemp1,f

goto $2

decfsztemp2,f

goto $4

retlw 00

;delaytocreatevalueforpotforspeed

PotDel movlw 040h

;40hproduces12loops

movwf temp1

decfsztemp1,f

goto $1

retlw 00

;***************************
;SubRoutines
*
;***************************

;positionofpotcreatesavalueinPotValue

Pot
bsf
status,rp0

bcf
trisio,0
;MakeGP0output

bcf
status,rp0

bcf
gpio,0
;makeGP0LOW

call
_1mS
;createdelaytodischarge100n

bsf
status,rp0

bsf
trisio,0
;MakeGP0input

bcf
status,rp0

clrf
PotValue

call
PotDel

incf
PotValue,f

btfss gpio,0
;isinputHIGH?

goto
$3

retlw 00
;returnswithavalueinPotValue

;******************
;*Main
*
;******************
Main

clrf
bcf

gpio
gpio,5 ;gpio,5highforashorttime

http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

10/17

06/10/2016

_1HSF_

_2HSF_

_3HSF_

_4HSF_

_5HSF_

_6HSF_

_7HSF_

_8HSF_

_C

StepperMotorController

call
bsf
nop
btfss
goto
goto
clrf
bsf
btfss
goto
goto

_1mS
gpio,5

btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
goto

movlw
goto
movlw
goto
movlw
goto
movlw
goto
movlw
goto
movlw
goto
movlw
goto
movlw
movwf
call
clrf
call
call
clrf
incf
bsf
nop
btfsc
goto
bcf
goto

movwf
call
clrf
call
call
bcf
rlf
bsf
nop
btfsc
goto
bcf
goto

Sw_Flag,0
_1HSF_
Sw_Flag,1
_2HSF_
Sw_Flag,2
_3HSF_
Sw_Flag,3
_4HSF_
Sw_Flag,4
_5HSF_
Sw_Flag,5
_6HSF_
Sw_Flag,6
_7HSF_
_8HSF_

gpio,3
$+2
$+6
;gotohalfstepForward
gpio

gpio,1
gpio,3
Reverse;gotohalfstepReverse
_FS;gotoFullStepforforwardorreverse

b'00100000'
_C

b'00110000'
_C

b'00010000'
_C

b'00010100'
_C

b'00000100'
_C

b'00000110'
_C

b'00000010'
_C

b'00100010'
gpio
_200mS
gpio
_200mS
_200mS
Sw_Flag
Sw_Flag,1
gpio,5

;1

;3

;4

;5

;6

;7

;8

;2

gpio,3 ;seeifswisstillpressedforfullspeed
HS_Fwd
gpio,5
Main

gpio
_200mS
gpio
_200mS
_200mS
status,0
Sw_Flag,1
gpio,5

;clearthecarry

gpio,3 ;seeifswisstillpressedforfullspeed
HS_Fwd
gpio,5
Main

http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

11/17

06/10/2016

Reverse

_1HSR_

_2HSR_

_3HSR_

_4HSR_

_5HSR_

_6HSR_

_7HSR_

_8HSR_

_D

StepperMotorController

;reversehalfstep

clrf
bcf
call
bsf
nop
btfss
goto

btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
goto

gpio

_1mS

movlw
movwf
call
clrf
call
call
Movlw
movwf
bsf
nop
btfsc
goto
bcf
goto

movlw
goto
movlw
goto
movlw
goto
movlw
goto
movlw
goto
movlw
goto
movlw
goto

movwf
call
clrf
call
call
bcf
rrf
bsf

b'00100000'
gpio

_200mS
gpio
_200mS
_200mS
80h
Sw_Flag
gpio,4

gpio,4 ;gpio,4highforashorttime
gpio,4

gpio,3
Main
Sw_Flag,0
_1HSR_
Sw_Flag,1
_2HSR_
Sw_Flag,2
_3HSR_
Sw_Flag,3
_4HSR_
Sw_Flag,4
_5HSR_
Sw_Flag,5
_6HSR_
Sw_Flag,6
_7HSR_
_8HSR_

;1

gpio,3 ;seeifswisstillpressedforfullspeed
HS_Rev

gpio,4
Main
b'00110000'
_D

b'00010000'
_D

b'00010100'
_D

b'00000100'
_D

b'00000110'
_D

b'00000010'
_D

b'00100010'
_D

;2

;3

;4

;5

;6

;7

;8

gpio
_200mS
gpio
_200mS
_200mS
status,0
Sw_Flag,1
gpio,4

;clearthecarry

http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

12/17

06/10/2016

StepperMotorController

nop
btfsc
goto
bcf
goto

;halfstepforward

HS_Fwd

_1HSF

_2HSF

_3HSF

_4HSF

_5HSF

_6HSF

_7HSF

_8HSF

_CC

HS_Rev

clrf
bcf
call
bsf
nop
btfss
goto

btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
goto

movlw
goto
movlw
goto
movlw
goto
movlw
goto
movlw
goto
movlw
goto
movlw
goto
movlw
movwf
call
clrf
clrf
incf
goto

movwf
call
clrf
bcf
rlf
goto

clrf

gpio,3 ;seeifswisstillpressedforfullspeed
HS_Rev
gpio,4

Main

gpio
gpio,5 ;gpio,5highforashorttime
_1mS

gpio,5

gpio,3
Main

Sw_Flag,0
_1HSF
Sw_Flag,1
_2HSF
Sw_Flag,2
_3HSF
Sw_Flag,3
_4HSF
Sw_Flag,4
_5HSF
Sw_Flag,5
_6HSF
Sw_Flag,6
_7HSF
_8HSF
b'00100000'
_CC

b'00110000'
_CC

b'00010000'
_CC

b'00010100'
_CC

b'00000100'
_CC

b'00000110'
_CC

b'00000010'
_CC

b'00100010'
gpio
_5mS
gpio

Sw_Flag
Sw_Flag,1
HS_Fwd
gpio
_5mS
gpio

status,0
Sw_Flag,1
HS_Fwd

;1

;3

;4

;5

;6

;7

;8

;2

;clearthecarry

;halfstepreverse
gpio

http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

13/17

06/10/2016

_1HSR

_2HSR

_3HSR

_4HSR

_5HSR

_6HSR

_7HSR

_8HSR

_G

_FS

StepperMotorController

bcf
call
bsf
nop
btfss
goto

btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
btfsc
goto
goto

movlw
movwf
call
clrf
Movlw
movwf
goto
movlw
goto
movlw
goto
movlw
goto
movlw
goto
movlw
goto
movlw
goto
movlw

movwf
call
clrf
bcf
rrf
goto

clrf
bsf
btfss
goto
goto
bsf
btfss
goto
goto
clrf
call
goto

gpio,4 ;gpio,4highforashorttime
_1mS
gpio,4

gpio,3
Main
Sw_Flag,0
_1HSR
Sw_Flag,1
_2HSR
Sw_Flag,2
_3HSR
Sw_Flag,3
_4HSR
Sw_Flag,4
_5HSR
Sw_Flag,5
_6HSR
Sw_Flag,6
_7HSR
_8HSR
b'00100000'
gpio
_10mS
gpio

80h
Sw_Flag
HS_Rev
b'00110000'
_G

b'00010000'
_G

b'00010100'
_G

b'00000100'
_G

b'00000110'
_G

b'00000010'
_G

b'00100010'
goto
_G

gpio
_10mS
gpio

status,0
Sw_Flag,1
HS_Rev

;1

;2

;3

;4

;5

;6

;7

;8

;clearthecarry

;decideonfullstepforwardorreverse
gpio
gpio,5
gpio,3
$+2
FS_Fwd

gpio,3
$+2
FS_Rev
gpio
_1mS
$10

gpio,4

http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

14/17

06/10/2016

FS_Fwd

FS_Rev

StepperMotorController

;FullStepForward

call
pot

;returnswithvalueinPotValue
movlw .50
movwf look
;lookatpotevery50loops
movlw b'00000010'

;fullstepforward
movwf gpio

movf
PotValue,w
movwf loops
call
_1mS
decfsz loops,1
goto
$2

movlw b'00000100'
movwf gpio
movf
PotValue,w
movwf loops
call
_1mS
decfsz loops,1
goto
$2

movlw b'00010000'
movwf gpio
movf
PotValue,w
movwf loops
call
_1mS
decfsz loops,1
goto
$2
movlw b'00100000'

movwf gpio
movf
PotValue,w
movwf loops
call
_1mS
decfsz loops,1
goto
$2
decfsz look,1
goto
FS_Fwd+3;don'tlookatpot
goto
FS_Fwd ;lookatpot

;FullStepReverse

call
pot
;returnswithvalueinPotValue
movlw .50
movwf look
;lookatpotevery50loops
movlw b'00100000'
;fullstepreverse
movwf gpio

movf
PotValue,w
movwf loops
call
_1mS
decfsz loops,1
goto
$2

movlw b'00010000'
movwf gpio
movf
PotValue,w
movwf loops
call
_1mS
decfsz loops,1
goto
$2

movlw b'00000100'
movwf gpio
movf
PotValue,w
movwf loops
call
_1mS
decfsz loops,1
goto
$2
movlw b'00000010'

movwf gpio
movf
PotValue,w
movwf loops
call
_1mS

http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

15/17

06/10/2016

StepperMotorController

decfsz
goto
decfsz
goto
goto

END

loops,1
$2
look,1
FS_Rev+3;don'tlookatpot
FS_Rev ;lookatpot

GOINGFURTHER
Youcanaddadditionalfeaturestothisprojectbywritingyourownprogramormodifyingthe
programabove.

Stepper Motor
Controller
PartsList

Cost:au$25.00 plus postage


Kits are available
1 - 39R SM resistor>
4 - 100R SM resistor
1 - 220R SM resistor
3 - 2k2 SM resistor
1 - 47k SM resistor
1 - 100k pot
2 - 100n SM capacitors
1 - 100u electrolytic
4 - SM yellow LEDs
1 - SM diode
4 - BD679 transistors
1 - 78L05 SM voltage regulator
1 - SPDT mini slide switch
3 - mini tactile buttons
1 - 8 pin IC socket
1 - 5 pin header
40cm fine enamelled wire
20cm fine tinned copper wire
20cm -very fine solder
1 - PIC12F629 chip (with Step routine)
1 - 4-cell battery holder
1 - battery snap

1PrototypePCboard
16/11/2010

http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

16/17

06/10/2016

StepperMotorController

http://www.talkingelectronics.com/projects/Stepper%20Motor%20Controller/StepperMotor.html

17/17

Anda mungkin juga menyukai