rf telemetry application licence thesis 2010

46
RF TELEMETRY APPLICATIO Osman GÜLERCA Graduation Project Department of Electrical and Electronics Engineering June 2010

Upload: donatello84

Post on 10-Apr-2015

326 views

Category:

Documents


0 download

DESCRIPTION

The aim of this RF Telemetry Project is to get the analog value from sensors which has information about Anadolu University Hydromobile Car, then to send these informations via an RF module to another host through the ISM (Industrial Scientific Medical) band of 433 Mhz. By that way, we can easily be informed what is going on about the car. This helps us to protect by warning the driver from any kind of accident and danger.

TRANSCRIPT

Page 1: RF Telemetry Application Licence Thesis 2010

RF TELEMETRY APPLICATIO�

Osman GÜLERCA�

Graduation Project

Department of Electrical and Electronics Engineering

June 2010

Page 2: RF Telemetry Application Licence Thesis 2010

i

ABSTRACT

LICENCE THESIS

RF TELEMETRY APPLICATION

Osman GÜLERCAN

Anadolu University

Faculty of Engineering and Architecture

Department of Electrical and Electronics Engineering

Supervisor: Assist. Prof. Dr. Emin GERMEN

2010

Abstract:

The aim of this RF TELEMETRY PROJECT is to get the analog values from sensors which

has information about Anadolu University Hydromobile, then to send these informations via

an RF module to another host through the ISM (Industrial Scientific Medical) band of 433

Mhz. By that way, we can easily be informed what is going on about the car. This helps us to

protect by warning the driver from any kind of accident and danger.

Also we can get information about speed, voltage and temperature values of the specific

circuit elements. By getting these informations we can easily make changes on the car to

reduce the performance and provide security to the driver.

Page 3: RF Telemetry Application Licence Thesis 2010

ii

ÖZET

LİSANS TEZİ

RF TELEMETRİ UYGULAMASI

Osman GÜLERCAN

Anadolu Üniversitesi

Mühendislik-Mimarlık Fakültesi

Elektrik-Elektronik Mühendisliği Bölümü

Danışman: Yard. Doç. Dr. Emin GERMEN

2010

Özet:

RF Telemetri Projesi’nin amacı Anadolu Üniversitesi Kybrid Hidrojen Arabasından analog

verileri alarak bu verileri bir RF modul ile 433 Mhz.’ lik ISM band üzerinden göndermek ve

başka bir lokal merkezde bu verileri göstererek araba hakkında bazı verilerin uzaktan

izlenmesini sağlamaktır. Bu sistemle araç sürücüsü tehlikeli olabilecek durumlardan

korunabilecektir.

Ayrıca araçtan alınan voltaj, sıcaklık ve hız bilgileri ile araç sürüş için daha güvenli bir hale

getirilecek ve test aşamasında da aracın verileri daha iyi izlenebilecektir.

Page 4: RF Telemetry Application Licence Thesis 2010

iii

TE;EKKÜR

Lisans tezim için bana yardımcı olan danışman hocam Yard. Doç. Dr. Emin GERMEN’e ve

her zaman yanımda olan aileme sonsuz teşekkür ederim.

Page 5: RF Telemetry Application Licence Thesis 2010

iv

CONTENTS

Pages

ABSTRACT ………………………………………………………………………...…...…….i

ÖZET ……………………………………………………...………………………….……….ii

TEŞEKKÜR ………………………………………………………...………………….…….iii

CONTENTS ………………………………………………...…………………..…………….iv

LIST OF FIGURES …………………………………………………………...…………..….vi

LIST OF TABLES …………………………………………………………...…………...….vii

LIST OF ABBREVIATIONS …………………………………………………………...….viii

1.I�TRODUCTIO� ………………………………………………….…………………..….1

2. PIC16F877A MCU ……………………….……………………….…………………..…..1

2.1 MCU Feautures …………………………………………………………………………....1

2.2 Pin Diagrams ………………………………………………………….………………...…2

2.3 I/O Ports …………………………………………………………………………………...2

2.4 Initializing PortA ……………………………………………………………………......…3

2.5 PortA Functions ………………………………………………………………………..….4

2.5 Special Function Registers …………………………………………………………….......6

2.5.1 STATUS Register ……………………………………………………………….6

2.5.2 OPTION_REG Register ………..……………………………………………......7

2.5.3 INTCON Register …………………………………………………………….....7

2.6 Analog-To-Digital Converter (A/D) Module ……………………………………………...8

2.6.1 ADCON0 Register ……………….………………………………………….…..9

2.6.2 ADCON1 Register ………………………...………….…………………….….10

2.6.3 A/D Block Diagram ………………………………………………………..….12

2.6.4 Selecting the A/D Conversion Clock ……………………………………..…...12

3. LM 35: PRECISIO� CE�TIGRADE TEMPERATURE SE�SORS ………………..13

3.1 Features ………………………………………………………………………….……….13

3.2 Applications of LM 35 ……………………………………………………………….…..13

4. L7800 SERIES: POSITIVE VOLTAGE REGULATORS ………………………..…..14

Page 6: RF Telemetry Application Licence Thesis 2010

v

5. HD44780-BASED LCD MODULES ……………………………………………..……..16

5.1 Registers ……………………………………………………………………………….....16

5.1.1 Register Selection ……………………………………………………………....16

5.1.2 Busy Flag …………………………………………………………………….....16

5.1.3 Address Counter (AC) ……………………………………………..………...…17

5.1.4 Display Data RAM (DD RAM) ………………………………………………..17

5.1.5 Character Generator ROM (CG ROM) ……………………….…………..……18

5.1.6 Character Generator RAM (CG RAM) ………………………..…………….…18

6. AMPLITUDE-SHIFT KEYI�G (ASK) MODULATIO� ……………….……………20

6.1 Encoding ………………….………………………………………………………...……20

6.2 ASK Modulation Using MATLAB ………………………………………………………21

6.2.1 Matlab Codes …………………………………………………………………...26

7. RF MODULES …………………………………………………………………….……..27

7.1 ATX-34S UHF ASK DATA TRANSMITTER & NRX-34U-R UHF ASK DATA RECEIVER …..…..…..27

7.1.1 General Feautures ……………………………………………………….…...…27

7.1.2 Application Areas …………………………………………………………..…..27

7.1.3 Data Communication ………………………………………………..……….....27

8. SIMULATIO� ………………………………………………………..………………….29

8.1 Program Codes …………………………………………………………………...………32

8.1.1 Transmitter Part Codes ……………………………………………..…………..32

8.1.2 Receiver Part Codes ……………………………………………………………33

9. CO�CLUSIO� …………………………………………………………………...………36

10. REFERE�CES …………………………………………………………………….……37

Page 7: RF Telemetry Application Licence Thesis 2010

vi

LIST OF FIGURES

Figure 1 PIC16F877A Pin Diagrams 2

Figure 2 PIC16F877A Block Diagram 4

Figure 3 PIC16F877A Register File Map 5

Figure 4 A/D Block Diagram 12

Figure 5 Lm 35 Plastic Package, Volt vs. Temp.e Characteristics, Application 13

Figure 6 L7800 Series Packages and Its Application Circuit 14

Figure 7 L7800 Block Diagram 15

Figure 8 Example of busy flag testing using an 8-bit interface 17

Figure 9 Example of busy flag testing using an 4-bit interface 18

Figure 10 Example of data transfer using a 4-bit interface 18

Figure 11 16x1 LCD Module 19

Figure 12 16x1 LCD Module Block Diagram and Power Connection 19

Figure 13 The ideal model for a transmission system using an ASK modulation 20

Figure 14 M=8 and n=2, ASK constellation vs. In-phase component 21

Figure 15 M=8 and n=2, Input and ASK baseband signal 22

Figure 16 M=8 and n=2, ASK baseband and passband signals 23

Figure 17 M=8, n=4, ASK constellation vs. In-phase component 23

Figure 18 M=8, n=4, Input and ASK baseband signal 23

Figure 19 M=8, n=4, ASK baseband and passband signals 24

Figure 20 M=16, n=4, ASK constellation vs. In-phase component 24

Figure 21 M=16, n=4, Input and ASK baseband signal 25

Figure 22 M=16, n=4, ASK baseband and passband signals 25

Figure 23 Data Format 28

Figure 24 ATX-34S Transmitter and NRX-34U-R Receiver Packages 28

Figure 25 RF Telemetry Application Simulation Circuit 29

Figure 26 Transmitter Part 30

Figure 27 Receiver Part 30

Figure 28 LCD Connection on Receiver Part 31

Figure 29 RF Telemetry Application Receiver and Transmitter Boards 31

Page 8: RF Telemetry Application Licence Thesis 2010

vii

LIST OF TABLES

Table 1 PIC16F877A Features 2

Table 2 PORTA Functions of PIC16F877A 4

Table 3 ADCON0 Register 9

Table 4 ADCON1 REGISTER 10

Table 5 TAD vs. MAXIMUM DEVICE OPERATING FREQUENCIES 11

Table 6 Electrical Characteristics For L7805 15

Table 7 16x1 LCD Module Pin Descriptions 19

Table 8 ATX-34 PIN Feautures 28

Table 9 NRX-34 PIN Feautures 28

Page 9: RF Telemetry Application Licence Thesis 2010

viii

LIST OF ABBREVIATIO�S

ADC Analog Digital Conversion

CPU Central Processing Unit

EEPROM Electrically Erasable Programmable Read Only Memory

MCU Micro Controller Unit

PWM Pulse Width Modulation

RF Radio Frequency

RSSI Received Signal Strength Indication

SCI Serial Communication Interface

ST Schmitt Trigger

WDT Watch-Dog Timer

Page 10: RF Telemetry Application Licence Thesis 2010

1

1. I�TRODUCTIO�

RF Telemetry Project is a system that we can get some analog informations from Anadolu

University Hydromobile Car, and send these information via an RF module to another host

through the ISM (Industrial Scientific Medical) band of 433 Mhz. The informations, we want

to send while the car is driven, are the values coming from temperature, speed and voltage

sensors.

Getting the analog values from the sensors is used for testing the experimental results.

Microcontroller which is used for measurement and sending data via RF module is

PIC16F877A. In the period of this report, an LCD display has been controlled by this MCU

and some of the sensor results are displayed on it.

RF modules are chosen UDEA’s NRX-34U ASK receiver module and ATX-34S ASK

transmitter module. Also, some of basic ASK applications are written and its waveforms are

observed in MATLAB.

2. PIC16F877A MCU

2.1 MCU Feautures

The PIC16F877A features 256 bytes of EEPROM data memory, self programming, an ICD, 2

Comparators, 8 channels of 10-bit Analog-to-Digital (A/D) converter, 2

capture/compare/PWM functions, the synchronous serial port can be configured as either 3-

wire Serial Peripheral Interface (SPI™) or the 2-wire Inter-Integrated Circuit (I²C™) bus and

a Universal Asynchronous Receiver Transmitter (USART). All of these features make it ideal

for more advanced level A/D applications in automotive, industrial, appliances and consumer

applications.

Page 11: RF Telemetry Application Licence Thesis 2010

2

Table 1. PIC16F877A Features

Parameter �ame Value

Program Memory Type Flash

Program Memory (KB) 14

CPU Speed (MIPS) 5

RAM Bytes 368

ata EEPROM (bytes) 256

Digital Communication Peripherals 1-A/E/USART,1-MSSP(SPI/I2C)

Capture/Compare/PWM Peripherals 2 CCP

Timers 2 x 8-bit, 1 x 16-bit

ADC 8 ch, 10-bit

Comparators 2

Temperature Range (C) -40 to 125

Operating Voltage Range (V) 2 to 5.5

Pin Count 40

2.2 Pin Diagrams

Figure 1. PIC16F877A Pin Diagrams

2.3 I/O Ports

Some pins for these I/O ports are multiplexed with an alternate function for the peripheral

features on the device. In general, when a peripheral is enabled, that pin may not be used as a

general purpose I/O pin.

Page 12: RF Telemetry Application Licence Thesis 2010

3

PORTA is a 6-bit wide, bidirectional port. The corresponding data direction register is

TRISA. Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input (i.e., put

the corresponding output driver in a High-Impedance mode). Clearing a TRISA bit (= 0) will

make the corresponding PORTA pin an output (i.e., put the contents of the output latch on the

selected pin).

Reading the PORTA register reads the status of the pins, whereas writing to it will write to the

port latch. All write operations are read-modify-write operations. Therefore, a write to a port

implies that the port pins are read, the value is modified and then written to the port data latch.

Pin RA4 is multiplexed with the Timer0 module clock input to become the RA4/T0CKI pin.

The RA4/T0CKI pin is a Schmitt Trigger input and an open-drain output.

All other PORTA pins have TTL input levels and full CMOS output drivers. Other PORTA

pins are multiplexed with analog inputs and the analog VREF input for both the A/D

converters and the comparators. The operation of each pin is selected by clearing/setting the

appropriate control bits in the ADCON1 and/or CMCON registers.

The TRISA register controls the direction of the port pins even when they are being used as

analog inputs. The user must ensure the bits in the TRISA register are maintained set when

using them as analog inputs.

2.4 Initializing PortA

Page 13: RF Telemetry Application Licence Thesis 2010

4

2.5 PortA Functions

Table 2. PORTA Functions of PIC16F877A

Figure 2: PIC16F877A Block Diagram

Page 14: RF Telemetry Application Licence Thesis 2010

5

Figure 3: PIC16F877A Register File Map

Page 15: RF Telemetry Application Licence Thesis 2010

6

2.5 Special Function Registers

The Special Function Registers are registers used by the CPU and peripheral modules for

controlling the desired operation of the device. These registers are implemented as static

RAM.

2.5.1 STATUS Register (Address 03h, 83h, 103h, 183h)

The Status register contains the arithmetic status of the ALU, the Reset status and the bank

select bits for data memory.

The Status register can be the destination for any instruction, as with any other register. If the

Status register is the destination for an instruction that affects the Z, DC or C bits, then the

write to these three bits is disabled. These bits are set or cleared according to the device logic.

Furthermore, the TO and PD bits are not writable, therefore, the result of an instruction with

the Status register as destination may be different than intended.

For example, CLRF STATUS, will clear the upper three bits and set the Z bit. This leaves the

Status register as 000u u1uu (where u = unchanged). It is recommended, therefore, that only

BCF, BSF, SWAPF and MOVWF instructions are used to alter the Status register because

these instructions do not affect the Z, C or DC bits from the Status register.

Page 16: RF Telemetry Application Licence Thesis 2010

7

2.5.2 OPTIO�_REG Register (ADDRESS 81h, 181h)

The OPTION_REG Register is a readable and writable register, which contains various

control bits to configure the TMR0 prescaler/WDT postscaler (single assignable register

known also as the prescaler), the external INT interrupt, TMR0 and the weak pull-ups on

PORTB.

2.5.3 I�TCO� Register (ADDRESS 0Bh, 8Bh, 10Bh, 18Bh)

The INTCON register is a readable and writable register, which contains various enable and

flag bits for the TMR0 register overflow, RB port change and external RB0/INT pin

interrupts.

Page 17: RF Telemetry Application Licence Thesis 2010

8

2.6 Analog-To-Digital Converter (A/D) Module

The Analog-to-Digital (A/D) Converter module has five inputs for the 28-pin devices and

eight for the 40/44-pin devices.

The conversion of an analog input signal results in a corresponding 10-bit digital number. The

A/D module has high and low-voltage reference input that is software selectable to some

combination of VDD, VSS, RA2 or RA3.

The A/D converter has a unique feature of being able to operate while the device is in Sleep

mode. To operate in Sleep, the A/D clock must be derived from the A/D’s internal RC

oscillator.

Page 18: RF Telemetry Application Licence Thesis 2010

9

The A/D module has four registers. These registers are:

- A/D Result High Register (ADRESH)

- A/D Result Low Register (ADRESL)

- A/D Control Register 0 (ADCON0)

- A/D Control Register 1 (ADCON1)

The ADCON0 register, shown in Table-3, controls the operation of the A/D module. The

ADCON1 register, shown in Table-4, configures the functions of the port pins. The port pins

can be configured as analog inputs (RA3 can also be the voltage reference) or as digital I/O.

2.6.1 ADCO�0 Register (ADDRESS 1Fh)

Table 3. ADCON0 Register

Page 19: RF Telemetry Application Licence Thesis 2010

10

2.6.2 ADCO�1 Register (ADDRESS 9Fh)

Table 4. ADCON1 REGISTER

The ADRESH:ADRESL registers contain the 10-bit result of the A/D conversion. When the

A/D conversion is complete, the result is loaded into this A/D Result register pair, the

GO/DONE bit (ADCON0<2>) is cleared and the A/D interrupt flag bit ADIF is set. The block

diagram of the A/D module is shown in Figure11-1.

Page 20: RF Telemetry Application Licence Thesis 2010

11

After the A/D module has been configured as desired, the selected channel must be acquired

before the conversion is started. The analog input channels must have their corresponding

TRIS bits selected as inputs.

To do an A/D Conversion, we should follow these steps:

1. Configure the A/D module:

- Configure analog pins/voltage reference and digital I/O (ADCON1)

- Select A/D input channel (ADCON0)

- Select A/D conversion clock (ADCON0)

- Turn on A/D module (ADCON0)

2. Configure A/D interrupt (if desired):

- Clear ADIF bit

- Set ADIE bit

- Set PEIE bit

- Set GIE bit

3. Wait the required acquisition time.

4. Start conversion:

- Set GO/DONE bit (ADCON0)

5. Wait for A/D conversion to complete by either:

- Polling for the GO/DONE bit to be cleared (interrupts disabled); OR

- Waiting for the A/D interrupt

6. Read A/D Result register pair (ADRESH:ADRESL), clear bit ADIF if required.

7. For the next conversion, go to step 1 or step 2 as required. The A/D conversion time

per bit is defined as TAD.

Table 5. TAD vs. MAXIMUM DEVICE OPERATING FREQUENCIES

Page 21: RF Telemetry Application Licence Thesis 2010

12

For correct A/D conversions, the A/D conversion clock (TAD) must be selected to ensure a

minimum TAD time of 1.6 µs.

2.6.3 A/D Block Diagram

Figure 4. A/D Block Diagram

2.6.4 Selecting the A/D Conversion Clock

The A/D conversion time per bit is defined as TAD. The A/D conversion requires a

minimum 12 TAD per 10-bit conversion. The source of the A/D conversion clock is

software selected. The seven possible options for TAD are:

- 2 TOSC

- 4 TOSC

- 8 TOSC

- 16 TOSC

- 32 TOSC

- 64 TOSC

- Internal A/D module RC oscillator (2-6 µs)

Table 5 shows the resultant TAD times derived from the device operating frequencies and

the A/D clock source selected.

Page 22: RF Telemetry Application Licence Thesis 2010

13

3. LM 35: PRECISIO� CE�TIGRADE TEMPERATURE SE�SORS

The LM 35 series are precision integrated-circuit temperature sensors, whose output voltage

is linearly proportional to the Celsius (Centigrade) temperature. The LM 35 thus has an

advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to

subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The

LM 35 does not require any external calibration or trimming to provide typical accuracies of

+/- ¼ °C at room temperature and +/- ¾ °C over a full -55 to +150°C temperature range. Low

cost is assured by trimming and calibration at the wafer level. The LM 35's low output

impedance, linear output, and precise inherent calibration make interfacing to readout or

control circuitry especially easy. It can be used with single power supplies, or with plus and

minus supplies.

3.1 Features

- Calibrated directly in ° Celsius (Centigrade)

- Linear a 10.0mV/°C scale factor

- 0.5°C accuracy guaranteeable (at a 25°C)

- Rated for full -55° to +150°C range

- Suitable for remote applications

- Low cost due to wafer-level trimming

- Operates from 4 to 30 volts

Figure 5. Lm 35 Plastic Package, Voltage vs. Temperature Characteristics, and Basic Application

Page 23: RF Telemetry Application Licence Thesis 2010

14

3.2 Applications of LM 35

The LM 35 can be applied easily in the same way as other integrated-circuit temperature

sensors. It can be glued or cemented to a surface and its temperature will be with in about

0.01˚C of the surface temperature.

This presumes that the ambient air temperature is almost the same as the surface temperature;

if the air temperature were much higher or lower than the surface temperature, the actual

temperature of the LM35 die would be at an intermediate temperature between the surface

temperature and the air temperature. This is expecially true for the TO-92 plastic package,

where the copper leads are the principal thermal path to carry heat into the device, so its

temperature might be closer to the air temperature than to the surface temperature.

To minimize this problem, be sure that the wiring to the LM 35, as it leaves the device, is held

at the same temperature as the surface of interest. The easiest way to do this is to cover up

these wires with a bead of epoxy which will insure that the lead sand wires are all at the same

temperature as the surface, and that the LM 35 die’s temperature will not be affected by the

air temperature.

4. L7800 SERIES: POSITIVE VOLTAGE REGULATORS

The L7800 series of three-terminal positive regulators is available in several packages and

fixed output voltages, making it useful in a wide range of applications. These regulators can

provide local on-card regulation, eliminating the distribution problems associated with single

point regulation.

Figure 6. L7800 Series Packages and Its Application Circuit

Page 24: RF Telemetry Application Licence Thesis 2010

15

Each type employs internal current limiting, thermalshut-down and safe area protection,

making it essentially in destructible. If adequate heat sinking is provided, they can deliver

over 1A output current. Although designed primarily as fixed voltage regulators, these

devices can be used with external components to obtain adjustable voltages and currents.

Figure 7. L7800 Block Diagram

Table 6. Electrical Characteristics For L7805

Page 25: RF Telemetry Application Licence Thesis 2010

16

5. HD44780-BASED LCD MODULES

5.1 Registers

The HD44780 has two 8 bit registers, an instruction register (IR) and a data register (DR).

The IR stores instruction codes such as display clear and cursor shift, and address information

for display data RAM (DD RAM) and character generator RAM (CG RAM). The IR can be

written from the MPU but not read by the MPU.

The DR temporarily stores data to be written into the DD RAM or the CG RAM and data to

be read out from the DD RAM or the CG RAM. Data written into the DR from the MPU is

automatically written into the DD RAM or the CG RAM by internal operation. The DR is

also used for data storage when reading from the DD RAM or the CG RAM. When address

information is written into the IR, data is read into the DR from the DD RAM or the CG

RAM by internal operation. Data transfer to the MPU is then completed by the MPU reading

DR. After the MPU reads the DR, data in the DD RAM or CG RAM at the next address is

sent to the DR for the next read from the MPU. Register selector (RS) signals make their

selection from these two registers.

5.1.1 Register Selection

RS R/W Enable Operation

== === ====== =========

0 0 H,H->L IR write as internal operation

(Display clear, etc.)

0 1 H Read busy flag (DB7) and

address counter (DB0-DB6)

1 0 H,H->L DR write as internal operation

(DR to DD RAM or CG RAM)

1 1 H DR read as internal operation

(DD RAM or CG RAM to DR)

5.1.2 Busy Flag

When the busy flag is "1", the HD44780 is in the internal operation mode, and the next

instruction will not be accepted. As the Register selection table above shows, the busy flag is

output to DB7 when RS = 0 and R/W = 1. The next instruction must be written after ensuring

that the busy flag is "0".

Page 26: RF Telemetry Application Licence Thesis 2010

17

5.1.3 Address Counter (AC)

The address counter (AC) assigns addresses to DD and CG RAMs. When an instruction for

address is written in IR, the address information is sent from IR to AC. Selection of either DD

or CG RAM is also determined concurrently by the instruction.

After writing into (or reading from) DD or CG RAM display data, AC is automatically

incremented or decremented by 1. AC contents are output as DB0-DB6 when RS = 0 and

R/W = 1, as shown in the Register selection table above.

5.1.4 Display Data RAM (DD RAM)

The display data RAM (DD RAM) stores display data represented in 8-bit character codes. Its

capacity is 80 x 8 bits, or 80 characters. On displays with fewer than 80 characters, any DD

RAM that is not used for display can be used as a general data RAM. The relationship

between DD RAM addresses and positions on the liquid crystal display are shown below. The

DD RAM address is set in the Address Counter (AC) and is expressed in hexadecimal.

Figure 8. Example of busy flag testing using an 8-bit interface.

Page 27: RF Telemetry Application Licence Thesis 2010

18

Figure 9. Example of busy flag testing using an 4-bit interface.

Figure 10. Example of data transfer using a 4-bit interface

5.1.5 Character Generator ROM (CG ROM)

The Character Generator ROM generates 5 x 7 dot or 5 x 10 dot character patterns from 8-bit

character codes. It contains 192 5 x 7 dot character patterns and 192 5 x 10 dot character

patterns.

5.1.6 Character Generator RAM (CG RAM)

The Character Generator RAM is RAM with which the user can redefine character patterns in

software. With 5 x 7 dots, 8 user-defined character patterns can be stored and with 5 x 10

dots, 4 user-defined character patterns can be stored.

Page 28: RF Telemetry Application Licence Thesis 2010

19

Table 7. 16x1 LCD Module Pin Descriptions

PI� �UMBER SYMBOL FU�CTIO�

1 Vss GND

2 Vdd + 5V

3 Vo Contrast Adjustment

4 RS H/L Register Select Signal

5 R/W’ H/L Read/Write Signal

6 E H → L Enable Signal

7 DB0 H/L Data Bus Line

8 DB1 H/L Data Bus Line

9 DB2 H/L Data Bus Line

10 DB3 H/L Data Bus Line

11 DB4 H/L Data Bus Line

12 DB5 H/L Data Bus Line

13 DB6 H/L Data Bus Line

14 DB7 H/L Data Bus Line

15 A/Vee + 4.2V for LED (RA = 0)

16 K Power Supply for B/L (0V)

Figure 11. 16x1 LCD Module

Figure 12. 16x1 LCD Module Block Diagram and Power Connection

Page 29: RF Telemetry Application Licence Thesis 2010

20

6. AMPLITUDE-SHIFT KEYI�G (ASK) MODULATIO�

Amplitude-shift keying (ASK) is a form of modulation that represents digital data as

variations in the amplitude of a carrier wave.

The amplitude of an analog carrier signal varies in accordance with the bit stream (modulating

signal), keeping frequency and phase constant. The level of amplitude can be used to

represent binary logic 0s and 1s. We can think of a carrier signal as an ON or OFF switch. In

the modulated signal, logic 0 is represented by the absence of a carrier, thus giving OFF/ON

keying operation and hence the name given.

Like AM, ASK is also linear and sensitive to atmospheric noise, distortions, propagation

conditions on different routes in PSTN, etc. Both ASK modulation and demodulation

processes are relatively inexpensive. The ASK technique is also commonly used to transmit

digital data over optical fiber. For LED transmitters, binary 1 is represented by a short pulse

of light and binary 0 by the absence of light. Laser transmitters normally have a fixed "bias"

current that causes the device to emit a low light level. This low level represents binary 0,

while a higher-amplitude lightwave represents binary 1.

6.1 Encoding

The simplest and most common form of ASK operates as a switch, using the presence of a

carrier wave to indicate a binary one and its absence to indicate a binary zero. This type of

modulation is called on-off keying, and is used at radio frequencies to transmit morse code

(referred to as continuous wave operation).

More sophisticated encoding schemes have been developed which represent data in groups

using additional amplitude levels. For instance, a four-level encoding scheme can represent

two bits with each shift in amplitude; an eight-level scheme can represent three bits; and so

on. These forms of amplitude-shift keying require a high signal-to-noise ratio for their

recovery, as by their nature much of the signal is transmitted at reduced power.

Figure 13. The ideal model for a transmission system using an ASK modulation

Page 30: RF Telemetry Application Licence Thesis 2010

21

6.2 ASK Modulation Using MATLAB

In this part, the MATLAB codes were implemented by changing the modulation types; also,

plotting the waveforms, the results were observed.

In the MATLAB codes, we first set the M-ary modulation parameter ‘M’ to 8 and the number

of symbol intervals ‘n’ to 2. By doing this, we observed 3 figures that show us some of

waveforms of PAM(ASK) signals.

Modulation constellations, input signals as M-ary levels, also both baseband and passband

signals were observed.

In this code, sampling rate of the message signal was constantly 1, we couldn’t change it

because some of the vector’s length had already assigned to 1.

Lastly, we set the the M-ary modulation parameter ‘M’ to 16, and the number of symbol

intervals ‘n’ to 4. Then we run it and observed the modulation waveforms again.

Figure 14. M=8 and n=2, ASK constellation vs. In-phase component

Page 31: RF Telemetry Application Licence Thesis 2010

22

Figure 15. M=8 and n=2, Input and ASK baseband signal

Figure 16. M=8 and n=2, ASK baseband and passband signals

Page 32: RF Telemetry Application Licence Thesis 2010

23

Figure 17. M=8, n=4, ASK constellation vs. In-phase component

Figure 18. M=8, n=4, Input and ASK baseband signal

Page 33: RF Telemetry Application Licence Thesis 2010

24

Figure 19. M=8, n=4, ASK baseband and passband signals

Figure 20. M=16, n=4, ASK constellation vs. In-phase component

Page 34: RF Telemetry Application Licence Thesis 2010

25

Figure 21. M=16, n=4, Input and ASK baseband signal

Figure 22. M=16, n=4, ASK baseband and passband signals

Page 35: RF Telemetry Application Licence Thesis 2010

26

6.2.1 Matlab Codes

% This program shows the illustration of PAM (ASK) signals.

% Both bandpass and passband signals are shown. Keep the n, Fs , and fc settings.

clear; clc; close all

n = 4; % Number of symbol intervals

M = 16; % Use M-ary modulation

Fd = 1; % Sampling rate of the message signal

Fs = 100; % Sampling rate of the modulated signal

fc = 18; % Carrier frequency

x = randint(n,1,M); % Random multilevel message signal (from zero to M-1)

xt = reshape(repmat(x,1,Fs)',1,n*Fs); t = 1:1:n*Fs; % Arrange time axis

% PAM (ASK) Signals

% A) Baseband ASK

sask = real(dmodce(x,Fd,Fs,'ask',M)); modmap('ask',M); set(gcf,'Color',[1 1 1])

pause

subplot(2,1,1); plot(t,xt); title('Input signal x(t) as M-ary levels')

axis ([min(t) max(t) -0.1 max(x)*1.1])

set(gca,'XTick',[50 100 150 200 250 300 350 400])

set(gca,'XTickLabel',{'T/2';'T';'3T/2';'2T';'5T/2';'3T';'10T/2';'4T'},'FontWeight','bold');

subplot(2,1,2); plot(t,sask); title('ASK baseband signal - s_m(t)'); xlabel('Time Axis')

axis ([min(t) max(t) -1.1 1.1])

set(gca,'XTick',[50 100 150 200 250 300 350 400])

set(gca,'XTickLabel',{'T/2';'T';'3T/2';'2T';'5T/2';'3T';'10T/2';'4T'},'FontWeight','bold');

pause; clf reset

% B) Bandpass PAM (ASK)

uask = dmod(x,fc,Fd,Fs,'ask',M);

subplot(2,1,1); plot(t,sask); set(gcf,'Color',[1 1 1])

title('ASK baseband signal - s_m(t)')

axis ([min(t) max(t) -1.1 1.1])

set(gca,'XTick',[50 100 150 200 250 300 350 400])

set(gca,'XTickLabel',{'T/2';'T';'3T/2';'2T';'5T/2';'3T';'10T/2';'4T'},'FontWeight','bold');

subplot(2,1,2); plot(t,uask); title('ASK bandpass signal - u_m(t)'); xlabel('Time Axis')

axis ([min(t) max(t) -1.1 1.1])

set(gca,'XTick',[50 100 150 200 250 300 350 400])

set(gca,'XTickLabel',{'T/2';'T';'3T/2';'2T';'5T/2';'3T';'10T/2';'4T'},'FontWeight','bold');

pause

Page 36: RF Telemetry Application Licence Thesis 2010

27

7. RF MODULES

RF Modules are divided into three; transmitters, recivers and tranceivers. The RF modules are

selected ATX-34S for data transmitter and NRX-34U-R for data receiver. They are the

products of UDEA which is an OSTĐM/ANKARA based Rf Manufacturer Company. They

have 1~200 m. ranges and uses too low energy.

7.1 ATX-34S UHF ASK DATA TRA�SMITTER & �RX-34U-R UHF ASK DATA RECEIVER

7.1.1 General Feautures:

- 433.920 MHz. UHF band with EN 300 220 standard.

- High Frequency Stability

- Low power consumes

7.1.2 Application Areas:

- Remote Control Systems

- Security Based Alarm Systems

- RF-Telemetry Systems

7.1.3 Data Communication

1- Physical Character

Communication Type: Asynchronous

Communication Speed: 2.4 Kbps

Link: RS232-TTL (0-5V DC)

2- Format of Data

8 bit data bits, no parity bit and one stop bit

3- Communication Protocol

ATX-34S transmitter module has a digital data input (DIN) which is given data by user to

send via RF.

The standard data protocol is

TX : preamble + synchron+ data1+.....+dataX

It is necessary to use a preamble to start sending process even if it is an easy communication

system. Preamble is an array bits derives from 1’s and 0’s. It can be 5 byte 0x55 or 0xAA.

Delays that corresponding 1’s and 0’s should be equal. Briefly, preamble provides hardware

synchronization.

Page 37: RF Telemetry Application Licence Thesis 2010

28

Figure 23. Data Format.

Synchron helps software synchronization. It is necessary to provide bit synchronization and

negotiation for start of message. This array bits length differs from application needs, and it

can be 5 byte 0x00 + 5 byte 0xFF.

While sending data, there should not empty, if so the preamble and synchron should be send

again.

At the receiver part, there is a digital data output pin (DOUT) which is demodulated signal

from RF signals. There is no need to look for preamble, only synchron is searched then data is

read.

Table 8. ATX-34 PIN Feautures Table 9. NRX-34 PIN Feautures

Pin �o Pin �ame I/O Description Pin �o Pin �ame I/O Description

4 Ant O 50 ohm antenna

connection point

1 Ant I 50 ohm antenna

connection point

3 Gnd - 2 Gnd - Ground

2 DIN I Digital Input 3 Vcc - +5V

1 Vcc - +5V 4 RSSI O Analog Output

5 Dout O Digital Output

Figure 24. ATX-34S Transmitter and NRX-34U-R Receiver Packages

Page 38: RF Telemetry Application Licence Thesis 2010

29

8. SIMULATIO�

PIC16F877A MCU has an internal ADC module that converts analog voltages to digital values.

In this application, it is used three ADC channels which are activated with multiplexing method

on the software. Converting digital values from the analog values at the transmmiter part, MCU

easily send these data to Receiver Part, and Receiver MCU writes these data to module LCD

according to HD44780 instruction set. For example, if we want to clear LCD display, we

should send 0x01 command or 0x05 to move cursor right. Fortunately, we have already used

the C programming language so that some of the libraries can easily be found like “lcd.c” .

Figure 25. RF Telemetry Application Simulation Circuit

Page 39: RF Telemetry Application Licence Thesis 2010

30

Figure 26. Transmitter Part

Figure 27. Receiver Part

Page 40: RF Telemetry Application Licence Thesis 2010

31

Figure 26 shows the Transmitter Part that three sensor (temperature, speed and voltage) output

are directly connected to MCU through serial resistors. These analog data are converted by

MCU’s A/D convertor module and digital data are send via RF module.

Figure 27 shows the Receiver Part that MCU gets three data from the RF module, and makes

some calculation for each data and display them on the LCD.

Figure 28. LCD Connection on Receiver Part

Figure 28 shows a connection diagram between LCD module and Receiver part. 11 wires are

connected between them. Last two wire are used for back light of LCD.

Figure 29. RF Telemetry Application Receiver and Transmitter Boards

Page 41: RF Telemetry Application Licence Thesis 2010

32

8.1 Program Codes

8.1.1 Transmitter Part Codes

#include "C:\Users\BenQ\Desktop\LCD\adc\ADC.h" #include "C:\Program Files\PICC\Drivers\LCD.c" #fuses XT #use delay(clock=4000000) //#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bi ts=8,Stream=PC) #use rs232(baud=2400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bi ts=8,Stream=RF) int t2,t1,t0; void gonder() { putc(0x55,RF); putc(0x55,RF); putc(0x55,RF); putc(0x55,RF); putc(0x55,RF); putc(0x00,RF); putc(0x00,RF); putc(0x00,RF); putc(0x00,RF); putc(0x00,RF); putc(0xFF,RF); putc(0xFF,RF); putc(0xFF,RF); putc(0xFF,RF); putc(0xFF,RF); putc(0xCC,RF); putc(0xCC,RF); putc(0xCC,RF); putc(0xCC,RF); putc(0xCC,RF); putc(t0,RF); putc(t1,RF); putc(t2,RF); return; } void main() { int value=0; // long value of data to read from ADC int n=0; // ADC channel number setup_adc_ports(AN0_AN1_AN3); // set ADC, the first 3 bits of PortA setup_adc(ADC_CLOCK_DIV_32); //adjust the ADC resolution setup_psp(PSP_DISABLED); setup_spi(FALSE); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1);

Page 42: RF Telemetry Application Licence Thesis 2010

33

while(n<3) { set_adc_channel(n); // select 1 of 3 ADC channel delay_us(10); // wait 10 miliseconds to initiate value=read_adc(); read_adc(ADC_START_ONLY); // start the ADC process value=read_adc(ADC_READ_ONLY); //read the value from the ADC delay_us(10); // wait for 10 miliseconds if(n==0){ // if the first channel is activated t0=make8(value,0); } else if(n==1){ // if the second channel is activated t1=make8(value,0); } else if(n==2){ // if the third channel is activated t2=make8(value,0); } if(n!=2) n++; // increase n except n=2 else { n=0; // otherwise reset n gonder(); delay_ms(10); } } // end of while loop } // end of main program

8.1.2 Receiver Part Codes #include <16F877.h> #fuses XT #use delay(clock=4000000) #use rs232(baud=2400,xmit=PIN_C3,rcv=PIN_C7,stream=RF) #include <LCD.c> #include <stdlib.h> float t0,t1,t2; void my_func() { output_b(t0); delay_ms(200); return; } void my_lcd() { char mystring0[8]; char mystring1[8]; char mystring2[8]; lcd_putc("\f"); // clear the screen lcd_gotoxy(1,1); printf(lcd_putc,"Temp : "); delay_ms(10);

Page 43: RF Telemetry Application Licence Thesis 2010

34

sprintf(mystring0,"%.1f",t0*500/255); if(mystring0[1]=='.'){ mystring0[3]=0XDF; mystring0[4]='C'; mystring0[5]=' ';} else{ mystring0[4]=0XDF; mystring0[5]='C';} lcd_gotoxy(10,1); // go to 1st row & 2nd column of the LCD printf(lcd_putc,mystring0); //and print the value as a string delay_ms(1000); lcd_putc("\f"); // clear the screen lcd_gotoxy(1,1); printf(lcd_putc,"Speed : "); delay_ms(10); sprintf(mystring1,"%.2f",t1*70/255); mystring1[4]='k'; mystring1[5]='m'; mystring1[6]='/'; mystring1[7]='h'; lcd_gotoxy(9,1); // go to 1st row & 2nd column of the LCD printf(lcd_putc,mystring1); //and print the value as a string delay_ms(1000); lcd_putc("\f"); // clear the screen lcd_gotoxy(1,1); printf(lcd_putc,"Volt : "); delay_ms(10); sprintf(mystring2,"%.2f",t2*12/255); mystring2[4]=' '; mystring2[5]='V'; lcd_gotoxy(10,1); // go to 1st row & 2nd column of the LCD printf(lcd_putc,mystring2); //and print the value as a string delay_ms(1000); lcd_putc("\f"); // clear the screen return; } Void Main() { char a; int8 i=0,j=0; set_tris_b(0); set_tris_d(0); output_b(0); lcd_init(); // initiate the lcd delay_ms(100); //delay 100 miliseconds lcd_putc("\f"); // clear the screen

Page 44: RF Telemetry Application Licence Thesis 2010

35

lcd_gotoxy(1,1); printf(lcd_putc,"NO DATA!"); delay_ms(10); for (;;) { a = fgetc(RF); if (a==0xFF) { if (j!=4) j++; } if ((a==0xCC) && (j==4)) { i++; if(i<5) continue; i=0; t0 = fgetc(RF); t1 = fgetc(RF); t2 = fgetc(RF); my_func(); my_lcd(); } if((i==4) && (j==4)) { i=0; j=0; } } }

Page 45: RF Telemetry Application Licence Thesis 2010

36

9. CO�CLUSIO�

The aim of this graduation project is to build an RF telemetry system for Departmant of

Electrical and Electronics Engineering of Anadolu University’s car (KYBRID) which will race

in TUBITAK FORMULA G races. Three analog data, selected as temperature, car’s

accumulator voltage and its speed, are converted by MCU’s A/D converter and an RF module

send them on wireless medium from KYBRID. These data are received and displayed on an

LCD module on the receiver side.

The RF modules are selected UDEA’s ATX-34S for data transmitter and NRX-34U-R for data

receiver. They provides 150 m. range for RF communication. While sending data, they are

decoded at the transmitter side on the syncron processes of the protocol. At the receiver side,

these information data are encrypted and first three data are converted to decimal number to

display on the LCD module properly.

LM 35 temperature sensor is used to measure the air temperature. It offers the voltage

differences for each 10.0 mV/°C. By using this differences, the A/D module converted its

voltage represantation in digitally format.

The voltage can be directly measured from the car’s accumulator but a trimpot is used between

MCU and accumulator to supply maximum +5V because it may damage the MCU or the

accumulator voltage types can be changed future. It can be easily calibrated to supply +5V by

changing the trimpot resistance.

Speed measurment is not complated because the speed sensor is not selected yet. Howewer, a

potentiometer represents the speed sensor on the transmitter board and when its resistance is

changed, the output speed text value on the LCD is also changed at the receiver side.

To sum up, RF Telemetry Application is designed to measure KYBRID’s performance and to

demonstrate the RF data communication. By this RF telemetry system, KYBRID can easily be

analyzed as speed, voltage, and also air temperature. Hydrogen leakage or flatting tire can

cause mortal threats. By this RF Telemetry Application, we could avoid these dangerous threats

by changing sensors.

Page 46: RF Telemetry Application Licence Thesis 2010

37

10. REFERE�CES

[1] Microchip Technology Inc., www.microchip.com

[2] National Semiconductor, www.national.com

[3] ST Microelectronics, www.st.com

[4] Longtech Optics, www.longtech-display.com

[5] Udea Elecronics, www.udea.com.tr

[6] Wikipedia, http://en.wikipedia.org/wiki/Amplitude-shift_keying