Final Report
Final Report
By
Arunkumar.V
Rahul T. Nath
Sarath R
Varun Venugopal
Vipin M S
Our prostrations at the lotus feet of our beloved amma, Satguru Mata Amritanan-
damayi Devi;the guiding light and inspiration for all.
Firstly all thanks to our Principal Dr.K.Sankaran for giving us all the facilities for the
project thereby helping us accomplish a goal we had been dreaming of for the past cou-
ple of years.
Next we express our heartfelt gratitude to our guide Mr.R Suresh Kumar who was
unparallel in his efforts in making this project a reality. We would also like to add that
had it not been for his continuous inspiration and guidance, our project would not have
achieved even half the success that we enjoy today in its completion.
We also express our deep gratitude to Br. Jairaj for showing a keen interest in our
Surveillance System and for providing us with solutions that helped us complete our
project.
We would also like to thank our project coordinator Dr. Sundar Gopalan for provid-
ing us with all the facilities and all guidance necessary in making this project a reality.
Special thanks to Br. Karthi B for the constant support and guidance that we received.
Last we thank all the other members of the great project Security and Surveillance Sys-
tems who have helped each other in the long process of the design phase of the project.
Thanks go to all people who have helped us directly or indirectly in the literary work of
this project
1
Abstract
The system is intended to establish a secure wireless channel for communication. The
channel is to be used for voice transmission. The voice data of the personnel is first
received by the voice encoder module which converts the signal to the corresponding
digital counterpart. The data is encrypted at the transmitter using the RC4 algorithm
and decrypted at the receiver end to ensure security during communication. The digital
counterpart of the data is sampled using delta modulation. The wired equivalent pri-
vacy (WEP) protocol is used to protect data during wireless transmission. The project
consists of mobile transceiver units which enables wireless channel for communication
between security personnel with the help of the Switching Unit.
2
Contents
1 Introduction 5
2 Project Description 7
2.1 Block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.1 Voice Acquisition . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.2 Crypto systems . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.3 Buffering and transmission . . . . . . . . . . . . . . . . . . . . 10
2.2.4 Receiver side . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5 Future Enhancements 24
A Source Codes 26
A.1 Delta modulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
A.2 RC4 encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
A.3 Buffer 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
A.4 Buffer 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
A.5 Receiver and decryption . . . . . . . . . . . . . . . . . . . . . . . . . 38
A.6 Demodulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3
B Datasheets 46
B.1 PIC16F877A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
B.2 Wired Equivalent Privacy Protocol . . . . . . . . . . . . . . . . . . . . 47
B.3 Wireless Transmitter and Receiver Modules . . . . . . . . . . . . . . . 48
4
Chapter 1
Introduction
The secure wireless communication system is a part of the security and surveillance
system which is intended to ensure the secure wireless communication between secu-
rity personnel. The main sub categories of this high end security system are BIOMET-
RIC SENSOR, RFID, TRACKING and POSITIONING, the WIRELESS COMMU-
NICATION SYSTEM, the SWITCHING STATION and the PC INTERFACE AND
DISPLAY UNIT of which the wireless communication system plays a major role in
ensuring the security aspects of the system.
The secure wireless communication system helps security personnel to communicate
between each other within the area under the Security and Surveillance System. There
will be four mobile transceiver units which will be with people who assume the same
priority under the security hierarchy. The request for calling any other user will be pro-
cessed by the switching station and the call will be allowed if the user being requested
is not engaged in another conversation. The security of communication is ensured by
the encryption used. The modulation scheme used for efficient transfer of data is Am-
plitude Shift Keying.
Wireless systems are now a major part of many commercial organizations and network-
ing infrastructures. The benefits of cost efficiency, flexibility and rapid deployment
have been utilized on mass for many years. The wireless networking faces many se-
curity issues. In wireless communication systems an encryption algorithm is used for
security reasons. In cryptography, RC4 (also known as ARC4 or ARCFOUR) is the
most widely-used software stream cipher and is used in popular protocols such as Se-
cure Sockets Layer (SSL) and WEP (to secure wireless networks). RC4 was designed
by Ron Rivest of RSA Security in 1987; while it is officially termed ”Rivest Cipher 4”,
the RC acronym is alternatively understood to stand for ”Ron’s Code”.
5
The RC4 encryption requires secure transfer of Encryption Key. For this secure key
transfer we use Asymmetric algorithms such as RSA. The algorithm was publicly de-
scribed in 1977 by Ron Rivest, Adi Shamir and Len Adleman at MIT; the letters RSA
are the initials of their surnames. RSA is an algorithm for public-key encryption. It was
the first algorithm known to be suitable for signing as well as encryption, and one of the
first great advances in public key cryptography. RSA is still widely used in electronic
commerce protocols, and is believed to be secure given sufficiently long keys. The sys-
tem that we are trying to implement is similar to Wired Equivalent Privacy (WEP). It
is a scheme that is a part of the IEEE 802.11 standards to secure wire less networks.
Because wireless broadcasts using radio, it is particularly susceptible to eavesdropping.
WEP uses stream cipher RC4 for confidentially and the CRC-32 checksum for integrity.
WEP relies on a secret key that is shared between a mobile station and an access point.
The secret key is used to encrypt packets before they are transmitted and an integrity
check is used to ensure that they are not modified in transit.
The RC4 initial key has two sets:
The first 24 bit keys are fixed in the two access points.
The next 24 bit is selected from a random key generation algorithm in the transmitter
side per frame and transmitted with each frame.
Key stream for a packet is generated from this initial key and one packet is encrypted
with this key stream generated. We need to initialize RC4 and generate key stream for
every frame. The 24 bit RC4 initial key is transmitted with the packet and is used in the
receiver to generate the key stream and decrypt the data.
6
Chapter 2
Project Description
2.2 Description
7
analog signal, digitize it using its inbuilt ADC, performs delta modulation based on
ADC output and then converts it into bytes of data. This data is then sent to the RC4
module. Proper acknowledgment is provided for synchronized communication between
these modules. The delta modulation scheme can be better understood with the help of
the algorithm.
4. Compare the previous byte of the ADC and the present byte
7. The delta bits are then collected and then transferred in the form of bytes.
8. Before transmitting, a signal is given to the RC4 module to indicate start of trans-
mission.
8
RC4
Stream ciphers are very important part of encryption algorithm. RC4 is a variable-key-
size stream cipher developed in 1987 by Ron Rivest of M.I.T. for RSA Data Security.
RC4 is used in a number of applications today. One of it most important use is in
SSL, which is used to secure most of the worlds electronics over the World Wide Web,
it is also used in IEEE802.11 wireless network security standards. RC4 is a binary
additive stream cipher. It uses a variable sized key that can be range between 8 and
2048 bits in multiples of 8 bits. This means that the core of the algorithm consist
of key stream generator function. This function generates a sequence of bits that are
then combined with the plain text with XOR. Decrypting consists of re-arranging this
key stream and XORing it to the clipper text, undoing it. The other major part of
the algorithm is the initialization function, n, which accepts a key of variable size and
uses it to create the initial state of the key stream generator. This is known as the key
scheduling algorithm. RC4 is actual a class of algorithms parameterized on the size of
its block. This parameter, n, is the word size for the algorithm. This is recommended n
= 8, but for analysis purpose it can be convenient to reduce this. Also, for extra security
it is possible to increase its value. The internal state of RC4 consists of a table of size
2n words and two word sized counters. The table is known as the S-box, and will be
known as S. It always contains a permutation of the possible 2n values of a word. The
two counters are known as i and j.
Initialisation:
1. for i=0 to 2n -1
s[i]=0
2. j=0
Scrambling:
1. For i=0 to 2n -1
j=j+S[i] +K [i mod l]
Swap(S[i], S[j])
The key scheduling algorithm of RC4 is shown above. It accepts as input the key stored
in K, and is l bytes long. It starts with the identity permutation in S and, using the key
continually swapping values to produce a new unknown key independent permutation.
Since the only action on S is to swap two values, the fact that S contains a permutation
9
is always maintained. The RC4 key stream generation is given below. It works by
continuously shuffling the permutation stored in S as time goes on, each time picking
a different value from the S permutation as output. One round of RC4 outputs an n bit
word as key stream, which can then be XORed with the plain text to produce the clipper
text.
Initialisation:
1. i=0, j=0
Generation loop:
1. i=i+1
2. j=j+S[i]
3. Swap(S[i], S[j])
The transmitter needs a pair of flip buffers, the frame structure is shown in
Frame
The frame format is shown in figure 2.2
Buffer 1 Algorithm
Inputs
Frame select key from RC4 algorithm
10
Figure 2.2: WEP frame format
3. loop:
Wait to get a high frame select signal from the RC4 algorithm
Allow buffer 2 to send data
Prevent buffer 2 to save data
Save the data in the buffer 1 buffer
Wait to get a low frame select signal from the RC4 algorithm
Allow buffer 2to save data
Prevent buffer 2 to send data
Send the frame through the serial port
4. goto loop
Buffer 2 Algorithm
Inputs
Buffer 2 control signal from buffer 1 from RC4 algorithm
Data clock to detect key and data from RC4
4 byte key followed by 20 byte parallel data
Output
Store the data in the buffer 1, while send the data from the other buffer
Switch the working of buffer 1 and buffer 2 buffers on completion of every frame
11
1. Define buffer memory of 25 locations
3. loop:
4. Wait to get a high buffer 2 control signal from the buffer 1 buffer
Save the data in the buffer 1 buffer
Send acknowledgment on receiving every data frame
5. Wait to get a low buffer 2 control signal from the buffer 1 buffer
Send the frame through the serial port
6. go to loop
A wireless transmission module of 433.92 MHz is used which uses amplitude shift
keying modulation scheme. Its data rate is 8kbps. The encrypted data which obeys the
WEP protocol is then coupled into the transmission module, where it gets transmitted.
The system uses a wireless receiver module (appendix B.3), which receives the trans-
mitted data and then converts into bitstream. This bit stream is then given into the
buffering and decryption block.
12
2. Decryption
After storing the data, the RC4 algorithm will be executed. The key generated by
the RC4 algorithm used to decrypt the data. This process of key generation and
decryption will repeat for each byte of data. The decryption is achieved through
a XOR operation (similar to the encryption process). The decrypted data is then
given to the Delta demodulation.
Delta demodulation
3. The received byte is shifted right to obtain each bit that is being sent.
4. If any particular bit is a ’1’, the data to be output is obtained by incrementing the
previous output value.
13
Chapter 3
The project Secure Wireless Communication system aims at establishing a secure, effi-
cient and robust communication channel enabling a communication which guarantees
confidentiality. To ensure this security, it was necessary that the voice data be encrypted
and this was accomplished using the RC4 algorithm which is a stream cipher. The RC4
algorithm was implemented using a microcontroller which served the requirements that
the algorithm demanded. The voice data is transmitted in a frame format to the receiver.
The RC4 key was distributed in two sessions consisting of an initial 4 byte which is
transmitted and saved at the receiver end. The remaining 4 bytes is transmitted along
with the encrypted data to the receiver. The initial key transfer requires high security in
its transmission and this was met with the efficient RSA algorithm.
14
Figure 3.1: One frame
15
Figure 3.2: Switching the frame
16
Figure 3.3: Reception and decryption
17
3.4 Flow charts and circuit diagrams
18
Figure 3.5: RC4 encryption
19
Figure 3.6: Buffer
20
Figure 3.7: Transmitter
21
Figure 3.8: Receiver
22
Chapter 4
The Secure Wireless Communication System is an integral part of the Security and
Surveillance System. The security and surveillance system is a high end security en-
sured system comprising of biometric sensors, RFID authentication, tracking and posi-
tioning system, secure wireless communication system, switching station and interfac-
ing and display unit. It allows secure voice communication between security personnel
within the security and surveillance system. Security is a major challenge faced by
wireless communication systems. The security of communication channel is ensured
using the encryption technique being employed. Efficient transmission of data through
the channel requires modulation for which we use the amplitude shift keying technique.
Both the transmitter and receiver ends were modeled in real time and the secure
communication channel between the security personnel were established.
23
Chapter 5
Future Enhancements
The system in its present state is a simplex communication system i.e. it consists of a
single transmitter and receiver. In future it needs to be modeled as a full duplex system.
The number of users needs to be incremented and this demands an efficient multiple
access technique such as the CDMA. Also control signals have to be incorporated which
enables communication with the base station.
24
Bibliography
25
Appendix A
Source Codes
void main(void)
{
//initialization
int count=0,delout=0,delta=0,byt_count=0,out_data[2],byt=0;
long int adc_out,prev_adc=0;
out_data[0]=0x00;
out_data[1]=0x00;
set_tris_b(0x03);
set_tris_c(0x00);
output_c(0x00);
//~~~configure ADC~~~
setup_adc_ports(AN0_VREF_VREF);
setup_adc(ADC_CLOCK_DIV_16);
set_adc_channel( 0 );
26
//*****reading from ADC*****
output_c(0x00);
loop:
if(byt_count==0)
//else
//output_low(PIN_B2);
count++;
if(count>8)
count=1;
27
}
delout+=delta;
prev_adc=adc_out;
if(count==8)
{
out_data[byt]=delout;
delout=0;
byt_count++;
byt++;
output_c(out_data[1]);
output_high(PIN_B3); //ackno for RC4 module: DTR22
while(!input(PIN_B1)); //waits for ack from RC4 module :RDT2
output_low(PIN_B3);
byt=0;
}
}
while (input(samp_clock)); //waits for sampling clock to go low
goto loop;
28
A.2 RC4 encryption
//------------------RC4 ENCRYPTION program-------------------
#include<16f877a.h>
void main(void)
{
//------------Initialization-----------
int temp,i,j,x,y,k,a,b,sa,z=0,p=0,sb=0;
int pf_key=0,count=0,en_data,fm_start=0,count_byte=0;
int xout[2];
set_tris_c(0xff);
set_tris_b(0x00);
set_tris_d(0xff);
set_tris_e(0x00);
output_b(0x00); //clearing the PORT B register
//output_c(0x00); //clearing the PORT C register
//output_d(0x00); //clearing the PORT D register
start:
for(i=00;i<80;++i)
write_bank(1,i,i);
for(j=00;j<96;++j)
write_bank(2,j,j+80);
for(j=00;j<=80;++j)
write_bank(3,j,j+176);
for(j=180;j<=183;++j)
write_bank(3,j-100,02);
for(j=184;j<=187;++j)
29
write_bank(3,j-100,07);
j=0;i=0;
//--------SCRAMBLING----------
do
{
if(i<80)
x=read_bank(1,i);
else if (i<176)
x=read_bank(2,i-80);
else if (i<=254)
x=read_bank(3,i-176);
else if(i==255)
x=read_bank(3,i-176);
y=read_bank(3,80+i%8);
temp=x;
j=j+x+y;
j=j%256;
if(j<80)
y=read_bank(1,j);
else if (j<176)
y=read_bank(2,j-80);
else if (j<=254)
y=read_bank(3,j-176);
else if (j==255)
y=read_bank(3,j-176);
x=y;
if(i<80)
write_bank(1,i,y);
30
else if (i<176)
write_bank(2,i-80,y);
else if (i<=254)
write_bank(3,i-176,y);
else if (i==255)
write_bank(3,i-176,y);
y=temp;
if(j<80)
write_bank(1,j,y);
else if (j<176)
write_bank(2,j-80,y);
else if (j<=254)
write_bank(3,j-176,y);
else if (j==255)
write_bank(3,j-176,y);
i++;
}while(i<=254);
count=0;
while(!input(PIN_C2)); //from delta modulation(C2)
fm_start=!fm_start;
output_bit(PIN_C0,(fm_start));
31
while(!input(PIN_C4)); //Acknoledgement to buffer(C4)
output_low(PIN_C3);
}
//------PSEUDO RANDOM GENERATION------
i=0;
j=0;
temp=0;
z=0;
repeat:
for(k=0;k<2;++k) //Receiving 2byte data
{
while ( !input(PIN_C5) ); // Information from delta (C5)
xout[k]=input_d(); // reception
output_high(PIN_C6); // Acknoledgement to delta (C6)
#use delay (clock=20000000)
delay_us( 20);
output_low(PIN_C6); // Reset Acknoledgement to delta (C6)
}
count_byte=0;
//-------Generation loop-----------
for(k=0;k<2;++k)
{
i=i+1;
p=i%256;
if(p<80)
x=read_bank(1,p);
else if (p<176)
x=read_bank(2,p-80);
else if (p<=254)
x=read_bank(3,p-176);
else if (p==255)
x=read_bank(3,p-176);
j=(j+x)%256;
32
if(i<80)
x=read_bank(1,i);
else if (i<176)
x=read_bank(2,i-80);
else if (i<=254)
x=read_bank(3,i-176);
else if (i==255)
x=read_bank(3,i-176);
if(j<80)
y=read_bank(1,j);
else if (j<176)
y=read_bank(2,j-80);
else if (j<=254)
y=read_bank(3,j-176);
else if (j==255)
y=read_bank(3,j-176);
temp=x;
x=y;
if(i<80)
write_bank(1,i,y);
else if (i<176)
write_bank(2,i-80,y);
else if (i<=254)
write_bank(3,i-176,y);
else if (i==255)
write_bank(3,i-176,y);
y=temp;
if(j<80)
write_bank(1,j,y);
else if (j<176)
write_bank(2,j-80,y);
33
else if (j<=254)
write_bank(3,j-176,y);
else if (j==255)
write_bank(3,j-176,y);
//...........................................
sa=y;
b=i%256;
if(b<80)
sb=read_bank(1,b);
else if (b<176)
sb=read_bank(2,b-80);
else if (b<=254)
sb=read_bank(3,b-176);
else if (b==255)
sb=read_bank(3,b-176);
a=(sa+sb)%256;
if(a<80)
z=read_bank(1,a);
else if (a<176)
z=read_bank(2,a-80);
else if (a<=254)
z=read_bank(3,a-176);
else if (a==255)
z=read_bank(3,a-176);
en_data=z^xout[k];
output_b(en_data); // To the output port
output_high(PIN_C3); // Information to buffer (C3)
while(!input(PIN_C4)); // Acknoledgement from buffer(C4)
output_low(PIN_C3); // Reset Information to buffer (C3)
++count;
++count_byte;
}
34
if(count>=23)
goto start;
if(count_byte>=2)
goto repeat;
A.3 Buffer 1
//Buffer_1 (Master)
#include<16f877a.h>
void main()
{
int buffer[25],pos=0;
set_tris_d(ALL_IN);
35
set_tris_e(0X00);
set_tris_c(ALL_IN);
set_tris_b(CONTROL_B);
buffer[0]=PREAMPLE;
LOW(TRANS_ENABLE);
LOW(DATA_ACKNOW);
LOW(SLAVE_CONTROL);
loop:
while (!input(FRAME_SELECT));
LOW(SLAVE_CONTROL);
pos=1;
do{
while (!input(DATA_CLK));
buffer[pos]=input_d();
HIGH(DATA_ACKNOW);
Pos++;
while (input(DATA_CLK));
LOW(DATA_ACKNOW);
}while (pos<23);
while (input(FRAME_SELECT));
HIGH(SLAVE_CONTROL);
HIGH(TRANS_ENABLE);
pos=0;
do{
putc(buffer[pos]);
pos++;
// delay_us(50);
}while(pos<25);
LOW(TRANS_ENABLE);
goto loop;
36
A.4 Buffer 2
//BUFFER_2 (Slave)
#include<16f877a.h>
void main()
{
int buffer[25],pos=0;
set_tris_d(ALL_IN);
set_tris_e(0X00);
set_tris_c(ALL_IN);
set_tris_b(CONTROL_B);
buffer[0]=PREAMPLE;
LOW(TRANS_ENABLE);
LOW(DATA_ACKNOW);
loop:
while (!input(SLAVE_CONTROL));
pos=1;
37
do{
while (!input(DATA_CLK));
buffer[pos]=input_d();
HIGH(DATA_ACKNOW);
pos++;
while (input(DATA_CLK));
LOW(DATA_ACKNOW);
}while (pos<25);
while (input(SLAVE_CONTROL));
HIGH(TRANS_ENABLE);
pos=0;
do{
putc(buffer[pos]);
pos++;
//delay_us(50);
}while(pos<23);
LOW(TRANS_ENABLE);
goto loop;
}
38
void main(void)
{
//----------Initialization-----------
int data=0,pos=0,buffer[24],temp;
int i,j,x,y,a,b,sa,z=0,p=0,sb=0,pf_key=0,count=0,de_data;
set_tris_c(ALL_IN);
set_tris_d(ALL_OUT);
set_tris_e(0X00);
set_tris_b(0x00); //output of the rc4 (key)is in port b
set_tris_e(0x00);
output_b(0x00); //clearing the PORT B register
start:
//RECEiVING THE FRAME
data=0;
count=0;
do{
data=getc();
}while(data!=PREAMBLE);
pos=0;
do
{
while(STATUS==0);
buffer[pos]=getc();
HIGH(PIN_D2);
LOW(PIN_D2);
++pos;
}while (pos<25);
for(i=00;i<80;++i)
write_bank(1,i,i);
for(j=00;j<96;++j)
write_bank(2,j,j+80);
39
for(j=00;j<=80;++j)
write_bank(3,j,j+176);
for(j=180;j<=183;++j)
write_bank(3,j-100,02);
for(j=184;j<=187;++j)
write_bank(3,j-100,07);
//------scrambling-------
j=0;i=0;
do{
if(i<80)x=read_bank(1,i);
else if (i<176)
x=read_bank(2,i-80);
else if (i<=254)
x=read_bank(3,i-176);
else if(i==255)
x=read_bank(3,i-176);
y=read_bank(3,80+i%8);
temp=x; j=j+x+y;j=j%256;
if(j<80)
y=read_bank(1,j);
else if (j<176)
y=read_bank(2,j-80);
else if (j<=254)
y=read_bank(3,j-176);
else if (j==255)
y=read_bank(3,j-176);
x=y;
if(i<80)
write_bank(1,i,y);
else if (i<176)
write_bank(2,i-80,y);
else if (i<=254)
write_bank(3,i-176,y);
40
else if (i==255)
write_bank(3,i-176,y);
y=temp;
if(j<80)
write_bank(1,j,y);
else if (j<176)
write_bank(2,j-80,y);
else if (j<=254)
write_bank(3,j-176,y);
else if (j==255)
write_bank(3,j-176,y);
i++;
}while(i<=254);
loop:
//pseudo random generation
i=0;j=0;temp=0;z=0;
//------------generation loop----------
i=i+1;
p=i%256;
if(p<80)
x=read_bank(1,p);
else if (p<176)
x=read_bank(2,p-80);
else if (p<=254)
x=read_bank(3,p-176);
else if (p==255)
41
x=read_bank(3,p-176);
j=(j+x)%256;
if(i<80)x=read_bank(1,i);
else if (i<176)
x=read_bank(2,i-80);
else if (i<=254)
x=read_bank(3,i-176);
else if (i==255)x=
read_bank(3,i-176);
if(j<80)
y=read_bank(1,j);
else if (j<176)
y=read_bank(2,j-80);
else if (j<=254)
y=read_bank(3,j-176);
else if (j==255)
y=read_bank(3,j-176);
temp=x;x=y;
if(i<80)
write_bank(1,i,y);
else if (i<176)
write_bank(2,i-80,y);
else if (i<=254)
write_bank(3,i-176,y);
else if (i==255)
write_bank(3,i-176,y);y=temp;
if(j<80)
write_bank(1,j,y);
else if (j<176)
write_bank(2,j-80,y);
else if (j<=254)
write_bank(3,j-176,y);
else if (j==255)
write_bank(3,j-176,y);
sa=y;b=i%256;
42
if(b<80)
sb=read_bank(1,b);
else if (b<176)
sb=read_bank(2,b-80);
else if (b<=254)
sb=read_bank(3,b-176);
else if (b==255)
sb=read_bank(3,b-176);
a=(sa+sb)%256;
if(a<80)z=read_bank(1,a);
else if (a<176) z=read_bank(2,a-80);
else if (a<=254)z=read_bank(3,a-176);
else if (a==255) z=read_bank(3,a-176);
++count;
data=buffer[count];
de_data=z^data; //Decryption
output_b(de_data); // To the output port
output_high(PIN_d0); // Information to DAC (C3)
while(!input(PIN_C4)); //Acknoledgement from DAC(C4)
output_low(PIN_d0); // Reset Information to DAC (C3)
if(count>=24)
goto start;
goto loop;
A.6 Demodulation
//RECEIVE DATA , DO DELTA DEMODULATION AND TO DAC
#include<16f877a.h>
43
#use delay(clock=4000000)
#byte rcv_val=0x51
#bit test_bit7=0x51.7
#byte check=0x52
#bit check_bit=0x52.0
int dac_val=0x7f,i=0,rcv_var[20],count=0,j=0;//dat=0x00;
do
{
while(!input(RTD)); //wait for ackno HIGH from RC4 module
rcv_var[count]=input_c();
count++;
output_high(DTR); // ackno to RC4 module
while(input(RTD)); //wait for ackno LOW from RC4 module
output_low(DTR); // ackno to RC4 module
}while(count<20);
44
do
{
check=shift_left(&rcv_val,1,0);
if(check_bit==1)
{
if(dac_val!=0xFF)
dac_val++;
}
else
{
if(dac_val!=0x00)
dac_val--;
}
delay_us(85);
output_b(dac_val);
i++;
}while(i<8);
j++;
}while(j<20);
goto LOOP;
45
Appendix B
Datasheets
B.1 PIC16F877A
MICROCHIP
Data Sheet
28/40/44-Pin Enhanced Flash
Microcontrollers
46
B.2 Wired Equivalent Privacy Protocol
47
B.3 Wireless Transmitter and Receiver Modules
WEN SHING
DATA SHEET
48