32
Pamantasan ng Cabuyao Laguna, Philippines 4025 COLLEGE OF ENGINEERING i PAGE APPENDICES

Appendix

Embed Size (px)

DESCRIPTION

extra

Citation preview

Page 1: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

i

PAGE

APPENDICES

Page 2: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

ii

PAGE

APPENDIX A

Datasheets and Components Specifications

Page 3: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

iii

PAGE

MK II Power Analyzer

Page 4: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

iv

PAGE

Arduino Uno R3 and Arduino Pro Mini

Page 5: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

v

PAGE

SIM900 GSM Module

Page 6: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

vi

PAGE

XBee Series 1 Module

Page 7: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

vii

PAGE

APPENDIX B

Source Codes

Page 8: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

viii

PAGE

Receiver Section Source Code

---------------------------------------------------------------------------------------------------

#include <LiquidCrystal.h>

#include <SoftwareSerial.h>

#include <String.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

SoftwareSerial mySerial(20, 21);

const long interval = 2000, interval2=60000;

unsigned long previousMillis = 0, previousMillis2=0;

int powerServer; // power sa server / receiver

int powerXbee; // power na narereceive sa xbee / transmitter

String readString; //main captured String

String stat, ver, vrms, irms, preal, va, qaverage, qinstant, pf,

temperature, pharmonic, pfundamental, pqfundamental, watthr,

intetx; //data String

int ind1, ind2, ind3, ind4, ind5, ind6, ind7, ind8, ind9, ind10,

ind11, ind12, ind13, ind14, ind15, ind16;

String inputString1 = ""; // a string to hold incoming

data

String inputString2 = "";

String inputString3 = "";

boolean stringComplete1 = false; // whether the string is

complete

Page 9: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

ix

PAGE

boolean stringComplete2 = false;

boolean stringComplete3 = false;

void setup() {

mySerial.begin(9600);

mySerial.print("\r");

Serial.begin(9600); // programmer

Serial1.begin(9600); // GSM

Serial1.print("\r");

delay(1000);

Serial2.begin(9600); // xbee

Serial3.begin(9600); // power analyzer

inputString1.reserve(200);

inputString2.reserve(200);

inputString3.reserve(200);

lcd.begin(16, 2);

pinMode(8, OUTPUT);

digitalWrite(8,LOW);

delay(1000);

digitalWrite(8,HIGH);

delay(2000);

digitalWrite(8,LOW);

delay(1000);

Page 10: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

x

PAGE

}

void loop() {

unsigned long currentMillis = millis();

unsigned long currentMillis2 = millis();

if (stringComplete2 && stringComplete3) {

powerXbee=inputString2.toInt();

lcd.setCursor(0,0);

lcd.print("Total Load: ");

lcd.print(powerServer); // display the total load to

lcd

lcd.setCursor(0,1);

lcd.print(" ");

lcd.setCursor(0,1);

lcd.print("Tx Load: ");

lcd.print(powerXbee); // display the power throw by

xbee

if(currentMillis - previousMillis >= interval) {

previousMillis = currentMillis;

if(powerServer > powerXbee){

lcd.setCursor(0,1);

Page 11: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xi

PAGE

lcd.print(" ");

lcd.setCursor(0,1);

lcd.print("Jumper Detected");

if(currentMillis2 - previousMillis2 >= interval2) {

previousMillis2 = currentMillis2;

SendMessage();

Serial.print("SEND SMS");

lcd.setCursor(0,1);

lcd.print(" ");

lcd.setCursor(0,1);

lcd.print("Sending SMS");

delay(1000);

}

}

// clear the string:

inputString2 = "";

stringComplete2 = false;

stringComplete3 = false;

}

}

}

//GSM

void serialEvent1(){

Page 12: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xii

PAGE

while (Serial1.available()) {

// get the new byte:

char inChar1 = (char)Serial1.read();

// add it to the inputString:

inputString1 += inChar1;

// if the incoming character is a newline, set a flag

// so the main loop can do something about it:

if (inChar1 == '\n') {

stringComplete1 = true;

}

}

}

//xbee

void serialEvent2(){

while (Serial2.available()) {

// get the new byte:

char inChar2 = (char)Serial2.read();

// add it to the inputString:

inputString2 += inChar2;

// if the incoming character is a newline, set a flag

// so the main loop can do something about it:

if (inChar2 == '\n') {

stringComplete2 = true;

Page 13: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xiii

PAGE

}

}

}

//Power Analyzer

void serialEvent3() {

while (Serial3.available()) {

char c = Serial3.read(); //gets one byte from serial buffer

if (c == 0x03) {

ind1 = readString.indexOf(','); //finds location of first

,

stat = readString.substring(0, ind1); //captures first

data String

ind2 = readString.indexOf(',', ind1+1 ); //finds location

of second ,

ver = readString.substring(ind1+1, ind2); //captures

second data String

ind3 = readString.indexOf(',', ind2+1 );

vrms = readString.substring(ind2+1, ind3);

ind4 = readString.indexOf(',', ind3+1 );

irms = readString.substring(ind3+1, ind4);

ind5 = readString.indexOf(',', ind4+1 );

preal = readString.substring(ind4+1, ind5);

ind6 = readString.indexOf(',', ind5+1 );

Page 14: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xiv

PAGE

va = readString.substring(ind5+1, ind6);

ind7 = readString.indexOf(',', ind6+1 );

qaverage = readString.substring(ind6+1, ind7);

ind8 = readString.indexOf(',', ind7+1 );

qinstant = readString.substring(ind7+1, ind8);

ind9 = readString.indexOf(',', ind8+1 );

pf = readString.substring(ind8+1, ind9);

ind10 = readString.indexOf(',', ind9+1 );

temperature = readString.substring(ind9+1, ind10);

ind11 = readString.indexOf(',', ind10+1 );

pharmonic = readString.substring(ind10+1, ind11);

ind12 = readString.indexOf(',', ind11+1 );

pfundamental = readString.substring(ind11+1, ind12);

ind13 = readString.indexOf(',', ind12+1 );

pqfundamental = readString.substring(ind12+1, ind13);

ind14 = readString.indexOf(',', ind13+1 );

watthr = readString.substring(ind13+1, ind14);

ind15 = readString.indexOf(',', ind14+1 );

intetx = readString.substring(ind14+1, ind15);

ind16 = readString.indexOf(',', ind15+1 );

powerServer = preal.toInt();

powerServer -=5;

Page 15: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xv

PAGE

preal="";

readString=""; //clears variable for new input

stringComplete3 = true;

}

else {

readString += c; //makes the string readString

}

}

}

void SendMessage() // send to cabuyao hospital

{

mySerial.print("AT+CMGF=1\r"); //Because we want to send the

SMS in text mode

delay(500);

mySerial.println("AT + CMGS = \"09367374546\"");//send sms

message, be careful need to add a country code before the

cellphone number

delay(500);

mySerial.println("Jumper Detected at Matalino St.,");//the

content of the message

delay(1000);

Page 16: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xvi

PAGE

mySerial.println("Katapatan Vill., Banay-banay, City of

Cabuyao");//the content of the message

delay(1000);

mySerial.println((char)26);//the ASCII code of the ctrl+z is 26

delay(500);

mySerial.println();

}

---------------------------------------------------------------------------------------------------

Page 17: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xvii

PAGE

Transmitter Section Source Code

---------------------------------------------------------------------------------------------------

#include <SoftwareSerial.h>

#include <LiquidCrystal.h>

LiquidCrystal lcd(4, 5, 6, 7, 8, 9);

SoftwareSerial mySerial(2, 3);

String readString; //main captured String

String stat, ver, vrms, irms, preal, va, qaverage, qinstant, pf,

temperature, pharmonic, pfundamental, pqfundamental, watthr,

intetx; //data String

int ind1, ind2, ind3, ind4, ind5, ind6, ind7, ind8, ind9, ind10,

ind11, ind12, ind13, ind14, ind15, ind16;

unsigned long previousMillis = 0; // will store last time

LED was updated

const long interval = 500; // interval at which to

blink (milliseconds)

void setup() {

Page 18: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xviii

PAGE

mySerial.begin(9600);

Serial.begin(9600);

lcd.begin(16, 2);

lcd.print(“Power Analyzer”);

delay(2000);

lcd.clear();

}

//#define C_STX 0x02

//#define C_ETX 0x03

void loop() {

unsigned long currentMillis = millis();

if (mySerial.available()) {

char c = mySerial.read(); //gets one byte from serial buffer

if (c == 0x03) {

//do stuff

ind1 = readString.indexOf(‘,’); //finds location of first

,

Page 19: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xix

PAGE

stat = readString.substring(0, ind1); //captures first

data String

ind2 = readString.indexOf(‘,’, ind1+1 ); //finds location

of second ,

ver = readString.substring(ind1+1, ind2); //captures

second data String

ind3 = readString.indexOf(‘,’, ind2+1 );

vrms = readString.substring(ind2+1, ind3);

ind4 = readString.indexOf(‘,’, ind3+1 );

irms = readString.substring(ind3+1, ind4);

ind5 = readString.indexOf(‘,’, ind4+1 );

preal = readString.substring(ind4+1, ind5);

ind6 = readString.indexOf(‘,’, ind5+1 );

va = readString.substring(ind5+1, ind6);

ind7 = readString.indexOf(‘,’, ind6+1 );

qaverage = readString.substring(ind6+1, ind7);

ind8 = readString.indexOf(‘,’, ind7+1 );

qinstant = readString.substring(ind7+1, ind8);

ind9 = readString.indexOf(‘,’, ind8+1 );

pf = readString.substring(ind8+1, ind9);

ind10 = readString.indexOf(‘,’, ind9+1 );

temperature = readString.substring(ind9+1, ind10);

ind11 = readString.indexOf(‘,’, ind10+1 );

Page 20: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xx

PAGE

pharmonic = readString.substring(ind10+1, ind11);

ind12 = readString.indexOf(‘,’, ind11+1 );

pfundamental = readString.substring(ind11+1, ind12);

ind13 = readString.indexOf(‘,’, ind12+1 );

pqfundamental = readString.substring(ind12+1, ind13);

ind14 = readString.indexOf(‘,’, ind13+1 );

watthr = readString.substring(ind13+1, ind14);

ind15 = readString.indexOf(‘,’, ind14+1 );

intetx = readString.substring(ind14+1, ind15);

ind16 = readString.indexOf(‘,’, ind15+1 );

if(currentMillis – previousMillis >= interval) {

previousMillis = currentMillis;

Serial.println(preal);

}

lcd.setCursor(0, 0);

lcd.print(“RP:”+preal);

lcd.print(“ V:”+vrms);

lcd.setCursor(0, 1);

lcd.print(“VA:”+va);

Page 21: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xxi

PAGE

lcd.print(“ W/H:”+watthr);

readString=””; //clears variable for new input

stat=””;

ver=””;

vrms=””;

irms=””;

preal=””;

va=””;

qaverage=””;

qinstant=””;

pf=””;

temperature=””;

pharmonic=””;

pfundamental=””;

pqfundamental=””;

watthr=””;

intetx=””;

}

else {

readString += c; //makes the string readString

}

}

Page 22: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xxii

PAGE

}

---------------------------------------------------------------------------------------------------

Page 23: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xxiii

PAGE

Source Code for the LCD Screen:

---------------------------------------------------------------------------------------------------

#include <SoftwareSerial.h>

char rxbyte;

int i;

char * range;

char * watts;

char * va;

char * var;

char * pf;

char * volts;

char * amps;

char padata[53];

bool StartDataReceived = false;

bool DataAvailable = false;

SoftwareSerial mySerial(2, 3);

void setup()

{

Serial.begin(9600);

mySerial.begin(9600);

Page 24: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xxiv

PAGE

}

void loop()

{

if (mySerial.available() > 0)

{

rxbyte = mySerial.read();

if ( rxbyte == 'I')

{

StartDataReceived = true;

padata[0] = rxbyte;

}

}

if (( StartDataReceived == true) && (

mySerial.available() > 0))

{

for ( i = 1; i < 53; i++ )

{

while (mySerial.available() ==

0){}

padata[i] = mySerial.read();

}

StartDataReceived = false;

Page 25: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xxv

PAGE

DataAvailable = true;

}

if ( DataAvailable == true)

{

range = strtok(padata, ",");

watts = strtok(NULL, ",");

va = strtok(NULL, ",");

var = strtok(NULL, ",");

pf = strtok(NULL, ",");

volts = strtok(NULL, ",");

amps = strtok(NULL, ",");

Serial.print("WATTS: ");

Serial.println(watts);

Serial.print("VA: ");

Serial.println(va);

Serial.print("VAR: ");

Serial.println(var);

Serial.print("PF: ");

Serial.println(pf);

Serial.print("VOLTS: ");

Serial.println(volts);

Page 26: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xxvi

PAGE

Serial.print("AMPS: ");

Serial.println(amps);

memset(padata, NULL, 53);

DataAvailable = false;

}

}

Page 27: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xxvii

PAGE

APPENDIX C

Schematic Diagrams

Page 28: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xxvii

i

PAGE

Schematic Diagram of the Receiver Section

Page 29: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xxix

PAGE

Schematic Diagram of the

Transmitter Section

Page 30: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xxx

PAGE

APPENDIX D

(Bill of Materials)

Page 31: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xxxi

PAGE

Components/Materials Quantity Unit Price (Php) Amount

Arduino Uno R3 1 500 500

Arduino Pro Mini 1 350 350

MK II Power Analyzer 2 1,000 2,000

Xbee Series 1 Module 2 1,442 2,884

Xbee Shield 2 300 600

LCD Screen 2 400 800

Potentiometer 2 15 30

SIM900 GSM Module 1 2,100 2,100

Platform 1 200 200

PVC Tubes 2 100 200

Paint 1 100 100

Power Supply 2 50 100

Casing 2 50 100

Total Amount 9,964

Page 32: Appendix

Pamantasan ng Cabuyao Laguna, Philippines 4025

COLLEGE OF ENGINEERING

xxxii

PAGE

APPENDIX E

Curriculum Vitae of the Researchers