GP2D02 IR and Stuttering forward
Special_K
Posts: 162
Hey Folks, I have a Boe-Bot that is connected to two GP2D02 IR sensors (right and left). The program takes a reading and depending on the values returned applies a forward (or turning) pulse (if..then code taken from fast IR roaming). The problem is that the Boe-Bot does not have continuous forward motion. It kind of stutters forward. Any way to correct this.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
If your Sharp sensors are like the other ones in the series that I have used. (GP2D12 and GP2D15), they daw a lot of power (around 60 mA each when they fire)
It could be that your stamp is resetting because of that. It would be especially so if you were runing the servos off the same battery, or if the batteries were low.
Rig up an LED to a pin on your BOEbot (with proper resistor, of course). Add some code to your program that lights the LED for a half second when the program starts, but NOT in the main loop.
It should light only once each time you start the robot. If it keeps lighting up, you know you have a power issue.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
there is no restart in the Basic stamp, I rigged the pizzo buzzer to sound (same thing right) and the stamp is not restarting, but it still the wheel servo stutters . If I take out the IR read subroutine·I get no jitter. If I take out the line
SHIFTIN DLLFT, CLLFT, MSBPOST, [noparse][[/noparse]IRLFT]······
there is no jitter is there something up with this code.
I popped your latest code into the editor and got an error on the Backward Label in your decision tree. Where's the subroutine?
Since I assume the robot will mostly go forward, I'd reverse the order of your decision tree. Then the code would drop trough the decision loops faster most of the time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hey, Chris Savage have you made this work? Do I need to go out and get a different Sharp IR sensor? Is the Sharp GP2D12 Analog Distance Sensor that Parallax sells the only sensor that works well with the Basic Stamp 2? If so, shouldn't Parallax post that on the Website somewhere?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
See if there is anything here that is helpful:
http://www.acroname.com/robotics/info/examples/GP2D02-4/GP2D02-4.html
Are you using an interfacing diode, as appears needs to be used?
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
the code
read02:
LOW cl ' turn on detector for reading
rl:
IF IN15 = 0 THEN rl ' wait for input high
SHIFTIN dt, cl, MSBPOST, [noparse][[/noparse]val02]
HIGH cl ' turn detector off
PAUSE 1 ' let detector reset
RETURN
is just the same as
READ_IRLFT:
LOW CLLFT ' turn on detector for reading
rl:
IF IN11 = 0 THEN rl ' wait for input high
SHIFTIN DLLFT, CLLFT, MSBPOST, [noparse][[/noparse]IRLFT]
HIGH CLLFT ' turn detector off
PAUSE 1 ' let detector reset
RETURN
I didn't look close enough to note its purpose, but you didn't mention if you had the required diode in place?
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
I used this post to get that right.
http://forums.parallax.com/forums/default.aspx?f=5&m=108889&g=109225#m109225
so the setup is the same as the diagram here.
http://www.acroname.com/robotics/info/examples/GP2D02-4/GP2D02-4.html
I just used pins 9 and 11
It may not be possible with this sensor. I downloaded the datasheet from this Google link below, and it takes too long for the sensor to fire and return data. Actually, the timing data is right in the google link itself (line 3 at the end)
[noparse][[/noparse]PDF] OPTOELECTRONIC/POWER DEVICES
File Format: PDF/Adobe Acrobat
GP2D02. Compact, High Sensitive Distance. Measuring Sensor. (Unit : mm). Features. Applications ... GP2D02. 70ms. 0.1ms. 0.1ms. 1.6ms. 2ms. (Ta=25C,Vcc=5V) ...
info.hobbyengineering.com/specs/SHARP-GP2D02.pdf - Similar pages
Note that it takes around 74 microseconds for the sensor to cycle once. If you read both sensors in one loop, and try to execute other code, you will be able to command the servos only every 160 microseconds or so---too slow.
Thats what is causing the stuttering, the servos aren't getting refreshed often enough, only 1/7to 1/9 as often as they should be.
Here are some things to try
1) get a servo controller to refresh the servos --the only drawback is the cost of the controller.
2) try rewiting your program so servos get refreshed after reading each sensor. the timing will be too slow, but that might be good enough. you will need a variable that remembers what the servo you DIDN'T read said during the previous time it was read.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Post Edited (Larry) : 3/16/2006 6:22:36 AM GMT
There are cheaper units that would also work, though they lack some features. Just Google "Servo Controller"
Larry
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Parallax has abundantly documented the matter of servos requiring a certain period (pause) between signals (not too short, not too long a period). Parallax has also has on many occasions needed to alert the reader to "timing" issues of all sorts.
But, it isn't reasonable to expect Parallax to provide information on every combination of products that exists or that could be combined by a customer·--especially so for products (specific models) that it does not even sell/support, and/or for applications which it has not specifically suggested that the specific product is suitable for.
Parallax has brought affordable·electronics learning, entertainment and even practical applications within the grasp of many by providing very well conceived·products and documentation. But, if you choose to step beyond that perimeter, things can·get messy in a hurry and the lessons can become expensive (or, valuable?).
PAR
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (Special_K) : 3/24/2006 4:39:32 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
do you have a link to code like that of the
Ping)) BASIC Stamp Example Code (.zip).
the docs that come with the PSC
http://www.parallax.com/dl/docs/prod/motors/PSCusbManBv3_3.pdf
Do not have code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
From Larry
Note that it takes around 74 microseconds for the sensor to cycle once. If you read both sensors in one loop, and try to execute other code, you will be able to command the servos only every 160 microseconds or so---too slow.
By the way thanks again Larry
I got the PSC so that I could have it provide the refresh statements to the servos in an acceptable time frame. I just did not know why the PSC USB documentation did not come with code or code snippet on how to have your Basic Stamp 2 control it. It just tells you how to control it via the computer and how do download the frames made into the Basic Stamp. I was hoping/looking for code kind of like that of the Ping)) documentation or at least a equivalent chart that said: You control a servo via the basic stamp like this.
PULSOUT 13, 650
PULSOUT 12,850
PAUSE 20
and like this with the basic stamp sending controls to the PSC.
????
I did not want code for controlling GP2D02
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
http://www.crustcrawler.com/code/index.php?prod=20
PAR
I have the PSC connected to a standard 9V battery.
Most servos are made to work in the 4.8-6.0 volt range. As with any motor, overvoltage will create heat, wear out the brushes sooner, and shorten the life of the motors.I'd cut the motor power back to the suggested levels unless you are willing to live with frequent servo replacement. (sometimes people in robot competitions will do anything to get an edge)
It's more economical, too. 9v batteries don't have many amp/hrs in them for the money. Take one apart, and you'll find teeney little battry cells in series. They just don't hold much energy in them.
I'd scale back on voltage and gain run time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔