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
servo 0, 90
servo 0, 150
servo 0, 200
servo 0, 150
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.
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...
Could you attach your full
Could you attach your full code and maybe some pictures of your 28 board for us…
Could be the battery is
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.
I did try a few lines of
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
servo 0, 150
readadc 0, b1
if b1<dangerlevel then
low 4: high 5: low 6: high 7
forward</p><p>return</p><p> </p><p>whichway:</p><p>gosub totalstop</p><p> </p><p>high 2</p><p> </p><p>gosub Rcheck</p><p>pause servo_turn</p><p>readadc 0, b2</p><p>gosub totalstop</p><p> </p><p>gosub Lcheck</p><p>pause servo_turn</p><p>readadc 0, b3</p><p>gosub totalstop</p><p> </p><p>low 2</p><p> </p><p>if b2>b3 then</p><p>gosub Rturn</p><p>else</p><p>gosub Lturn</p><p>end if</p><p>return</p><p> </p><p>Lcheck:</p><p>servo 0, 85</p><p>return</p><p> </p><p>Rcheck:</p><p>servo 0, 215</p><p>return</p><p> </p><p>Lturn:</p><p>high 4: low 5: low 6: high 7 Left
low 4: high 5: high 6: low 7 `Right
low 4:low 5:low 6:low 7
servo 0, 150
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.
Your setup looks just fine.
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.
My batteries were indeed
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.
Definitely will be checking
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?
Man, I think you might have
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.
If the contact between the
If the contact between the resistor array legs and the socket isn’t good then you can get an unusually high resistance on the servo signal lines, which makes them sensitive to noise.
That would explain a lot of
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!
Thanks, that’s very
Thanks, that’s very educational.
IT’s the kind of thing most books don’t tell you because for some strange reason they assume all components are working fine and your connections are all perfect.
I have an idea… I’m not
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
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!