Quadcopter Tracker
ECE 4180 FINAL PROJECT
TEAM MEMBERS:
Ryan McNeal
Kim Yie
Project Description:
- Use an antenna dish to locate and track a Quadcopter by detecting its 5.8Ghz telemetry signal.
- Track the signal’s bearing via high precision (4096 Pulse per revolution) optical encoders, send angles to LCD display.
- Detect signal using a 5.8 Ghz/3.3 degree viewing window- dish antenna, RF signal strength detector with DC voltage output, then use ADC to perform calculations and display to LCD.
Optical Encoder Code
#include <iostream>
#include <stdlib>
#include <unistd>
#include <string>
#include "eqep.h"
#include "ip_connection.h"
#include "bricklet_lcd_16x2.h"
using namespace std;
#define HOST "localhost"
#define PORT 8000
#define UID "passiveradar" // Change to your UID
int main (int argc, char** argv)
{
float phi, theta;
char buffer[20];
// Create IP connection
IPConnection ipcon;
ipcon_create(&ipcon);
// Connect to brickd
if(ipcon_connect(&ipcon, HOST, PORT) < 0) {
fprintf(stderr, "Could not connect\n");
exit(1);
}
// Don't use device before ipcon is connected
// Allocate an instance of
eQEP eqep1("/sys/devices/ocp.2/48300000.epwmss/48302180.eqep", eQEP::eQEP_Mode_Absolute);
eQEP eqep2("/sys/devices/ocp.2/48302000.epwmss/48302180.eqep", eQEP::eQEP_Mode_Absolute);
// Set the unit time period to 100,000,000 ns, or 0.1 seconds
eqep1.set_period(100000000L);
eqep2.set_period(100000000L);
LCD16x2 lcd;
lcd_16x2_create(&lcd, UID, &ipcon);
// Turn backlight on
lcd_16x2_backlight_on(&lcd);
// Query back the period
// std::cout << "[eQEP " << argv[1] << "] Period = " << eqep1.get_period() << " ns" << std::endl;
// Read position indefintely
while(1)
{
std::cout << "[eQEP " << argv[1] << "] Position = " << eqep1.get_position() << std::endl;
phi = eqep1.get_position();
theta = eqep2.get_position();
// convert quadrature ticks into degrees - multiply by 360 deg / 4096 ticks
phi = phi * 360 / 4096;
theta = theta * 360 / 4096;
// print the values into a string buffer to display on lcd
sprintf(buffer, "Phi: %.04f\n", phi);
lcd_16x2_write_line(&lcd, 0, 0, buffer);
sprintf(buffer, "Theta: %.04f\n", phi);
lcd_16x2_write_line(&lcd, 1, 0, buffer);
// sleep 50 milliseconds to avoid overrefreshing LCD
usleep(50*1000);
}
ipcon_destroy(&ipcon); // Calls ipcon_disconnect internally
// Return success
return 0;
}
RF Code
#include <iostream>
#include <stdlib.h>
#include <unistd.h>
#include <string>
#include <math.h>
#include "eqep.h"
#include "ip_connection.h"
#include "bricklet_lcd_16x2.h"
using namespace std;
#define HOST "localhost"
#define PORT 8000
#define UID "passiveradar" // Change to your UID
int main (int argc, char** argv)
{
float phi, theta;
char buffer[20];
char value_str[7];
double value, voltage, DCin, powerdBm, powerLin=0;
FILE* f0 = fopen("/sys/bus/iio/devices/iio:device0/in_voltage0_raw", "r");
// Create IP connection
IPConnection ipcon;
ipcon_create(&ipcon);
// Connect to brickd
if(ipcon_connect(&ipcon, HOST, PORT) < 0) {
fprintf(stderr, "Could not connect\n");
exit(1);
}
// Don't use device before ipcon is connected
LCD16x2 lcd;
lcd_16x2_create(&lcd, UID, &ipcon);
// Turn backlight on
lcd_16x2_backlight_on(&lcd);
while(1)
{
// read ADC in
fread(&value_str, 6, 6, f0);
value = strtod(value_str,NULL,0);
voltage = value * 1.8;
DCin = voltage+0.4;
powerdBm = 4*sqrt(1837-625*DCin)-135;
powerLin = pow(10,((powerdBm-30)/10));
printf("%d\n", value);
fflush(stdout);
rewind(f0);
// Print power in dBm
sprintf(buffer, "%.2f dBm\n", powerdBm);
lcd_16x2_write_line(&lcd, 0, 0, buffer);
// Print power in linear scale
if (powerLin > 1) {
sprintf("%.3f Watts", powerLin);
} else if (powerLin >= pow(10, -3)) {
powerLin *= pow(10, 3);
sprintf("%.3f mW", powerLin);
} else if (powerLin >= pow(10, -6)) {
powerLin *= pow(10, 6);
sprintf("%.3f uW", powerLin);
} else if (powerLin >= pow(10, -9)) {
powerLin *= pow(10, 9);
sprintf("%.3f nW", powerLin);
} else if (powerLin >= pow(10, -12)) {
powerLin *= pow(10, 12);
sprintf("%.3f pW", powerLin);
} else {
powerLin *= pow(10, 12);
sprintf("%.3f pW", powerLin);
}
lcd_16x2_write_line(&lcd, 1, 0, buffer);
usleep(2000);
}
ipcon_destroy(&ipcon); // Calls ipcon_disconnect internally
return 0;
}
}
Hardware
| Equipment | =Quantity |
|---|---|
| BeagleBone Black | 2 |
| 4096p/r Quadrature Optical Encoders | 2 |
| 16X2 LCD | 2 |
| antenna | 1 |
| RF detector | 1 |
RF DETECTION MODULE
| BBB Pin | LCD Pin |
|---|---|
| P9_7 | BREADBOARD POWER RAIL |
| BREADBOARD POWER RAIL | POTENTIOMETER AND PIN2(VDD) AND PIN 15(LED+) |
| P8_2 | BREADBOARD GROUND RAIL |
| BREADBOARD GROUND RAIL | PIN1(VSS) AND PIN5(R/W) |
| MIDDLE OF POTENIOMETER | PIN 3 (VO/CONTRAST) |
| P8_8 | LCD PIN4(RS) |
| P8_10 | PIN6(E/CLOCK ENABLE) |
| P8_18 | PIN 11 (DB4) |
| P8_16 | PIN12 (DB5) |
| P8_14 | PIN 13 (DB6) |
| P8_12 | PIN 14 (DB7) |
| P9_16 | PIN 16(-R/RED) |
| P9_14 | PIN 17 (-G/GREEN) |
| P8_13 | PIN 18 (-B/BLUE) |
| P9_40 | RF OUTPUT |
| P9_46 | GROUND BATTERY |
QUADRATURE OPTICAL ENCODER MODULE
| BBB Pin | LCD Pin |
|---|---|
| P9_7 | BREADBOARD POWER RAIL |
| BREADBOARD POWER RAIL | POTENTIOMETER AND PIN2(VDD) AND PIN 15(LED+) |
| P8_2 | BREADBOARD GROUND RAIL |
| BREADBOARD GROUND RAIL | PIN1(VSS) AND PIN5(R/W) |
| MIDDLE OF POTENIOMETER | PIN 3 (VO/CONTRAST) |
| P8_8 | LCD PIN4(RS) |
| P8_10 | PIN6(E/CLOCK ENABLE) |
| P8_18 | PIN 11 (DB4) |
| P8_16 | PIN12 (DB5) |
| P8_14 | PIN 13 (DB6) |
| P8_12 | PIN 14 (DB7) |
| P9_16 | PIN 16(-R/RED) |
| P9_14 | PIN 17 (-G/GREEN) |
| P8_13 | PIN 18 (-B/BLUE) |
| P9_42 | Quadrature Encoder 1 channel A |
| P9_27 | Quadrature Encoder 1 channel B |
| P8_35 | Quadrature Encoder 2 channel A |
| P8_33 | Quadrature Encoder 2 channel B |
Gallery
Please log in to post comments.
