senior project - Çankaya Üniversitesiacademic.cankaya.edu.tr/~o.gazi/senior project murat.doc ·...

14
SENIOR PROJECT REPORT REMOTE CONTROL CAR MURAT DİNÇER 200114017 ELECTRONIC AND COMMUNICATION ENGINEERING Advisor: Orhan GAZI

Upload: phungkhue

Post on 17-Mar-2018

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: SENIOR PROJECT - Çankaya Üniversitesiacademic.cankaya.edu.tr/~o.gazi/SENIOR PROJECT Murat.doc · Web viewMy project is about making a remote controlled car. It has 3 basic parts:-Transmitter-Receiver-Microcontrollers

SENIOR PROJECTREPORT

REMOTE CONTROL CAR

MURAT DİNÇER

200114017

ELECTRONIC AND COMMUNICATIONENGINEERING

Advisor: Orhan GAZI

Page 2: SENIOR PROJECT - Çankaya Üniversitesiacademic.cankaya.edu.tr/~o.gazi/SENIOR PROJECT Murat.doc · Web viewMy project is about making a remote controlled car. It has 3 basic parts:-Transmitter-Receiver-Microcontrollers

REMOTE CONTROL CAR

INTRODUCTION

My project is about making a remote controlled car. It has 3 basic parts:-Transmitter-Receiver-Microcontrollers

I bought the transmitter and receiver from an electronic shop. So I do not need to make calibrations to them. The hard part about the Project is the microcontroller programming. I used two (one in transmitter and one in receiver) PIC 16F84 microcontrollers. I used PIC because it is cheap and easy to program. What is PIC16F84?

PIC means Peripheral Interface Controller.This microcontroller is selected because of:

- Its software can be owned from Microchip or internet with not paying anything- It has wide customer group- It is cheap and can be found easily- It has cheap programming circuit- Very easy to program

Here is the PIC16F84 pin diagram:

Page 3: SENIOR PROJECT - Çankaya Üniversitesiacademic.cankaya.edu.tr/~o.gazi/SENIOR PROJECT Murat.doc · Web viewMy project is about making a remote controlled car. It has 3 basic parts:-Transmitter-Receiver-Microcontrollers

Ready to use Transmitter and Receiver Modules

TRANSMITTER

RECEIVER

I used relays for driving the dc motors

Page 4: SENIOR PROJECT - Çankaya Üniversitesiacademic.cankaya.edu.tr/~o.gazi/SENIOR PROJECT Murat.doc · Web viewMy project is about making a remote controlled car. It has 3 basic parts:-Transmitter-Receiver-Microcontrollers

Methods and Experiments

My Project has two main circuits. One is serial communication circuit and the other is the dc motor driving circuit. Let’s take a look to the circuit diagrams:

SERIAL COMMUNICATION CIRCUIT

Page 5: SENIOR PROJECT - Çankaya Üniversitesiacademic.cankaya.edu.tr/~o.gazi/SENIOR PROJECT Murat.doc · Web viewMy project is about making a remote controlled car. It has 3 basic parts:-Transmitter-Receiver-Microcontrollers

OSC1/CLKIN16

RB0/INT 6

RB1 7

RB2 8

RB3 9

RB4 10

RB5 11

RB6 12

RB7 13

RA0 17

RA1 18

RA2 1

RA3 2

RA4/T0CKI 3

OSC2/CLKOUT15

MCLR4

U1

PIC16F84A

X14Mhz

C1

22pF

C2

22pF

VDD

OSC1/CLKIN16

RB0/INT 6

RB1 7

RB2 8

RB3 9

RB4 10

RB5 11

RB6 12

RB7 13

RA0 17

RA1 18

RA2 1

RA3 2

RA4/T0CKI 3

OSC2/CLKOUT15

MCLR4

U2

PIC16F84A

X24Mhz

C3

22pF

C4

22pF

A

B

bbb

R1470R

R2470R

bb

R3470RR4470RR5470RR6470R

D1

LED-BLUE

D2

LED-GREEN

D3

LED-RED

D4

LED-YELLOW

*I connected leds instead of dc motor…

MOTOR DRIVING CIRCUIT

Page 6: SENIOR PROJECT - Çankaya Üniversitesiacademic.cankaya.edu.tr/~o.gazi/SENIOR PROJECT Murat.doc · Web viewMy project is about making a remote controlled car. It has 3 basic parts:-Transmitter-Receiver-Microcontrollers

*M1 Relates to the motor that is used for forward-backward motion and M2 relates to the motor for the direction. (Left-Right motion)

I used relays for decreasing the current. The current need is decreased by 50% rate.

The program code (Serial Communication Program) for Pic 16F84 is in the appendix part.

Page 7: SENIOR PROJECT - Çankaya Üniversitesiacademic.cankaya.edu.tr/~o.gazi/SENIOR PROJECT Murat.doc · Web viewMy project is about making a remote controlled car. It has 3 basic parts:-Transmitter-Receiver-Microcontrollers

Discussions

This projects main aim is learning and using the basics of programming. It is the hardest part of the Project. The driving of the dc motors and connecting the transmitter and receiver are relatively easy to make. The steering is also made by dc motor, this simplifies my Project. If I use stepper motor instead of dc, I need to write some microcontroller codes to drive that. I bought a toy car and used the dc motors on it. So the fitting of the motors are not a problem. The most interesting part of my Project is the usage of Proteus ISIS program. This program really helped me. I don’t need to construct the circuit over and over for adding new components. I don’t need to program the PIC microcontroller as I change the code of the program. I just simply compile the code and start my simulation at the ISIS. This program also makes the PCB schematic automatically, so if you want to make a practical model of your design, it is not a problem.

Summary

This project makes me a good beginner assembly programmer. I learned a lot of new things about this subject. It effected my future selections about job looking. I learned a new program named ISIS. This program helped me very much. I think the main aim to make a project is learning new things by yourself. I learned so many things myself so the project reach to its goal.

REFERENCES

- Mikroişlemciler ve PIC Programlama – Orhan Altınbaşak- Microcontrol’n Applications – David Benson

Page 8: SENIOR PROJECT - Çankaya Üniversitesiacademic.cankaya.edu.tr/~o.gazi/SENIOR PROJECT Murat.doc · Web viewMy project is about making a remote controlled car. It has 3 basic parts:-Transmitter-Receiver-Microcontrollers

APPENDIX

Code of the program:

Transmitter Part

list p=16f84include "P16F84A.inc"sendreg equ h'0c'sendreg2 equ h'0d'sendreg3 equ h'0e'sendreg4 equ h'0f'count equ h'10'start

bsf STATUS,5movlw b'00001111'movwf TRISAclrf TRISBbcf STATUS,5

bsf PORTB,0 switch

movlw b'00100000' ;number to be sentmovwf sendregbtfsc PORTA,0goto switch2goto ser_out

switch2movlw b'00010000'movwf sendreg2btfsc PORTA,1goto switch3goto ser_out2

switch3movlw b'00001000'

movwf sendreg3btfsc PORTA,2goto switch4goto ser_out3

switch4movlw b'00000100'movwf sendreg4btfsc PORTA,3goto switchgoto ser_out4

circle;goto circle

ser_outbcf INTCON,5 ; disable tmr0 interruptsbcf INTCON,7 ; disable global int.clrf TMR0CLRWDTbsf STATUS,5movlw b'11011000'movwf OPTION_REGbcf STATUS,5movlw h'08' ;counter for 8 bitsmovwf countbcf PORTB,0clrf TMR0bcf INTCON,2 ;clear tmr0 flag

Page 9: SENIOR PROJECT - Çankaya Üniversitesiacademic.cankaya.edu.tr/~o.gazi/SENIOR PROJECT Murat.doc · Web viewMy project is about making a remote controlled car. It has 3 basic parts:-Transmitter-Receiver-Microcontrollers

time1btfss INTCON, 2 ;timer overflow? goto time1bcf INTCON, 2 ;clear tmr0 flag

nxtbitbcf STATUS,0rlf sendreg, f ; rotate leftbtfsc STATUS,0 ;test carry flaggoto setportbbcf PORTB,0goto time2

setportbbsf PORTB,0

time2 btfss INTCON, 2 ;timer overflow?goto time2bcf INTCON, 2 ;clear timer overflow flagdecfsz count, f ;decrease countergoto nxtbitbsf PORTB, 0 ;output mark

time3 btfss INTCON, 2 ;timer overflow?goto time3goto switch

ser_out2bcf INTCON,5 ; disable tmr0 interruptsbcf INTCON,7 ; disable global int.clrf TMR0

“CLRWDTbsf STATUS,5movlw b'11011000'movwf OPTION_REGbcf STATUS,5movlw h'08' ;counter for 8 bitsmovwf countbcf PORTB,0clrf TMR0bcf INTCON,2 ;clear tmr0 flag

time1_serout2btfss INTCON, 2 ;timer overflow?goto time1_serout2bcf INTCON, 2 ;clear tmr0 flag

nxtbit2bcf STATUS,0rlf sendreg2, f ; rotate leftbtfsc STATUS,0 ;test carry flaggoto setportb2

bcf PORTB,0goto time2_serout2

setportb2bsf PORTB,0

time2_serout2btfss INTCON, 2 ;timer overflow?goto time2_serout2bcf INTCON, 2 ;clear timer overflow

flagdecfsz count, f ;decrease countergoto nxtbit2bsf PORTB,0 ;output markbtfss INTCON, 2 ;timer overflow?goto time3_serout2goto switch

ser_out3bcf INTCON,5 ; disable tmr0 interruptsbcf INTCON,7 ; disable global int.clrf TMR0CLRWDTbsf STATUS,5movlw b'11011000'movwf OPTION_REGbcf STATUS,5movlw h'08' ;counter for 8 bitsmovwf countbcf PORTB,0clrf TMR0bcf INTCON,2 ;clear tmr0 flag

time1_serout3btfss INTCON, 2 ;timer overflow?goto time1_serout3bcf INTCON, 2 ;clear tmr0 flag

nxtbit3bcf STATUS,0rlf sendreg3, f ; rotate leftbtfsc STATUS,0 ;test carry flaggoto setportb3bcf PORTB,0goto time2_serout3

setportb3bsf PORTB,0

time2_serout3btfss INTCON, 2 ;timer overflow?goto time2_serout3bcf INTCON, 2 ;clear timer overflow

flagdecfsz count, f ;decrease countergoto nxtbit3

Page 10: SENIOR PROJECT - Çankaya Üniversitesiacademic.cankaya.edu.tr/~o.gazi/SENIOR PROJECT Murat.doc · Web viewMy project is about making a remote controlled car. It has 3 basic parts:-Transmitter-Receiver-Microcontrollers

bsf PORTB,0 ;output marktime3_serout3

btfss INTCON, 2 ;timer overflow?goto time3_serout3goto switch

ser_out4bcf INTCON,5 ; disable tmr0 interruptsbcf INTCON,7 ; disable global int.clrf TMR0CLRWDTbsf STATUS,5movlw b'11011000'movwf OPTION_REGbcf STATUS,5movlw h'08' ;counter for 8 bitsmovwf countbcf PORTB,0clrf TMR0bcf INTCON,2 ;clear tmr0 flag

time1_serout4btfss INTCON, 2 ;timer overflow?goto time1_serout4bcf INTCON, 2 ;clear tmr0 flag

nxtbit4bcf STATUS,0rlf sendreg4, f ; rotate leftbtfsc STATUS,0 ;test carry flaggoto setportb4bcf PORTB,0goto time2_serout4

setportb4bsf PORTB,0

time2_serout4btfss INTCON, 2 ;timer overflow?goto time2_serout4bcf INTCON, 2 ;clear timer overflow flagdecfsz count, f ;decrease countergoto nxtbit4bsf PORTB,0 ;output mark

time3_serout4btfss INTCON, 2 ;timer overflow?goto time3_serout4goto switch

end

Page 11: SENIOR PROJECT - Çankaya Üniversitesiacademic.cankaya.edu.tr/~o.gazi/SENIOR PROJECT Murat.doc · Web viewMy project is about making a remote controlled car. It has 3 basic parts:-Transmitter-Receiver-Microcontrollers

Receiver Part

“list p=16f84include "P16F84A.INC"rcvreg equ 0x0ccount equ 0x0dtemp equ 0x0ecounterr equ 0x0fstart

bsf STATUS,5movlw b'00000001'movwf TRISAclrf TRISBbcf STATUS,5clrf PORTAmovlw b'11111111'movwf PORTBclrf rcvreg

switchcall ser_inmovf rcvreg, 0 ;get the byte receivedmovwf PORTBgoto switch

ser_inbcf INTCON, 5 ;disable tmr0 intr.bcf INTCON, 7 ;disable global intr.clrf TMR0CLRWDTbsf STATUS,5movlw b'11011111'movwfOPTION_REGbcf STATUS,5movlw h'08'movwf count ;counter for 8 bits

sbitbtfsc PORTA, 0 ;look for start bitgoto incrementgoto cont

incrementincf counterr,fbtfss counterr,7goto sbitbtfss counterr,6goto sbitbtfss counterr,5goto sbitgoto setbgoto sbit

setbclrf PORTB;movlw b'11111111';movwf PORTBclrf counterrgoto sbit

contclrf counterrmovlw 0x80 ;tmr0 valuemovwfTMR0bcf INTCON, 2 ;clear timer flag

time1 btfss INTCON,2 ;timer overflow?goto time1btfsc PORTA,0 ;start bit still low?goto sbit ;false go backclrf TMR0 ;clear tmr0 valuebcf INTCON,2 ;clear timer flag

time2btfss INTCON,2 ;timer overflow?goto time2 ;nobcf INTCON,2 ;yes, clear flagmovf PORTA,w ;write the value to wmovwf temp ;write the bit value to temprrf temp, f ;rotate right temprrf rcvreg, f ;rotate left the

rcvregdecfsz count, f ;decrement countergoto time2

time3 btfss INTCON,2 ;timer overflow?goto time3 ;noreturn ;yes, byte received

end

Page 12: SENIOR PROJECT - Çankaya Üniversitesiacademic.cankaya.edu.tr/~o.gazi/SENIOR PROJECT Murat.doc · Web viewMy project is about making a remote controlled car. It has 3 basic parts:-Transmitter-Receiver-Microcontrollers