compass stearing
Archiver
Posts: 46,084
Is there any way possible to interface a compass module and BS2 to
stear an electric motor, just turning it in the direction I choose
to go and keep it there.
stear an electric motor, just turning it in the direction I choose
to go and keep it there.
Comments
The devantech website has example code for a basic stamp2 cpu.
http://www.robot-electronics.co.uk/htm/cmps2pwm.shtml
The code outputs a degree range from 0-359.
Could you not then create some if/then statments that would check a compass
range and then turn towards that direction?
For example:
if bearing = 0 or <=30 then gosub 15 degrees ' turn to heading 15 degrees
if bearing = 31 or <=60 then gosub 45 degrees ' turn to heading 45 degrees
My code is messy, but you should get the idea from this. Maybe there is a
way to input the bearing you receive directly to a motor control statment,
bypassing all the if statments.
On my tracked robot, for a turn I run the track motors: one forward, one
reverse and pause for a certain length of time. The pause gives the motors
time to rotate the robot an approximate angle.
pause 30 'turns 30 degrees
pause 60 'turns 60 degrees etc.
Possibly you could incorporate the bearing angle into the pause statment by
replacing it with a veariable.
pause bearing
Than you could run the compass routine a 2nd time and see if the robot had
actually turned as far as expected. You would probably want a threshold
range as well. If the robot turned to within 10% of the reading than okay.
Differant ground surfaces will cause the motors to require extra time to
turn. On wood floor I must use a smaller turn time (pause value) than on rugs.
Good luck.
-Kerry
At 01:30 AM 3/6/04 -0000, you wrote:
>Is there any way possible to interface a compass module and BS2 to
>stear an electric motor, just turning it in the direction I choose
>to go and keep it there.
>
>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>Yahoo! Groups Links
>
>
>
>
>
>
Very respectfully, your obedient servant.
Brig. Gen. Johnston Pettigrew
Admin@M...
WWW server hosting [url=Http://mntnweb.com]Http://mntnweb.com[/url]
Kerry Barlow
p.o. box 21
kirkwood ny
13795
607-775-1575
I must say something about this compass
....ok it is working (in your living room)
but.....be careful. This compass is only a toy.
It need calibration and reset all the time, and is affected from all
metal around.
Go for some GPS unit with inbuilt compass.
Stein.
--- In basicstamps@yahoogroups.com, Kerry Barlow <admin@m...> wrote:
> Regarding the Compass,
> The devantech website has example code for a basic stamp2 cpu.
> http://www.robot-electronics.co.uk/htm/cmps2pwm.shtml
> The code outputs a degree range from 0-359.
> Could you not then create some if/then statments that would check
a compass
> range and then turn towards that direction?
> For example:
>
> if bearing = 0 or <=30 then gosub 15 degrees ' turn to heading 15
degrees
> if bearing = 31 or <=60 then gosub 45 degrees ' turn to heading 45
degrees
>
> My code is messy, but you should get the idea from this. Maybe
there is a
> way to input the bearing you receive directly to a motor control
statment,
> bypassing all the if statments.
> On my tracked robot, for a turn I run the track motors: one
forward, one
> reverse and pause for a certain length of time. The pause gives
the motors
> time to rotate the robot an approximate angle.
> pause 30 'turns 30 degrees
> pause 60 'turns 60 degrees etc.
> Possibly you could incorporate the bearing angle into the pause
statment by
> replacing it with a veariable.
>
> pause bearing
>
> Than you could run the compass routine a 2nd time and see if the
robot had
> actually turned as far as expected. You would probably want a
threshold
> range as well. If the robot turned to within 10% of the reading
than okay.
> Differant ground surfaces will cause the motors to require extra
time to
> turn. On wood floor I must use a smaller turn time (pause value)
than on rugs.
> Good luck.
> -Kerry
>
>
>
>
>
> At 01:30 AM 3/6/04 -0000, you wrote:
> >Is there any way possible to interface a compass module and BS2
to
> >stear an electric motor, just turning it in the direction I
choose
> >to go and keep it there.
> >
> >
> >
> >To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@yahoogroups.com
> >from the same email address that you subscribed. Text in the
Subject and
> Body of the message will be ignored.
> >
> >Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> Very respectfully, your obedient servant.
> Brig. Gen. Johnston Pettigrew
>
> Admin@M...
> WWW server hosting [url=Http://mntnweb.com]Http://mntnweb.com[/url]
> Kerry Barlow
> p.o. box 21
> kirkwood ny
> 13795
> 607-775-1575