LAMPIRAN A
Sintaks Program Sistem Autotracking pada Stasiun Pengirim
#include <TinyGPS++.h> #include <SoftwareSerial.h> #include
#include #include <SPI.h> #include "printf.h" #include <Wire.h> #include
Adafruit_BMP085 bmp;
static const int RXPin = 3, TXPin = 4; // GPS connections (RX pin connects to TX on module and other wise) static const uint32_t GPSBaud = 9600; // GPS Baud Rate
SoftwareSerial ss(RXPin, TXPin); // The serial connection to the GPS device TinyGPSPlus gps;
// The TinyGPS++ object
// BMP Altitude[0] double myAlt[1]; //current BMP height // GPS Latitude[0]/Longitude[1] double myLL[2];
//current GPS location
Universitas Sumatera Utara
RF24 radio(7,8); // nRF24L01 radio attached (CE, CSN) RF24Network network(radio); const uint16_t channel = 60;
// Network uses that radio // Channel of our node
const uint16_t this_node = 1; // Address of our node const uint16_t other_node = 0; // Address of the base
unsigned long packets_sent;
// How many packets have we sent already
// Structure of our payload, limited to 32 bytes struct payload_t
// 32 bytes max
{ unsigned long counter; // 4 bytes double lat;
// 4 bytes
double lng;
// 4 bytes
double Altitude;
// 4 bytes
};
void setup() { Serial.begin(9600); Wire.begin(); ss.begin(GPSBaud); // start Software Serial bmp.begin(); printf_begin();
Universitas Sumatera Utara
SPI.begin(); radio.begin(); network.begin(channel, this_node); }
void loop() { while (ss.available() > 0) { if (gps.encode(ss.read())) { getGPS(); sendPayload();
//Baca data latitude, longitude dan altitude //kirim data yang telah terbaca
smartDelay(2000);
if (millis() > 5000 && gps.charsProcessed() < 10) { Serial.println(F("No GPS detected: check wiring.")); while(true); } } } }
void getGPS() //Baca data latitude, longitude dan altitude {
Universitas Sumatera Utara
if (gps.location.isValid()) { myLL[0] = gps.location.lat(); myLL[1] = gps.location.lng(); myAlt[0]= bmp.readAltitude(101500); printf("Altitude = "); Serial.print(myAlt[0],6); printf(" lat: "); Serial.print(myLL[0],6); printf(" lng: "); Serial.print(myLL[1],6); printf("\n"); } }
void sendPayload() //kirim data yang telah terbaca { payload_t payload = {packets_sent++, myLL[0], myLL[1], myAlt[0]}; RF24NetworkHeader header(/*to node*/ other_node); bool ok = network.write(header,&payload,sizeof(payload)); radio.powerDown();
// Power down the radio. Note that the radio will get powered back up on the next write() call.
}
static void smartDelay(unsigned long ms) // ensures that the gps object is being "fed" {
Universitas Sumatera Utara
unsigned long start = millis(); do { while (ss.available()) gps.encode(ss.read()); } while (millis() - start < ms); }
Sintaks Program Sistem Autotracking pada Stasiun Penerima
#include <TinyGPS++.h> #include <SoftwareSerial.h> #include <Servo.h> #include #include #include <SPI.h> #include "printf.h" #include <Wire.h> #include #include #include
HMC5883L compass; int error = 0;
static const int RXPin = 4, TXPin = 3;
Universitas Sumatera Utara
static const uint32_t GPSBaud = 9600;
Servo myservo; Servo myservo1; LiquidCrystal_I2C lcd(0x27, 20, 4); Adafruit_BMP085 bmp; TinyGPSPlus gps; SoftwareSerial ss(RXPin, TXPin);
double x1,x2,y1,y2,a,b,c,alt1,alt2; double sudut,jarak,sudut_elevasi;
RF24 radio(7,8); RF24Network network(radio);
// Network uses that radio
const uint16_t channel = 60;
// Channel of our node
const uint16_t this_node = 0;
// Address of our node
const uint16_t other_node = 1; // Address of the other node
unsigned long packets_sent;
// How many packets have we sent already
// GPS Latitude[0];Longitude[1] double setLL[2]; //stored location double myLL[2]; //current GPS location double setAlt[1]; //stored altitude double myAlt[1]; //current BMP altitude
Universitas Sumatera Utara
// Structure of our payload, limited to 32 bytes struct payload_t
// 32 bytes max
{ unsigned long counter; // 4 bytes double lat;
// 4 bytes
double lng;
// 4 bytes
float Altitude;
// 4 bytes
};
void setup() { lcd.begin(); lcd.backlight();
Serial.begin(9600);
bmp.begin();
myservo.attach(9); //azimuth myservo.write(180); delay(900);
myservo1.attach(10); //elevasi myservo1.write(16);
Universitas Sumatera Utara
delay(900);
myservo.detach(); myservo1.detach();
printf_begin();
ss.begin(9600);
SPI.begin();
// Start the SPI interface.
radio.begin(); network.begin(channel,this_node);
Wire.begin();
// Start the I2C interface.
compass = HMC5883L();
// Construct a new HMC5883 compass.
error = compass.SetScale(1.3); // Set the scale of the compass. if(error != 0)
// If there is an error, print it out.
Serial.println(compass.GetErrorText(error)); // Set the measurement mode to Continuous error = compass.SetMeasurementMode(Measurement_Continuous); if(error != 0)
// If there is an error, print it out.
Serial.println(compass.GetErrorText(error));
} //end of void setup
Universitas Sumatera Utara
void loop() {
ss.begin(9600); //GPS on delay(10);
network.update(); //pump the radio network regularly delay(100);
//latitude, longitude & altitude stasiun penerima----------x1 = gps.location.lat(); y1 = gps.location.lng(); alt1 = bmp.readAltitude(101500);
Serial.print("x1 : "); Serial.println(x1,6); Serial.print("y1 : "); Serial.println(y1,6); Serial.print("alt1 : "); Serial.println(alt1); smartDelay(100); //----------------------------------------------------------
//latitude, longitude & altitude stasiun pengirim-----------
Universitas Sumatera Utara
x2 = setLL[0]; y2 = setLL[1]; alt2 = setAlt[0];
Serial.print("x2 : "); Serial.println(x2,6); Serial.print("y2 : "); Serial.println(y2,6); Serial.print("alt2 : "); Serial.println(alt2); //latitude, longitude & altitude stasiun pengirim-----------
ss.end();
//GPS off
//kompas-----------------MagnetometerRaw raw = compass.ReadRawAxis(); MagnetometerScaled scaled = compass.ReadScaledAxis(); int MilliGauss_OnThe_XAxis = scaled.XAxis;// (or YAxis, or ZAxis) float heading = atan2(scaled.YAxis, scaled.XAxis);
float declinationAngle = 0.0457; heading += declinationAngle;
if(heading < 0) heading += 2*PI;
Universitas Sumatera Utara
if(heading > 2*PI) heading -= 2*PI;
float headingDegrees = heading * 180/M_PI; Serial.println(headingDegrees); //kompas------------------------
while(network.available()) { getRadioData();
//Terima data Stasiun pengirim
//LCD-----------------------------lcd.clear();
lcd.setCursor(0, 0); lcd.print(x2,6);
lcd.setCursor(0, 1); lcd.print(y2,6);
lcd.setCursor(0, 2); lcd.print(x1,6);
lcd.setCursor(0, 3); lcd.print(y1,6);
Universitas Sumatera Utara
lcd.setCursor(10,0); lcd.print("sdt");
lcd.setCursor(10,1); lcd.print(sudut);
lcd.setCursor(10,2); lcd.print("b/a");
lcd.setCursor(10,3); lcd.print(c);
lcd.setCursor(15,0); lcd.print("komp");
lcd.setCursor(15,1); lcd.print(headingDegrees);
lcd.setCursor(15,2); lcd.print("elv");
lcd.setCursor(15,3); lcd.print(sudut_elevasi); //LCD---------------------------------------}
Universitas Sumatera Utara
if (x1 != 0 && x2 != 0) { hitung_sudut(); elevasi();
//--------------------------------------AZIMUTH-------------------------------if (headingDegrees >=100 && headingDegrees <= 110) // ----> badan stasiun penerima ke arah TIMUR { if(a>0 && b >0) { int pos; pos = 180 - (sudut * 0.84); myservo.attach(9); myservo.write(pos); delay(100); myservo.detach(); } else if (a<0 && b>0) { int pos; pos = 180 - ((180-sudut) *0.84) ; myservo.attach(9); myservo.write(pos); delay(100);
Universitas Sumatera Utara
myservo.detach(); } } //---------------------------AZIMUTH----------------------------------------
//--------elevasi--------int pos; myservo1.attach(10); pos = 16 + sudut_elevasi; myservo1.write(pos); delay(1000); myservo1.detach(); //--------elevasi---------}
if (millis() > 5000 && gps.charsProcessed() < 10) Serial.println(F("No GPS data received: check wiring"));
} //end of void loop
double hitung_sudut() { a = x2 - x1; b = y2 - y1; c = b/a; if (c < 0)
Universitas Sumatera Utara
{ c = c*(-1); }
sudut = round(atan(c)*180/3.14159265); delay(10); Serial.print("sudut : "); Serial.println(sudut);
}
double elevasi() { //Euclidean Formula double xy = sqrt((pow(a,2)) + (pow(b,2))); jarak = 111319 * xy; double t_per_j = (alt2 - alt1)/jarak; sudut_elevasi = round(atan(t_per_j)*180/3.14159265);
}
// This custom version of delay() ensures that the gps object is being "fed". static void smartDelay(unsigned long ms) { unsigned long start = millis(); do
Universitas Sumatera Utara
{ while (ss.available()) gps.encode(ss.read()); } while (millis() - start < ms); }
void getRadioData() { RF24NetworkHeader header; payload_t payload={packets_sent++, myLL[0], myLL[1], myAlt[0]}; bool done = false;
while (!done) { done = network.read(header,&payload,sizeof(payload)); setLL[0] = payload.lat; setLL[1] = payload.lng; setAlt[0]= payload.Altitude;
printf(" Alt: ",setAlt[0],6); Serial.print(setAlt[0],6);
printf(" Lat: ",setLL[0],6); Serial.print(setLL[0],6);
printf(" Lng: ",setLL[1],6);
Universitas Sumatera Utara
Serial.print(setLL[1],6); printf("\n"); } }
Universitas Sumatera Utara
LAMPIRAN B Diagram Alir Sistem Autotracking Stasiun Pengirim
Universitas Sumatera Utara
Diagram Alir Sistem Autotracking Sudut Azimuth
Universitas Sumatera Utara
Diagram Alir Sistem Autotracking Sudut Elevasi
jarak = (√𝐴2 + 𝐵2 ) 𝑥 111.319
Universitas Sumatera Utara
LAMPIRAN C Tabel hasil pengujian autotracking sudut azimuth pertama Posisi RX
Posisi TX
No Latitude
Longitude
Latitude
Besar Sudut Besar Sudut Besar Longitude Perhitungan Pengukuran Kesalahan
1
3.557109 98.658201 3.557471 98.658882
62°
63°
1°
2
3.557109 98.658201 3.557471 98.658882
62°
62°
0°
3
3.557109 98.658201 3.557471 98.658882
62°
63°
1°
4
3.557109 98.658201 3.557471 98.658882
62°
63°
1°
5
3.557109 98.658201 3.557471 98.658882
62°
63°
1°
6
3.557109 98.658201 3.557471 98.658882
62°
62°
0°
7
3.557109 98.658201 3.557471 98.658882
62°
63°
1°
8
3.557109 98.658201 3.557471 98.658882
62°
63°
1°
9
3.557109 98.658201 3.557471 98.658882
62°
63°
1°
10
3.557109 98.658201 3.557471 98.658882
62°
63°
1°
Rata3.557109 98.658201 3.557471 98.658882 Rata
62°
62,8°
0,8°
Grafik hasil pengujian autotracking sudut azimuth pertama
PENGUJIAN AUTOTRACKING AZIMUTH 1 BESAR SUDUT (DERAJAT)
Hasil Perhitungan
Hasil Pengukuran
63.5 63 62.5 62 61.5 1
2
3
4
5
6
7
8
9
10
PERCOBAAN
Universitas Sumatera Utara
Tabel hasil pengujian autotracking sudut azimuth kedua Posisi RX
Posisi TX
Besar Sudut Besar Sudut Besar Perhitungan Pengukuran Kesalahan Longitude
No Latitude
Longitude
Latitude
1
3.557109 98.658201 3.556967 98.659556
96°
95°
1°
2
3.557109 98.658201 3.556967 98.659556
96°
95°
1°
3
3.557109 98.658201 3.556967 98.659556
96°
95°
1°
4
3.557109 98.658201 3.556967 98.659556
96°
95°
1°
5
3.557109 98.658201 3.556967 98.659556
96°
95°
1°
6
3.557109 98.658201 3.556967 98.659556
96°
95°
1°
7
3.557109 98.658201 3.556967 98.659556
96°
95°
1°
8
3.557109 98.658201 3.556967 98.659556
96°
95°
1°
9
3.557109 98.658201 3.556967 98.659556
96°
95°
1°
10
3.557109 98.658201 3.556967 98.659556
96°
95°
1°
Rata3.557109 98.658201 3.556967 98.659556 Rata
96°
95°
1°
Grafik hasil pengujian autotracking sudut azimuth kedua
PENGUJIAN AUTOTRACKING AZIMUTH 2 Hasil Perhitungan
Hasil Pengukuran
BESAR SUDUT (DERAJAT)
96.2 96 95.8 95.6 95.4
95.2 95 94.8 94.6 94.4 1
2
3
4
5
6
7
8
9
10
PERCOBAAN
Universitas Sumatera Utara
Tabel hasil pengujian autotracking sudut azimuth ketiga Posisi RX
Posisi TX
Besar Sudut Besar Sudut Besar Perhitungan Pengukuran Kesalahan Longitude
No Latitude
Longitude
Latitude
1
3.557109 98.658201 3.556495 98.659558
114°
112°
2°
2
3.557109 98.658201 3.556967 98.659556
114°
112°
2°
3
3.557109 98.658201 3.556967 98.659556
114°
113°
1°
4
3.557109 98.658201 3.556967 98.659556
114°
112°
2°
5
3.557109 98.658201 3.556967 98.659556
114°
112°
2°
6
3.557109 98.658201 3.556967 98.659556
114°
112°
2°
7
3.557109 98.658201 3.556967 98.659556
114°
112°
2°
8
3.557109 98.658201 3.556967 98.659556
114°
112°
2°
9
3.557109 98.658201 3.556967 98.659556
114°
112°
2°
10
3.557109 98.658201 3.556967 98.659556
114°
113°
1°
Rata3.557109 98.658201 3.556967 98.659556 Rata
114°
112°
1,8°
Grafik hasil pengujian autotracking sudut azimuth ketiga
PENGUJIAN AUTOTRACKING AZIMUTH 3 Hasil Perhitungan
Hasil Pengukuran
BESAR SUDUT (DERAJAT)
114.5 114 113.5 113 112.5 112 111.5 111 1
2
3
4
5
6
7
8
9
10
PERCOBAAN
Universitas Sumatera Utara
Tabel hasil pengujian autotracking sudut elevasi pertama
No
Ketinggian Ketinggian RX (m) TX (m)
Jarak kedua Stasiun (m)
Besar Sudut Besar Sudut Besar Perhitungan Pengukuran Kesalahan
1
71
76
17,37
16°
16°
0°
2
71
76
17,37
16°
17°
1°
3
71
76
17,37
16°
16°
0°
4
71
76
17,37
16°
16°
0°
5
71
76
17,37
16°
16°
0°
6
71
76
17,37
16°
17°
1°
7
71
76
17,37
16°
17°
1°
8
71
76
17,37
16°
16°
0°
9
71
76
17,37
16°
16°
0°
10
71
76
17,37
16°
15°
1°
RataRata
71
76
17,37
16°
16,2°
0,4°
Grafik hasil pengujian autotracking sudut elevasi pertama
PENGUJIAN AUTOTRACKING ELEVASI 1 Hasil Perhitungan
Hasil Pengukuran
BESAR SUDUT (DERAJAT)
17.5
17 16.5 16 15.5 15 14.5 14 1
2
3
4
5
6
7
8
9
10
PERCOBAAN
Universitas Sumatera Utara
Tabel hasil pengujian autotracking sudut elevasi kedua
No
Ketinggian Ketinggian RX (m) TX (m)
Jarak kedua Stasiun (m)
Besar Sudut Besar Sudut Besar Perhitungan Pengukuran Kesalahan
1
71
81
17,37
30°
31°
1°
2
71
81
17,37
30°
32°
2°
3
71
81
17,37
30°
30°
0°
4
71
81
17,37
30°
31°
1°
5
71
81
17,37
30°
31°
1°
6
71
81
17,37
30°
31°
1°
7
71
81
17,37
30°
32°
2°
8
71
81
17,37
30°
31°
1°
9
71
81
17,37
30°
31°
1°
10
71
81
17,37
30°
31°
1°
RataRata
71
81
17,37
30°
31,1°
1,1°
Grafik hasil pengujian autotracking sudut elevasi kedua
PENGUJIAN AUTOTRACKING ELEVASI 2 Hasil Perhitungan
Hasil Pengukuran
BESAR SUDUT (DERAJAT)
32.5
32 31.5 31 30.5 30 29.5 29 1
2
3
4
5
6
7
8
9
10
PERCOBAAN
Universitas Sumatera Utara
Tabel hasil pengujian autotracking sudut elevasi ketiga
No
Ketinggian Ketinggian RX (m) TX (m)
Jarak kedua Stasiun (m)
Besar Sudut Besar Sudut Besar Perhitungan Pengukuran Kesalahan
1
71
86
17,37
41°
41°
0°
2
71
86
17,37
41°
41°
0°
3
71
86
17,37
41°
40°
1°
4
71
86
17,37
41°
40°
1°
5
71
86
17,37
41°
41°
0°
6
71
86
17,37
41°
41°
0°
7
71
86
17,37
41°
41°
0°
8
71
86
17,37
41°
41°
0°
9
71
86
17,37
41°
41°
0°
10
71
86
17,37
41°
41°
0°
RataRata
71
86
17,37
41°
40,8°
0,2°
Grafik hasil pengujian autotracking sudut elevasi ketiga
PENGUJIAN AUTOTRACKING ELEVASI 3 Hasil Perhitungan
Hasil Pengukuran
BESAR SUDUT (DERAJAT)
41.2
41 40.8 40.6 40.4 40.2 40 39.8 39.6 39.4 1
2
3
4
5
6
7
8
9
10
PERCOBAAN
Universitas Sumatera Utara