adsense

2012-03-21

自走車 步進馬達


'ServoMotorPULSEOUT.inb : DC Servo Control Using PULSEOUT Command
Const ServoTable(3) As Word ={100,300,500,300} 'PULSEOUT Duration Parameter
Sub main()
Dim I As Byte = 0 'Local Variable
Dim k As Byte
Dim J As Byte 'Local Variable
Low (8) 'Set P8 State to Low
Do
For J=1 To 100 '100 PWM Cycle
Pulseout (8,ServoTable(I)) 'Pulse High
k=(ServoTable(I)*5)\1000:Pause(20-k) 'Pulse Low
'Pause(20-(ServoTable(I)*5)\1000) 'old寫法
Next J
If (I=3) Then I=0 Else I+=1 'Update Index
Loop
End Sub

沒有留言:

張貼留言