Application Notes Rf (transmitter And Receiver)

  • Uploaded by: Goai Teck Liang
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Application Notes Rf (transmitter And Receiver) as PDF for free.

More details

  • Words: 1,256
  • Pages: 10
GOAI TECK LIANG HK2006-3572

Application Note for Speed control using RF (Transmitter/Receiver) Abstract This document is mainly about how to use universal synchronous asynchronous receiver transmitter (usart) to control the speed of stepper motor. The document includes hardware and software testing. The first testing part connects the transmitter and a switch into microcontroller, once the switch is pressed the transmitter will transmit the signal to receiver and Led at receiver will start to blink. The second testing part connects a potentiometer to analog pin of microcontroller and transmitter to the microcontroller. The speed can be varying by controlling the potentiometer.

Introduction

Figure 1 : RF Transmitter These RF Transmitter/Receiver Modules are very small in dimension and have a wide operating voltage range (3V-12V). The low cost RF Transmitter/Receiver can be used to transmit signal up to 100 meters (the antenna design, working environment and supply voltage will seriously impact the effective distance). It is good for short distance, battery power device development. In this project design RF Transmitter Modules 315MHz will be used.

1

GOAI TECK LIANG HK2006-3572

The application of RF includes Industrial remote control, telemetry and remote sensing. Beside that RF also can be used as Alarm systems and wireless transmission for various types of low-rate digital signal. In addition RF can be used as remote control for various types of household appliances and electronics projects.

PRODUCT LAYOUT

Figure 2 RF Transmitter 315MHZ

Label Description Data :The Data pin of the transmitter. VCC:The power supply to the transmitter. GND :The Ground of the transmitter. ANT :The hole to solder and connect antenna. (Please select the correct antenna length, which is 24cm)

2

GOAI TECK LIANG HK2006-3572

Hardware and Software testing Testing 1:

Figure 3: Circuit diagram for RF transmitter

Figure 4: Circuit diagram for RF receiver For the first part, the circuit for the transmitter and receiver above are connected. When the button of the transmitter circuit is pressed, the transmitter will transmit the signal to the 3

GOAI TECK LIANG HK2006-3572 circuit of the receiver. Once the receiver receives the data from transmitter, the green and red led will start to blink. BANKSEL

SPBRG

MOVLW

D'255'

MOVWF

SPBRG

BANKSEL

TXSTA

MOVLW

B'00100000'

MOVWF

TXSTA

BANKSEL

RCSTA

MOVLW

B'10010000'

MOVWF

RCSTA

CALL

BANK0

Program above is shown as the setup for the usart.

In this circuit design, the asynchronous mode (BRGH=0) is chosen and the oscillator used for microcontroller is 20 MHz. Therefore set the SPBRG = 255, the most slow speed for usart.

4

GOAI TECK LIANG HK2006-3572

For the transmitter part, the transmit enable bit is enabled. Others functions of transmitter are turned off. Therefore, TXSTA should set as B'00100000'.

BTFSS SWITCH1 CALL

SWITCH1_ON

GOTO $-2 SWITCH1_ON MOVLW

D'4'

% decimal 4 is moved to the working register

MOVWF

TRA

% decimal 4 is moved from working register to TRA file

BANKSEL

PIR1

% select register PIR1

BTFSS

PIR1,TXIF

% Test for the TXIF in register PIR1

GOTO

WAITTX1

% if TXIF=0, back to the WAITTx1

MOVLW

D'1'

% decimal 1 is moved to the working register

AGAI

WAITTX1

5

GOAI TECK LIANG HK2006-3572

WAITTX2

BANKSEL

TXREG

% select TXREG register

MOVWF

TXREG

% decimal 1 is sent

DECFSZ

TRA

% decrease TRA

GOTO

AGAI

% if TRA not equal zero go to AGA 1

BANKSEL

PIR1

% select PIR1 register

BTFSS

PIR1,TXIF

% Test for the TXIF in register PIR1

GOTO

WAITTX2

% if TXIF=0, back to the WAITTx2

MOVLW

D'2'

% decimal 2 is moved to the working register

BANKSEL

TXREG

% select TXREG register

MOVWF

TXREG

% decimal 2 is sent

BTFSS

SWITCH1

% test switch1

GOTO

$-1

% if switch is clear, go to previous step

Program above shows the programming of the transmitter to transmit the signal. The transmitter will continue to send 4 times decimal 1 and 1 times decimal 2 to the receiver when the button is pressed. Once the TXREG register transfers the data to the TSR register, the TXREG register is empty and the TXIF is set.

The set up for receiver is similar to the set up for transmitter. ASDF BANKSEL

RCSTA

BCF

RCSTA,CREN

BSF

RCSTA,CREN

BANKSEL

PIR1

BTFSS

PIR1,RCIF

GOTO

$-1

BANKSEL

RCREG

MOVF

RCREG,W

MOVWF

REC1

MOVF

REC1,W

AGAIN

WAITRX

6

GOAI TECK LIANG HK2006-3572 SUBLW

D'1'

BTFSC

STATUS,Z

GOTO

AGA1

MOVF

REC1,W

GOTO

AGAIN

BANKSEL

PIR1

BTFSS

PIR1,RCIF

GOTO

WAITRX1

BANKSEL

RCREG

MOVF

RCREG,W

MOVWF

REC1

MOVF

REC1,W

SUBLW

D'1'

BTFSC

STATUS,Z

GOTO

AGA1

MOVF

REC1,W

SUBLW

D'2'

BTFSS

STATUS,Z

GOTO

AGAIN

MOVWF

PORTB

BSF

PORTB

GOTO

ASDF

AGA1

WAITRX1

Program above shows the programming of my receiver. The receiver will receive 4 times of decimal 1 and 1 times of decimal 2. Once the TXREG register transfers the data to the TSR register, the TXREG register is empty and the TXIF is set. If the transfer complete, RCIF is set.

7

GOAI TECK LIANG HK2006-3572

Testing 2

Figure 5: Circuit for transmitter

Figure 6: Circuit for the receiver The analog signal (0 or 5v) must be changed to the digital signal (0 to 255) in order to control the speed of stepper motor. Therefore a potentiometer should be connected to any analog pin of microcontroller to read the analog to digital. Every digital value represents one speed of stepper motor. After that the transmitter will send digital value to the receiver. The 8

8

GOAI TECK LIANG HK2006-3572 led in the photo above indicates that the digital values (0-255). To make sure the receiver receive the correct signal, the 8 led on and off at receiver must be same as the transmistter.

The Setting up the usart is similar to the Testing 1.

CALL

READ_ADC1

%change analog to digital values

MOVWF

PORTB

%move the digital values to Port B

MOVWF

DTA_SEND

%move the digital values to DTA_SEND

MOVLW

D'4'

% decimal 4 is moved to the working register

MOVWF

TRA

BANKSEL

PIR1

%decimal 4 is moved from working register to TRA file

AGAI

WAITTX1

BTFSS

% select register PIR1 PIR1,TXIF

% Test for the TXIF in register PIR1

GOTO

WAITTX1

% Test for the TXIF in register PIR1

MOVF

DTA_SEND,W

% move DTA_SEND to the file W

BANKSEL

TXREG

%select register TXREG

MOVWF

TXREG

%send the file W

DECFSZ

TRA

% decrease TRA

GOTO

AGAI

% if TRA not equal zero go to AGA 1

Programming above shows that analog signal is changing to the digital signal and then sends it out from transmitter. The transmitter will continue send 4 times of the data to receiver to decrease the error of usart.

ASDF BANKSEL

RCSTA

%select register RCSTA

BCF

RCSTA,CREN

%clear CREN register

BSF

RCSTA,CREN

%Set CREN register

BANKSEL

PIR1

%select PIR1

AGAIN

WAITRX GOTO

BTFSS

PIR1,RCIF $-1

%test the RCIF register %if RCIF = 0 test again for RCIF

9

GOAI TECK LIANG HK2006-3572 BANKSEL

RCREG

%select RCREG register

MOVF

RCREG,W

%move data in RCREG to the W file

MOVWF

PORTB

%move W file to PORT B

GOTO

ASDF

%infinity loop for the program

Programming above shows that the receiver always prepares to receive the data from transmitter. Once it receives the data, it will move the data to Port B of 16 F 877A. You can check the digital value from 8 led.

Conclusion This application note shows the RF transmitter/receiver can be used as speed control for stepper motor.

Reference 1. Chunk Hellebuyck, Programming PIC Microcontroller with PIC Basic 2. Tim Wilmshurst, Designing Embedded Systems with PIC Microcontrollers, Principles and Application. 3. PIC 16F87XA data Sheet 28/40/44-Pin Enhanced Flash Microcontroller 4. www.cytron.com.my 5. http://en.wikipedia.org/wiki/RF

10

Related Documents


More Documents from ""