Let's Make Robots!

Some more unusual servo reactions in "start here" robot *FIXED*

I put together the "start here" robot and it worked perfectly, I then put together a chassis (foamcore, glue gun and thick wire), added a switch to turn it on/off and added a LED so it could communicate a few things and help debug. All this worked well but then I turned it on again and now the servo is acting completely erraticaly. In the "whichway" subroutine it now only looks left and then proceeds to move forward. Every time.

I tried a few simple programs to try and zero in on the problem and am now convinced that there's something very wrong with the servo. I tried this and just let it run for a minute or two...

 

servo 0, 150

pause 1000

servo 0, 90

pause 1000

servo 0, 150

pause 1000

servo 0, 200

pause 1000

servo 0, 150

pause 1000

After a few cycles the servo started skipping or shortening a few pauses and then just started to look left and center only.
I'm at a bit of a loss as to how to debug this.
Could it just be that the servo is fried somehow? Where could it be getting noise from? It was working fine for a long while and nothing on the hardware side was changed prior to this erratic behavior.

 

 


-Update-

I finally got some time to look at my machine and I decided to start from the beginning. I unplugged everything and then proceeded to check every soldering point, redo a few of the less confidence-inspiring ones (one of the IR wires was very iffy), changed the batteries, re-inserted the resistor array and re-read my whole code. I then plugged it in and my little guy came to life with swift determination and a firm grasp of what I wanted him to accomplish. Yay!

 

Thank you to Isotope, Telefox and Ezekiel181. 

Now I can move forth towards my next problem...

 

Comment viewing options

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

Could you attach your full code and maybe some pictures of your 28 board for us...

Could be the battery is going flat and the servo is now causing your micro to reset. Try putting some lines at the very start to blink the LED a few times before starting the servo moving, then watch for errant blinks.

My batteries were indeed getting a bit low so I changed them and that worked somewhat. When I run a small little servo test routine I get a perfect behaviour. Plus it's quite a lot faster now.

I still have erratic behavior when I run the main code. For some reason now it just stays stuck in the "whichway" subroutine it seems, It won't move forward.

I'll have to spend a bit more time debugging it this weekend. It's so very frustrating to have to do things like sleep and work when there's such an exciting and challenging problem to solve.

Man, I think you might have a somwhat faulty 28x1. After you whote the above post I understood that I had similar problem with 28x1. I runs small programms perfectly, but a lager ones for some reason appear to stuck in one subroutine or even skip entering some. Swaping to other Picaxe programmed with absolutely same program resolved my problem. I tried rearranging code for "faluty" chip and it was becoming stuck in different place of code... I ended up using this chip for test programs that are fairly short.

That would explain a lot of the strange things I get. I know I am new to this but I feel confident I have been quite thorough in testing all modules separately and doing the same with the program.

I think I'll have to order a new Picaxe. Darn!  Then again, If i'm lucky and my chip is in fact not the issue then I'll have a brand new Picaxe to start my next project!

I have an idea... I'm not sure how exactly Picaxe compiler arranges the code and if this "fault" in chip occures in single place or in multiple, but this maybe worth trying: What if you could find the subroutine which fails, and make it dead, put some bunch of instructions like pause, if statements, whatever will be swallowed by compiler, rename this sub into say, deadcode: and never call it from your program, but leave it in place. There could be the problem with Picaxe's memory area in which program is stored, and if you are lucky to overwrite this area with code which is never executed... Who knows :)

That's actually a very smart idea. I like this kind of roundabout way of thinking about problems. I guess that is why I was attracted to robot building.

I'll try something like that and let you know how it worked. Thanks!

I did try a few lines of code with blinks in there to try and get a clearer picture but it just seems as if the code gets mangled or something. It just skips steps and jumps back and forth as soon as the servo is involved.

Here's the full code I use:

symbol dangerlevel= 65

symbol turn=700

symbol servo_turn=700

 

Init:

servo 0, 150

pause 500

 

main:

readadc 0, b1

if b1<dangerlevel then

gosub nodanger

else

gosub whichway

end if

goto main

 

nodanger:

low 4: high 5: low 6: high 7 `forward

return

 

whichway:

gosub totalstop

 

high 2

 

gosub Rcheck

pause servo_turn

readadc 0, b2

gosub totalstop

 

gosub Lcheck

pause servo_turn

readadc 0, b3

gosub totalstop

 

low 2

 

if b2>b3 then

gosub Rturn

else

gosub Lturn

end if

return

 

Lcheck:

servo 0, 85

return

 

Rcheck:

servo 0, 215

return

 

Lturn:

high 4: low 5: low 6: high 7 `Left

pause turn

gosub totalstop

return

 

Rturn:

low 4: high 5: high 6: low 7 `Right

pause turn

gosub totalstop

return

 

totalstop:

low 4:low 5:low 6:low 7

servo 0, 150

wait 1

return

 

and here's a picture of my board. It was a little hard to see because of my bad camera but I added a small chart.

Bot board

Your setup looks just fine. ... Is 330R resistor array is sitting tight in dip socket? Try ro remove it and put in place again. And when it is out you could check resistance to be 330 Ohm in between legs which correspond to output #0.

Definitely will be checking that resistor array as soon as I get more time.

Would the absence or malfunction of the array cause enough noise to generate this sort of erratic behavior?