Step Motordriverimplement0118v01.docx
《Step Motordriverimplement0118v01.docx》由会员分享,可在线阅读,更多相关《Step Motordriverimplement0118v01.docx(6页珍藏版)》请在冰豆网上搜索。
![Step Motordriverimplement0118v01.docx](https://file1.bdocx.com/fileroot1/2023-5/17/e36bc1d3-7620-4367-8c53-86f2cdda4c6a/e36bc1d3-7620-4367-8c53-86f2cdda4c6a1.gif)
StepMotordriverimplement0118v01
StepMotorDriverImplementDocument
TianjinUniversity—InfineonAutomotiveElectronicJointLaboratory
StateKeyLaboratoryofEngines
TianJinUniversity,China
Revisionhistory
Version
By
Modifications
V0.1,18thJan2008
JiangTang
Creation
Contents
1Introduction4
1.1Overview4
1.2Reference4
2.Typedefinition5
3GlobalVariable6
4FunctionDefinitions7
4.1WritePin7
4.2StepMotorReset8
4.3StepMotor_AccSlowdown9
4.4StepMotorC10
5ResourcesConfiguration11
5.1PeriperalConfig11
5.2InterruptConfig11
6CompileEnvironment12
1Introduction
1.1Overview
ThisdocumentdescribestheimplementationsoftheStepMotordrivertobedevelopedintheframeoftheGEMS-K1project.
TheStepMotordriverconfiguresworkingstepofstepmotor.Thestepwayishalf-step.Thereisaresetfunctionthatpullsdownthestepmotortotheposition“0”.Theresetfunctioniswalkingback500steps.Whenagoalstepfinished,resetalltherelatedpins.Whenanewgoalstepstarted,firstwalktothelaststate,thenspeedup,whenthegoalstepisnear,slowdown.
1.2Reference
[1]StepMotordrivertestreport
2.Typedefinition
Type
Description
Range
OCStepMotor_ErrorType
Recommendedtype:
16bitunsignedvalue.Numbersfrom0to15arereservedfortheHISIOLibraryitself,numbersbetween16and63aredefinedintheHISIODriverdocument.Errorcodesfrom64to127arefordriverspecificerrorcodesnotdefinedintheHISIODriverdocumentandnumbersstartingfrom128arereservedforfutureuse.
OCStepMotor_R_OK
3GlobalVariable
Thischapterdescribestheglobalvariableusedbyscheduler.
Varialbes
Type
Description
N_Coef
int
Controlwalksteplength
counter
int
Controlwalksteplength
StepMotor
STEP_STATUS
Thestatusofstepmotor
StepMotor.step
Setthegoalstepposition
StepMotor.NowPosition
Thepositionofcurrentstep
4FunctionDefinitions
4.1WritePin
Syntax
OCStepMotor_ErrorTypeWritePin(void);
Parameters
none
Return
OCStepMotor_R_OK:
writepinwassuccessful.
Notification
Description
WritetostepmotorcontrolpinaccordingtoStepMotor.NowPosition
Reentrancy
No
Remarks
StepMotor.NowPosition
P1.8
P1.9
P1.10
P1.11
0
1
0
1
0
1
1
0
0
0
2
1
0
0
1
3
0
0
0
1
4
0
1
0
1
5
0
1
0
0
6
0
1
1
0
7
0
0
1
0
4.2
StepMotorReset
Syntax
OCStepMotor_ErrorTypeStepMotorReset(void)
Parameters
None
Return
OCStepMotor_R_OK:
currentresetwassuccessful.
Notification
Description
Resetstepmotortotheposition“0”
Reentrancy
No
Remarks
4.3
StepMotor_AccSlowdown
Syntax
OCStepMotor_ErrorTypeStepMotor_AccSlowdown(void)
Parameters
none
Return
OCStepMotor_R_OK:
Acceleratingorslowdownfunctionsteparesuccessful
Notification
Description
Thefunctionacceleratesthewalksteporslowsdownthewalkstep.
Forexample,whenStepMotor.step=300,changeStepMotor.stepto10,andcurrentpositionisbetween10and300,thesethingswillhappen:
Slowdown(forward)—Accelerates(backward)—SlowDown(backward)
—Resetallpins.
Reentrancy
No
Remarks
4.4
StepMotorC
Syntax
OCStepMotor_ErrorTypeStepMotorC(void)
Parameters
none
Return
OCStepmotor_R_OK:
Controlstepmotorsuccessfully.
Notification
Description
Thefunctionwasthewholecontrolfunctionofstepmotor,otherfunctionwasembeddedinthisfunction.
Reentrancy
No
Remarks
5ResourcesConfiguration
Theresourceusedbystepmotordriver
5.1PeriperalConfig
Source
Description
P2.6
Asstepmotorenablepin,highlevelenable
P2.7
Asstepmotorenablepin,highlevelenable
P1.8
StepA+
P1.9
StepA-
P1.10
StepB+
P1.11
StepB-
5.2InterruptConfig
Source
SRN
TOS
Priority
Name
Description
6CompileEnvironment
CompileTool:
TaskingforTricore