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 17:21 in General Discussion
You might first start with fixing your code ... you have lots of GOSUBs
and not a single RETURN. Another thing you don't need is a 100 ms delay
to discharge a cap for RCTIME. Depending on the cap you're using 1
millisecond will probably do. This is part of the jerkiness issue as
servos want to be updated every 20 milliseconds or so -- you're killing
100 milliseconds everytime you read a sensor.

-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office


Original Message
From: crazyidagain [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=JlH88GonO48yDUe5bPiC-U_Outk0e5_OLqdwXphKCkbxRuLrn1S2-IXNlER2nATWF18gY1MHlrOWcGDwEYJ9]crazyidagain@y...[/url
Sent: Friday, April 02, 2004 9:22 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] //////Can you'Help me with //////Servo Motor ??


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:












To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.

Yahoo! Groups Links







This message has been scanned by WebShield. Please report SPAM to
abuse@p....
Sign In or Register to comment.