Sei sulla pagina 1di 19

10.1.

1 Detailed Discussion of Pertinent Subsystems


Wireless Transceiver Subsystem

The Wireless Transceiver Subsystem was a very crucial decision for the final
design. The wireless aspects of any two-way car alarm security system have
to be carefully crafted to work reliably and integrate with the existing system
architecture. Unfortunately, the later part integration of the Wireless
Transceiver Subsystem with the rest of the system proved ill conceived.
While the TRM-433-LT transceivers boasted variability in power biasing and
long-range, high-power reliable RF communication link, the system could not
operate at 5 V power supply. The datasheet explains that the highest power
supply useable by the transceivers is 4 V, experimentation deemed that at 4 V
this system had questionable reliability. In the end, transmissions were
successful with these transceivers using test data. But their use with other
subsystems was unsuccessful. For more detailed analysis of the Wireless
Transceiver Subsystem, consult Section 5.8 of Design Project Details.

Direct-Sequence Spread Spectrum Subsystems

This DSSS Subsystem was crucial to the full-duplex secure operation of the
Novel Two-Way Car Alarm Security System. In general, by theoretical
understanding of pseudo-random sequence characteristics over a wireless
channel a truly multiple access system is capable on any transmission
medium. In this regard, using two distinctly different PN sequences to spread
data, two independent data streams can be supplied simultaneously. Although
only one direction of communication was built in the prototype, a direct
duplicate in all aspects aside from the feedback taps of the PN generators
could provide the second half of the communication system. For more
detailed information of the DSSS Subsystems, consult Section 5.4 of Design
Project Details.

136
10.2 Ryan Ginter

10.2.1 Overview Discussion of the Project


Initially this project began with the desire to create a car-to-human communications alert
system. This was thought to have been a novel idea that was not readily available on the market.
When research began this assumption had been immediately proven wrong. There were in fact
several such systems already available for purchase. Following this discovery the projects goals
were adjusted. Now not only was there the goal of providing a secure car-to-human alarm
system, but now it was desired to accomplish this initial goal at a minimized cost. The reason
why the systems that are currently available were not known about initially was because they
cost a substantial amount of money. With this high price the demand for the product is not very
high, thus most people have continued to use the standard audio alarm systems. Producing the
direct alarm system at a lower cost would lead to a lower price for the end user. This would lead
to a greater demand of direct car-to-user alarm systems. Once people start to purchase these
systems the cases of annoying car alarms going on for hours will become a thing of the past. Car
owners will also receive the peace of mind that goes along with knowing their car is safe.
After the goals of the project were clearly set the next step was to decide upon the design
methodology to follow in order to implement a prototype system. One initial concern was how to
ensure that each car can only communicate with one user responder device. It would be very
undesirable if there was a chance that a user would receive an alert from someone else’s car. To
solve this research into Direct Sequence Spread Spectrum (DSSS) was completed. This involves
modulating the data with high frequency random noise sequences. Doing this before the wireless
transmission spreads the data over a large spectral area. This makes the signal appear as noise to
all other receivers that operate in the transmission frequency range. The only receiver that can
despread the data and recover it is one that has an exact replica of the noise sequence used to
spread the spectrum. Not only does this DSSS method help avoid inter-user interference, but it
also allows for a full duplex system. Full duplex meaning the car and user can communicate back
and forth between one another on the same frequency channel. The way this system provides the
full duplex channel is to used two separate noise sequences for each direction of communication.
After DSSS was decided to be used in order to provide secure transmission, the question
became how to wirelessly transmit the data. For this concern several modulation options were

137
explored including frequency shift keying (FSK), amplitude shift keying (ASK), on-off shift
keying (OOK), and binary phase shift keying (BPSK). Initially it was desired to use FSK or
BPSK because of there resilience against noise, but because of hardware limitations OOK was
the only viable option. However within the DSSS Subsystem, BPSK was performed at a low
frequency to prove that is an option given the appropriate hardware to convert it to higher
frequencies.
Along with the DSSS and wireless communication necessary for the system to be secure
it was also determined that some form of error checking should be implemented to eliminate the
chance of false alarms. To do this research was done into several error correction methods before
the final decision was made to implement Hamming (7, 4) codes. The reason for this choice was
because of its ability to both detect and correct bit errors. The last piece of the project was the
baseband communications that was necessary to accurately convey the sensor data to the DSSS
system and interpret the data accurately at the user’s responder.
After the design methods for the overall system were defined, the system was categorized
into two major parts. The first being the DSSS communications system and the second being the
baseband communications system. In the final prototype these two systems were to be integrated
to provide a secure and accurate communication link between sensor status and alert. After
defining the two systems and dividing the work evenly between group members, individual
research was performed on hardware possibilities for each system. Following this research
hardware test were designed and performed to characterize each subsystem before attempting the
final integration.
Following the subsystem hardware tests the final integration between DSSS and
baseband communications was performed. This integration went very well leading to a final
prototype, two sensor system, whose alerts are conveyed by LEDs that correspond to the specific
sensor that was triggered. The final prototype was able to use DSSS to effectively spread and
despread the data, however it was never performed wirelessly. While an OOK wireless link was
established it was not able to be correctly integrated within the final system, because of
unforeseen characteristics of the OOK transceivers used. Despite this issue evidence was shown
that this form of car-to-user communication is very possible. Not only is it possible, but it can be
done at an inexpensive cost.

138
This project, while successful in creating a prototype, was very challenging process.
Throughout the process a great appreciation was developed for the complexities of the systems
that being implemented on standard ICs, such as the UART and DSSS transmission system.
Along with this appreciation came the rewarding sense of accomplishment in having the chance
to develop a project from concept to end prototype.

10.2.2 Detailed Discussion of Pertinent Subsystem


As mentioned in 10.2.1 the project was divided between DSSS communication and
baseband communication. Within the area of baseband communication the goal was to take the
information generated from sensor and convert it to the appropriate transmission format. Then
upon receiving the data it must be checked for errors that may have occurred throughout the
transmission, and converted to a readable format such that the appropriate alerts can be indicated.
One baseband design method concern was what sensors to use, and how to go about
transmitting and interpreting the data that was indicated by the sensors. The sensor of most
interest was the SQ-SEN-200, which had several useful qualities. It was able to be mounted in
any direction and detect any vibration or tilting. This was ideal to sensing car windows being
broken or pulls of the car door handle. The major design aspect of this sensor was that while it
essentially acted like a switch, it was a switch that when triggered simply chattered rather then
changing states. For this reason previous knowledge of digital logic was drawn upon to develop
the SR latch trigger system. Using this method allowed for the output of the SR latch to remain
logic high even in the event that the sensor went back to an idle state. In the final prototype a
variant of this sensor system was implemented. The SQ-SEN-200 was simulated with toggle
switches, and the SR latch was removed because there was yet to be any user-to-car
communication to reset the latch.
After the sensor choice had been established, the question of transmitting the data from
the sensors and interpreting the data after it was received started to be of concern. Initially it was
thought that to save on cost the baseband communication between sensor and alert could be
easily done with simple logic ICs. While using ICs did help save on cost implementing the
system with logic was not simple. The biggest issue being how to ensure that the data is correctly
interpreted by the receiver. Research then took place into asynchronous data recovery. From this
research it was determined that there was the need to frame the data. Another concern was
139
finding the appropriate ICs to use in the system. Without the proper searches the desired
hardware was hard to find. Because of the difficulty to find hardware and the synchronization
issue a UART was going to be used. The Universal Asynchronous Receiver Transmitter
accomplished both framing of the data and converting the data from parallel-to-serial and serial-
to-parallel, not to mention it also added a parity bit for error detection. In the end the UART idea
was discarded because it involved expensive and complex controls, in order to get the desired
functions for this project from it.
This then left the option of creating parallel and serial shift registers through the used of
several D flip-flop ICs. While this would involve a lot of ICs, at the time it seemed to be the only
option in hardware. As this detailed design idea was about to be implemented research began
into how to detect start bits that would be used to frame the data. From this research, the
functional designs of a UART were discovered. Within these designs were several 74HC series
ICs that accomplished exactly what was current being planned to be done by D flip-flops. This
quickly led to the change to using 74HC series ICs. Then the UART designs were analyzed and
altered to create a baseband system that would be customized to the car-to-user systems needs.
In parallel with the research on transmitting the baseband data the error detection method
was also being researched. Within this research several error detection methods were discovered.
The methods of most interest were Cyclic Redundancy Checks (CRC), Hamming (7, 4) codes,
repetition codes, and parity bits. While each one had its own advantages and drawbacks, the final
decision was made to use Hamming for its correction capabilities. Once decided upon further
research was done into how Hamming codes work. It was discovered that it involves some
simple linear algebra techniques to generate three parity bits. Then using these parity bits along
with the data, a check can be performed to determine if the data corresponds to the parity bits
sent. If not using linear algebra again it can be determined where exactly an error has occurred.
For more information on the details of these algebraic methods refer back to Section 5.7.
The final step of the Hamming process was to implement it in hardware. This was done
simply with XOR gates to perform the proper matrix multiplications and additions modulus two
to generate the parity bits. Then parity checkers and a decoder were able to be combined to check
for errors, and look up where the errors occurred. After this hardware was built several extensive
test were complete as shown in Section 5.7.2. Then as the Baseband Transmit and Receive Data

140
Subsystem designs were completely tested it was decided to integrate the overall baseband
system on a PCB.
The PCB decision came about in order to make the design more presentable, and to
simplify the integration process between the DSSS system and baseband system. This PCB
design process involved deciding upon the best IC layout that would minimize the space needed
by the board, along with minimizing the complexity of the connections on the board. After
several designs were attempted the final PCB design in Figs. 3.4.9 – 3.4.12 were decided upon.
Within these designs several connections were changed to simplify the number of connections on
the board. This was possible because only the two sensor system was being prototyped. The next
step in the PCB design process was to manufacture the boards. This involved first creating
transparencies of the PCB designs. Then the transparencies were placed over the copper clad
boards and exposed to a UV light. Next the board is place in a solution of positive developer to
remover the protective coating of the copper clad board except in the areas that were not exposed
to the UV light. Then the board was place in a Ferric Chloride which removed all of the copper
that was exposed the UV light. This left just the copper that outlined the pathways of the circuit.
The board was then assembled and tested. Despite the initial concerns, the board functioned just
as it did the protoboard level, with the added functionality of Hamming correction codes.
After all of the baseband processes were built and tested the system was integrated with
the DSSS subsystem. The only issue that came about during this process was the need for the
data to be inverted for the two systems to work properly. Once this adjustment was made
transmissions were tested and the system was characterized appropriately as described in Section
3.3. While this integration was being completed the wireless communication link was being
established. As mentioned earlier in Section 10.2.1 OOK was the choice made for the final
wireless link. To complete this system, transceivers were isolated from older systems, than
rewired to be tested. Once a link was established it was attempted to send the baseband data over
this link, but it was ultimately unsuccessful. Data was able to be sent and received, however it
was never done accurately. The reason for this was discovered to be a difference in framing
protocols between the baseband communications and wireless transceivers. The solution to this
issue would involve reworking either the baseband’s framing method or the transceiver choice.
At the point of this discovery it was too late for either of these options to be pursued. The
wireless test was not a complete failure it still proved that a wireless link could be established

141
with the overall system given the proper specifications for interpreting the data. For further detail
into the wireless issues and solutions refer to Section 5.8.
Overall while the final system had many subsystems operational and interrogated, the
final prototype was simply a proof of concept. This prototyped demonstrated the possibility for a
communication link to be established between a car and user via DSSS transmission method. It
also demonstrated that the baseband processes can be done inexpensively if the proper parts are
found. While in the end the Hamming codes were seemingly unnecessary, they were proven to
work. The Hamming codes become more important if the prototype eventually develops a
wireless component. Steps that would be necessary to carry this project forward would be to first
rework the wireless method, then to PCB the whole system in to a more compact and user
friendly product.

142
References
1. Chiang, Chin-Yi. Serial-to-Parallel Data Converter and Method of Conversion. Patent No:
6,768,431 B2. Jul. 27, 2004. http://www.freepatentsonline.com/6768431.pdf

2. C, J. MATLAB File Exchange. “BPSK and ASK Simulation”. 18 Apr. 2005. <
http://www.mathworks.com/matlabcentral/fileexchange/7458-bpsk-and-ask-
simulation>

3. CRC-Digital Hardware Design Concept. http://ishakcute.tripod.com/00000.pdf

4. Digi-key electronics product finder. Digi-key Corporation. Spring 2010.


<www.digikey.com>.

5. Dipperstein, Michael. “Hamming (7,4) Code Discussion and Implementation.”


http://michael.dipperstein.com/hamming/index.html

6. Haykin, Simon. Communication Systems. “7.2 Pseudo-Noise Sequences”. 2001. 4th Edition.

7. Hornet Car Security – Technology. Hornet Car Security Glossary. 02/17/2010. <
http://www.hornetcarsecurity.com/Technology/Glossary.aspx

8. ISM band 433/868 http://www.iaf-bs.de/projects/ism-433-868.en.html

9. Kesteloot, André. The ARRL Spread Spectrum Sourcebook. “Experimenting With Direct-
Sequence Spread Spectrum”. Pages 8-31 – 8-35. Published 1991.

10. Micrel. “4-bit Parallel-to-Serial Image Converter.” Micrel, Inc. 2006.


http://www.micrel.com/_PDF/HBW/sy10-100e446.pdf

11. Mouser electronics product finder. Mouser electronics. 02/03/2010. <http://mouser.com>.

12. Mueller, Dieter. “Build your own UART”. 2007.


http://www.6502.org/users/dieter/uart/uart_1.htm
13. SignalQuest: Precision Microsensors. http://www.signalquest.com/sq-sen-200.htm

14. Viper Car Alarm – Technology. Viper Car Alarms. 02/17/2010. <
http://www.viper.com/Technology/>

15. Wakerly, John F. Digital Design: Principles and Practices. “Hamming.” Pages 63, 450-
451.

16. Wakerly, John F. Digital Design: Principles and Practices. “Counters.” Pages 711-713.

17. Wakerly, John F. Digital Design: Principles and Practices. “Shift Registers.” Pages 727-
730.

143
18. Ebay. Estimated prices of competing systems drawn from the following:

a. http://cgi.ebay.com/ebaymotors/DEI-564T-HORNET-2WAY-ALARM-
SYSTEM-564T-
_W0QQcmdZViewItemQQhashZitem3ee9f4fb01QQitemZ27021311872
1QQptZCarQ5fAudioQ5fVideo#ht_554wt_939

b. http://cgi.ebay.com/Viper-5002-Responder-2-Way-Security-System-Car-
Alarm-/140400966969?
cmd=ViewItem&pt=LH_DefaultDomain_0&hash=item20b08cbd39

c. http://cgi.ebay.com/VIPER-5902-2-Way-HD-Car-Alarm-Remote-Start-
Pager-/140400965158?
cmd=ViewItem&pt=LH_DefaultDomain_0&hash=item20b08cb626#ht_
12416wt_1165

144
APPENDICES

Appendix 1: List of Equipment

Oscilloscope
• Tektronix DPO 4032 Digital Phosphor Oscilloscope
o Used to observe waveforms in time domain.

Spectrum Analyzer
• Agilent E4411B ESA-L Series Spectrum Analyzer
o Used to observe frequency content of waveforms
o Frequency analysis capability of range 9 kHz - 1.5 GHz

Function Generators
• Tektronics FG 501A 2 MHz Function Generator
o Used to generate modulating signal (50 Hz to 15 kHz)
• Hewlett Packard 3314A Function Generator
o Used to generate carrier signal during modulation exercise and used to generate
AM modulated signal for synchronous demodulation exercise

Power supplies
• Tektronix PS503A Dual Power Supply
o Used to provide DC bias power to circuit components.

Multimeter
• Agilent 34401A 6½ Digit Multimeter
o Aided in circuit debugging via voltmeter mode.
o Aided in quality assurance of resistor values in ohmeter mode.

Protoboards
• EIC-104-1
o Provided layout for easy connection of components to form circuits used in
experiments.

BNC connectors
• Various sizes
o Used to for isolated signal transport between circuit and equipment modules.
o Manufacturers: Pomona Electronics, Pasternack Enterprises

145
Appendix 2: Simulations and Program Code
Hamming (7, 4).m

%Hamming code simulation-JC-4/15/06


%To run hit F5 and observe command window
%Simulation for encoding and decoding of a [7,4] Hamming code.
The decoder
%can correct one error as shown and as theory states. The table
at the end
%of the file shows the various outputs with different error
positions and
%message bits. One error can be placed at any of the 7 bit
locations and
%corrections made.
clear
n = 7%# of codeword bits per block
k = 4%# of message bits per block
A = [ 1 1 1;1 1 0;1 0 1;0 1 1 ];%Parity submatrix-Need
binary(decimal combination of 7,6,5,3)
G = [ eye(k) A ]%Generator matrix
H = [ A' eye(n-k) ]%Parity-check matrix
% ENCODER%
msg = [ 1 1 1 1 ] %Message block vector-change to any 4 bit
sequence
code = mod(msg*G,2)%Encode message
% CHANNEL ERROR(add one error to code)%
%code(1)= ~code(1);
code(2)= ~code(2);
%code(3)= ~code(3);
%code(4)= ~code(4);%Pick one,comment out others
%code(5)= ~code(5);
%code(6)= ~code(6);
%code(7)= ~code(7);
recd = code %Received codeword with error
% DECODER%
syndrome = mod(recd * H',2)
%Find position of the error in codeword (index)
find = 0;
for ii = 1:n
if ~find
errvect = zeros(1,n);
errvect(ii) = 1;
search = mod(errvect * H',2);
if search == syndrome
find = 1;
index = ii;
146
end
end
end
disp(['Position of error in codeword=',num2str(index)]);
correctedcode = recd;
correctedcode(index) = mod(recd(index)+1,2)%Corrected codeword
%Strip off parity bits
msg_decoded=correctedcode;
msg_decoded=msg_decoded(1:4)

%Error position Syndrome Decimal 4 bit word


codeword dmin
% 1 111 7 0000 0000000
% 2 110 6 0001 0001011
3
% 3 101 5 0010 0010101
4
% 4 011 3 0011 0011110
3
% 5 100 4 0100 0100110
3
% 6 010 2 0101 0101101
3
% 7 001 1 0110 0110011
4
%No error will give syndrome of 000 0111 0111000
3
% 1000 1000111
4
% 1001 1001100
3
% 1010 1010010
4
% 1011 1011001
3
% 1100 1100001
3
% 1101 1101010
3
% 1110 1110100
4
% 1111 1111111
3
%Any exclusive or additions of any two codewords should give
another
%codeword.
147
-------------------------------------------------------------------------------------------------------

BPSK_ASKsims_elds.m – A few modifications were made to the code to make the output
graphs more usable for the report. Shows BPSK vs. ASK theoretical BER and also
simulation results via MATLAB computation. Varies each run of the code slightly as the
noise is randomly generated. [2]
%Run from editor Debug(F)
%This m file(ASK.m) analyzes a coherent amplitute shift keyed(ASK) and a
binary
%phase shift keyed(BPSK) communication system. The receiver uses a correlator
%(mixer-integrator [lpf]) configuration with BER measurements comparing
measured
%and theoretical results. The band pass and low pass filters used in the
%receiver are
%constructed using z transforms. M files on BPF and LPF design using z
%transforms can be found in the author index (CJ) mathworks file exchange. A
%fundemental
%question to ask is: "Why does BPSK show a 3dB improvement(as you will see
using %the
%program)in BER over ASK?". A simple answer is that the signal for ASK is
being
%transmitted only half the time. A reference is provided at the end of the
%program that
%was used in writing the program. Always remember a journey of a thousand
%miles requires a first one small step.

%========================================
% Set universal parameters
%=======================================
clear
fs=8e5;%sampling frequency
fm=20e3;%square wave modulating frequency(NRZ)= 40KHz bit rate
n=2*(6*fs/fm);
final=(1/fs)*(n-1);
fc=2e5; % carrier frequency
t=0:1/fs:(final);
Fn=fs/2;%nyquist frequency

%=========================================
%Generate square wave by using cosine wave
%==========================================
% cosine wave
% 2 pi fc t is written as below
twopi_fc_t=2*pi*fm*t;
A=1;
phi=0;
x = A * cos(twopi_fc_t + phi);

% square wave
am=1;

148
x(x>0)=am;
%x(x<0)=0;%use for ASK-comment out BPSK
x(x<0)=-1;%use for BPSK-remember ASK variables become BPSK

figure(1)
subplot(211);
plot(t,x);
axis([0e-4 100e-6 -2 2]);
title('Square Wave Modulating Input To Transmitter');
grid on

car=sin(2*pi*fc*t);%Sinewave carrier waveform


ask=x.*car;%modulate carrier(ASK or BPSK)

subplot(212);
plot(t,ask);
axis([0 100e-6 -2 2]);
title('Modulated Sinewave Carrier Waveform');
grid on;
%=====================================================
%Noise generator SNR=Eb/No=20log(Signalrms/Noiserms)
%======================================================
%vn=0;
vn=.1;%set noise level 0.1~=6db=SNR=Eb/No
noise=vn*(randn(size(t)));%noise generator

figure(2)
subplot(311);
plot(t,ask);
axis([0 100e-6 -2 2]);
title('Modulated Sinewave Carrier Waveform');
grid on;

subplot(312);
plot(t,noise);
grid on;
title('Noise Level');
axis([0 100e-6 -1 1]);

askn=(ask+noise);%modulated carrier plus noise


subplot(313);
plot(t,askn);
axis([0 100e-6 -2 2]);
title('Modulated Carrier Waveform Plus Noise');
grid on;

%% STOPPED HERE -- 03-01-2010 (consider changing the frequency so the plots


%% are easier to see!!!

%======================================================================
%Receiver bandpass filter(two poles two zeros)
%======================================================================
fBW=40e3; %Bandwidth = 40 kHz

149
f=(0:3e3:40e3); %spectrum 0 to 40 kHz, 3 kHz intervals.
w=2*pi*f/fs;
z=exp(w*j); %#ok<*IJCL>
BW=2*pi*fBW/fs;
a=.8547;%BW=2(1-a)/sqrt(a)
p=(j^2*a^2);
gain=.135;
Hz=gain*(z+1).*(z-1)./(z.^2-(p));

figure(3)
subplot(411);
plot(f,abs(Hz));
title('Receiver Bandpass Filter Response');
grid on;

Hz(Hz==0)=10^(8);%avoid log(0)
subplot(412);
plot(f,20*log10(abs(Hz)));
grid on;
title('Receiver -3dB Filter Response');
axis([1e5 3e5 -3 1]);

%filter coefficients
a=[1 0 .7305];%[1 0 p]
b=[.135 0 -.135];%gain*[1 0 -1]
faskn=filter(b,a,askn);
figure(3)
subplot(413);
plot(t,faskn);
axis([0 100e-6 -2 2]);
title('Receiver BPF Output');
grid on;

cm=faskn.*car;%multiply modulated carrier with unmodulated carrier


figure(3)
subplot(414);
plot(t,cm);
axis([0 100e-6 -2 2]);
grid on;
title('Receiver Multiplier Output');

%%

%===================================================================
%Low pass filter(one pole one zero)
%==================================================================
p=.72;
gain1=.14;%gain=(1-p)/2
Hz1=gain1*(z+1)./(z-(p));
%0.65=53KHz
%0.7=45KHz
%0.72=40KHZ=best for lowest BER-Theory says set equal to the bit rate
%0.75=37KHz

150
%0.8=28KHz

%subplot(323);
%plot(f,abs(Hz1));
%title('Receiver LPF Response');
%grid on;

subplot(323);
Hz1(Hz1==0)=10^(-8);%avoid log(0)
plot(f,20*log10(abs(Hz1)));
grid on;
title('LPF -3dB response');
axis([0 5e4 -3 1]);

%filter coefficients
a1=[1 -.72];%(z-(p))
b1=[.14 .14];%gain*[1 1]

so=filter(b1,a1,cm);
so=so*10;%add gain
so=so-mean(so);%removes DC component
subplot(324);
plot(t,so);
axis([1e-4 3e-4 -2.5 2.5]);
title('Receiver Output Signal-LPF');
grid on;

%%

%======================================================
%Comparator
%======================================================
High=2.5;
Low=-2.5;
vt=0;%sets comparator threshold
error=0;
%calculate the number of elements in matrix so, the output of the filter
len1=length(so); %number of elements in so
for ii=1:len1
if so(ii) >= vt
Vs(ii)=High;
else
Vs(ii)=Low;
end
end
Vo=Vs+2.5;
subplot(325);
plot (t,Vo), title('Receiver Regenerated signal'),
axis([1e-4 3e-4 -8 8])
grid on;
xlabel('Time (s)'), ylabel('Magnitude(V)'),

%%

151
%========================================================
%Generate delayed squarewave
%=========================================================
%cosine wave delayed to match receiver regenerated signal square waves.
%filters have delay
% 2 pi fc t is written as below
twopi_fc_t1=2*pi*fm*(t-.59e-4);%adds delay
%A=1;
phi1=0;
x1 = A * cos(twopi_fc_t1 + phi1);

% square wave
x1(x1>0)=am;
x1(x1<0)=0;

sr=x1;
sf=5*sr;
subplot(326);
plot (t,sf), title('Input signal-delayed'),
axis([1e-4 3e-4 -8 8]);
grid on;
xlabel('Time (s)'), ylabel('Magnitude(V)'),

a=5*xor(sf,Vo); %show where errors occur against time.


figure(3);
plot (t,a), title('Error pulses'),
axis([0 8e-4 -8 8]);
grid on;
xlabel('Time (s)'), ylabel('Magnitude(V)'),
%for ii=1:len1;
for ii=20:1:len1%during startup,errors are generated. The first 20 samples
of len1
%(480 samples) are bypassed and no noise gives zero errors.
480-20=460
if sf(ii) ~= Vo(ii) % if output and input are not the same then increment
error
error=error+1;
end
end
error %display number of errors

figure(4);
err=[0 0 0 0 0 0 error/460 0 0];%Measured at different values of SNR by
setting vn
snr=10.^ ( [0:0.1:12]./10);
Pb= 0.5*erfc(.707*sqrt(snr)); % BER (Theoretical-ASK)
Pb1= 0.5*erfc(sqrt(snr)); % BER (Theoretical-BPSK)
semilogy([0:8],err,'*',[0:0.1:12],Pb,'-',[0:0.1:12],Pb1,'--'); % plot
grid on; xlabel('SNR=Eb/No(dB)'); ylabel('BER');
title('Simulation of BER for ASK and BPSK');
legend('BER','ASK Theoretical','BPSK Theoretical');
BER=error/460%display BER
%Could have set up a for loop using vn to calculate all points(err) but would
%complicate matters.Easier to run by hand and observe BER plot. Presently
%set for SNR=6dB.

152
%%

%===================================================
%Frequency domain plots
%====================================================
%Lets take a look at askn(unfiltered carrier + noise) and
%faskn(band pass filtered carrier + noise) output on a spectrum analyzer.
%This fft code is somewhat complex but comes from the mathworks. Works
%great as it shows one what they would actually see using a spectrum analyzer.

%y=askn;%unfiltered carrier + noise


y=faskn;%band pass filtered carrier + noise
NFFY=2.^(ceil(log(length(y))/log(2)));
FFTY=fft(y,NFFY);%pad with zeros
NumUniquePts=ceil((NFFY+1)/2);
FFTY=FFTY(1:NumUniquePts);
MY=abs(FFTY);
MY=MY*2;
MY(1)=MY(1)/2;
MY(length(MY))=MY(length(MY))/2;
MY=MY/length(y);
f1=(0:NumUniquePts-1)*2*Fn/NFFY;

figure(5)
% subplot(2,2,1); plot(f1,MY);xlabel('FREQUENCY');ylabel('AMPLITUDE');
% axis([0 3e5 -.5 1]);%zoom in/out
% title('Modulated Tx carrier plus noise');
% grid on;
plot(f1,20*log10(abs(MY).^2));xlabel('FREQUENCY');ylabel('DB');
axis([0 3e5 -60 5]);
grid on;
title('Power Spectral Density of BPSK data')

%Reference
%http://soe.unn.ac.uk/ocr/people/ghassemlooy/
%Prof. Z Ghassemlooy's website
%Good site for theory and m files. I structured this m file from his work
%and have added a few things. I constructed filters using z transforms
%since I don't have the filter toolbox functions.

153
Appendix 3: Datasheets
TRM-433-LT - Transceiver RF 433 MHz LT Series
http://www.linxtechnologies.com/Documents/TRM-xxx-LT_Data_Guide.pdf

SQ-SEN-200 - Omnidirectional Tilt and Vibration Sensor


http://www.signalquest.com/datasheets/SQ-SEN-200%20Omnidirectional%20Tilt
%20and%20Vibration%20Sensor%20Datasheet.pdf

74HC04 - Inverters
http://www.fairchildsemi.com/ds/MM/MM74HC04.pdf

74HC00 - NAND
http://www.fairchildsemi.com/ds/MM/MM74HC00.pdf

74HC08 - AND
http://www.fairchildsemi.com/ds/MM/MM74HC08.pdf

74HC86 - XOR
http://www.fairchildsemi.com/ds/MM/MM74HC86.pdf

HCF4077BEY - XNOR
http://www.st.com/stonline/products/literature/ds/8229/hcf4077.pdf

74HC138 - 3:8 Decoder


http://www.fairchildsemi.com/ds/MM/MM74HC138.pdf

74HC280 – Parity Checker


http://www.st.com/stonline/books/pdf/docs/1938.pdf

MC14043BCPG – SR Latch
http://www.onsemi.com/pub_link/Collateral/MC14043B-D.PDF

74HC163 – 4 Bit Synchronous Binary Counter


http://focus.ti.com/lit/ds/symlink/sn74hc163.pdf

74HC574 – Hold Register


http://www.fairchildsemi.com/ds/MM/MM74HC574.pdf

74HC166 – Parallel-to-Serial Shift Register


http://www.nxp.com/documents/data_sheet/74HC_HCT166_CNV.pdf

74HC151 – 8:1 Multiplexer


http://focus.ti.com/lit/ds/symlink/sn74hc151.pdf

74HC164 – Serial-to-Parallel Shift Register


http://focus.ti.com/lit/ds/symlink/sn74hc164.pdf

74HC74 – D Flip-Flop
http://focus.ti.com/lit/ds/symlink/sn74hc74.pdf

154

Potrebbero piacerti anche