DAFTAR PUSTAKA Evans, Brian. 2011. Beginning Arduino Programming, Technologi in Action. Apress Margolis, Michael.2011.Arduino Cookbook 2nd Edition Recipe 6.14: Getting Location from a GPS. O’Reilly Media, Inc. Advantages and Disadvantages Global Positioning System, http://www.roseindia.net/services/trackingsystem/advantaesanddisadvantagesofgps.sh tml (4 November 2014) An Arduino powered, easily extendable GPS Datalogger, http://www.openelectronics.org/an-arduino-powerer-easily-extendable-gps-datalogger/ (4 November 2014) Architecture and programming of 8051 MCU's, http://www.mikroe.com/chapters/view/64/chapter-1-introduction-to-microcontrollers/ (5 November 2014) Arduino and GPS Receivers, http://www.hobbytronics.co.uk/arduino-gps-receiver (4 November 2014) Arduino GPS Map Navigation System, http://www.elecfreaks.com/projects/arduinogps-map-navigation-system/ (7 November 2014) Arduino GPS tutorial Latitude and Longitude Coordinates, http://allaboutee.com/2012/12/03/arduino-gps-tutorial-get-latitude-and-longitudecoordinates/ (9 November 2014)
118
119
Arduino IMU: Pitch & Roll from an Accelerometer, http://theccontinuum.com/2012/09/24/arduino-imu-pitch-roll-from-accelerometer/ Arduino Mega 2560 R3, http://arduino.cc/en/Main/arduinoBoardMega2560 (31 Oktober 2014) Data Logging from NMEA Devices, http://www.windmill.co.uk/nmea.html (4 November 2014) DFRDuino GPS Shield LEA-5H, http://www.dfrobot.com/wiki/index.php/DFRduino_GPS_Shield-LEA5H_%28SKU:TEL0044%29 (30 Oktober 2014) GPS - NMEA sentence information, http://aprs.gids.nl/nmea/ (4 November 2014) GPS on Arduino, http://quaxio.com/arduino_gps/ (9 November 2014) GPS Shield Quickstart Guide, https://www.sparkfun.com/tutorials/173 (5 November 2014) GPS Tutorial, http://playground.arduino.cc/Tutorials/GPS (5 November 2014) How Parabolic Dish Antennas work?, http://www.analyzemath.com/parabola/parabola_work.html (4 November 2014) I2C Arduino GPS shield, http://hackaday.com/2011/05/24/i2c-arduino-gps-shield/ Lesson 24 Understanding GPS NMEA sentences, http://www.toptechboy.com/highaltitude-ballooning/lesson-24-understanding-gps-nmea-sentences/ (5 November 2014) Marine electronics, NMEA and Arduino, http://www.skrue.de/wp/?p=63 (5 November 2014) NMEA DATA http://www.gpsinformation.org/dale/nmea.htm, (5 November 2014)
120
Reading GPS Data, https://learn.sparkfun.com/tutorials/gps-basics/reading-gps-data (5 November 2014) Satellite Communication History, http://history.nasa.gov/satcomhistory.html (5 November 2014) The Parabolic Reflector Antenna (Satellite Dish), http://www.antennatheory.com/antennas/reflectors/dish.php (4 November 2014) Tilt Compensation Azimuth ? with Pitch Ø et le Roll ?, http://diy.powet.eu/2011/03/19/tilt-compensation-azimuth-pitch-le-roll/?lang=en (10 November 2014) Using the Accelerometer, http://husstechlabs.com/projects/atb1/using-theaccelerometer/ (10 November 2014) Wahyu Pamungkas, Pointing antena parabola dan perhitungan interferensi satelit, https://www.academia.edu/6347703/Pointing_antena_parabola_dan_perhitungan_inte rferensi_satelit (13 November 2014) What is GPS?, http://www8.garmin.com/aboutGPS/ (5 November 2014) What is Satellite, http://www.nasa.gov/audience/forstudents/5-8/features/what-is-asatellite-58.html (5 November 2014)
LAMPIRAN char mapping[]={'1','2','3','A','4','5','6', 'B','7','8','9','C','.','0','-','D'}; byte pins[]={29, 27, 25, 23, 37, 35, 33, 31};
#include "Wire.h" #include "I2Cdev.h" // Inisialisasi GPS #if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" #define WireSend(args) Wire.write(args) #define WireRead(args) Wire.read(args) #define printByte(args) Serial.write(args) #define printlnByte(args) Serial.write(args),Serial.println() #else #include "WProgram.h" #define WireSend(args) Wire.send(args) #define WireRead(args) Wire.receive(args) #define printByte(args) Serial.print(args,BYTE) #define printlnByte(args) Serial.println(args,BYTE) #endif
phi_matrix_keypads my_btns(mapping, pins, 4, 4); phi_serial_keypads debug_keypad(&Serial,38400); multiple_button_input * keypads[] = {&my_btns,&debug_keypad,0}; char up_keys[]={"2"}; char down_keys[]={"8"}; char left_keys[]={" "}; char right_keys[]={" "}; char enter_keys[]={'A','5'}; char escape_keys[]={" "}; char * function_keys[]={up_keys,down_keys,left _keys,right_keys,enter_keys,escape_keys }; // Selesai
#define BUFFER_LENGTH 16 //Menyimpan pesan dalam memori PROGMEM prog_char msg_00[]=" Sist. Kendali\n Otomatis Antena\n Parabola\n Tekan 'ENT'\n untuk melanjutkan"; PROGMEM prog_char msg_01[]=" M Nashiruddin A\n NIM 41412120121\n Univ. Mercubuana\n Th. 2014\n Tekan 'ENT'\n untuk melanjutkan"; PROGMEM prog_char msg_02[]=" Panduan Pengguna:\n tombol arah atas bawah untuk navigasi \n tombol ENT untuk masuk/ aktifkan dan Back untuk kembali\n Tombol '-' untuk menandakan lintang selatan atau bujur barat\n Tombol '.' untuk menandakan notasi koma. Prototipe alat tugas akhir ini sudah dilengkapi fitur otomatis dan manual di setiap menu nya untuk menggerakan antena secara otomatis dan manual.\n Disertai pengaturan offset untuk jenis antena dengan LNB offset.\n Tekan 'ENT'\n untuk melanjutkan";
int GPSAddress = 0x42; // Selesai //Inisialisasi Accelerometer #include "Adafruit_Sensor.h" #include "Adafruit_ADXL345_U.h" Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345); //Selesai // Inisialisasi Kompas #include "compass.h" //Selesai //Inisialisasi LCD #define lcd_rows 4 #define lcd_columns 20 #define #define #define #define #define #define
LCD_RS LCD_EN LCD_D4 LCD_D5 LCD_D6 LCD_D7
22 24 26 28 30 32
#include <Servo.h> Servo servo_azim, servo_elev; // Definisi pembacaan input teks char bufsat[8]; char buflon[8]; char buflat[8]; char bufoffset[6]; char bufaz[4]; char bufel[4]; int i;
#include "LCD.h" #include "LiquidCrystal.h" LiquidCrystal lcd(LCD_RS,LCD_EN,LCD_D4,LCD_D5,LCD_D6, LCD_D7); // Selesai
// Definisi tambahan azimuth, elevasi, kompas, GPS float pulse_az,pulse_el; int sudut_az=0; int sudut_el=0;
// Inisialisasi Keypad dan Menu Navigasi #include "phi_interfaces.h" #include "phi_prompt.h"
121
122
int el=0; int az=0; float Azimuth=0; float Elevasi=0; int Polar=0; int servo_az = 34; int servo_el = 36; float ant_offset=0; int sudut_awal = 0; float mata_angin; float koordinat_long=0; float koordinat_lat=0; char arah_long,arah_lat; //database koordinat satelit float satelit_palapa_d = 113; float satelit_telkom1 = 108.2; float satelit_telkom2 = 118; float satelit_asiasat3 = 120; float satelit_asiasat5 = 100.5; float satelit; void setup() { //Set up Serial dan wire Serial.begin(38400); Wire.begin(); accel.begin(); accel.setRange(ADXL345_RANGE_8_G); //Set up Kompas compass_x_offset = 102.34; compass_y_offset = 111.28; compass_z_offset = 366.35; compass_x_gainError = 0.98; compass_y_gainError = 0.99; compass_z_gainError = 1.01; // compass_init(2); // compass_debug = 1; // compass_offset_calibration(3); //Set up LCD lcd.begin(lcd_columns, lcd_rows); init_phi_prompt(&lcd, keypads ,function_keys, lcd_columns, lcd_rows, '\x7e'); lcd.clear(); lcd.setCursor(3,1); lcd.print("Mohon Tunggu"); lcd.setCursor(2,2); lcd.print("Kalibrasi Servo"); for (int i=0;i<3;i++) { lcd.print("."); delay(500); } lcd.blink(); //Set up servo dan kalibrasi awal servo_azim.attach(servo_az,975,1940); servo_elev.attach(servo_el,945,1940); for(sudut_awal = 0; sudut_awal <= 180; sudut_awal++) // goes from 0 degrees to 180 degrees { sudut_az=sudut_awal;
sudut_el=180-sudut_awal; if (sudut_el<90) sudut_el=90; servo_elevasi(); servo_azimuth(); lcd.setCursor(8,3); lcd.print(sudut_awal);lcd.print(char(22 3));lcd.print(" "); } for(sudut_awal = 180; sudut_awal >= 0; sudut_awal--) // goes from 180 degrees to 0 degrees { sudut_az=sudut_awal; sudut_el=sudut_awal/2; servo_elevasi(); servo_azimuth(); lcd.setCursor(8,3); lcd.print(sudut_awal);lcd.print(char(22 3));lcd.print(" "); } //Menampilkan Kredit Menu tentang_skripsi(); } void loop() { menu_utama(); } // Inisialisasi Menu Utama PROGMEM prog_char top_menu_item00[]="Set Otomatis"; PROGMEM prog_char top_menu_item01[]="Set Manual"; PROGMEM prog_char top_menu_item02[]="Tentang Skripsi"; PROGMEM prog_char top_menu_item03[]="Tentang Saya"; PROGMEM prog_char top_menu_item04[]="Panduan Penggunaan"; PROGMEM const char *top_menu_items[] = {top_menu_item00, top_menu_item01, top_menu_item02, top_menu_item03, top_menu_item04}; PROGMEM prog_char sub_menu_2_item00[]="Ant. Center Fokus"; PROGMEM prog_char sub_menu_2_item01[]="Ant. Offset Fokus"; PROGMEM prog_char sub_menu_2_item02[]="Kembali"; PROGMEM const char *sub_menu_2_items[] = {sub_menu_2_item00, sub_menu_2_item01, sub_menu_2_item02}; PROGMEM prog_char sub_menu_1_item00[]="1. PROGMEM prog_char sub_menu_1_item01[]="2. PROGMEM prog_char sub_menu_1_item02[]="3. PROGMEM prog_char sub_menu_1_item03[]="4.
Palapa D"; Telkom 1"; Telkom 2"; Asiasat 3";
123
break;
PROGMEM prog_char sub_menu_1_item04[]="5. Asiasat 5"; PROGMEM prog_char sub_menu_1_item05[]="6. Input Manual"; PROGMEM prog_char sub_menu_1_item06[]="Kembali"; PROGMEM const char *sub_menu_1_items[] = {sub_menu_1_item00, sub_menu_1_item01, sub_menu_1_item02, sub_menu_1_item03, sub_menu_1_item04, sub_menu_1_item05, sub_menu_1_item06};
case 2: tentang_skripsi(); break; case 3: tentang_saya(); break; case 4: panduan(); break;
int global_style=109; void menu_utama() { int menu_pointer_1=0; phi_prompt_struct myMenu; myMenu.ptr.list=(char**)&top_menu_items ; myMenu.low.i=0; myMenu.high.i=4; myMenu.width=lcd_columns((global_style&phi_prompt_arrow_dot)!=0 )((global_style&phi_prompt_scroll_bar)!= 0); myMenu.step.c_arr[0]=lcd_rows-1; myMenu.step.c_arr[1]=1; myMenu.step.c_arr[2]=0; myMenu.step.c_arr[3]=lcd_columns-4((global_style&phi_prompt_index_list)!= 0); myMenu.col=0; myMenu.row=1; myMenu.option=global_style; while(1) { kompas(); latitude(); longitude(); lcd.clear(); //center_text(" Menu Utama "); lcd.setCursor(0,0); lcd.print(">>Kompas=");lcd.print(mata_a ngin);lcd.print(char(223)); myMenu.option=global_style; myMenu.width=lcd_columns((global_style&phi_prompt_arrow_dot)!=0 )((global_style&phi_prompt_scroll_bar)!= 0); myMenu.step.c_arr[3]=lcd_columns-4((global_style&phi_prompt_index_list)!= 0); select_list(&myMenu); menu_pointer_1=myMenu.low.i; switch (menu_pointer_1) { case 0: pilihan_antena(); break; case 1: menu_manual();
default: break; } } } void pilihan_antena() { int menu_pointer_1=0; phi_prompt_struct myMenu;
myMenu.ptr.list=(char**)&sub_menu_2_ite ms; myMenu.low.i=0; myMenu.high.i=2; myMenu.width=lcd_columns((global_style&phi_prompt_arrow_dot)!=0 )((global_style&phi_prompt_scroll_bar)!= 0); myMenu.step.c_arr[0]=lcd_rows-1; myMenu.step.c_arr[1]=1; myMenu.step.c_arr[2]=0; myMenu.step.c_arr[3]=lcd_columns-4; myMenu.col=0; myMenu.row=1; myMenu.option=global_style; while(1) { kompas(); latitude(); longitude(); lcd.clear(); center_text(" Tipe Antena "); myMenu.option=global_style; myMenu.width=lcd_columns((global_style&phi_prompt_arrow_dot)!=0 )((global_style&phi_prompt_scroll_bar)!= 0); select_list(&myMenu); menu_pointer_1=myMenu.low.i; switch (menu_pointer_1) { case 0: ant_offset=0; menu_otomatis(); break; case 1: antena_offset(); break;
124
for (int a=5; a>0; a--) { lcd.setCursor(6,3); lcd.print(a); lcd.print(" detik"); delay(1000); } antena_offset();
case 2: menu_utama();; break; default: break; }
} menu_otomatis();
} } } void antena_offset() { i=0; bufoffset[0] = '\0'; lcd.clear(); center_text("Masukkan OFFSET"); lcd.setCursor(0,1); lcd.print("OFFSET:");lcd.print("_____ 0 ~ 30"); lcd.setCursor(7,1); lcd.print(bufoffset); lcd.setCursor(12,2); lcd.print("ENT:SAVE"); lcd.setCursor(12,3); lcd.print(char(127));lcd.print(":BACK") ; lcd.blink(); while( i < sizeof(bufoffset) - 1) { char temp=my_btns.getKey(); if (temp == 'A') { break; } if (temp == 'B') { pilihan_antena(); } if (temp == 'C' || temp == 'D' || temp == '-') { i=i; } else if ( temp != NO_KEY) { bufoffset[i] = temp; i++; bufoffset[i]= '\0'; } lcd.setCursor(7,1); lcd.print(bufoffset); } String offset = bufoffset; offset.toCharArray(bufoffset, sizeof(bufoffset)); ant_offset = atof(bufoffset); if (ant_offset > 30 || ant_offset < 0) { lcd.clear(); lcd.setCursor(1,0); lcd.print("Offset diluar Range"); lcd.setCursor(3,2); lcd.print("Kembali dalam");
void menu_otomatis() { int menu_pointer_1=0; phi_prompt_struct myMenu; myMenu.ptr.list=(char**)&sub_menu_1_ite ms; myMenu.low.i=0; myMenu.high.i=6; myMenu.width=lcd_columns((global_style&phi_prompt_arrow_dot)!=0 )((global_style&phi_prompt_scroll_bar)!= 0); myMenu.step.c_arr[0]=lcd_rows-1; myMenu.step.c_arr[1]=1; myMenu.step.c_arr[2]=0; myMenu.step.c_arr[3]=lcd_columns-4; myMenu.col=0; myMenu.row=1; myMenu.option=global_style; while(1) { kompas(); latitude(); longitude(); lcd.clear(); //center_text(" Set Otomatis "); lcd.setCursor(0,0); lcd.print(">>>Offset=");lcd.print(ant_o ffset);lcd.print(char(223)); myMenu.option=global_style; myMenu.width=lcd_columns((global_style&phi_prompt_arrow_dot)!=0 )((global_style&phi_prompt_scroll_bar)!= 0); select_list(&myMenu); menu_pointer_1=myMenu.low.i; switch (menu_pointer_1) { case 0: palapa_d(); break; case 1: telkom1(); break; case 2: telkom2(); break;
125
case 3: asiasat3(); break; case 4: asiasat5(); break; case 5: input_manual(); break; case 6: pilihan_antena();; break; default: break; } } } void palapa_d() { notifikasi_gps(); satelit=satelit_palapa_d; perhitungan_az_el(); arah_servo(); lcd.clear(); lcd.print(">>Palapa D =");lcd.print(satelit);lcd.print(char(2 23));lcd.print("<"); menu_set_otomatis(); servo_otomatis(); gerak_servo_manual(); } void telkom1() { notifikasi_gps(); satelit=satelit_telkom1; perhitungan_az_el(); arah_servo(); lcd.clear(); lcd.print(">>Telkom 1 =");lcd.print(satelit);lcd.print(char(2 23));lcd.print("<"); menu_set_otomatis(); servo_otomatis(); gerak_servo_manual(); } void telkom2() { notifikasi_gps(); satelit=satelit_telkom2; perhitungan_az_el(); arah_servo(); lcd.clear(); lcd.print(">>Telkom 2 =");lcd.print(satelit);lcd.print(char(2 23));lcd.print("<"); menu_set_otomatis(); servo_otomatis(); gerak_servo_manual(); } void asiasat3()
{ notifikasi_gps(); satelit=satelit_asiasat3; perhitungan_az_el(); arah_servo(); lcd.clear(); lcd.print(">Asiasat 3 =");lcd.print(satelit);lcd.print(char(2 23));lcd.print("<"); menu_set_otomatis(); servo_otomatis(); gerak_servo_manual(); } void asiasat5() { notifikasi_gps(); satelit=satelit_asiasat5; perhitungan_az_el(); arah_servo(); lcd.clear(); lcd.print(">Asiasat 5 =");lcd.print(satelit);lcd.print(char(2 23));lcd.print("<"); menu_set_otomatis(); servo_otomatis(); gerak_servo_manual(); } void input_manual() { kompas(); i=0; bufsat[0] = '\0'; buflon[0] = '\0'; buflat[0] = '\0'; bufoffset[0] = '\0'; lcd.clear(); lcd.blink(); lcd.print("Sat:");lcd.print("_______"); lcd.setCursor(4,0); lcd.print(bufsat); lcd.setCursor(12,0); lcd.print("C:");lcd.print(mata_angin);l cd.print(" "); lcd.setCursor(0,1); lcd.print("Lat:");lcd.print("_______"); lcd.setCursor(12,1); lcd.print("\'-\':AXIS"); lcd.setCursor(4,1); lcd.print(buflat); lcd.setCursor(0,2); lcd.print("Lon:");lcd.print("_______"); lcd.setCursor(4,2); lcd.print(buflon); lcd.setCursor(12,2); lcd.print("ENT:SAVE"); lcd.setCursor(0,3); lcd.print("OFFSET:");//lcd.print("___") ; lcd.setCursor(7,3); lcd.print(ant_offset); lcd.setCursor(14,3);
126
lcd.print(char(127));lcd.print(":BACK") ; while( i < sizeof(bufsat) - 1) { char temp=my_btns.getKey(); if (temp == 'A') { break; } if (temp == 'B') { menu_otomatis(); } if (temp == 'C' || temp == 'D') { i=i; } else if ( temp != NO_KEY) { bufsat[i] = temp; i++; bufsat[i]= '\0'; } lcd.setCursor(4,0); lcd.print(bufsat); } String sat = bufsat; sat.toCharArray(bufsat, sizeof(bufsat)); float sat2 = atof(bufsat); i=0; while( i < sizeof(buflat) - 1) { char temp=my_btns.getKey(); if (temp == 'A') { break; } if (temp == 'B') { menu_otomatis(); } if (temp == 'C' || temp == 'D') { i=i; } else if ( temp != NO_KEY) { buflat[i] = temp; i++; buflat[i]= '\0'; } lcd.setCursor(4,1); lcd.print(buflat); } String lat = buflat; lat.toCharArray(buflat, sizeof(buflat)); float lat2 = atof(buflat); if(lat2 > 0 || lat2 < 0) koordinat_lat=lat2; if(lat2 == 0) latitude();
i=0; while( i < sizeof(buflon) - 1) { char temp=my_btns.getKey(); if (temp == 'A') { break; } if (temp == 'B') { menu_otomatis(); } if (temp == 'C' || temp == 'D') { i=i; } else if ( temp != NO_KEY) { buflon[i] = temp; i++; buflon[i]= '\0'; } lcd.setCursor(4,2); lcd.print(buflon); } String lon = buflon; lon.toCharArray(buflon, sizeof(buflon)); float lon2 = atof(buflon); if(lon2 > 0 || lon2 < 0) koordinat_long=lon2; if(lon2 == 0) longitude(); // i=0; // while( i < sizeof(bufoffset) - 1) // { // char temp=my_btns.getKey(); // if (temp == 'A') // { // break; // } // if (temp == 'B') // { // menu_otomatis(); // } // if (temp == 'C' || temp == 'D' || temp == '-' || temp == '.') // { // i=i; // } // else if ( temp != NO_KEY) // { // bufoffset[i] = temp; // i++; // bufoffset[i]= '\0'; // } // lcd.setCursor(7,3); // lcd.print(bufoffset); // } // // String offset = bufoffset; // offset.toCharArray(bufoffset, sizeof(bufoffset)); // ant_offset = atof(bufoffset); if (sat2 > 180 || sat2 < -180 || koordinat_lat > 80 || koordinat_lat < -
127
80 || koordinat_long > 180 || koordinat_long < -180)// || ant_offset > 30 || ant_offset < 0) { lcd.clear(); lcd.setCursor(1,0); lcd.print("Koordinat diluar"); lcd.setCursor(6,1); lcd.print("Range"); lcd.setCursor(3,2); lcd.print("Kembali dalam"); for (int a=5; a>0; a--) { lcd.setCursor(6,3); lcd.print(a); lcd.print(" detik"); delay(1000); } input_manual(); } satelit=sat2; notifikasi_gps_manual(); perhitungan_az_el(); arah_servo(); lcd.clear(); lcd.noBlink(); lcd.print(">>Satelit =");lcd.print(satelit);lcd.print(char(2 23));lcd.setCursor(19,0);lcd.print("<") ; menu_set_otomatis(); servo_otomatis(); gerak_servo_manual(); } void menu_manual() { kompas(); latitude();lat_dir(); longitude();lon_dir(); i=0; bufaz[0] = '\0'; bufel[0] = '\0'; notifikasi_gps_manual(); lcd.clear(); lcd.setCursor(0,0); center_text(" Set Manual "); lcd.setCursor(0,1); lcd.print("Lat:"); lcd.setCursor(4,1); lcd.print(koordinat_lat);lcd.print((cha r)223);lcd.print(" ");lcd.setCursor(11,1);lcd.print(arah_l at); lcd.setCursor(0,2); lcd.print("Lon:"); lcd.setCursor(4,2); lcd.print(koordinat_long);lcd.print((ch ar)223);lcd.print(" ");lcd.setCursor(11,2);lcd.print(arah_l ong); lcd.setCursor(0,3); lcd.print("C :");lcd.print(mata_angin);lcd.print((ch
ar)223);lcd.print(" ");lcd.setCursor(11,3);lcd.print("U"); lcd.setCursor(13,3); lcd.print((char)127);lcd.print("=EXIT") ; lcd.setCursor(13,1); lcd.print("EL:"); lcd.setCursor(13,2); lcd.print("AZ:"); lcd.blink(); while( i < sizeof(bufel) - 1) { char temp=my_btns.getKey(); if (temp == 'A') { break; } if (temp == 'B') { menu_utama(); } if (temp == 'C' || temp == 'D' || temp == '-' || temp == '.') { i=i; } else if ( temp != NO_KEY) { bufel[i] = temp; i++; bufel[i]= '\0'; } lcd.setCursor(16,1); lcd.print(bufel); } String elev = bufel; elev.toCharArray(bufel, sizeof(bufel)); el = atof(bufel); i=0; while( i < sizeof(bufaz) - 1) { char temp=my_btns.getKey(); if (temp == 'A') { break; } if (temp == 'B') { menu_utama(); } if (temp == 'C' || temp == 'D' || temp == '-' || temp == '.') { i=i; } else if ( temp != NO_KEY) { bufaz[i] = temp; i++; bufaz[i]= '\0'; } lcd.setCursor(16,2); lcd.print(bufaz); } String azim = bufaz;
128
{
azim.toCharArray(bufaz, sizeof(bufaz)); az = atof(bufaz);
i++; if(i==7) { Wire.endTransmission(); return 1;
servo_otomatis(); gerak_servo_manual(); }
} } else i=0;
//Inisialisasi data logging dari GPS double Datatransfer(char *data_buf,char num) { double temp=0.0; unsigned char i,j;
} Wire.endTransmission(); } }
if(data_buf[0]=='-') { i=1; while(data_buf[i]!='.') temp=temp*10+(data_buf[i++]0x30); for(j=0;j
void rec_data(char *buff,char num1,char num2) { char i=0,count=0; if(ID()) { while(1) { rec_init(); while(Wire.available()) { buff[i] = WireRead(); if(count!=num1) { if(buff[i]==',') count++; } else { i++; if(i==num2) { Wire.endTransmission(); return; } } } Wire.endTransmission(); } }
void rec_init() { Wire.beginTransmission(GPSAddress); WireSend(0xff); Wire.endTransmission();
} void latitude() { char dir[1]={'0'}; rec_data(dir,2,1); char lat[10]={
Wire.beginTransmission(GPSAddress); Wire.requestFrom(GPSAddress,10); } char ID() { char i = 0; char value[7]={ '$','G','P','G','G','A',',' char buff[7]={ '0','0','0','0','0','0','0' while(1) { rec_init(); while(Wire.available()) { buff[i] = WireRead(); if(buff[i]==value[i])
}; };
'0','0','0','0','0','0','0','0','0','0' }; rec_data(lat,1 ,10); String latstring = lat; latstring.toCharArray(lat, sizeof(lat)); float lat2floatawal = atof(lat); int lat2digitawal = lat2floatawal/100; float latfloat = (lat2floatawal lat2digitawal*100)/60; float latdeg=lat2digitawal + latfloat;
129
switch (dir[0]) { case 'N': latdeg=latdeg; case 'S': latdeg=-1*latdeg; default : break; } koordinat_lat=latdeg; } void lat_dir() { char lintang; char dir[1]={'0'}; rec_data(dir,2,1); switch (dir[0]) { case 'N': lintang = 'U'; case 'S': lintang = 'S'; default : break; } arah_lat=lintang; } void longitude() { char dir[1]={'0'}; rec_data(dir,4,1); char lon[11]={ '0','0','0','0','0','0','0','0','0','0' ,'0' }; rec_data(lon,3,11); String lonstring = lon; lonstring.toCharArray(lon, sizeof(lon)); float lon2floatawal = atof(lon); int lon2digitawal = lon2floatawal/100; float lonfloat = (lon2floatawal lon2digitawal*100)/60; float londeg = lon2digitawal + lonfloat; switch (dir[0]) { case 'W': londeg=-1*londeg; case 'E': londeg=londeg; default : break; } koordinat_long=londeg; } void lon_dir() { char bujur; char dir[1]={'0'}; rec_data(dir,4,1); switch (dir[0]) { case 'W': bujur = 'B'; case 'E': bujur = 'T'; default : break; } arah_long=bujur;
// Program Kompas dan Akselerometer // Mengambil data Kompas void kompas() { compass_scalled_reading(); //Pembacaan sumbu X, Y, Z kompas float Xcom=compass_x_scalled; float Ycom=compass_y_scalled; float Zcom=compass_z_scalled; //Mengambil data Accelerometer sensors_event_t event; accel.getEvent(&event); //Pembacaan sumbu X, Y, Z accelerometer float Xacc=event.acceleration.x; float Yacc=event.acceleration.y; float Zacc=event.acceleration.z; //Menghitung Pitch dan Roll accelerometer float rollRadians = atan2 (Yacc, Zacc) ; float pitchRadians = atan2 (Xacc, Zacc) ; if(rollRadians > 0.78 || rollRadians < -0.78 || pitchRadians > 0.78 || pitchRadians < -0.78) { rollRadians = NAN; pitchRadians = NAN; } //Menghitung arah kompas dengan toleransi Accelerometer float cosRoll = cos(rollRadians); float sinRoll = sin(rollRadians); float cosPitch = cos(pitchRadians); float sinPitch = sin(pitchRadians); float Xtol = Xcom * cosPitch + Zcom * sinPitch; float Ytol = Xcom * sinRoll * sinPitch + Ycom * cosRoll - Zcom * sinRoll * cosPitch; mata_angin=atan2(Ytol, Xtol); // Koreksi sudut dengan pengaruh deklinasi magnetik dari www.magneticdeclination.com float sudut_deklinasi = 0.7667; mata_angin = mata_angin + sudut_deklinasi; // Perbaikan jika simbol negatif if(mata_angin < 0) mata_angin = mata_angin + 2*PI; // Cek penambahan deklinasi if(mata_angin > 2*PI) mata_angin = mata_angin - 2*PI;
} // Selesai
// Ubah nilai radians ke degree untuk mempermudah pembacaan mata_angin = mata_angin * 180/PI;
130
//koreksi sumbu Utara karena Antena mengarah ke Barat mata_angin = mata_angin -135; //koreksi jika mata_angin bernilai negatif if (mata_angin<0) mata_angin = mata_angin+360; } // Selesai void menu_set_otomatis() { lcd.setCursor(0,1);lcd.print("Lat:");lc d.print(koordinat_lat);lcd.print(" "); lcd.setCursor(13,1);lcd.print("EL:");lc d.print(el);lcd.print(" "); lcd.setCursor(0,3);lcd.print("C:");lcd. print(mata_angin);lcd.print(" "); lcd.setCursor(10,3);lcd.print("Pol:");l cd.print(Polar);lcd.print(char(223));lc d.print(" "); lcd.setCursor(0,2);lcd.print("Lon:");lc d.print(koordinat_long);lcd.print(" "); lcd.setCursor(13,2);lcd.print("AZ:");lc d.print(az);lcd.print(" "); } // Pergerakan servo otomatis mengingat berdasarkan nilai sudut ter set sebelumnya void servo_otomatis() { if (el<0) el=0; if (el>180) el=180; if (az<0) az=0; if (az>180)az=180;
for(sudut_az=sudut_az;sudut_az>=az;sudu t_az--) { servo_azimuth(); } sudut_az=az; } if(sudut_el<el) { for(sudut_el=sudut_el;sudut_el<=el;sudu t_el++) { servo_elevasi(); } sudut_el=el; } if(sudut_el>el) { for(sudut_el=sudut_el;sudut_el>=el;sudu t_el--) { servo_elevasi(); } sudut_el=el; } } void gerak_servo_manual() { lcd.noBlink(); while(1) { kompas(); char temp=my_btns.getKey(); switch(temp) { case 'B': return; break; case '2': el++; servo_otomatis(); break;
lcd.setCursor(16,1); lcd.print(" "); lcd.setCursor(16,1); lcd.print(el); lcd.setCursor(16,2); lcd.print(" "); lcd.setCursor(16,2); lcd.print(az);
case '8': el--; servo_otomatis(); break; case '6': az++; servo_otomatis(); break;
if (sudut_az
az) {
case '4': az--; servo_otomatis(); break; default: break; } } }
131
// Parameter pergerakan azimuth dan elevasi ke servo dikarenakan pergerakan servo terbatas 180 derajat berlawanan arah jarum jam, sedangkan azimuth searah jarum jam hingga 360 derajat void arah_servo() { float koreksi=mata_angin-Azimuth; if(koreksi >= 0 && koreksi <= 180) { az=koreksi; el=Elevasi; } if(koreksi > 180 && koreksi < 360) { az=koreksi-180; el=180-Elevasi; } if(koreksi <= 0 && koreksi >= -180) { az=180+koreksi; el=180-Elevasi; } if(koreksi < -180 && koreksi > -360) { az=360+koreksi; el=Elevasi; } } // Selesai // Perhitungan rumus azimuth dan elevasi void perhitungan_az_el() { float beda_long=(koordinat_longsatelit)/57.29578; Azimuth=180+57.29578*atan(tan(beda_long )/sin((koordinat_lat/57.29578))); if (koordinat_lat<0) Azimuth=Azimuth180; if (Azimuth<0) Azimuth=Azimuth+360.0; float koordinat_latr=koordinat_lat/57.29578; float r1=1+35786/6378.16; float v1=r1*cos(koordinat_latr)*cos(beda_long )-1; float v2=r1*sqrt(1cos(koordinat_latr)*cos(koordinat_latr) *cos(beda_long)*cos(beda_long)); Elevasi=57.29578*atan(v1/v2)ant_offset; if (Elevasi < 0) Elevasi = NAN; Polar=57.29578*atan(sin(beda_long)/tan(koordi nat_latr)); } // Pergerakan Servo void servo_elevasi() { //elevasi //pulse_el = sudut_el * 5.58 + 935; servo_elev.write(sudut_el);
delay(25); } void servo_azimuth() { //azimuth //pulse_az = sudut_az * 5.49 + 974; servo_azim.write(sudut_az); delay(25); } // Notifikasi koordinat GPS void notifikasi_gps() { if(koordinat_long == 0 || koordinat_lat == 0) { lcd.clear(); lcd.setCursor(3,0); lcd.print("Koordinat GPS"); lcd.setCursor(2,1); lcd.print("Tidak ditemukan"); lcd.setCursor(5,2); lcd.print("Ulangi dalam"); for (int a=10; a>0; a--) { lcd.setCursor(6,3); lcd.print(a); lcd.print(" detik "); delay(1000); } menu_otomatis(); } } void notifikasi_gps_manual() { if(koordinat_long == 0 || koordinat_lat == 0) { lcd.clear(); lcd.setCursor(4,0); lcd.print("Koordinat GPS"); lcd.setCursor(3,1); lcd.print("Tidak ditemukan"); lcd.setCursor(2,2); lcd.print("Lanjutkan dalam"); for (int a=3; a>0; a--) { lcd.setCursor(8,3); lcd.print(a); lcd.print(" detik "); delay(1000); } } } // Pesan dan Kesan void tentang_saya() { phi_prompt_struct myLongMsg; lcd.clear(); lcd.noBlink(); center_text(" Pembuat "); myLongMsg.ptr.msg_P=msg_01; myLongMsg.low.i=0; myLongMsg.high.i=strlen_P(msg_01); myLongMsg.step.c_arr[0]=lcd_rows-1; myLongMsg.step.c_arr[1]=lcd_columns1;
132
myLongMsg.col=0; myLongMsg.row=1; myLongMsg.option=1; text_area_P(&myLongMsg); } void panduan() { phi_prompt_struct myLongMsg; lcd.clear(); lcd.noBlink(); center_text(" Panduan "); myLongMsg.ptr.msg_P=msg_02; myLongMsg.low.i=0; myLongMsg.high.i=strlen_P(msg_02); myLongMsg.step.c_arr[0]=lcd_rows-1; myLongMsg.step.c_arr[1]=lcd_columns1; myLongMsg.col=0; myLongMsg.row=1; myLongMsg.option=1; text_area_P(&myLongMsg); }
void tentang_skripsi() { phi_prompt_struct myLongMsg; lcd.clear(); lcd.noBlink(); center_text(" Tentang "); myLongMsg.ptr.msg_P=msg_00; myLongMsg.low.i=0; myLongMsg.high.i=strlen_P(msg_00); myLongMsg.step.c_arr[0]=lcd_rows-1; myLongMsg.step.c_arr[1]=lcd_columns1; myLongMsg.col=0; myLongMsg.row=1; myLongMsg.option=1; text_area_P(&myLongMsg); }
133
134
135
136
137
138