Shop OBEX P1 Docs P2 Docs Learn Events
Programs For Newbies learning about CR servos with the BOE — Parallax Forums

Programs For Newbies learning about CR servos with the BOE

MigsMigs Posts: 95
edited 2007-09-02 14:12 in Robotics
Friends:

Here are two useful programs for learning about the BS2 controlling a continuous rotation servo. Hook up the servo to Board of Education (BOE) at the #12 servo port, set your power input jack (between the port plugs) as necessary, and switch the on-off switch to position 2 so the servo is active.

Try this program first and notice the effect on the servo speed by listening to it as you watch the debug screen. (Then do the same with the next program and notice the range where the servo pulses start to have and effect on the servo.) See the attached picture if you have any doubts. I'm using a wall wart type power supply.

'Program:ServoRangeLimited.bs2
'Created by: Miguel Reznicek
'Creation Date: 8/29/2007
'Purpose: This program sends control pulses to the continuous
'range servo connected to P12 for for visual appreciation and
'prints the current pulse value on screen.
'Special Requirements:
'For Basic Stamp 2
' {$STAMP BS2}
'Written in PBasic version 2.5
' {$PBASIC 2.5}

pulse VAR Word
counter VAR Word

FOR pulse = 650 TO 850 STEP 10
DEBUG ? pulse
FOR counter = 1 TO 200
PULSOUT 12, pulse
PAUSE 20
NEXT
NEXT
END


This is the other program (notice the broader range of servo pulses):



'Program:ServoRangeBroad.bs2
'Created by: Miguel Reznicek
'Creation Date: 8/29/2007
'Purpose: This program sends control pulses to the continuous
'range servo connected to P12 for for visual appreciation and
'prints the current pulse value on screen.
'Special Requirements:
'For Basic Stamp 2
' {$STAMP BS2}
'Written in PBasic version 2.5
' {$PBASIC 2.5}

pulse VAR Word
counter VAR Word

FOR pulse = 0 TO 1000 STEP 10
DEBUG ? pulse
FOR counter = 1 TO 50
PULSOUT 12, pulse
PAUSE 20
NEXT
NEXT
END

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Sometimes we forget that the world itself is paradise." Douglas Coupland, 'Microserfs'
"If the doors of perception were cleansed every thing would appear to man as it is, infinite" - William Blake
"We either make ourselves miserable, or we make ourselves strong. The amount of work is the same." Carlos Castaneda
"One single grateful thought raised to heaven is the most perfect prayer. " G. E. Lessing
“How much of human life is lost in waiting.” Ralph Waldo Emerson
"Men often mistake notoriety for fame, and would rather be remembered for their vices and follies than not be noticed at all.” Harry Truman
My website: www.intoku.net my e-mail:mreznicek@pretensa.com me:Miguel Reznicek
360 x 270 - 144K
Sign In or Register to comment.