hi, im new at this.· i have a bsII and BOE board and im learning how to control servos.· do you use pulsout pin, variable.· If so , what does the variable mean.·
·· What you should probably do·now is to download and read the "What's A Microcontroller?" text.· It will help you understand how to program the BASIC Stamp, and with some of your other questions.· It is free as a PDF download from our website.· A link has been posted below for your convenience.
The "variable" portion of the PULSOUT statement lets you use a variable value to generate the pulse.· For example, you can cause a servo to swing back and forth with this bit of code:
pos··· VAR··· Word
idx··· VAR··· Nib
Setup: · LOW 15
Main: · FOR pos = 500 TO 1000 ··· FOR idx = 1 TO 5 ····· PULSOUT 15, pos ····· PAUSE 20 ··· NEXT · NEXT
· FOR pos = 1000 TO·500 ··· FOR idx = 1 TO 5 ····· PULSOUT 15, pos ····· PAUSE 20 ··· NEXT · NEXT
· GOTO Main
The outer loop (pos) sets the position of the servo.· On the BS2 PULSOUT uses units of 2 microseconds, hence a PULSOUT of 500 sends a 1000 microsecond (1 millisecond) pulse.· The inner loop (idx) simply slows the motion a bit -- make that loop bigger to make the servo move slower.
Don't leave out the setup section; PULSOUT works by inverting the state of the specified pin.· Since the servo wants a high-going pulse we must start with the pin low.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Jon Williams Applications Engineer, Parallax
Dallas, TX· USA
thanks for the help, that code really helped me understand the servos better.· another question i have is can i have two servos holding at their positions at the same time, with two different pins.
Yes; just use separate position variables for each and use two PULSOUT statements. Have a look at our Robotics text, it will show you how to control two servos at once.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Jon Williams Applications Engineer, Parallax
Comments
·· What you should probably do·now is to download and read the "What's A Microcontroller?" text.· It will help you understand how to program the BASIC Stamp, and with some of your other questions.· It is free as a PDF download from our website.· A link has been posted below for your convenience.
http://www.parallax.com/detail.asp?product_id=28123
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (Chris Savage (Parallax)) : 5/24/2005 5:58:59 PM GMT
pos··· VAR··· Word
idx··· VAR··· Nib
Setup:
· LOW 15
Main:
· FOR pos = 500 TO 1000
··· FOR idx = 1 TO 5
····· PULSOUT 15, pos
····· PAUSE 20
··· NEXT
· NEXT
· FOR pos = 1000 TO·500
··· FOR idx = 1 TO 5
····· PULSOUT 15, pos
····· PAUSE 20
··· NEXT
· NEXT
· GOTO Main
The outer loop (pos) sets the position of the servo.· On the BS2 PULSOUT uses units of 2 microseconds, hence a PULSOUT of 500 sends a 1000 microsecond (1 millisecond) pulse.· The inner loop (idx) simply slows the motion a bit -- make that loop bigger to make the servo move slower.
Don't leave out the setup section; PULSOUT works by inverting the state of the specified pin.· Since the servo wants a high-going pulse we must start with the pin low.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
For pos = 1000 TO 500 STEP (the number you want)
If the step number is 2 for exable the countdown time will be reduced to the half...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Rule your Destiny-
--Be Good. Be Bad. Be Provas--