Help! Having trouble getting my servos to go forward correctly!
omgitsaliv55
Posts: 24
Hi. My name is Patrick and I am very interested in robotics and have been for about three months. I've written a lot of PBASIC 2.5 programs, however I have just run into a dilema with my Boe Bot. I recently had to recailibrate my continous rotation servos because one was moving slightly slow that the others. I got it to a point of nearly perfect calibration and reassembled my Boe Bot. I fixed up a few things in the code just to make outputs match up and found that my problem was far from fixed. It had actually worsened. Now, one of the servos made a strange "clicking" noise. But that wasn't the big problem. The big problem was that one of the servos was only going half the speed of the other one now (don't worry. the one that was clicking worked fine. it was the one that sounded normal that was strange). I thought to myself, "Maybe its a defective servo..." and switched the servo ports to see if the same servo would go slow again. Surprisingly, it didn't. The other one was going slow now. This scared me. I was really worried that my servo port had weakened, however when I ran a program that looked like this:
' {$STAMP BS2}
' {$PBASIC 2.5}
DO
PULSOUT 12, 650
PULSOUT 13, 850
LOOP
...It went forward perfectly! I was relieved. I knew then I was most likely having a software problem. So, I played around with my program a bit to try and figure out what was the problem. Eventually, I had it all the way down to the attached program "buggy code!.bs2" (it use to be a complete light seeking and object avoiding program). It still didn't go forward correctly. And strangely, when I held my hand in front of one of the IR detectors, it's left wheel rotated bacdkwards. There is NOTHING in the code to tell it to go backwards! I'm thinking I should get new servos, but what if its my BS2? That's a pretty good chunk of change for replacement parts if it happens to be my BS2, or even worse, my Board of Education. Any help is appreciated. Thanks!
' {$STAMP BS2}
' {$PBASIC 2.5}
DO
PULSOUT 12, 650
PULSOUT 13, 850
LOOP
...It went forward perfectly! I was relieved. I knew then I was most likely having a software problem. So, I played around with my program a bit to try and figure out what was the problem. Eventually, I had it all the way down to the attached program "buggy code!.bs2" (it use to be a complete light seeking and object avoiding program). It still didn't go forward correctly. And strangely, when I held my hand in front of one of the IR detectors, it's left wheel rotated bacdkwards. There is NOTHING in the code to tell it to go backwards! I'm thinking I should get new servos, but what if its my BS2? That's a pretty good chunk of change for replacement parts if it happens to be my BS2, or even worse, my Board of Education. Any help is appreciated. Thanks!
bs2
599B
Comments
This may not be the only bug, but I noticed that you are using:
<snipped other declarations>
leftir CON 13
DO
DEBUG CLS, DEC irright, CR, DEC irleft
FREQOUT rightir, 1, 37500
irright = IN0
FREQOUT leftir, 1, 37500
irleft = IN14
IF (irleft = 1) AND (irright = 1) THEN
PULSOUT 13, leftforward
PULSOUT 12, rightforward
ENDIF
LOOP
From the code it appears the command FREQOUT leftir·is sending·signals to both the servo and the IR led, and the servo can't interpret it.·Are·you using the·IR circuits directly from the book?
-Stephanie Lindsay
Oops, Stephanie sure picked up on the probable cause. The FREQOUT output is not something a servo can interpret properly.
Post Edited (Mike Green) : 10/11/2006 10:34:07 PM GMT
Another thing that helps is to use the PIN declaration rather than CON when you're defining I/O pins. The Stamp Basic statements sometimes use numbers for I/O pins and sometimes use special names (like IN1). The PIN declarations allows you to give a specific name to an I/O pin that can be used in either context and the compiler will "put in the right thing".
Post Edited (Mike Green) : 10/11/2006 10:57:54 PM GMT
Have a great day!
Bye
If you are using Servo Port 13, you are connected to I/O pin P13, and anything you plug into the P13 socket to the left of the breadboard area will receive the same output signals you send to the servo.· If you tried to use the P13 socket as an input, whatever device you are trying to read with·I/O pin·13 will probably also be sending interference to the servo.· So the answer is yes, the P12 and P13 connections next to the breadboard should not be used for other circuits while you are using servos in the X5 header.·The BASIC Stamp still has the same 16 I/O pins it always had, it's just that two of them are busy with the servos. That still leaves 14 I/O pins to play with though!
Thanks Mike for pointing out the need for PAUSE commands.· I spotted the pin use conflict and didn't dig any further.
-Stephanie Lindsay
·