Skip to content

Commit 5456b10

Browse files
committed
Initial file commit
1 parent 5a53288 commit 5456b10

13 files changed

+236
-0
lines changed

Beamforming/Main.m

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
clc;
2+
close all;
3+
clear a;
4+
a= arduino('com3','uno');%detect the arduino board
5+
6+
samples=10;
7+
v0=zeros(samples,1);
8+
v1=zeros(samples,1);
9+
v2=zeros(samples,1);
10+
11+
12+
%t0=milliseconds(v0);
13+
%t1=milliseconds(v1);
14+
%t2=milliseconds(v2);
15+
16+
%figure
17+
%h = animatedline;
18+
%ax = gca;
19+
%ax.YGrid = 'on';
20+
%ax.YLim = [0 7];
21+
22+
%startTime = datetime('now');
23+
while 1
24+
for i=1:samples
25+
v0(i) = readVoltage(a,'A0');
26+
v1(i) = readVoltage(a,'A1');
27+
v2(i) = readVoltage(a,'A2');
28+
end
29+
dot_product = dot(v0,v1);
30+
norm_product = (norm(v0)*norm(v1));
31+
phase_shift_in_degrees = acos(dot_product/norm_product)*(180/pi);
32+
disp(phase_shift_in_degrees);
33+
end
34+
clear a;

Circuit.jpg

4.34 MB
Loading

Ckt.jpg

3.82 MB
Loading

MicDetected.c

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
#include<lpc214x.h>
3+
#define bit(x) (1<<x)
4+
#define delay for(i=0;i<7000;i++);
5+
6+
#define SOUND (IO1PIN & (1<<24))
7+
8+
unsigned int i;
9+
10+
void lcd_int();
11+
void dat(unsigned char);
12+
void cmd(unsigned char);
13+
void string(unsigned char *);
14+
15+
void main()
16+
{
17+
IO0DIR =0XFFF;
18+
IO1DIR = 0x0;
19+
lcd_int();
20+
cmd(0x80);
21+
string("Sound Detected hello ");
22+
while(1) {
23+
if(SOUND == 0) { //When the sound detection module detects a signal, Print in the LCD
24+
string("Sound Detected");
25+
}
26+
delay;delay;
27+
cmd(0x01);
28+
}
29+
}
30+
31+
void lcd_int()
32+
{
33+
cmd(0x38);
34+
cmd(0x0c);
35+
cmd(0x06);
36+
cmd(0x01);
37+
cmd(0x80);
38+
}
39+
40+
void cmd(unsigned char a)
41+
{
42+
IO0PIN&=0x00;
43+
IO0PIN|=(a<<0);
44+
IO0CLR|=bit(8); //rs=0
45+
IO0CLR|=bit(9); //rw=0
46+
IO0SET|=bit(10); //en=1
47+
delay;
48+
IO0CLR|=bit(10); //en=0
49+
}
50+
51+
void dat(unsigned char b)
52+
{
53+
IO0PIN&=0x00;
54+
IO0PIN|=(b<<0);
55+
IO0SET|=bit(8); //rs=1
56+
IO0CLR|=bit(9); //rw=0
57+
IO0SET|=bit(10); //en=1
58+
delay;
59+
IO0CLR|=bit(10); //en=0
60+
}
61+
62+
void string(unsigned char *p)
63+
{
64+
while(*p!='\0') {
65+
dat(*p++);
66+
}
67+
}

MiniProject.vi

31.8 KB
Binary file not shown.

Phasediff.m

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
clc;
2+
close all;
3+
clear all;
4+
5+
a= arduino;%detect the arduino board
6+
f=1000;%in Hz
7+
c=343;%in m/sec
8+
%v=343;%speed of
9+
samples=input('Enter the input sample size: ');
10+
lambda=c/f; %source wavelength in m
11+
l=.04;%in m
12+
%filename = 'Testdata.xlsx';
13+
v0=zeros(samples,1);%A0
14+
v1=zeros(samples,1);%A1
15+
v2=zeros(samples,1);%A2
16+
17+
v3=zeros(samples,1);%A1
18+
v4=zeros(samples,1);%A2
19+
v5=zeros(samples,1);%A0
20+
21+
v6=zeros(samples,1);%A2
22+
v7=zeros(samples,1);%A0
23+
v8=zeros(samples,1);%A1
24+
25+
26+
while 1
27+
%tic;
28+
%1st for loop(Sampling order= 0 1 2)
29+
for i=1:samples
30+
v0(i) = readVoltage(a,'A0');
31+
v1(i) = readVoltage(a,'A1');
32+
v2(i) = readVoltage(a,'A2');
33+
end
34+
%2nd for loop(Sampling order= 1 2 0)
35+
for i=1:samples
36+
v3(i) = readVoltage(a,'A1');
37+
v4(i) = readVoltage(a,'A2');
38+
v5(i) = readVoltage(a,'A0');
39+
end
40+
%3rd for loop(Sampling order= 2 0 1)
41+
for i=1:samples
42+
v6(i) = readVoltage(a,'A2');
43+
v7(i) = readVoltage(a,'A0');
44+
v8(i) = readVoltage(a,'A1');
45+
end
46+
47+
%Phase Seq 1
48+
phim101 = myphase(v0,v1);
49+
phim112 = myphase(v1,v2);
50+
51+
%Phase seq 2
52+
phim201 = myphase(v5,v3);
53+
phim212 = myphase(v3,v4);
54+
55+
%Phase seq 3
56+
phim301 = myphase(v7,v8);
57+
phim312 = myphase(v8,v6);
58+
59+
phi1=myphase((v0+v5+v7)/3,(v1+v3+v8)/3);
60+
phi2=myphase((v1+v3+v8)/3,(v2+v4+v6)/3);
61+
theta2=(phi1+phi2)/2;
62+
63+
%fprintf('Phi1: %f\t%f\t%f\n',phim101,phim201,phim301);
64+
%fprintf('Phi2: %f\t%f\t%f\n',phim112,phim212,phim312);
65+
P1=phim101*phim112;
66+
P2=phim201*phim212;
67+
P3=phim301*phim312;
68+
69+
if(P1>=0)
70+
if(P2>=0)
71+
if(P3>=0)
72+
ph_diff1=(phim101+phim201+phim301)/3;
73+
ph_diff2=(phim112+phim212+phim312)/3;
74+
else
75+
ph_diff1=(phim101+phim201)/2;
76+
ph_diff2=(phim112+phim212)/2;
77+
end
78+
elseif(P3>=0)
79+
ph_diff1=(phim101+phim301)/2;
80+
ph_diff2=(phim112+phim312)/2;
81+
else
82+
ph_diff1=phim101;
83+
ph_diff2=phim112;
84+
end
85+
elseif(P2>=0)
86+
if(P3>=0)
87+
ph_diff1=(phim201+phim301)/2;
88+
ph_diff2=(phim212+phim312)/2;
89+
else
90+
ph_diff1=phim201;
91+
ph_diff2=phim212;
92+
end
93+
elseif(P3>=0)
94+
ph_diff1=phim301;
95+
ph_diff2=phim312;
96+
else
97+
ph_diff1=pi/2;
98+
ph_diff2=pi/2;
99+
end
100+
101+
102+
AngleOfArrival12=asin((ph_diff1*lambda)/(2*pi*l));
103+
%disp(AngleOfArrival12_deg);
104+
105+
AngleOfArrival23=asin((ph_diff2*lambda)/(2*pi*l));
106+
107+
theta=(AngleOfArrival12+AngleOfArrival23)/2;
108+
polarscatter(theta2,1);
109+
drawnow;
110+
%toc;
111+
end

Results/BeamPattern.fig

63.1 KB
Binary file not shown.

Results/BeamPattern.jpg

20.4 KB
Loading
22.3 KB
Loading
24.2 KB
Loading

Simultaneousacq.m

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
clc;
2+
close all;
3+
clear all;
4+
a=arduino;
5+
samples=100;
6+
v0 = readVoltage(a,'A0');
7+
v1 = readVoltage(a,'A1');
8+
v2 = readVoltage(a,'A2');
9+
b=zeros(samples,1);
10+
while 1
11+
tic;
12+
for i=1:samples
13+
b(i)=[v0 v1 v2];
14+
disp(b);
15+
end
16+
toc;
17+
end
18+

experimental_data.xlsx

20.6 KB
Binary file not shown.

myphase.m

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function phase = myphase(v10,v11)
2+
phase = acos(dot(v10,v11)/(norm(v10)*norm(v11)));
3+
if (phase < 0)
4+
phase = phase + 2*pi;
5+
end
6+
end

0 commit comments

Comments
 (0)