# Trying to obtain phase angle using AD 8302 phase detector chip

I am trying to use the AD 8302 phase detector chip to obtain phase angle between antenna's receiving a RF signal due to the vertical separation of the antennas. I want to use the phase angle to calculate the distance from the transmitter to the receiving antennas that are placed on an upright wooden platform. These antennas have a vertical separation of 5 ft from each other. I use RF SMA cables to connect to the phase detector and have stripped each end to create antennas.

The transmitter operates on 433 MHz and its the generic transmitter/ receiver pair. The phase detector gives me phase output in terms of Volts that has a range of 30mV to 1.8 V. In the data sheet this range represents 180 degrees to 0 degrees. The outputs from the phase detector chip go into the arduino and that is how I make the calculations for the distance as well as the angle.

I have calculated antenna lengths (reception antenna's using SMA cable) for Quarter Wavelength.

This is to calculate antenna length using a piece of wire: http://www.csgnetwork.com/antennagenericfreqlencalc.html

I am not able to obtain the correct phase angle needed to calculate the distance from the transmitter to the antennas.

PIC_1 is the structure and PIC_2 is the transmitter.

This is the code for the transmitter:

#define rfTransmitPin 12  //RF Transmitter pin = digital pin 12
#define ledPin 13        //Onboard LED = digital pin 13

void setup(){
pinMode(rfTransmitPin, OUTPUT);
pinMode(ledPin, OUTPUT);
}

void loop(){
//for(int i=4000; i>5; i=i/800){
digitalWrite(rfTransmitPin, HIGH);     //Transmit a HIGH signal
digitalWrite(ledPin, HIGH);            //Turn the LED on
//delay(2000);                           //Wait for 1 second

// digitalWrite(rfTransmitPin,LOW);      //Transmit a LOW signal
// digitalWrite(ledPin, LOW);            //Turn the LED off
// delay(i);                            //Variable delay
// }
}


This is the code for the Receiver:

//#define rfReceivePin 8  //RF Receiver pin = Analog pin 0
#define vmag A1
#define vphs A0
#define ledPin 13        //Onboard LED = digital pin 13
//int vphs = 0;
//int vmag = 1;
unsigned int data = 0;   // variable used to store received data
unsigned int DATA = 0;
unsigned int data1 = 0;
unsigned int DATA1 = 0;

const unsigned int upperThreshold = 70;  //upper threshold value
const unsigned int lowerThreshold = 50;  //lower threshold value

String angle="Angle:";
String mag="Vmag:";
String dis="Distance";

void setup(){
pinMode(ledPin, OUTPUT);
pinMode(vmag,INPUT);
pinMode(vphs,INPUT);
analogReference(DEFAULT);
Serial.begin(9600);
}

void loop(){
data = analogRead(vphs);    //listen for data on Analog pin 0
/*Serial.println(((data)/10)*2);*/
/*DATA=*/
Serial.print(angle);
Serial.println((((data)/10)*2)-40);
Serial.print(dis);
Serial.println((5/tan(data)));
delay(500);

/*DATA1*/
Serial.print(mag);
Serial.println(((data1)/30)*2);

delay(500);
//Serial.println(6/tan(DATA*(180/3.14)));

/* if(data>upperThreshold){
digitalWrite(ledPin, LOW);   //If a LOW signal is received, turn LED OFF
Serial.println(data);
}

if(data<lowerThreshold){
digitalWrite(ledPin, HIGH);   //If a HIGH signal is received, turn LED ON
Serial.println(data);

}*/
}