Let's Make Robots!

Servo problem with "start here" bot

Hi all,

So a friend and I are working on our version of the start here bot. Everything is hooked up and working fine...with the exception of the servo. I am using the 28x1 picaxe with firmware a.5 (so this isn't a problem that i've seen in other threads about the wrong firmware). 

When i plug the battery pack in, the servo does a quick twitch, but when i send any commands to it...i get nothing at all. I've removed the darlington and I'm using the resistor in the proper location. The only other thing I can think of that is different is that we are using only a 3xAA battery pack...but that should still be enough power for it to at least do something?

 I'm just using simple commands as well

main:

servo 0, 75
wait 1
servo 0, 225
wait 1
servo 0, 150

goto main

 

any ideas on what I might be missing?I've attached a pic of the connection as well.

AttachmentSize
servoconn.jpg68.03 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vince086's picture

try this code :

main:

for b1 = 80 to 175 step 5

servo 0,b1

pause 15 'make this smaller to make the servo go faster

next b1

for b1 =175 to 80 step -5

servo 0,b1

pause 15 'make this smaller to make the servo go faster

next b1

goto main

OK....

Added secondary power supply. Now we have a 3xAA for everything else, and a 4xAA for just the servo.

tried the new code above, that didn't work either. We still aren't getting anything to the servo.

Just to try and troubleshoot a bit more, we moved the servo from pin#0 to pin#4 and upated our code to send commands to that pin. Still nothing...servo didn't move.

We also tried another servo entirely just to make sure we didn't have a burned out one to start with, but that doesn't do anything either.

One weird thing we came across was that if we send commands to pins 4-7, we get a very weak signal to one of our motors (servo 4,5 move motor A, and servo 6,7 move motor B)??? Is that just wacky crosstalk or could this be some kind of problem??

 ---

 and even a bit more research...

we ran an LED to pin#0 and Ground pin#0

This lit up the LED so we know signal and power are working. Although,we didn't have to run any code to make it light up...it is always turned on...which seems wrong? Shouldn't we have to use the "high 0" command?

Apparently we had a resistor that was way too crazy (i'm pretty sure it was 330k instead of 330). We plopped a different resistor in that came with a bunch of LED's that we had lying around ( I have no idea what resistance they even are...) but it made everything work like a charm!

Servo is working it's magic and all of the other components are doing their thing :) 

Thanks everyone!

jka's picture

One problem might be, that you are telling servo 0 to go to position 75 and then go on to tell servo 1 to move to 225 and 150. If you only have a servo in position 0, it is just sitting there, being happy to know that it is in the position that you told it to be. This can be fixed by changing "servo 1,225" to "servo 0,225" and "servo 1,150" to "servo 0,150". Note two things:

1.  You start by moving all the way in one direction (servo 0,75). You then wait 1 second to give the servo time to move to this position. Then you tell it to move all the way in the other direction (servo 0,225) and you give it 1 second to do this. Now, depending on your servo, this might not be time enough. Especially, if you are only using 3xAA batteries. 

2. The last servo command is followed by a goto to the beginningog the code. This is fair enough, but if you do this, you will tell the servo to move to 150 and immediately to 75 without giving it time to move to 150. Since it is moving from 225, it is the same direction,  so you might not notice this. But, you ought to add another wait statement after the last servo command like this:

So, with the proposed changes, your program should look like:

main:

servo 0, 75
wait 2
servo 0, 225
wait 1
servo 0, 150
wait 2

goto main

 

Hope it helps

 Good luck

ok...I used the updated code, added extra wait time, and still no luck.

Still nothing happening at all. I'm going to try some fresh batteries just in case (i'm not using rechargables), but even with only using 3xAA I should still get at least some kind of movement? Is there an easy way to check that the servo isn't hosed? I'm assuming that it works because when I plug the battery pack into the board, the servo gives a quick twitch.

ezekiel181's picture
Try using 4xAA`s instead. I don`t know what minimum voltage the picaxe can run from but it`s possible the servo is pulling the voltage so low that the picaxe resets itself continuously.
rik's picture

search "picaxe for dummies" on this site

I use it daily.

rik's picture

Your code tries to initialize a pulsing signal on "leg 0" of the board. Then waits a while and tries to initialize a pulsing signal on "leg 1".

The first time it wants to turn servo #0 to the far right. The second time it wants to turn a second servo #1 to the far left. I'm guessing you want only to turn servo #0 since your photo shows a connector on leg 0 only. Correct your code.

While you do that, try to use the "servo" command only once in your program. At startup the servo command initialises the pulsing. From that moment on, the chip will send a pulsing signal from a pin to leg 0.

After that first command, you can readjust the servo position using a different command called "servopos". Works just the same, but it will not reset the internal timer of the micro controller. This method will reduce jitter in all the servos and many other time sensitive activities.

You brought up the issue of power. Som AA batteries have a lot more juice in them than others. I run my servos on a second power supply to the picaxe. I use 4xAA NiMh rechargeables. Seems to do the trick. When in doubt, buy a measuring thingey. And learn how to use it, not to fry it.

Lastly, totally non related: redo the wiring for the mototrs please! Those naked wires are screaming for a short circuit. Contrary to very popular belief, that kind of circuitry will not turn your bot into a living wild wisecracking singing encyclopedic robot yelling "need more input". It will simply die prematurely. Die untill it's dead.

blahh...oops. That was a typo in my post...not in my code :)

I've updated it above. In my actual code I was only sending a signal to 0. I've tried both the servo and the servopos commands as well. It's just seems like nothing is reaching the servo.

and yeah...we got carried away when stripping our motor wires, but it's working for now, but we will probably fix it up.