wireless data transmission over ask

35

Upload: shaunak-de

Post on 07-Apr-2015

1.779 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Wireless Data Transmission over ASK
Page 2: Wireless Data Transmission over ASK

Table of ContentsWireless communication......................................................................................................................4

Introduction.......................................................................................................................4Wireless Services...............................................................................................................4Wireless networks..............................................................................................................5Modes................................................................................................................................5

History.........................................................................................................................................5Photophone........................................................................................................................5Radio..................................................................................................................................5Early wireless work...........................................................................................................6Electromagnetic Spectrum.................................................................................................8

Applications of wireless technology...........................................................................................9Security systems................................................................................................................9Television remote control..................................................................................................9Cellular telephone (phones and modems)........................................................................10Wi-Fi................................................................................................................................10Radio communication......................................................................................................10Amateur radio..................................................................................................................11Broadcasting....................................................................................................................11

The Advantages Of Wireless Communication...................................................................................14Abstract...............................................................................................................................................16

Research Focus................................................................................................................16Issue(s) Addressed...........................................................................................................16Research Method.............................................................................................................16Conclusions and Recommendations................................................................................16

Operation............................................................................................................................................17Algorithm and Data-flow...................................................................................................................18

Transmitter................................................................................................................................18Checksum..................................................................................................................................18Receiver....................................................................................................................................19

Transmitter..........................................................................................................................................20Receiver..............................................................................................................................................21Transmitter Printed Circuit Board......................................................................................................22Receiver Printed Circuit Board..........................................................................................................23Transmitter Code................................................................................................................................24

global.h......................................................................................................................................24checksum.h................................................................................................................................24a2d.c..........................................................................................................................................24tx.c.............................................................................................................................................27

Receiver Code....................................................................................................................................30sevenseg.h.................................................................................................................................30checksum.h................................................................................................................................31rx.c.............................................................................................................................................31

HEX code...........................................................................................................................................34transmitter.................................................................................................................................34Receiver....................................................................................................................................35

Conclusion..........................................................................................................................................37Bibliography.......................................................................................................................................38

Books:.......................................................................................................................................38Website:.....................................................................................................................................38

License................................................................................................................................................39

Page 3: Wireless Data Transmission over ASK

Wireless communicationIn telecommunication wireless communication is the transfer of information without the use of wires. The distances involved may be short (a few meters as in television remote control) or long (thousands or millions of kilometers for radio communications). The term is often shortened to "wireless". It encompasses various types of fixed, mobile, and portable two-way radios, cellular telephones, personal digital assistants (PDAs), and wireless networking. Other examples of wireless technology include GPS units, garage door openers and or garage doors, wireless computer mice, keyboards and headsets, satellite television and cordless telephones.

Introduction

Wireless operations permits services, such as long range communications, that are impossible or impractical to implement with the use of wires. The term is commonly used in the telecommunications industry to refer to telecommunications systems (e.g. radio transmitters and receivers, remote controls, computer networks, network terminals, etc.) which use some form of energy (e.g. radio frequency (RF), infrared light, laser light, visible light, acoustic energy, etc.) to transfer information without the use of wires. Information is transferred in this manner over both short and long distances.

Wireless Services

The term "wireless" has become a generic and all-encompassing word used to describe communications in which electromagnetic waves or RF (rather than some form of wire) carry a signal over part or the entire communication path. Common examples of wireless equipment in use today include:

• Professional LMR (Land Mobile Radio) and SMR (Specialized Mobile Radio) typically used by business, industrial and Public Safety entities.

• Consumer Two way radio including FRS Family Radio Service, GMRS (General Mobile Radio Service) and Citizens band ("CB") radios.

• The Amateur Radio Service (Ham radio).

• Consumer and professional Marine VHF radios.

• Cellular telephones and pagers: provide connectivity for portable and mobile applications, both personal and business.

• Global Positioning System (GPS): allows drivers of cars and trucks, captains of boats and ships, and pilots of aircraft to ascertain their location anywhere on earth.

• Cordless computer peripherals: the cordless mouse is a common example; keyboards and printers can also be linked to a computer via wireless.

• Cordless telephone sets: these are limited-range devices, not to be confused with cell phones.

• Satellite television: allows viewers in almost any location to select from hundreds of channels.

• Wireless gaming: new gaming consoles allow players to interact and play in the same game regardless of whether they are playing on different consoles.

Page 4: Wireless Data Transmission over ASK

Wireless networks

Wireless networking (i.e. the various types of unlicensed 2.4 GHz WiFi devices) is used to meet many needs. Perhaps the most common use is to connect laptop users who travel from location to location. Another common use is for mobile networks that connect via satellite. A wireless transmission method is a logical choice to network a LAN segment that must frequently change locations. The following situations justify the use of wireless technology:

• To span a distance beyond the capabilities of typical cabling,

• To provide a backup communications link in case of normal network failure,

• To link portable or temporary workstations,

• To overcome situations where normal cabling is difficult or financially impractical, or

• To remotely connect mobile users or networks.

Modes

Wireless communication can be via:

• radio frequency communication,

• microwave communication, for example long-range line-of-sight via highly directional antennas, or short-range communication, or

• infrared (IR) short-range communication, for example from remote controls or via Infrared Data Association (IrDA).

Applications may involve point-to-point communication, point-to-multipoint communication, broadcasting, cellular networks and other wireless networks.

History

Photophone

The world's first, wireless telephone conversation occurred in 1880, when Alexander Graham Bell and Charles Sumner Tainter invented and patented the photophone, a telephone that conducted audio conversations wirelessly over modulated light beams (which are narrow projections of electromagnetic waves). In that distant era when utilities did not yet exist to provide electricity, and lasers had not even been conceived of in science fiction, there were no practical applications for their invention, which was highly limited by the availability of both sunlight and good weather. Similar to free space optical communication, the photophone also required a clear line of sight between its transmitter and its receiver. It would be several decades before the photophone's principles found their first practical applications in military communications and later in fiber-optic communications.

Radio

The term "wireless" came into public use to refer to a radio receiver or transceiver (a dual purpose receiver and transmitter device), establishing its usage in the field of wireless telegraphy early on; now the term is used to describe modern wireless connections such as in cellular networks and wireless broadband Internet. It is also

Page 5: Wireless Data Transmission over ASK

used in a general sense to refer to any type of operation that is implemented without the use of wires, such as "wireless remote control" or "wireless energy transfer", regardless of the specific technology (e.g. radio, infrared, ultrasonic) used. While Guglielmo Marconi and Karl Ferdinand Braun were awarded the 1909 Nobel Prize for Physics for their contribution to wireless telegraphy.

Early wireless work

David E. Hughes, eight years before Hertz's experiments, transmitted radio signals over a few hundred yards by means of a clockwork keyed transmitter. As this was before Maxwell's work was understood, Hughes' contemporaries dismissed his achievement as mere "Induction". In 1885, T. A. Edison used a vibrator magnet for induction transmission. In 1888, Edison deployed a system of signaling on the Lehigh Valley Railroad. In 1891, Edison obtained the wireless patent for this method using inductance (U.S. Patent 465,971).

In the history of wireless technology, the demonstration of the theory of electromagnetic waves by Heinrich Hertz in 1888 was important. The theory of electromagnetic waves was predicted from the research of James Clerk Maxwell and Michael Faraday. Hertz demonstrated that electromagnetic waves could be transmitted and caused to travel through space at straight lines and that they were able to be received by an experimental apparatus. The experiments were not followed up by Hertz. Jagadish Chandra Bose around this time developed an early wireless detection device and help increase the knowledge of millimeter length electromagnetic waves. Practical applications of wireless radio communication and radio remote control technology were implemented by later inventors, such as Nikola Tesla.

Illustration 1: Nikola Tesla

Page 6: Wireless Data Transmission over ASK

Electromagnetic Spectrum

Light, colors, AM and FM radio, and electronic devices make use of the electromagnetic spectrum. In the US, the frequencies that are available for use for communication are treated as a public resource and are regulated by the Federal Communications Commission. This determines which frequency ranges can be used for what purpose and by whom. In the absence of such control or alternative arrangements such as a privatized electromagnetic spectrum, chaos might result if, for example, airlines didn't have specific frequencies to work under and an amateur radio operator were interfering with the pilot's ability to land an airplane. Wireless communication spans the spectrum from 9 kHz to 300 Ghz.

Applications of wireless technology

Security systems

Wireless technology may supplement or replace hard wired implementations in security systems for homes or office buildings. It is much safer than wired security since it cant be disabled by simply breaking the physical connection, as possible with wired security.

Television remote control

Modern televisions use wireless (generally infrared) remote control units. Now radio waves are also used.

Illustration 2: The Electromagnetic Spectrum

Page 7: Wireless Data Transmission over ASK

Cellular telephone (phones and modems)

Perhaps the best known example of wireless technology is the cellular telephone and modems. These instruments use radio waves to enable the operator to make phone calls from many locations worldwide. They can be used anywhere that there is a cellular telephone site to house the equipment that is required to transmit and receive the signal that is used to transfer both voice and data to and from these instruments.

Wi-Fi

Wi-Fi is a wireless local area network that enables portable computing devices to connect easily to the Internet. Standardized as IEEE 802.11 a,b,g,n, Wi-Fi approaches speeds of some types of wired Ethernet. Wi-Fi hot spots have been popular over the past few years. Some businesses charge customers a monthly fee for service, while others have begun offering it for free in an effort to increase the sales of their goods.

Radio communication

A radio communication system send signals by radio. Types of radio communication systems deployed depend on technology, standards, regulations, radio spectrum allocation, user requirements, service positioning, and investment.

The radio equipment involved in communication systems includes a transmitter and a receiver, each having an antenna and appropriate terminal equipment such as a microphone at the transmitter and a loudspeaker at the receiver in the case of a

Page 8: Wireless Data Transmission over ASK

voice-communication system.

Amateur radio

Amateur radio, often called ham radio, is both a hobby and a service in which participants, called "hams", use various types of radio communications equipment to communicate with other radio amateurs for public services, recreation and self-training. Amateur radio operation is licensed by an appropriate government entity (for example, by the Department of Telecom) as coordinated through the International Telecommunication Union.[3]

An estimated two million people throughout the world are regularly involved with amateur radio.

The term "amateur" does not imply a lack of skill or quality, but rather that amateur radio and its operators work outside of an official, governmental or commercial capacity.

Broadcasting

Broadcasting is the distribution of audio and video content to a dispersed audience via radio, television, or other, often digital transmission media. Receiving parties may include the general public or a relatively large subset of thereof.

The original term broadcast referred to the literal sowing of seeds on farms by

Illustration 3: A Broadcast Antenna

Page 9: Wireless Data Transmission over ASK

scattering them over a wide field. It was first adopted by early radio engineers from the Midwestern United States to refer to the analogous dissemination of radio signals. Broadcasting forms a very large segment of the mass media. Broadcasting to a very narrow range of audience is called narrow-casting.

Historically, there have been several different types of electronic broadcasting mediums:

Telephone broadcasting (1881–1932): the earliest form of electronic broadcasting (not counting data services offered by stock telegraph companies from 1867, if ticker-tapes are excluded from the definition). Telephone broadcasting began with the advent of Théâtrophone ("Theater Phone") systems, which were telephone-based distribution systems allowing subscribers to listen to live opera and theater performances over telephone lines, created by French inventor Clément Ader in 1881.

Radio broadcasting (experimentally from 1906, commercially from 1920): radio broadcasting is an audio (sound) broadcasting service, broadcast through the air as radio waves from a transmitter to an antenna and, thus, to a receiving device. Stations can be linked in radio networks to broadcast common programming, either in syndication or simulcast or both.

Television broadcasting (experimentally from 1925, commercially from the 1930s): this video-programming medium was long-awaited by the general public and rapidly rose to compete with its older radio-broadcasting sibling.

Cable radio (also called "cable FM", from 1928) and cable television (from 1932): both via coaxial cable, serving principally as transmission mediums for programming produced at either radio or television stations, with limited production of cable-dedicated programming.

Satellite television (from circa 1974) and satellite radio (from circa 1990): meant for direct-to-home broadcast programming (as opposed to studio network uplinks and down-links), provides a mix of traditional radio or television broadcast programming, or both, with satellite-dedicated programming.

Webcasting of video/television (from circa 1993) and audio/radio (from circa 1994) streams: offers a mix of traditional radio and television station broadcast programming with internet-dedicated webcast programming.

Page 10: Wireless Data Transmission over ASK

The Advantages Of Wireless CommunicationWireless communication modes offer the following productivity, convenience, and cost advantages over wired networks:

• Mobility: Wireless systems can provide users with access to real-time information anywhere in their infrastructure. This mobility supports productivity and service opportunities not possible with wired networks.

• Installation Speed and Simplicity: Installing a wireless system can be fast and easy and can eliminate the need to pull cable through walls and ceilings.

• Reduced Cost-of-Ownership: While the initial investment required for wireless hardware can be higher than the cost of wired hardware, overall installation expenses and life-cycle costs can be significantly lower. Long-term cost benefits are greatest in dynamic environments requiring frequent moves and changes.

• Scalability: Wireless systems can be configured in a variety of topologies to meet the needs of specific applications and installations. Configurations are easily changed and range can be varied simply by adding additional transponders.

Apart from these benefits, there are many applications where it is not possible to gather data over a wire. Some examples of such situations are:

• Rotating machines: If a machine is rotating at a very high speed and the volume of data to be transferred is high, then a brush and slip ring arrangement will not suffice due to the high amount of noise added by the contact-brush. Example of such a situation include the collection of temperature readings from an engine flywheel1, or scan readings from a CT machine2.

1 A flywheel is a mechanical device with a significant moment of inertia used as a storage device for rotational energy.

2 X-ray computed tomography

Illustration 4: The Gantry of A CT Machine

Page 11: Wireless Data Transmission over ASK

• Hazardous Environment: Many a times the physical environment may be dangerous and tend to cause damage to cables and wires. For example the factory floor of metal working factories, or the engine room of a ship. Recurring repair costs will be incurred from the replacement of wires. Also the productivity may be hit if wired solutions are used. Wires and cables may also get in the way of the machines or workers and pose to be a safety hazard.

• Aesthetic Concerns: In modern offices and factories, aesthetics is of major concern. Unsightly wires and cabling are usually concealed inside walls. Wireless links help to preserve the neat look of such spaces.

Illustration 5: The Engine Room of a Ship

Page 12: Wireless Data Transmission over ASK

Abstract

Research Focus

The objective of the project was to build an apparatus to reliably transfer data from one point to another over a wireless RF link.

The reliability of the link, and error checking of transmitted data was the primary concern. Speed of transfer was also maximized to 1200 baud per second. The encoding chosen for the data is "ASK3 modulation".

433 Mhz was chosen as a carrier frequency as it may be used unlicensed for armature radio equipment.

The data chosen to serve as an example is temperature.

Issue(s) Addressed

The primary issue faced in the project was the high noise susceptibility of the ASK modules. Even a slight amount of noise is sufficient to distort the transmission. To improve the noise performance two steps were taken:

• A error checking checksum was developed and applied to the data and transmitted. This was verified on the receiving end. Data was considered valid only of the checksum matched at the receiving end.

• The signal power was increased to improve the SNR4 by using specially designed antennas made of steel and isolated from the ground plane.

Research Method

The development of the software was done on a pair of Atmega16 development boards. The C code was written in SciTE and compiled using the GNU C compiler on the Fedora platform. The code was burned to the micro-controller using the on-board “In System Programming” peripheral using AvrDude and usbasp.

Conclusions and Recommendations

We have found that sufficiently reliable communication may be established using ASK communication modules when used in conjunction to specially designed antennas and error checking codes.

For higher reliability FSK5 transmission and the 2.4Ghz band is recommended.

3 Amplitude Shift Keying4 Signal To Noise Ratio5 Frequency Key Shifting

Page 13: Wireless Data Transmission over ASK

OperationThe system consists of four basic components:

1. Source: This generates the data that is to be transmitted. In this case it is the LM35 temperature sensor. Readings from this sensor are taken with the micro-controller's Analog to Digital converter. This data is then forwarded for transmission.

2. Transmitter: The microcontroller formats the data and generates a checksum. It then clocks this data at 1200 bps to the transmitting module. The data is transmitted over a 433MHZ RF channel by this module.

3. Receiver: The receiver accepts the data, checks it for errors and then if found to be error free, decodes it to make it suitable for display. It processes the data and formats it for display. It also contains the display driver firmware which appropriately multiplexes the seven segment displays.

4. Destination: This is where the data is displayed or stored. In this case we use 3 seven segment displays to display the data to the user. The driver logic for the Seven Segment Display is as follows:

Number to Display Data at PortB [Common Cathode]0 0x3F H1 0x06 H2 0x5B H3 0x4F H4 0x66 H5 0x6D H6 0x7D H7 0x07 H8 0x7F H9 0x67 H

LM35 Antenna Antenna Display

433 Mhz Link

Page 14: Wireless Data Transmission over ASK

Algorithm and Data-flow

TransmitterThe transmitter micro-controller takes a reading of its on-board Analog to Digital Conversion channel AD0, on which the LM35 temperature sensor it attached, when the analog to digital conversion complete interrupt occurs.

The ADC on the Atmega16 has 10-bit precision. To improve transmission efficiency, this data is scaled to 8-bits. Mathematical operations are performed for this scaling and compacting. The result of the operation is an 8-bit data packet ready for transmission.

A checksum is generated from this data packet and it is transmitted via USART6 headed by two synchronization bytes: 0xAA and 0x55 [ASCII character 'Z']. The synchronization byte plays a vital role in allowing the receiving radio module to regenerate the clock pulses.

The two bytes together form an alternating pattern of ones and zeros. This helps the PLL on the receiver to lock on easily. These bytes are followed by the data byte and check-sum byte.

Following is an illustration of a typical data packet formed for transmission:

Header: 0xAA Header: 0x55 'Z' Data Checksum

10101010 1010101 00100111 10001101

Table 1: Example transmission of '39'

ChecksumWe have developed a checksum method specifically to suit the transmission of data over ASK7. The checksum used is a invert-swap checksum. The data byte is taken and inverted. Then the lower and higher nibble of the data byte is swapped.

By experimentation this has been found to perform as well as a standard CRC algorithm, for ASK, but requires far fewer CPU operations to calculate.

Step Data

I Consider a sample data byte – 10001010 [0x8A]

II It is inverted – 01110101 [0x75]

III Now the lower and upper nibbles are swapped – 01010111 [0x57]This is the checksum.

Table 2: Sample checksum generation

6 Universal asynchronous receiver/transmitter7 Amplitude-shift keying

Page 15: Wireless Data Transmission over ASK

ReceiverThe receiver demodulated the data using a PLL8 receiving loop. This data is then given bit by bit to the processor's USART9.

When the USART buffer fills, an interrupt is generated, which prompts the processor to fetch the data byte. If this data byte is the opening header byte [0xAA], then the processor goes into listening mode. It monitors the data on the next three bytes on the USART.

The processor expects the following byte to be the next header. ASCII 'Z'. If the second header is correct, it accepts the data byte and checksum byte from the packet and proceeds to validate the checksum. If not, it exits listening mode, freeing up resources for other processing.

The received byte is checked against the checksum, and if found invalid discarded. Valid bytes are then formatted to extract individual digits. These digits are then displayed onto the seven segment display over PORT B and PORT C.

PORT B is used to assert or negate the LED10s in the seven segment display, and PORT C chooses the display segment.

For example to display the number '6' in tens place, “0x7D” is loaded onto PORT B and “0x02” is loaded onto PORT C.

This display is refreshed several times a second so that it appears steady to the human eye.

8 Phase Locked Loop9 Universal asynchronous receiver/transmitter10 Light Emitting Diode

Page 16: Wireless Data Transmission over ASK

Transmitter

Page 17: Wireless Data Transmission over ASK

Receiver

Page 18: Wireless Data Transmission over ASK

Transmitter Printed Circuit Board

Page 19: Wireless Data Transmission over ASK

Receiver Printed Circuit Board

Page 20: Wireless Data Transmission over ASK

Transmitter Code

global.h#ifndef GLOBAL_H#define GLOBAL_H

// global AVRLIB defines#include "avrlib/avrlibdefs.h"// global AVRLIB types definitions#include "avrlib/avrlibtypes.h"

#define CYCLES_PER_US ((F_CPU+500000)/1000000) // cpu cycles per microsecond

#endif

checksum.hunsigned char checksum (unsigned char data){

unsigned char t,l,h;t=~data;l = (t<<4);h = (t>>4);

t = l | h;

return t;}

a2d.c#include <avr/io.h>#include <avr/interrupt.h>

#include "global.h"#include "a2d.h"//! Software flag used to indicate when// the a2d conversion is complete.

Page 21: Wireless Data Transmission over ASK

volatile unsigned char a2dCompleteFlag;// initialize a2d convertervoid a2dInit(void){

sbi(ADCSR, ADEN); // enable ADC (turn on ADC power)cbi(ADCSR, ADFR); // default to single sample convert modea2dSetPrescaler(ADC_PRESCALE); // set default prescalera2dSetReference(ADC_REFERENCE); // set default referencecbi(ADMUX, ADLAR); // set to right-adjusted result

sbi(ADCSR, ADIE); // enable ADC interrupts

a2dCompleteFlag = FALSE; // clear conversion complete flag

sei(); // turn on interrupts (if not already on)}

// turn off a2d convertervoid a2dOff(void){

cbi(ADCSR, ADIE); // disable ADC interruptscbi(ADCSR, ADEN); // disable ADC (turn off ADC power)

}

// configure A2D converter clock division (prescaling)void a2dSetPrescaler(unsigned char prescale){

outb(ADCSR, ((inb(ADCSR) & ~ADC_PRESCALE_MASK) | prescale));}

// configure A2D converter voltage referencevoid a2dSetReference(unsigned char ref){

outb(ADMUX, ((inb(ADMUX) & ~ADC_REFERENCE_MASK) | (ref<<6)));}

// sets the a2d input channel

Page 22: Wireless Data Transmission over ASK

void a2dSetChannel(unsigned char ch){

outb(ADMUX, (inb(ADMUX) & ~ADC_MUX_MASK) | (ch & ADC_MUX_MASK)); // set channel}

// start a conversion on the current a2d input channelvoid a2dStartConvert(void){

sbi(ADCSR, ADIF); // clear hardware "conversion complete" flag

sbi(ADCSR, ADSC); // start conversion}

// return TRUE if conversion is completeu08 a2dIsComplete(void){

return bit_is_set(ADCSR, ADSC);}

// Perform a 10-bit conversion// starts conversion, waits until conversion is done, and returns resultunsigned short a2dConvert10bit(unsigned char ch){

a2dCompleteFlag = FALSE; // clear conversion complete flag

outb(ADMUX, (inb(ADMUX) & ~ADC_MUX_MASK) | (ch & ADC_MUX_MASK)); // set channel

sbi(ADCSR, ADIF); // clear hardware "conversion complete" flag

sbi(ADCSR, ADSC); // start conversion

//while(!a2dCompleteFlag); // wait until conversion complete

//while( bit_is_clear(ADCSR, ADIF) ); // wait until conversion complete

while( bit_is_set(ADCSR, ADSC) ); // wait until conversion complete

Page 23: Wireless Data Transmission over ASK

// CAUTION: MUST READ ADCL BEFORE ADCH!!!return (inb(ADCL) | (inb(ADCH)<<8)); // read ADC (full 10

bits);}

// Perform a 8-bit conversion.// starts conversion, waits until conversion is done, and returns resultunsigned char a2dConvert8bit(unsigned char ch){

// do 10-bit conversion and return highest 8 bitsreturn a2dConvert10bit(ch)>>2; // return ADC MSB

byte}

//! Interrupt handler for ADC complete interrupt.SIGNAL(SIG_ADC){

// set the a2d conversion flag to indicate "complete"a2dCompleteFlag = TRUE;

}

tx.c/*** Program to transmit charecters over the serial interface** Wiring: PD0-RXD, PD1-TXD** Serial: 1200N1*/#define F_CPU 12000000UL

#include<avr/io.h>#include<util/delay.h>

#include "global.h"#include"avrlib/a2d.h"

#include"checksum.h"

void USART_init(void){

UCSRA=0x00; //Set up to 8N1 1200 transmissionUCSRB=0x18;

Page 24: Wireless Data Transmission over ASK

UCSRC=0x86;UBRRH=0x02;UBRRL=0x70;

}

void USART_TX(unsigned char c){

while( (UCSRA & 0x20) == 0x00 ){;}

UDR=c;}

unsigned char USART_RX(void){unsigned char data;while((UCSRA & 0x80) == 0x00){;}data = UDR;return data;}

unsigned char get_temp(){

unsigned int reading;unsigned char output;

reading = a2dConvert10bit(0);

output = ((unsigned char)reading)>>1;return output;

}

int main(void){

unsigned char check, data;USART_init();a2dInit();

while(1){

// data = a2dConvert8bit(0);// data = data*2;

data = get_temp();USART_TX(0xAA);USART_TX(0xAA);USART_TX('Z');USART_TX(data);check = checksum(data);USART_TX(check);

}

Page 25: Wireless Data Transmission over ASK

return 0;}

Page 26: Wireless Data Transmission over ASK

Receiver Code

sevenseg.h/* Seven Segment Board Functions */void write_led(unsigned char d)// Writes number to single 7 segment{

if(d==0){ PORTA = 0x3F; }else if(d==1){ PORTA = 0x06; }else if(d==2){ PORTA = 0x5B; }else if(d==3){ PORTA = 0x4F; }else if(d==4){ PORTA = 0x66; }else if(d==5){ PORTA = 0x6D; }else if(d==6){ PORTA = 0x7D; }else if(d==7){ PORTA = 0x07; }else if(d==8){ PORTA = 0x7F; }else if(d==9){ PORTA = 0x67; }

// else if(d=='A' || d=='a'){ PORTA = 0x77; }// else if(d=='B' || d=='b'){ PORTA = 0x7C; }// else if(d=='C' || d=='c'){ PORTA = 0x39; }// else if(d=='D' || d=='d'){ PORTA = 0x5E; }// else if(d=='E' || d=='e'){ PORTA = 0x79; }// else if(d=='F' || d=='f'){ PORTA = 0x71; }

else{ PORTA = 0x00; } // Turnoff display}

void choose_disp(unsigned int dispNum)// Chooses 7 segment to write to, using PORTC; {

if(dispNum == 0){ PORTB= ~(0x01); }else if(dispNum == 1){PORTB= ~(0x02); }else if(dispNum == 2){ PORTB= ~(0x04); }else if(dispNum == 3){ PORTB= ~(0x08); }else if(dispNum == 4){ PORTB= ~(0x0F); }else if(dispNum == 5){ PORTB= ~(0x20); }else if(dispNum == 6){ PORTB= ~(0x40); }else{ PORTB == ~(0x80);}

// Remember to add 2ms delay addded due to slow LED turn on-off }

void disp_byte(unsigned char n){unsigned char digit,i;

Page 27: Wireless Data Transmission over ASK

for(i=0;i<3;i++){digit = n%10;n=(unsigned char)n/10;choose_disp(2-i);write_led(15); // Turnoff display first to

cool display_delay_ms(3);write_led(digit);_delay_ms(2); // Write digit later so as to

retain it during next operation cycle.}

}

checksum.hunsigned char checksum (unsigned char data){

unsigned char t,l,h;t=~data;l = (t<<4);h = (t>>4);

t = l | h;

return t;}

rx.c

#define F_CPU 12000000UL#define PAYLOAD 2

#include<avr/io.h>#include<util/delay.h>#include<avr/interrupt.h>#include<util/crc16.h>#include"sevenseg.h"#include"checksum.h"

//_crc_ibutton_update(0xFF, data)

/* Globals */unsigned char message[PAYLOAD];

Page 28: Wireless Data Transmission over ASK

/* USART functions */void USART_init(void){

UCSRA=0x00; //Setup 1200 8N1 transmissionUCSRB=0x98;UCSRC=0x86;UBRRH=0x02;UBRRL=0x70;

}

void USART_TX(unsigned char c){

while( (UCSRA & 0x20) == 0x00 ){;}

UDR=c;}

unsigned char USART_RX(void){unsigned char data;while((UCSRA & 0x80) == 0x00){;}data = UDR;return data;}

/* Message Handling */void get_msg(){

unsigned short int i;unsigned char oldmsg[PAYLOAD];

oldmsg[0]=message[0];oldmsg[1]=message[1];

char x = USART_RX();if(x==0xAA){;}else if(x=='Z')

{ for(i=0;i<PAYLOAD;i++){message[i] = USART_RX();} }else{;}

unsigned char chk;chk = checksum(message[0]);if( chk == message[1] ){ ;}else { message[0] = oldmsg[0] ; message[1] = oldmsg[1]; }

}

Page 29: Wireless Data Transmission over ASK

//void check_msg()//{

//}

void disp_msg(){

//check_msg();unsigned char chk;

chk = checksum(message[0]);

if( chk == message[1] ){ disp_byte(message[0]);

}else{;}

}

int main(){

/* Initialization */DDRA = 0xFF; DDRB = 0xFF; PORTA=0x00; PORTB=0x00;message[0]=0; message[1]=checksum(0); USART_init();sei();

while(1){disp_msg(); }

return 0;}

/* ISR */ISR(USART_RXC_vect){

get_msg();}

Page 30: Wireless Data Transmission over ASK

HEX code

transmitter:100000000C942A000C9447000C9447000C94470071:100010000C9447000C9447000C9447000C94470044:100020000C9447000C9447000C9447000C94470034:100030000C9447000C9447000C94C3000C944700A8:100040000C9447000C9447000C9447000C94470014:100050000C94470011241FBECFE5D4E0DEBFCDBF16:1000600010E0A0E6B0E0E8EAF1E002C005900D92F1:10007000A036B107D9F710E0A0E6B0E001C01D92AC:10008000A136B107E1F70E9463000C94D2000C94F2:1000900000008095829508951BB888E18AB986E8AA:1000A00080BD82E080BD80E789B908955D9BFECF69:1000B0008CB908955F9BFECF8CB1089580E00E94BB:1000C000A800869508951F930E944C000E948E0000:1000D0000E945E00182F8AEA0E9456008AEA0E9457:1000E00056008AE50E945600812F0E945600812FFB:1000F0000E9449000E945600EBCF3398379808952C:1001000096B1987F982B96B9089597B18295880FEC:10011000880F807C9F73892B87B90895379A35980B:1001200086E00E94800081E00E9485003D98339A1D:10013000109260007894089597B18F71907E892B0A:1001400087B90895349A369A089586B180740895CF:100150001092600097B18F71907E892B87B9349A85:10016000369A3699FECF24B135B1932F80E030E036:10017000282B392BC90108950E94A80096958795D0:100180009695879508951F920F920FB60F9211249E:100190008F938FEF809360008F910F900FBE0F9021:0801A0001F901895F894FFCFA1:00000001FF

Page 31: Wireless Data Transmission over ASK

Receiver:100000000C942A000C9447000C9447000C94470071:100010000C9447000C9447000C9447000C94470044:100020000C9447000C9447000C9447000C94260154:100030000C9447000C9447000C9447000C94470024:100040000C9447000C9447000C9447000C94470014:100050000C94470011241FBECFE5D4E0DEBFCDBF16:1000600010E0A0E6B0E0E0EBF2E002C005900D92F7:10007000A036B107D9F710E0A0E6B0E001C01D92AC:10008000A236B107E1F70E9414010C9456010C94BA:100090000000882311F48FE321C0813011F486E041:1000A0001DC0823011F48BE519C0833011F48FE448:1000B00015C0843011F486E611C0853011F48DE648:1000C0000DC0863011F48DE709C0873039F08830D3:1000D00011F48FE703C0893019F487E68BBB0895CC:1000E0001BBA0895009711F48EEF1DC08130910561:1000F00011F48DEF18C08230910511F48BEF13C00D:100100008330910511F487EF0EC08430910511F40E:1001100080EF09C08530910511F48FED04C0863061:10012000910519F48FEB88BB089588B30895BF92A9:10013000CF92DF92EF92FF920F931F93CF93DF93B3:10014000C82EC2E0D0E09AE0D92E08E213E280E7A0:10015000E82E87E1F82E8C2D6D2D0E944A01C82EC5:10016000B92ECE010E9472008FE00E944900F80172:100170003197F1F78B2D0E944900F7013197F1F784:1001800021978FEFCF3FD80731F7DF91CF911F91A4:100190000F91FF90EF90DF90CF90BF9008958095E2:1001A000829508951BB888E98AB986E880BD82E007:1001B00080BD80E789B908955D9BFECF8CB9089515:1001C0005F9BFECF8CB108950F931F930091600049:1001D000109161000E94E0008A3541F40E94E00025:1001E000809360000E94E000809361008091600035:1001F0000E94CF0090916100891721F00093600068:10020000109361001F910F9108951F93109160004A:10021000812F0E94CF0090916100891719F4812FDE:100220000E9497001F9108958FEF8ABB87BB1BBA6E

Page 32: Wireless Data Transmission over ASK

:1002300018BA1092600080E00E94CF0080936100A5:100240000E94D20078940E940501FDCF1F920F9268:100250000FB60F9211242F933F934F935F936F9399:100260007F938F939F93AF93BF93EF93FF930E94DE:10027000E400FF91EF91BF91AF919F918F917F919A:100280006F915F914F913F912F910F900FBE0F9003:100290001F901895991B79E004C0991F961708F0D4:1002A000961B881F7A95C9F780950895F894FFCF1B:00000001FF

Page 33: Wireless Data Transmission over ASK

ConclusionWe have created a system capable of transmitting 8 bit data, over a Radio Frequency channel, reliably and quickly.

The system is robust, performs well under noisy conditions and has redundant error checking mechanisms.

The highlights of the system are:

1. Low Cost: The system uses low cost 433 Mhz ASK modules and antenna. And yet it can perform as reliably as costlier FSK module systems.

2. Error Checking: Data is checked for errors at many stages of the transmission and reception.

3. Robust: The system can operate in fairly noisy environments.

4. Maintainable: The transmission and sensors can be readily swapped.

5. Universal: The system uses the 433 Mhz radio band which is universally open for civilian/amateur use.

6. Range: Communication upto 80m is possible.

This wireless communication system is reliable, low cost and robust. It was built using economic easily available components and assembled on a standard easy to manufacture PCB with wide traces.

Page 34: Wireless Data Transmission over ASK

Bibliography

Books:• Atmel AVR Microcontroller Primer: Programming and Interfacing - Steven F.

Barrett and Daniel Pack

• Programming and Customizing the AVR Microcontroller - Dhananjay Gadre

• AVR: An Introductory Course - John Morton

• Wireless Networks: The Definitive Guide, Second Edition - Matthew Gast

Website:• AVR-GCC Programming Guide -

http://electrons.psychogenic.com/modules/arms/art/3/AVRGCCProgrammingGuide.php#progc

• Configuring fuses on the AVR - http://www.instructables.com/id/Build-a-Complete-AVR-System-and-Play-Mastermind/step5/Configure-Fuses-on-the-AVR/

• Atmega16 - www.atmel.com/atmel/acrobat/doc2466.pdf

• C Programming and the ATmega16 Microcontroller - http://www2.tech.purdue.edu/eet/courses/referencematerial/atmel/

• Avr Freaks - http://www.avrfreaks.net/index.php?module=Freaks%20Devices&func=displayDev&objectid=56

• WormFood's AVR Baud Rate Calculator - http://www.wormfood.net/avrbaudcalc.php

• Procyon AVRlib - http://www.mil.ufl.edu/~chrisarnold/components/microcontrollerBoard/AVR/avrlib/

Page 35: Wireless Data Transmission over ASK

LicenseAll software and hardware contained in this project is released

under the “The GNU General Public License v3.0” found at http://www.gnu.org/licenses/gpl.html