Wheel turning 90 degrees
bee896
Posts: 25
Recently I'm trying to make the boe-bot turn exactly 90 degrees so that it won't keep turning and eventually go "off the line".
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 leftservo = 1 rightservo = 2 VAR byte counter long Pause, Pulsout PUB left Pause := clkfreq/1_000 Pulsout := clkfreq/500_000 dira[leftservo_pin]~~ outa[leftservo_pin]~ dira[rightservo_pin]~~ outa[rightservo_pin]~ repeat counter from 1 to 19 ' Loop for 1 seconds outa[rightservo_pin]~~ waitcnt(Pulsout * 650 + cnt) ' clockwise outa[rightservo_pin]~ outa[leftservo_pin]~~ waitcnt(Pulsout * 650 + cnt) ' clockwise outa[leftservo_pin]~ waitcnt(Pause * 20 + cnt)The code above causes the robot to turn right but not exactly 90 degrees. Anyone has any idea how to improve it?
Comments
To make it move or turn very accurately, you need to get these
http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/wheel/List/0/SortField/4/ProductID/80/Default.aspx
-Phil
So with my current condition, without using Boe-Bot Digital Encoder Kit, the best way is to make it turn 90 degrees as accurate as possible?
The loop value from 1 to 19 causes it turn around 92 degrees, while from 1 to 18 around 88 degrees. I am trying to find a way where I can make the counter repeat like 18.5 times but to no avail
waitcnt(Pause * 10 + cnt)
then you can repeat any number from 38 to 48 times with better accuracy.
John Abshier
I actually thought of running the 2 servos in a different cog so that the right servo and left servo can run at the same time.
The current code invokes the right servo first continued by the left servo, so I believe there will be a short little delay for the left servo to start
John: If I'm not mistaken will wait for 80 ms right?
John Abshier
Rich H
Also, there is a balance in overall wheel velocity that you should explore for best consistency, both in turning and travelling in a straight line. High velocity without ramping may lead to wheel slip on startup or stopping, but the increased torque at high speeds reduces sensitivity to rolling friction and yields more consistent speeds overall. Just the opposite applies at low wheel velocity. Try several different speeds to see what works best for your given bot.
using another cog to control the servos will allow more things to happen simultaneously, making your robot more responsive.
It is up to your ingenuity to implement the code.
So it will wait for 80 milliseconds right?
Clkfreq is always equal to the number of clock tics per second. In other words, clkfreq is equal to one second.
So (clkfreq / 1000) is one thousandth of a second, otherwise know as a millisecond.
turntime (800) * one millisecond = 800 milliseconds.
Rich H