assistance needed!!!!
Trezitorul
Posts: 68
I bought a servo to play around with and I wired it up and ran it using the demo program and various programs off of this forum but my servo only heads to the neutral position no matter what pulse length I put in. Can some one enlighten me on whether or not servos only spin in one direction and how can the direction be reversed. . Also can anyone give me a schematic for attaching a photocell to the prop.
Comments
What kind of photocell are you talking about? A CdS resistive photosensor? Typically, those are connected as part of either a voltage divider or an RC circuit. The "Basic Analog and Digital" tutorial that's downloadable from the Stamps in Class webpage has a chapter on this for use with a Stamp, but the same thing applies to the Propeller. You can even use the BS2 compatibility library from the Object Exchange to provide an equivalent to the RCTIME statement in Stamp Basic.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Definetly a E3 (Electronics Engineer Extrodinare!)
"I laugh in the face of imposible,... not because i know it all, ... but because I don't know well enough!"
I use a 6V power supply (either a 5 cell NiMH battery pack or a 6V 2A "wall wart") to power my BoeBot which has 3 servos of which only 2 are in use at a time, a PING, a couple of IR LEDs, and some other low power sensors, all connected to a Propeller Protoboard with the Accessory Kit. The servos are powered directly from the 6V source. The 5V regulator only powers the logic and sensors.
Download BoeBotBasic from the Propeller Object Exchange and use the servo control statements to set a couple of different servo positions. There's enough documentation and one example included that should help you.
con
_clkmode = RCFAST
Pub start
repeat
dira[noparse][[/noparse]0]~~
outa[noparse][[/noparse]0]~~
waitcnt(clkfreq/572 + cnt) 'servo at 180 with pulse of 1.75
outa[noparse][[/noparse]0]~
waitcnt(clkfreq/50 + cnt) '20ms pause between pulses
Thanks for mentioning the power supply because now that I tested my batteries I found out that they were only producing 4.6 volts the minimum so the servo was still turning but the power was really low. How many amps do 4AA batteries produce and is the servo suposed to get really hot after only a few minutes of use. How do you ground the servo if it is already grounded to the battery. The funny thing is that the servo will always spin counter clockwise till it hits the mechanical stop no matter what pulse.(this might explain the heat).
Thanks so much everyone for answering my many questions!
Your servo should not get really hot. If you only connect the power leads to the servo and leave the control lead unconnected, the servo should just sit there. You should be able to turn the output shaft slowly against mechanical resistance, but the servo motor should not attempt to keep it from moving. The servo should not get hot at all this way since the control circuitry should be idle (with no control pulses coming in).
The ground lead (-) of the servo should be connected to the battery ground. The ground lead of the Propeller circuitry should also be connected to the battery ground.
I am wondering is there any possibility that I got a faulty servo or that I unknowingly broke it? When I was testing it I would spin the shaft manually all the way from the front 0 degree position to the max position. Would a picture of it and my setup be useful.
Post Edited (Trezitorul) : 6/29/2007 11:07:02 PM GMT
Graham
Post Edited (Mike Green) : 6/30/2007 12:18:34 AM GMT
One more thing how many clock cycles are in a megahertz and how many megahertz are in a ms. This is confusing me a great deal especially when I look over other peoples programs. The results from your program Mike were the same the manually positioned servo spun from the 180 position the back ( long end of the servo) or where the mechanical block is to the mechanical block at the front(short end) with no stop in between.
The neutral position of a servo is (by definition) at 1.5ms control pulse width and should occur roughly half way between the two mechanical stops. This is the same as 1500us (which is 15 * 100us). 1 second = 1000 milliseconds (ms). 1 millisecond = 1000 microseconds (us). 1 microsecond = 1000 nanoseconds (ns).
The Demo Board has a 5MHz crystal. The phase locked loop (PLL) in the system clock circuitry can multiply this by up to 16 times to give an 80MHz system clock (5MHz x 16 = 80MHz). If you take the inverse of this, you get a clock pulse width of 12.5ns. The Propeller executes native instructions in 4 clock cycles or 50ns. That gives an execution rate of 20 million instructions per second (MIPS). With 8 cogs executing simultaneously, that gives an aggregate rate of 160 MIPS. Spin is an interpreted language and it takes about 80 or so native instructions to perform an operation in Spin (like A++). That's approximately 2 million Spin operations per second total.
Further to Mike's description of ms, us etc.
Frequency is the number of cycles (repetitions of the waves pattern) per second so 1Mhz for example is one million cycles per second. That means that the length of one cycle (the time period T) is 1/1000000, in seconds. If you then wanted it in ms multiply by 1000 or in us by 1000000. (note as there are a million cycles per second at 1Mhz and a million us in a second the period must be 1us).
This gives you the useful formula:
T = 1/f (think one second divided into f parts where f is the number of parts per second)
And
f = 1/T (think one second divided into the length of one cycle giving the number of cycles that fit in a second)
So you can convert from one to the other easily and the equations is easy to remember (especially if you understand it).
The knowledge of units is important and you should try to understand them, some are easy because we are used to them mm (1000 in a M) some are less so, like micro, nano, pico, femto but all represent a small fraction of the full unit. You should read up on this in a text book aimed at what you feel it your level as it will really help all your programming and experimentation.
Graham
About the photocell... you can use "Test RC Decay Circuit (testrcdecay.spin) from the PEK Counters and Circuits Lab... and simply substitute the photoresister for the resistor. remember... light decreases the resistance of the photoresistor... not the other way around... so low light takes longer to detect than bright light. The Lab is great fun and very instructive.
About the servo ... I got exactly the same behavior and it had nothing to do with the software or hardware... my setup was constantly causing a reset.
The problem is... until it works... it doesn't work... and if you are new to both the hardware and the software... it seems like nothing works... That's where the Labs come in... unless you make a mistake... they work exactly correctly.
Once you get the lab working... you can experiment from there.
Rich
If you did you should definately be able to get the servo so stop and change direction with the pot as long as the pulse width sent to the servo is correct.
Graham
This doesn't display or select properly for me to just drop the image into this reply. Pages 123-126 will answer all your questions about servo's.
If you can't download a 5.15MB file easy, i'll scan it from my WAM book and post for you. Hope this helps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Definetly a E3 (Electronics Engineer Extrodinare!)
"I laugh in the face of imposible,... not because i know it all, ... but because I don't know well enough!"