Magic Compass Project update
Thomas Fletcher
Posts: 91
Magic Compass Project: To make a compass that points toward a geocache location instead of north using digital compass, GPS, and a servo to point needle.
So far I only have the digital compass HM55b. A micro servo is in the mail and I have to save up some pennies to get a GPS.
After some hair pulling dealing with real numbers, I believe I have the code ready for a north pointing compass.
My equation for determining the bearing between two points had unexpected but workable results. It returns 0 degrees for East, -90 for North, 90 for South and 180 for West.
Added an if statement to change the result into a 0-360 degree scheme that matches the compass.
The person's direction is pulled from the compass and the position the needle should point is worked out with another nested if.
Pretty sad looking code, but it has been a long time.
All that is left is to add code to manipulate the servo and to bring the (lat2/long2) values from the gps.
Post Edited (Thomas Fletcher) : 3/14/2009 1:45:21 PM GMT
So far I only have the digital compass HM55b. A micro servo is in the mail and I have to save up some pennies to get a GPS.
After some hair pulling dealing with real numbers, I believe I have the code ready for a north pointing compass.
My equation for determining the bearing between two points had unexpected but workable results. It returns 0 degrees for East, -90 for North, 90 for South and 180 for West.
Added an if statement to change the result into a 0-360 degree scheme that matches the compass.
The person's direction is pulled from the compass and the position the needle should point is worked out with another nested if.
Pretty sad looking code, but it has been a long time.
All that is left is to add code to manipulate the servo and to bring the (lat2/long2) values from the gps.
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 Enable = 0 Clock = 1 Data = 2 OBJ F32 : "Float32full" vp : "Conduit" HM55B : "HM55B Compass Module Asm" VAR long lat1 long long1 long lat2 long long2 long r long degree long bearing long direction long needle 'long place1, place2, place3 'long first, second, third 'long place3 long angle PUB MAIN | temp vp.config(string("start:dso")) 'start in dso mode vp.config(string("var:degree(base=-2), bearing(base=-2), direction(base=-2), needle(base=-2)")) vp.share(@degree,@needle) F32.start HM55B.start(Enable,Clock,Data) lat1 := 28.963105 'coordinates have north bearing 0 long1 := -81.471019 lat2 := 28.963763 long2 := -81.471019 'place1 := F32.Radians(F32.Fsub(long2,long1)) The math for r broken down in chunks. 'place2 := f32.radians(f32.fsub(90.0,lat2)) 'place3 := f32.radians(f32.fsub(90.0,lat1)) 'first:= F32.fmul(F32.sin(F32.Radians(F32.Fsub(long2,long1))),F32.cos(f32.radians(f32.fsub(90.0,lat2)))) 'second:=F32.fmul(F32.cos(f32.radians(f32.fsub(90.0,lat1))),F32.sin(f32.radians(f32.fsub(90.0,lat2)))) 'third:=F32.fmul(F32.fmul(F32.sin(f32.radians(f32.fsub(90.0,lat1))),F32.cos(f32.radians(f32.fsub(90.0,lat2)))),f32.cos(F32.Radians(F32.Fsub(long2,long1)))) 'r := F32.atan2(f32.fsub(second,third),first) r := F32.atan2(f32.fsub(F32.fmul(F32.cos(f32.radians(f32.fsub (90.0,lat1))),F32.sin(f32.radians(f32.fsub(90.0,lat2)))),F32.fmul(F32.fmul(F32.sin (f32.radians(f32.fsub(90.0,lat1))),F32.cos(f32.radians(f32.fsub(90.0,lat2)))),f32.cos (F32.Radians(F32.Fsub(long2,long1))))),F32.fmul(F32.sin(F32.Radians(F32.Fsub(long2,long1))), F32.cos(f32.radians(f32.fsub(90.0,lat2))))) degree := F32.degrees(r) ' degree comes out 0:east -90:north 90:south 180,-180:west if f32.fcmp(degree,-90.0)==1 and f32.fcmp(0.0,degree)== 1 ' Convert degrees to 0-360 bearings bearing := f32.fsub(90.0,f32.fabs(degree)) elseif F32.fcmp(degree,-90.0) == 0 or F32.fcmp(degree,0.0) == 0 bearing := f32.fsub(90.0,f32.fabs(degree)) elseif f32.fcmp(-90.0,degree)==1 bearing := f32.fsub(450.0,f32.fabs(degree)) elseif f32.fcmp(degree,0.0)==1 bearing := f32.fadd(90.0,degree) repeat 'set needle position to point to destination depending on how you are facing direction := f32.fdiv(f32.degrees(HM55B.theta),1302) if f32.fcmp(181.0,direction) == 1 angle := direction if f32.fcmp(direction,bearing) == 1 temp := f32.fsub(direction,bearing) needle := f32.fsub(360.0,temp) else needle := f32.fsub(bearing,angle) else if f32.fcmp(bearing,0.0) == 0 bearing:= 360.0 angle := f32.fsub(360.0,direction) if f32.fcmp(bearing, direction) == 1 needle := f32.fsub(bearing,direction) else needle := f32.fsub(bearing,angle)
Post Edited (Thomas Fletcher) : 3/14/2009 1:45:21 PM GMT
Comments
For those of you that don't know what it is. Geocaching is a game/sport/hobby wherein someone hides a "cache", a waterproof
container, and posts GPS coordinates and hints on the Geocaching website. Sometimes there is a prize exchange in the
cache(usually with a theme, but never expensive), sometimes a logbook. The real reward is getting out for a good hike,
and solving the puzzle of where it's hidden. You'd be surprised how many people that participate in this activity (I just checked,
there are 497 active geocaches within 25 miles of my location and 743,828 worldwide)
one small question. Most servos I have used do not have the ability to turn a full 360 degrees. Except of course the continuous rotation
servos that are used to drive the wheels on a BOEBot. But the continuous rotation servos have no positional feedback. How do you plan
to accomplish the positioning of the needle with a full 360 degree sweep?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Brian
uController.com - home of SpinStudio - the modular Development system for the Propeller
PropNIC - Add ethernet ability to your Propeller! PropJoy - Plug in a joystick and play some games!
SD card Adapter - mass storage for the masses Audio/Video adapter add composite video and sound to your Proto Board
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Brian
uController.com - home of SpinStudio - the modular Development system for the Propeller
PropNIC - Add ethernet ability to your Propeller! PropJoy - Plug in a joystick and play some games!
SD card Adapter - mass storage for the masses Audio/Video adapter add composite video and sound to your Proto Board
Scott
Hmmm. Did not know that.
This is a video for hacking servos for 360 movement.
http://www.metacafe.com/watch/yt-CtLN8BoMIlQ/robot_builders_guide_3_hacking_a_servo/
I wonder if you just stopped at the first step in the video if you could pulse up into the higher positions that become available by
removing the locking stub.
lose all feedback. You'd need some sort of position encoder to resolve direction.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Brian
uController.com - home of SpinStudio - the modular Development system for the Propeller
PropNIC - Add ethernet ability to your Propeller! PropJoy - Plug in a joystick and play some games!
SD card Adapter - mass storage for the masses Audio/Video adapter add composite video and sound to your Proto Board
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Need to make your prop design easier or secure? Get a PropMod has crystal, eeprom, and programing header in a 40 pin dip 0.7" pitch module with uSD reader, and RTC options.
hahaha
running count of the # of steps and in which direction you stepped, But if you lost a few steps here or there by bumping the needle
position, your direction will continue to be off.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Brian
uController.com - home of SpinStudio - the modular Development system for the Propeller
PropNIC - Add ethernet ability to your Propeller! PropJoy - Plug in a joystick and play some games!
SD card Adapter - mass storage for the masses Audio/Video adapter add composite video and sound to your Proto Board
This guy sounds like he will do the trick. More money then I was planning on spending but maybe I will make a robo-owl in the future.
www.acroname.com/robotics/parts/R298-1T-SERVO.html
A single hall-effect or photo interrupter used as a zero point calibration would solve that pretty quickly. If you were worried about bumping or otherwise you can run a quick (and it would be quick) periodic re-calibration.
The Navman marine wind instruments are stepper driven and use a hall effect to determine zero point. Actually, now I think of it the Speedo and Tacho in my Audi were stepper units also.
Personally I'd be using something like a mobile phone LCD or OLED and a virtual display/pointer.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cardinal Fang! Fetch the comfy chair.
Cool project!
Jim-
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Signature space for rent, only $1.
Send cash and signature to CannibalRobotics.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Whit+
"We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths." - Walt Disney
interested in going in the direction the needle is pointing instead of getting a heading off of North. You can always take it all apart and add an encoder later.
Just an idea.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Need to make your prop design easier or secure? Get a PropMod has crystal, eeprom, and programing header in a 40 pin dip 0.7" pitch module with uSD reader, and RTC options.
If you are going to do that you may as well use a stepper and a hall or photo interrupter.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cardinal Fang! Fetch the comfy chair.
I read your project description and it brought back memories of me backpacking in Boy Scouts. Not to change what you had in mind for your project but I was thinking, it sounds like you are making something similar to a car GPS. If I understand the project description correctly, you are just looking for the direction to the next point. You might not need servo with a full 360 degree rotation. I am thinking that the direction of the needle only would provide a starting direction and correction indication. At the begining of your trip the needle could move to show the correct starting direction. If the endpoint was to your left, the needle could turn 90 degrees to the left, etc. As you physically start to turn in the correct direction, the needle would also start moving until it points straight in front of you. If you change directions from a straight line than the needle would move accordingly. With this type of movement, any points behind you could still be 'pointed to' by having the servo turn to it's max roation in the correct direction. As you turn in the correct direction, again, the needle would eventually point straight forward. Just a thought. Good luck.
I also liked the idea a while back of using leds on the needle as distance indicators. My needle is actually going to be a disk with an arrow and I thought about lighting up the arrow to show >3,000ft on down to within 10ft with 5 or 6 leds, but I can't decide
which way sounds better to me. Should the lights go out to the tip of arrow as you get closer? Or should the lights move back toward the center as you get closer?
I am also wondering about the wiring. I was thinking of using two disks with the bottom stationary wired disk having conductive tracks that powers the leds on the top moving disk (bumper car style) but I am wondering if this could cause sparks.
there should be more leds the closer you get think wifi finder and stronger signal if closer
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Need to make your prop design easier or secure? Get a PropMod has crystal, eeprom, and programing header in a 40 pin dip 0.7" pitch module with uSD reader, and RTC options.
I am making progress. I now have a very expensive compass. I haven't purchased a GPS yet so now it is just pointing north.
I haven't been able to get the 1T 360 servo to work at all as I believe it needs it's own power supply.
I was able to get the micro servos I got off of EBay for $5 each to work and used RobertW's suggestion to make use of the sub 90 degree arc of the servo.
I really like the effect but the servo is a lot louder then I thought they would be. Is there a whisper quite servo?