Basic servo demo for propeller?
Ravenkallen
Posts: 1,057
Hey, i am working on a autonomous navigation robot that will use a ping·module for its main sensory input. My robot already has its drive/ control systems installed and working. However, i need to use a servo( with the ping mounted on it) to provide at least a 180 degree rotation ability. I have used servos with other micros( Picaxe, Basic Stamp..) but never with the propeller. In fact, my robot used to have a Picaxe 40X2 as its main controller, but i switched to the propeller for more power. So, does anybody have a good servo demo for the Propeller? Something kinda easy to test out, but hopefully easy to modify. Thanks in advance..... I might upload some pics if you guys want to see what it looks like. I am pretty proud of·it...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller + Picaxe = Romeo & Juliet
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller + Picaxe = Romeo & Juliet
Comments
http://obex.parallax.com/objects/search/?q=servo&csrfmiddlewaretoken=39be308f103736d8a27c770f2b7d5024
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
···································Fix it, if ain't broke!
D Rat
Dave Ratcliff N6YEE
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller + Picaxe = Romeo & Juliet
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller + Picaxe = Romeo & Juliet
I can blink an LED on pin0, so I know the PP pin works. It also blinks at the rate I expect (once a second).
The PRC4PP shield basically puts a 1 K ohm resistor to a servo header and Vbat to the center pin. I use a volt meter to ensure ground is ground, and Vbat is on the center pin. I also used the ohm meter to ensure P0 has 1K ohm to the left pin. I plug the servo into the board with the white lead to left, ground to right to match the header.
I run the program in the above post setting the pin to P0 and the servo will twitch, but not move to the correct offset. If I change pins it won't move at all, so it appears to be getting some kind of signal.
Honestly the PRC4PP is electrically pretty simple and I've controller servos with the BS2. So I am starting to wonder if the timing in the PP is off somehow, but don't know how to validate that. I've tried with multiple servos, so I don't think that's the problem.
Martin
You've got to provide your program code. From your description of the wiring, that all sounds fine. You've got power to the servo (assuming your battery is ok) and some kind of control pulse is getting to the servo. The PP itself should be fine. That leaves the program as the likely culprit.
Sorry, you did mention that you used ratronic's demo. His demo uses pin 8 for the servo and you mention that you're using pin 0. Try changing the program (look at the comments) or rewiring your servo.
John Abshier
You mentioned you used multiple servos. Where they all the same brand?
I've found some of my servos don't like the 3.3V logic signal. You might want to try a different servo brand or use a level shifter.
Since the BS2 uses 5V with its signal you wouldn't have seen a problem when you used the stamp with your servos.
Duane
In terms of debugging, you could try a simple Spin-only servo movement test like:
I was thinking back to times I used servos with the Propeller and remembered another thing to try.
Try bypassing the resistor. I had a servo that wouldn't work until I replaced a resistor with a piece of wire. I'm not sure what the value of the resistor was but it wasn't higher than 10K ohms.
@John Abshier and @Duane, I'm using 6 volts with Power HD servos. I had the Parallax serial terminal up in my other program and didn't notice a reset as I had a debug message at program start. I will try another brand also.
I tried bypassing the resistor, no luck. I was using power HD, so I tried a GWS and that didn't work. I then tried a cheapie generic servo and it worked with a direct pin connection. I then plugged the cheapie servo into the PRC4PP and it worked there as well. I plugged all the servos into a Basic Stamp and they all worked with that.
So this is a 3.3v versus 5v logic level incompatibility with Power HD heavy duty and GWS mini servos. Groan, this was exactly the sort of thing I was afraid of with the 3.3v propeller chip.
so transfer all your depressive thoughts to marvin to feel good again ;-))
Some small transistors or any other logic levelshifter will do it.
best regards
Stefan
Are these Digital or Analog servos? I have had no problems driving either one directly off the Propeller, (once I bypassed the dang translators).
I think you'll need some sort of transistor to control the servos. I have a couple of these I plan to use. I haven't tried them yet but I'll find the various parts I need and try it tonight or tomorrow. I'll let you know if they work.
The board I linked to above uses these transistor arrays. Edit: The board does not use these transistor arrays. The transistor arrays are used in a different SparkFun level shifter (RS-232).
I'm not sure if the thread about the board it the right place to discuss the problem since the board works with most servos.
Duane
With regards to the PRC thread or this thread. I'm willing to discuss it in this thread, and thanks for your help already. I guess I was hoping to buy a board which allowed the Propeller to control all viable servos, and not most or some servos. Granted the PRC uses the same technique that everyone says to use, but it seems like a lurking gotcha with using it or the Propeller chip in general. I certainly wasn't happy to encounter it and was really lost when it happened.
I found my servo that doesn't work with the Prop. The level shifter doesn't work. Dang it!
It's really strange. I scoped the input and output of the signal to and from the shifter and it looks great as long as no servo is attached.
Once a servo is attached the output voltage drops to near the input. Edit: It drops to below the input.
I tried paralleling two of the shifters together. I looked better on the scope; the output was a little higher with a servo attached but it still didn't control the servo.
I'm sure this is solvable. I'll work on it some more tomorrow.
Duane
Edit: I changed the images from huge bitmaps to small png. I also noticed the output with a servo attached is below the input voltage of the level shifter.
http://forums.parallax.com/showthread.php?118121-Digital-servo-s-on-USB-servocontroller/page2&highlight=servo+problems
The level translator I'm using isn't the same kind as from the other thread. It's not bidirectional.
I've got my stubborn servo to finally work. Ahem. . . Here's the embarrassing part. The servo works fine with the level shifter from SparkFun if . . . I have the current turned up high enough on my power supply.
I use a current limiting power supply and I usually leave it set to a few hundred mA. Well this servo draws spikes of current of up to 495mA. Insane.
It's a special "gyro" servo for a RC helicopter. It's supposed to be very fast. I guess the speed come at the cost of high current draw.
The current peaks aren't noticeable normally on my multimeter (a nice Fluke). It's only when I use the Max/Min function can I catch these current spikes.
@Martin, How is your power supply? Can it source enough current? I still needed the level shifter with my servo even with the current turned up.
I noticed SparkFun is currently sold out of the level shifters. They usually replace stock quickly.
I think I have an extra level shifter board. PM me your address and I'll send it off to you.
Duane
FYI, I'm moving to this thread so all the posts will be in one place.
In reading online about level shifters there's a fair number of ways to do it, but I am out of my depth on how to modify the PRC4PP board. I'd like to use it rather than scrap it and start again. The servo headers use an RC circuit (R is 1K ohm and C is 0.01 uF) on pins 0 to 7 to filter servo noise and limit current to the propeller. This seems pretty reasonable and looks like this ASCII schematic:
One level shift circuit I saw uses a diode and pull up resistor like this:
I think I could merge these two as follows:
But I bread boarded the level shift circuit above and it neither helped nor hurt. The servo that worked still worked, the servos that didn't still didn't. I retested with a BS2 and all the servos worked. So at this point I have no clue how to reliably use a servo with a propeller chip. I will be curious to see how the transistor level shift works out.
I think the chip on this board http://www.nkcelectronics.com/5v-to-33v-logic-level-shifter-bo.html might be the same one used on the Parallax servo control board and the robot control board. But I'm not keen on buying something only to have it not work either.
For another project I ordered some GWS standard servos a week and a half ago. They came in the mail today, and they work fine with 3.3 volt control signals. So right now it seems that it's 50/50 if a servo will work or not without level shifters. Those are not great odds.
http://forums.parallax.com/attachment.php?attachmentid=58334
Martin_H,
With that level shifter you have the diode is always in forward conductance... The path is from the 5V supply through the 10k resistor, through the diode, and when the I/O is HIGH to a 3.3V supply ; when the I/O is LOW it's to GND. Either way the Anode side of the diode always has a voltage potential causing the diode to conduct. This conduction allows the 3.3V to pull down the 5V supply your intending to go to the servo to about 3.9V when the I/O is HIGH (3.3V) .... it's a little better with the version using the additional 1k resistor (..almost 4V) but still this is not a 'correct' way to design or make use of a level shifter. The transistorised version provides much better isolation between the 3.3V and 5V (or 6V) servo supply.
@Beau, thanks for the level shifter schematic and the description of what's wrong with the diode one. I have enough spare parts that I can bread board the transistor version tonight.
Thanks to all for the help as I'm a software guy with limited hardware experience. The Basic Stamp is within my comfort zone, so I knew stepping into the Propeller world might bring on difficulties.
That works with my finicky servo.
Thanks
I bread boarded Beau's circuit and the mini servos and several of the Power HD servo's started working. However, the base rotation servo (which bears the entire load of the arm) did not, and I noticed that the propeller chip was resetting with that servo. So I hooked up two power supplies, one for the propeller and one for the servos, and the base servo began working. On a lark I removed Beau's level shifter and that servo still worked. So I went back to the other problematic servos and they all worked in the no level shifter two power supply configuration.
So I am happy, but slightly mystified. When I was using a single supply I was running the servos off Vbatt, not the output of the regulator. I also have beefier than normal voltage regulator (1.5 amp). I could see a Power HD servo drawing enough power under load to brown out the prop. But not the GWS mini's.
But why would the level shifter help?
Why would two power supplied definitively solve the problem?
Why is the Basic Stamp 2 and my Freeduino (shudder) not effected by what ever is effecting the Propeller Platform board? I soldered together my BS 2 and my Freeduino, so it's not like the Propeller Platform kit is the first thing I put together.
Two power supplies for servo's doesn't surprise me, in fact I would recommend it.
As far as the level shifter helping out, servo's produce a lot of electrical noise when in motion, the level shifter could be acting as a filter.
The BS2 and the 'Freeduino' you mention, the higher voltage (5V) provides a 'better' signal to your particular servos that want 5V. This could also explain the level shifter helping out as well.