Servo horn + pulsout command
shmee.again
Posts: 5
What's a Microcontroller? (pg 115+116)
the command is
(Pg. 115)
FOR counter = 1 TO 150
PULSOUT 14, 1000
PAUSE 20
NEXT
1.it says:
"the FOR...NEXT loop deliver 150 pulses each of which last 2.0 ms"
wouldnt this mean 150 * 2ms = 300 ms for all 150 pulses?
2.later in the gray box it says:
"PULSOUT 14, 1000 sends a pulse that lasts 1000 * 2 μs. Thats 2000 μs or 2 ms."
if each one lasts 2.0 ms like it says above you would multiply by 2 ms not 2 μs...
is it 1 or 2???
the book doesnt explain why you multiply it by 2 microseconds...why do you multiply it by 2 μs?
someone please just explain this whole thing to me...so lost...
the command is
(Pg. 115)
FOR counter = 1 TO 150
PULSOUT 14, 1000
PAUSE 20
NEXT
1.it says:
"the FOR...NEXT loop deliver 150 pulses each of which last 2.0 ms"
wouldnt this mean 150 * 2ms = 300 ms for all 150 pulses?
2.later in the gray box it says:
"PULSOUT 14, 1000 sends a pulse that lasts 1000 * 2 μs. Thats 2000 μs or 2 ms."
if each one lasts 2.0 ms like it says above you would multiply by 2 ms not 2 μs...
is it 1 or 2???
the book doesnt explain why you multiply it by 2 microseconds...why do you multiply it by 2 μs?
someone please just explain this whole thing to me...so lost...
Comments
So each PULSOUT value is 2uS
PULSOUT 14, 1000
would send a pulse lasting 1000 * 2uS = 2mS
The FOR-NEXT loop sends that pulse 150 times. The servo wants a 20mS pause between each pulse, so there is a PAUSE 20 in there.
So, total time would be roughly (2mS + 20mS) x 150, with a little added for prcoessing time.
This help?
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
StampPlot - Graphical Data Acquisition and Control
AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
In the example, the PULSOUT command will make PIN 14 go HIGH and then go back to LOW. The time that PIN 14 is HIGH is determined by the second number which is called the DURATION parameter. The DURATION parameter for the BS2 has a unit of 2 uS (not 1uS, and not 1mS).
A PULSOUT DURATION value of 1000 will last for 1000 units of 2 uS.
After the PULSOUT is performed by the BS2, PIN 14 will be LOW. It will be LOW while the BS2 performs the PAUSE 20. The unit of the PAUSE parameter is 1 mS, so the pause will last for 20 units of 1 mS.
The LOOP will be repeated 150 times, causing a train of 150 separate pulses to be generated by the BS2.
PULSOUT 14, 1 would send a pulse lasting 2uS. This is the shortest duration that they could achieve with the BASIC Stamp.
So each PULSOUT value is 2uS
PULSOUT 14, 1000
would send a pulse lasting 1000 * 2uS = 2mS
The FOR-NEXT loop sends that pulse 150 times. The servo wants a 20mS pause between each pulse, so there is a PAUSE 20 in there.
So, total time would be roughly (2mS + 20mS) x 150, with a little added for prcoessing time.
This help?
-Martin
OKAY. so each pulse is lasts (2uS*1000=) 2ms and is divided by 20ms, so for the counter, this occurs over and over 150 times...OKAY
SOOOOOO:
Why does the Servo prefer we use pulsout why cant we just use high and low commands instead??
so what exactly is the PULSOUT value??
if each pulse has a duration of 2000uS or 2mS then why dont we simply write PULSOUT 14, 2000,
WHY do we multiply by 2 to get the pulsout duration??
OFF TOPIC: whats the difference between Vdd Vin and Vss, dont think the book explains that...?? why do we use like a resistor instead of jumper wires, and that sort of thing, cause it would short out?
So, each time the servo 'sees' the commanded pulse, it 'moves' the output shaft a little in the commanded direction. So it takes multiple 'views' of that signal to finish the move. And even after the servo gets to the commanded position, it still has to recieve that signal every 20 mSec if it's going to 'hold' that position.
Now, a 'modified' servo (which is used for wheels) has disconnected the variable resistor from the output shaft, and the variable resistor is set at its 'center' position. Thus a 1.5 mSec pulse 'matches' the internal pulse, and the servo stops. More than 1.5 mSec spins one way, less than 1.5 mSec spins the other.
Okay, so the input voltages. Vin is the 6 to 20 volt 'battery' or 'unregulated' voltage input. Vdd is the 'regulated' +5 volts -- output from either the 7805 Linear Regulator, the 3240-5 regulator, or the regulator on the BS2 module itself. Vss is 'ground', to which all the 'plus' voltages are referenced.
We use the PULSOUT signal, because it's very accurate and has a 2 uSec resolution. Also, the smallest pulse you can generate with LOW-HIGH-LOW keywords is about 1 mSec and it's NOT very accurate. A LOW-HIGH-HIGH-LOW sequence would be about 2 mSec.
When using pulse out with a servo you can increase and decrease the speed at which a servo moves. By using a shorter pause time you can actually get hobby servos to strip gears (not suggested). To decrease speed on the servo·increase· your pause time.
DO NOT go less then 5 for pause time - even at 5 servos can strip out.
Unless you need to move really fast, the times in the book are more then adaquate for most projects.
Post Edited (AIman) : 11/9/2006 6:45:58 PM GMT
to clear my mind up on this part:
Vdd is 0-5 volts
Vin is 6-20 volts
Vss is 20+ volts?
more (hehe):
Resistors restrict the amount of electricity/signal going through the wire?
Jumper cables sends the max volts the voltage inputs can put out?
GRACIAS AS WE SAY IN L.A.!!
In BS2 parlance, "Vss" IS the "Ground". So, technically (by definition) it's ALWAYS at zero volts, unless something very bad has happened.
The 'resistor' equation is Ohms Law -- V == I * R, or I == V / R, or "The current (in Amps) through a Resistor (in Ohms) is equal to the Voltage Applied (in Volts) divided by the Resistor Value (in Ohms)". In typical electronics, the independent value is the Voltage, the Resistance is fixed (each resistor has its own resistance) and the Current changes as you change the Voltage.
so i understand vss and vdd, so what exactly is Vin or did i get that right as 6-20volts?
With the on-module linear regulator, you can connect a 9-volt battery directly across the Vin (positive 9 volts) and Vss (the 'ground' wire) and have a running micro-controller.
i think thats all i can think of to ask for now, thanks a lot!
Here is the example program on page 115 of What's a Microcontroller:
counter VAR Word
DEBUG "counterclockwise 10 oclock", CR
FOR counter = 1 TO 150
PULSOUT 14, 1000
PAUSE 20
NEXT
DEBUG "clockwise 2 oclock", CR
FOR counter = 1 TO 150
PULSOUT 14, 500
PAUSE 20
NEXT
DEBUG "center 12 oclock", CR
FOR counter = 1 TO 150
PULSOUT 14, 750
PAUSE 20
NEXT
DEBUG "all done"
END
What makes the Servo turn clockwise versus counterclockwise? I see no difference in the commands for the three movements except for the duration of the PULSOUT????
Also, does this program actually make the servo horn move to the various clock positions? Or is it just making the Servo horn rotate through a given number of degrees, without regard to where the horn is "pointing"????
Thanks for your help... I bought this book to learn about this stuff on my own, so I have no one to ask!
Assume that shorter pulse lengths (<750)·cause the servo to turn clockwise, to some particular position.
Assume that longer pulse lengths (>750)·cause the servo to turn counterclockwise, to some particular position.
Assume that when the servo is positioned at "750", it is at its "12 o'clock" position.
Then, setting the servo·with a specific shorter pulse value will cause the servo to position itself at that specific "clock" position. Ditto for a specific longer pulse value.
The above refers to "standard" type servos, not to the modified "continuous rotation" type.
For more detailed descriptions of how these servos are controlled by pulse lengths, you might look at Chapter 2· (ver 1.0) of Understanding Signals, http://www.parallax.com/dl/docs/prod/sic/Signals.pdf, and/or Chapter 2 (ver. 2.2) Robotics with the BOE-Bot, http://www.parallax.com/dl/docs/books/edu/Roboticsv2_2.pdf, esp. Activities #4 and #6.
PAR
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
More about Standard Servo Control with the BASIC Stamp 2
Please check it out, and post any questions you might have there so that we can make sure the subject is well covered.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.