Shop OBEX P1 Docs P2 Docs Learn Events
//////Can you''Help me with //////Servo Motor ?? — Parallax Forums

//////Can you''Help me with //////Servo Motor ??

ArchiverArchiver Posts: 46,084
edited 2004-04-02 16:22 in General Discussion
Hello.
Just a little help,
WHAT DO I DO?????

Everything works the way it should except, the rate of motion, the
VELOSITY,
it is to fast

I think the problem IS in ''Suburoutine' Servo_A:
How do I make it do subroutine smoothely slowly, not so jerky??


thanks dave...

:::[noparse]:D[/noparse]ESCRIPTION:::::

' this program moves a servo motors
' when light is pointed directly at respective photoresistor
' Photo_A and Photo_B.


'{$STAMP BS2}
'{$PBASIC 2.5}

'
'I/O Definitions
'

PhotoA CON 0
PhotoB CON 1
ServoA CON 14
ServoB CON 15

'
'EEPROM MEMEORY
'
RightLeft DATA 800
UpDown DATA 800
StepOne DATA 800


'
'Variables
'

X VAR Word
lightA VAR Word
lightB VAR Word

P VAR Word
counter VAR Word



'
'Program Code
'

Main:


GOSUB Photo_A:
DEBUG "Back in main.", CR
PAUSE 2000
GOSUB Photo_B:

END


'
'Suburoutines
'

Photo_A:
DEBUG "Reading Light from Photo_A Now"
HIGH 0
PAUSE 100
RCTIME 0, 1, lightA
DEBUG HOME, "lightA = ", DEC5 lightA
IF (lightA > = 03000) THEN Servo_A:

PAUSE 2000

GOSUB Photo_B:

Photo_B:
DEBUG "Reading Light from Photo_B Now"
HIGH 1
PAUSE 100
RCTIME 1, 1, lightB
DEBUG HOME, "lightB = ", DEC5 lightB
IF (lightB > 05000) THEN Servo_B:

PAUSE 3000

GOSUB Photo_A:

'''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''
Servo_A:
PAUSE 3000
READ RightLeft, x


FOR counter = x TO (x - 1) STEP 1
PULSOUT 14, (x - 1)
PAUSE 20
WRITE RightLeft, (x - 1)
PAUSE 20
DEBUG DEC5 counter, CRSRUP
NEXT
PAUSE 2000
GOSUB Photo_A:
''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''

Servo_B:
READ UpDown, P

PULSOUT 15, (P + 1)
WRITE UpDown, (P + 1)

PAUSE 1000


GOSUB Photo_A:
Sign In or Register to comment.