3

I am working on an Arduino device I am building. I have bought a GPS module and a tilt sensing compas with an accelerometer.

I wish to determine true north so that I can always point an object towards the sun. Basically I want the device to always find true north wherever it is. The GPS will give a position, the compass will find magnetic north. I guess the true north can be obtained during movement of the device and written to RAM then retrieved for use when the device is stationary.

But how?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user701052
  • 31
  • 2
  • Magnetic north and true north seem close enough, no? – fingerman Apr 10 '11 at 17:31
  • A clock and GPS is enough ? That is great, since the GPS and arduino have a clock already. Is there a calculation I need to determine the suns position anywhere with just GPS + Clock ? Actually when in a stationary position how do you determine your direction ? to within a degree or so ? – user701052 Apr 10 '11 at 18:06
  • Without compass your device can not determine North accurately if it turns to the left or to the right without moving forward or backward. You can see the effect if you take a look at some GPS mapping software on a mobile phone or a car navigator device without embedded compass. When you turn left or right, your direction is much delayed on a display, since software needs significant movement to determine change of direction. – avra Apr 11 '11 at 09:16
  • 1
    If all you need is point to the sun, then you can have two light sensors point to +-45 degrees from the center of your rotational pointer. Then simply wake Arduino every minute and move 1 degree to the side where you get more light from. You can repeat this idea for vertical alignment, too. No GPS, no compass, no complicated astronomical calculations... – avra Apr 17 '11 at 22:13

2 Answers2

1

Are you trying to get the most sun for your rotational solar panel? If so then you can get away with just rough position setting between East and West according to your clock (you can improve this with taking long/lat position into the account to calculate sun rise and sun set times). You will need a lot of astronomy calculations if you want to control both azimuth and elevation precisely. Arduino does not support double, and with single you will not have very accurate results (they will be enough for solar panel tracker, but not enough if you want telescope to track some sky object). My advice would be to either investigate a lot on the topic, or take a look at some open source astronomy software and extract the needed calculations from the source (if licence terms permit). Just to give you a hint, this is a small extract from PilotLogic TMoon component that you can get in CodeTyphon/Lazarus/FPC installation package found here:

procedure Sun_Position_Horizontal(date:TdateTime; longitude,latitude: extended; var elevation,azimuth: extended);
var
  pos1: T_Coord;
begin
  pos1 := sun_coordinate(date);
  calc_horizontal(pos1,date,longitude,latitude);
end;

function sun_coordinate(date:TDateTime):t_coord;
var
  l,b,r: extended;
  lambda,t: extended;
begin
  earth_coord(date,l,b,r);
  (* convert earth coordinate to sun coordinate *)
  l := l+180;
  b := -b;
  (* conversion to FK5 *)
  t := (julian_date(date)-2451545.0)/365250.0*10;
  lambda:=l+(-1.397-0.00031*t)*t;
  l := l-0.09033/3600;
  b := b+0.03916/3600*(cos_d(lambda)-sin_d(lambda));
  (* aberration *)
  l := l-20.4898/3600/r;
  (* correction of nutation - is done inside calc_geocentric *)
{   calc_epsilon_phi(date,delta_phi,epsilon); }
{   l := l+delta_phi; }
  (* fill result and convert to geocentric *)
  result.longitude := put_in_360(l);
  result.latitude := b;
  result.radius := r*AU;
  calc_geocentric(result,date);
end;

procedure calc_horizontal(var coord:t_coord; date:TDateTime; longitude,latitude: extended);
var
  h: extended;
begin
  h := put_in_360(star_time(date)-coord.rektaszension-longitude);
  coord.azimuth := arctan2_d(sin_d(h), cos_d(h)*sin_d(latitude)-
                             tan_d(coord.declination)*cos_d(latitude));
  coord.elevation := arcsin_d(sin_d(latitude)*sin_d(coord.declination)+
                              cos_d(latitude)*cos_d(coord.declination)*cos_d(h));
end;

If you had a case that your device is not moving after installation (which is not the case after I reread your question so you can ignore the rest of the message), then your longitude and latitude are fixed and you know them at compile time, or you can enter them manually when device is first installed. That way GPS is not needed. You can also find North once at installation time, so you don't need compass either.

avra
  • 3,690
  • 19
  • 19
0

Compass will get haywire when it gets near some magnetic material and will not be practical at all. You can calculate the azimuth and elevation of the sun with respect to your location. It is more practical to use some digital encoders with your system and make calculated incremental movements. A calibrate button on the arduino could be used to normalize the parameters using a standard tools. For fine tune, manual buttons could be provided for up and down movements.

seccpur
  • 4,996
  • 2
  • 13
  • 21