Monday, March 06, 2006

w_6_servo motor_code from Todd

''****************************************************************
'* Name : UNTITLED.BAS *
'* Author : Todd Holoubek *
'* Notice : Copyright (c) 2004 Todd Holoubel *
'* : All Rights Reserved *
'* Date : 6/7/2004 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
DEFINE OSC 4
start:
pulseWidth var byte
'thes values can be vary with different motors
minPulse CON 75
maxPulse CON 250
refreshPeriod CON 5
'pulsewidth = maxPulse
myDir var byte
myDir = 1
main:
low PORTD.2
PulsOut PORTD.2, pulseWidth
pause refreshPeriod
if myDir = 1 then
pulsewidth = pulseWidth + 1
else
pulsewidth = pulseWidth - 1
endif
IF pulseWidth <= minPulse THEN
myDir = 1
ENDIF
IF pulseWidth >= maxPulse THEN
myDir = 0
ENDIF
GOTO main

0 Comments:

Post a Comment

<< Home