+ All Categories
Home > Documents > my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of...

my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of...

Date post: 04-May-2020
Category:
Upload: others
View: 12 times
Download: 0 times
Share this document with a friend
23
2008 Summer Two Shores Academic Report Single Chip Controlled Car Author: Yu Chen, Cheng National Tsing Hua University EE department Advisor: Professor Rui Feng, Li Robotic Institute Harbin Institute of Technology
Transcript
Page 1: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

2008 Summer Two Shores Academic Report

Single Chip Controlled Car

Author: Yu Chen, Cheng

National Tsing Hua University

EE department

Advisor:

Professor Rui Feng, Li

Robotic Institute Harbin Institute of Technology

Teacher Da Ming, Zhang

Robotic Institute Harbin Institute of Technology

August 25th, 2008

Abstracts

Page 2: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

This experiment is mainly using single chip to accomplish simple machine control. With flash programmable and erasable read only memory (PEROM), a manufactured printed circuit board (PCB) and a simple structure model car, it can save much time to understand the specification of chips. With C language the user can get familiar faster. That is also easy to read and find out the error. It cost less time to build a sub-system with in-system programming and series port transmission. The reason is that the series port transmission is much easier than parallel transmission and USB transmission. After all, this project is how to develop a sub-system to communicate with PC---that is a controlled model car.

Key Words: microprocessor; PEROM; AT89S52; model car.

Contents1 Preface-------------------------------------------------------------------------P.12 Purpose of Research--------------------------------------------------------P.13 Design and Flow Paths-----------------------------------------------------P.3

Experiment equipments---------------------------------------------------------------P.3Design of experiments-----------------------------------------------------------------P.4The flow path of experiments--------------------------------------------------------P.7

Constructing Hardware---------------------------------------------------------P.8Develop Software-----------------------------------------------------------------P.9Adaption--------------------------------------------------------------------------P.10

4 Results and Discussions---------------------------------------------------P.105 Conclusions-----------------------------------------------------------------P.13Thanks--------------------------------------------------------------------------P.14Diagram and Graph---------------------------------------------------------P.14Reference----------------------------------------------------------------------P.15

1 Preface

For these numbers of decade, the microprocessor is gradually used commonly over many products. For example, an electronic fan or a cell phone etc. These processors are almost low-power, high-performance microcomputers. Especially, PEROM is suitable for me to develop a new system with some simple material. This project is focus on how to build a simple system with AT89S52 microprocessor to control a model car.

P.1

Page 3: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

2 Purpose of Research

I like satellites very much, but that is a complicate structure. For my two years in National Tsing Hua University, I didn’t have any course that can make a real product. That is why I do desire to build a new one. I thought I can learn many things from this when I am in china, then I set up too many thing to accomplish. That made the research purpose change twice. The purpose changing process is below:This project can be divided to two parts: Hardware and softwareI. Before coming to mainland china, I anticipated making a sound controlled car:

1. Hardware:(i) The car is made on my own way.(ii) Draw a PCB and sent to a factory to manufacture.(iii) Adapter for analog to digital.(iv) Build a download machine.(v) Develop it with USB.

2. Software(i) Assemble language(ii) C language

II. When I came to mainland china, I discover that I could not finish on these few weeks. Then I change it to easier one: remote controlled car.1. Hardware:

(i) Use a model car.(ii) Draw a PCB and sent to a factory to manufacture.(iii) With two 80C51 chips to do the system and remote controller

separately.(iv) Build a download machine.(v) Develop it with USB.

2. Software:(i) Assemble language(ii) C language

III. Nevertheless the topic was changed after discussion with teacher. It became much simple one: Wired series controlled car.1. Hardware:

(i) Use a model car.(ii) Use the PCB that teacher used and reconstruct.(iii) With directly download chips like 80C52 can save time in build a

download machine.(iv) Develop it with Series port.

P.2

Page 4: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

2. Software:(i) C51

In this experiment, I expect to learn how to build a sub-system and to get familiar with C51 language. Besides, I also want to know the specification of these chips.

3 Design and Flow Paths

Experiment equipments:I. Single chip:

1. AT89S52. (Core chip)2. MAX232. (Communication with PC)3. 74LS244. (Download programming process to 8052)

II. PCB(teacher’s product):1. A motherboard for AT89S52 and MAX232.2. A motherboard for 74LS244.

III. Passive component:1. Resistors:

i. a resistor with 10k ohms.ii. 3 resistors with 5.1k ohms.

iii. 6 resistors with 1k ohms.iv. 7 resistors with 100 ohms.

2. Capacitors:i. 2 capacitors with 100uF.

ii. 2 capacitors with 30pF.iii. 5 capacitors with 100nF

3. 3 relays.(replace step motor with relays and normal motor to decrease cost)4. 3 Bipolar Junction Transistors C9013.5. 4 light emitter diodes with 3 red light 1 green light.6. 3 diodes IN4007.7. A no source quartz crystal oscillator with 16MHz.8. A DIP switch.9. Several wires (different color wires are better).

IV. A model car:1. 2 motors with 3V working voltage.2. 3 pair with different tooth gear wheels.3. A pair wheels.4. A 360 degrees direction wheel.5. 2 different length metal bars.

P.3

Page 5: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

6. Several screws and nuts.V. A PC with PRINT port, COM port and USB port.

1. PRINT port is used to download programming file to AT89S52.2. COM port is used to communicate between PC and the car.3. USB is used to supply main power.

VI. Software:1. OS: XP is much ideal.2. Development software:

i. Wavee6000: C51 language development.ii. ISP down: Used to download file to AT89S52.

iii. Serial transmission adaptor (Simplified Chinese tool): Transmit signal to the sub system to control the car.

Design of experiments:I. The design of microcontroller. (Figure 1)In this figure, we know that the original name is coming from a part of teacher’s project. L1 represent power indicator light on my PCB board, also L4, L3, L2 are replace by led1, led2, led3. In addition, led3 is green and also the moving indictor.Figure 1: The whole design for microcontroller

1. Typically use in quartz crytal oscillatorFigure 2: typical crystal oscillator installization

Notes: C1, C2 = 30 pF ± 10 pF for Crystals= 40 pF ± 10 pF for Ceramic Resonators

(Manual of ATMEL chips AT89C52)2. RST

Reset input. A high on this pin for two machine cycles while

P.4

Page 6: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

the oscillator is running resets the device. (Manual of ATMEL chips AT89C52) We place a polar capacitor 100 uF between VCC and RST. As the power supply connects to the sub-system, the capacitor will conduct to make RST in high. Then the chips will reset.

3. Typical operating circuit Clearly, the core chip is AT89S52. Other chips also plays an important role in this design. MAX232 is use to deal with the signal from PC to the core chip. The below is typical MAX232 chip operating circuit.

Figure 3: typical MAX232 operating circuitTable 1: Typical capacitor used in Figure 3

(+5V-Powered, Multichannel RS-232 Drivers/Receivers)

P.5

Page 7: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

Because the MAX232 we used is much compact than the manual one, the chip we used allows us using the nonpolar capacitors.

4. 74HC244Besides, the 74HC244 is used to work between PRINT ports to the chips AT89S52. We cannot observe 74HC244 on the PCB which is AT89S52 located. It hid in the joint between PC and 6 transmission lines. The 74HC244 connection and function table is on the below.

Figure 4: Connection diagram for 74HC244

(DM74LS244 Octal 3-STATE Buffer/Line Driver/Line Receiver)

Table 2: Function table for 74HC244

(DM74LS244 Octal 3-STATE Buffer/Line Driver/Line Receiver)

5. COMI only used three of the COM ports. #2 is used to receive data. #3 is used to transmit data. #5 is the system ground.

Figure 5: COM ports

P.6

Page 8: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

6. PRINTWe used 18 of the PRINT ports. #15 and #18~25 are connected to ground. #7 and #10 are connected together. #14 is used to control the #2 #3 #8 signal pass of not. #11 and #12 are receiver. They receive the signal form AT89S52 MISO (after 74HC244) and #9.Figure 6: PRINT port

II. Relays on model carTable 3: the specification of relays and led.

Relay1 Relay2(left) Relay3(right) Led1 Led2 Led3Stop 0 X X 1 1 1

Turn right 1 1 0 0 1 0Turn left 1 0 1 1 0 0Forward 1 1 1 0 0 0

Backward 1 0 0 1 1 0

Table 4: relays status & relays statusInput status Collector current in

a BJTVoltage at negative node of a relay

Relay status

High Increase Decrease OnLow Decrease Increase OffIf the input (outputs for microcontroller) is high, the collector current in the BJT will increase and makes the relay on.

Figure 7: the design of relays.

P.7

Page 9: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

1 2 3 4

A

B

C

D

4321

D

C

B

A Title

Number Revisio nSize

A4

Date: 24 -Aug -2 008 Sh eet of File: D:\isp.ddb Drawn By:

RELAY-2

RELAY-1

+-

+-

+

+--

RELAY-3

+

+--

S1C901 3

S2C901 3

S3C901 3

-

+ +

+

R1

5.1k o hms

R2

5.1k o hms

R3

5.1k o hms

1 2 3

1

2

3

R41k o hms

R51k o hms

R61k o hms

+

+

+

III. Software with C51Because I develop the system by C51 and the instructions is simple (only forward, backward, turn right and turn left), the only thing I can do is put the command list in the last of my reports. The difference between C and C51 in my project is only at the first few lines:

void input() {if (RI==1)//If RI is 1, it means receive success. Stop receive and clear RI to 0 {command=SBUF; RI=0; }}void output(unsigned char i) {SBUF=i; while (TI==0) { };//if TI is 1, it means output success. Stop output and clear to 0 TI=0;}void main() { TMOD=0x21; //T1:method 2; T0:method 1; TH1=0xf7; TL1=0xf7; //silicon osciliator:16MHz PCON=0x80; //SMOD=1 Transferring rate 9600Hz (actually it is nearly 9260Hz) * SCON=0x50; TR1=1; //Method 1:8 bits UART allow Transferring rate changing……………..}

P.8

Page 10: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

We must consider the transferring rate:

smod = 1 means transferring rate double.TH1 is the initial value in the register.12 means the relation between frequency of oscillator and frequency of machine.The method 1 of SCON will attribute 32 at denominator.The flow path of experiments:Mainly, it can be separate to three steps:Figure 8: Flow path

I. Constructing Hardware:

1. Microcontroller: (Figure 1)i. Design a schema.

ii. Use welder to connect all things to PCB:(1) Solder 89S52 and MAX232 chips, capacitors, resistors, led and

I/O port to the PCB board.(2) Weld 74HC244 chips and 7 resistors to the board on download

wire (6 lines output to PCB board).(3) Building series port cable by connecting 3 ports (No.2, 3, 5) from

COM ports to PCB board. 2. Model car: (Figure 7 & 9)

P.9

Page 11: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

i. According to the manual, build up a model car without battery box. (Figure 9)

ii. Construct relays in order to control motor to turn clockwise or counterclockwise. (Figure 7)

Figure 9: the model car without battery box.

II. Develop Software:1. Using Wavee6000 software and Compiler Keil C to develop a simple code.2. With ISPDOWN software, it can be easily to download programming

process via download wire to Microcontroller.III. Adaption:

1. From car’s representation, it can be tuned to proper one. For example, the motion turning right can be change to almost 90 degree turn.

2. Check the current, because the power is coming from USB. The system cannot get over 500 mA, otherwise PC mother board will be damaged.

3. Make sure that the programming process is done without mistake.

4 Results and Discussions

P.10

Page 12: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

We expect that after finished the microcontroller and the car, the specification is:1. I/O:

i. COM9 port: communicationii. PRINT port: download

iii. Model car: machines for representation2. Power supply:

i. USB 5VProgramming process, by using PC to input a HEX code:Table 5:Input a HEX code Meanings Output to PC00 Stop AA01 forward BB02 backward CC03 turn left DD04 turn right EE05 turn whole around E106 moving like Z way E207 moving like Y way E3others Null Null

Teacher suggested me to order a model car because it was hard to make a new car by myself. After few days, the car was sent to the library. At that day, I finished the car model at the night. (Figure 2)However, the process is not as good as we think. On August 4th, I have done the Microprocessor PCB at first time.

Figure 10: (The first PCB board)

P.11

Page 13: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

On August 5th, whatever we gave any signal, the output never deliver signal to PC. My teacher told me that the crystal oscillator was short. After that we change a new one without source crystal oscillator. Nevertheless, when we tested the system, the output was always wrong at the first bit. My teacher told me that the chip MAX232 was broken. The result is: Change PCB board to the one that my teacher was used. The day after 5th, teacher gave me the PCB board that he already adjusted.

Figure 11: (Adjusted PCB board form the old one teacher used)

P.12

Page 14: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

Figure 12: (The model car with relays)

On August 18th, I combine the microcontroller to the model car. For some safety

P.13

Page 15: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

reason I just use the transformer to be power supply in order not to burn the mother board in PC. (220V AC to 5V DC transformer)The critical thing happened. As I downloaded the process to microcontroller, it was failed. Finally, I knew that the reason is that the car would dissipate the energy when it’s downloading.On August 20th, my teacher advised me to make a DIP switch to avoid that thing. Even the downloading is fine; it still brought error to us. After the process is downloaded and then open the switch, the system wouldn’t output the value as inputting any none 00 values. The most important thing is that as the error occurs, the car is always rolling back. That means all relays are active. Until now, I deduce that relays on the car dissipate too much power to make Microcontroller unstable.Finally, teacher welded two capacitors (one is a polar capacitor, the other is nonpolar one) between VCC and GND and then it works. I think the capacitors can avoid the current spike as motors and relays turned on. Before I replace the power transformer with USB, I measured the current and voltage in the next table.

Table 6: Current MeasurementsDIP switch Status CurrentOff Car is stop Nearly 40mAOn One direction moving < 280mAOn Many direction moving < 380mA

Table 7: Output voltage MeasurementsDIP switch Output status VoltageOff high Nearly 5.00VOff low Nearly 0.32VOn high Nearly 4.25VOn low Nearly 0.30V

After all, it shows that we can replace the transformer to USB because of USB can supply 500mA current and 5V working environments.

5 Conclusions

Before I started to deal this project, I didn’t expect the car must add a switch to avoid downloading error. But, finally, the model car was done. It can be controlled by a computer (NOT a notebook) because it needs COM, PRINT ports and USB. For this

P.14

Page 16: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

reason, the only place I can test my system is the Robotic Institute. In this project, I designed only 3 cases that it can represent itself and I can modify it with a computer at any time.Besides, the reason why I cannot derive the accurate machine working time is that I develop the program with C51 not assemble language. Assemble language can let us know the exact time it costs.However, there was a little difference between my expectations and the final results. Nevertheless, I still satisfy with my project and I have used my knowledge in it. Even there were lots of things were solved by my teacher, I also learned a lot form constructing hardware to adaption.

Thanks

This is my first time to do an academic report. I have to thank professor Li first; he gave me a nice direction of experiment that made me have clear idea to do this job. Second, I have to thank teacher zhang. From idea to real product, zhang thought me a lot. Especially, the main design was done with teacher’s help. In a simple word, if teacher did not give me direction, I will be stuck in this project. I am really satisfied with building a simple hardware structure even though I did not accomplish my expectation that the system is stable. After all, I have to thank for my two advisors again. With their help, I finished my project and learned a lot.

Diagram and Graph

Table 8:TMOD(定时器模式控制寄存器)

7 6 5 4 3 2 1 0

GATE C/T M1 M0 GATE C/T M1 M0

T0 T1GATE: 门控位。当 GATE=1 时计数器受外部中断信号控制

            C/T : 计数器和定时器选择位。C/T=0 为定时器            M1M0: 操作方式控制位             M1M0     操作方式 功能 波特率             0 0      方式 0            13 位计数器 fos/12             0 1      方式 1            16 位计数器 changeable             1 0      方式 2            可以自动重新装载的 8 位计数器,(串行通讯) fos/64 or fos/32             1 1      方式 3            T0 分为 2 个独立的计数器、T1 停止计数。 changeable             注意:当单片机复位时 TMOD 各位都为 0。 

TCON(时间控制寄存器)7 6 5 4 3 2 1 0

TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0TF1:T1 溢出标志。当 T1 溢出时,有硬件置 1,可向 CPU 发出中断请求,CPU 响应中断后由硬件自动清 0。

P.15

Page 17: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

         TR1:启动 T1 标志。          IE1:外部中断 1 请求标志         IT1:外部中断触发方式,IT1=0 为电平触发方式,低电平有效。IT1=1 为边沿触发标志下降沿产生一个中断。

 T2CON(时间控制寄存器)

7 6 5 4 3 2 1 0

TF2 EXF2 RCLK TCLK EXEN2 RT2 C/T2 CP/RL2     

SCON(串口控制寄存器)7 6 5 4 3 2 1 0

SM0 SM1 SM2 REN TB8 RB8 TI RISM0 SM1    工作方式 功能说明

             0  0        0      移位寄存器方式(用于 IO 扩展)             0  1       1      8 位 UART 波特率可变              1  0        2      9 位 UART             1  1        3      9 位 UART

          REN:允许接收控制位。==1 允许接收,==0 禁止接收          TI : 发送中断,硬件置位,软件清 0          RI :接收中断,硬件置位,软件清 0

 PCON(串口控制寄存器)

7 6 5 4 3 2 1 0

SMOD              SMOD:SMOD=1 波特率加倍 

IE(中断允许寄存器)7 6 5 4 3 2 1 0

EA   ET2 ES ET1 EX1 ET0 EX0EA:总中断允许位 ==1 允许

             ES:串口中断允许位             ET1:T1 中断允许位

 IP(中断优先级寄存器)

7 6 5 4 3 2 1 0

    PT2 PS PT1 PX1 PT0 PX0

低----------------------------------->高Figure 13: Block diagram of AT89C52:

P.16

Page 18: my.nthu.edu.twmy.nthu.edu.tw/~exten/chinese/docs/winner_6/44.doc  · Web viewThe design of microcontroller. (Figure 1) In this figure, we know that the original name is coming from

ReferenceManual of ATMEL chips AT89C52.+5V-Powered, Multichannel RS-232 Drivers/ReceiversDM74LS244 Octal 3-STATE Buffer/Line Driver/Line Receiver单片机高级语言C51应用程序设计 徐爱钧 彭秀华编着寄存器.mht (given by teacher zhang)

P.17


Recommended