Main Page – Real time planet tracking system
Things you need :
- Arduino Mega (or MCU with more than 33Kbyte flash )- This is important because my final code was around 33KB and i couldnt fit it in an UNO.
- U-BLOX GPS Receiver ( NEO-6M ) or any GPS Module.
- MPU9250 (9 axis gyro-accelero-magneto) for auto Yaw stabilization [OPTIONAL]
- Pan- tilt Mechanism with Servos.(pan servo should be of 3.5turns and Tilt servo can be a normal 180 degree servo )
- A laser pointer –to be fixed to the tilt servo to show planet location in a closed rooom
- Optional Power Distribution board and Battery Eliminator Circuit (BEC).
- A Potentiometer to be used as Planet selector and a Switch as Mode Selector.
Starting with the GPS
Using the GPS is very easy when we use TinyGPS++ Libraries : http://arduiniana.org/libraries/tinygpsplus/
GPS uses Serial communication so I have connected it to Serial2 of Mega That is pin 16 and pin 17.
After connecting burn a test code from library named “FullExample“.The library use Software serial make sure you have converted it to Serial2 also change the GPSBaud to 9600. Also, have a look at the code named “DeviceExample“. Both of the aformentioned code examples can be found here.The reason why I am asking you to understand these codes because we will be using SmartDelay to update GPS values from the GPS buffer
1 2 3 4 5 6 7 8 9 |
static void smartDelay(unsigned long ms) { unsigned long start = millis(); do { while (ss.available()) gps.encode(ss.read()); } while (millis() - start < ms); } |
Also we will be using the following functions call statements to get Latitude,Longitude,Year,Month,Date,Day,Hour,Minute
1 2 3 4 5 6 7 |
gps.location.lat() gps.location.lng() gps.date.year() gps.date.month() gps.date.day() gps.time.hour() gps.time.minute() |
Now that we have our GPS ready we can go for pan-tilt mechanism with Laser.
We need to get a 3.5 turns Servo for PAN and a normal 180° Servo for TILT. I wont tell you much about a servo pan-tilt mechanism rather focus on the connections and its mapping.
Principle : The mechanisms used in pan tilt is the same as the one used for moving large telescopes in Space Observatory !
- The pan-tilt can rotate roughly 360° from side-to-side (pan motor) and can tilt up & downward (tilt motor) around 180°.
- A laser pointer will be mounted on this pan-tilt mechanism
- Calculated azimuth angle could be traced by pan motor. Elevation angle traced by tilt motor.
first the connections..we will be using Pin 9 for Pan Servo and Pin 10 for Tilt Servo
I have also added a potentiometer (present in the featured image at the top of this page, which is my final schematic) as a switch to select planets. This is optional and can be implemented easily.
Servo mapping
Just look on the servo library examples …you will understand how to make a servo work.We just need three lines of code from the library for each servo.
We need to define Servo objects and attach the pins and initialize them:
1 2 3 4 5 6 7 |
#include <servo.h> Servo myservoAz; // create servo object to control a servo Servo myservoEl; myservoAz.attach(9); //Attach the pins myservoEl.attach(10); myservoAz.write(5); //initialize the servo to go to its zero myservoEl.write(2); //for my servos it was 5 (for pan/azimuth servo) and 2(for tilt servo) |
Our pan servo is a 3.5 turns servo and it takes input from 5 to 29 to rotate from 0° to 360°
Then we do our mapping which is quit simple.Lets assume the variable “Azim” gives us the value of Azimuth and the variable “Elevation” altitude,then we do our mapping as
1 2 3 4 |
Azi = map(Azim, 0, 360, 5, 29); //its for my 3.5 turn servo that gives a 360° turn runs on values 5-29 Az = (int)Azi; Elev = map(Elevation, -90, 90, 2, 178); //its for my 180° servo that runs on values 0-180 El = (int)Elev; |
Azi and El are the right mappings and can be fed to the pan tilt as :
1 2 |
myservoAz.write(Az); myservoEl.write(El); |
Now all you need to do is convert the calculation of Azimuth-Altitude from the previous post into an Arduino code and use the data from GPS and get the output and feed it to the servo Link.
Note: You must align your pan-tilt setup at its initial position (both at 0° ) with the 0° Azimuth of your actual location ….that is nothing but North Direction!.
In the next post I’ll integrate MPU9250 so that my Pan Servo Automatically senses the north of my location and Automatically shows me the planet position by adjusting itself even if I dont keep it at Azimuth 0°…again this step is optional.
RTPT (Real Time Planet Tracking System and Trajectory Prediction) Copyright © 2016 Shubham Paul , Samhita Ganguly ,Rohit Kumar GNU GPL3+
Pingback: Real-Time Planet Tracking System & Trajectory Prediction | paulsite.com