1. Trang chủ
  2. » Luận Văn - Báo Cáo

Microcontrollers Laboratory Manual Edited By Division Of Electronics-Telecommunication Thí Nghiệm Vi Điều Khiển.pdf

33 0 0
Tài liệu được quét OCR, nội dung có thể không chính xác
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Get familiar with the Proteus software
Trường học Ton Duc Thang University
Chuyên ngành Microcontrollers
Thể loại Laboratory Manual
Định dạng
Số trang 33
Dung lượng 3,62 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

UNIT OBJECTIVE ¥ Students know how to use Proteus software to draw circuit Y To use to simulate the circuit, microcontroller circuits as PIC16F877A 1 Summary Protues is a program that si

Trang 1

TON DUC THANG UNIVERSITY

FACULTY OF ELECTRICAL-ELECTRONICS ENGINEERING

DIVISION OF ELECTRONICS-TELECOMMUNICATIONS

DAI HOC TON ĐỨC THẮNG

TON DUC THANG UNIVERSITY

Microcontrollers Laboratory

Manual

Edited by Division of Electronics-Telecommunication

(Internal only)

Trang 2

Unit 1 — Get familiar with the Proteus software

UNIT OBJECTIVE

¥ Students know how to use Proteus software to draw circuit

Y To use to simulate the circuit, microcontroller circuits as PIC16F877A

1) Summary

Protues is a program that simulates the power circuit applications, electronic we do not need

to insert the circuit but can still know how they work

In this experiments, we will introduce this software and applicative exercises for PIC16F877A 2) Proteus software

Interface screen

S5 UNTITLH) - ISIS Professional

File View Edit Tools Design Graph Source Debug Library Template System Help

OCW Gh | Ga ||Grz:|+\4aaaqa Ty ®

® Z8 W8 ñ

Trang 3

3) The steps for creating simulation circuit run in Protues

Step 1: Get in Protues components

Method 1: Press the P button on the keyboard

Method 2: Press icoyf P on interface

File Wow Edt Tools Ossqn Ggth Source Debug Lorary Template Symem Heb

) 2H OM | aR A: |+/4RAQa Oe) x mm Dae & te?

Trang 4

The interface appears as follows when we choose:

Match Whole Words?

Show only parts with models?

File View Edit Tools Design Graph Source Debug Library Template System Help

Om dim| am +/+QQQa8|//9C|xXmE &

Trang 5

Step 3: Connect wires

isis UNTITLED - ISIS Professional

File wew Edit Tools Design Graph Source Debug Library Template System Help

D c7 ki | @i tá | œ © || Bl] + | + AAAS! De| ow! || & at # > [2 | 8 75 | Ba ee ts

Trang 6

Exercise 2: Change the variable resistor R3, use the oscilloscopes to measure waves (Get in the instrumentation see the previous section

ES UNTITLED - ISIS Professional (Änimating)

3] REOANSIRD © RCI TIOsVeCRe 7%

_ Ta—| REL/ANGWR 19 Í RE2/ANr/0S RG3/SOK/SOL ROZICCPI

: THDLR/Vpp/THV RO4/SDUSDA RCS/TX/CK RG5/SDO |)

R©z/RX/DT |2 RD0/PsPo | J3

Biển Lộ i Rogers | 2

Trang 7

// code for above circuit

case 0: output_c(0); break;

case 1: output_c(Ob00000001); break; case 2: output_c(Ob0000001 1); break; case 3: output_c(Ob00000111); break; case 4: output_c(Ob00001111); break; case 5: output_c(Ob00011111); break; case 6: output_c(Ob00111111); break; case 7: output_c(Ob01111111); break; case 8: output_c(Ob11111111); break; default: break;

}

delay_ms(300);

}

Trang 8

Exercise 4: Draw the microcontroller circuit, Programming for leds Light as follows:

Roarsr2 [Z1 Rosrsrs Z2 122 ROBIPSPS ROTIPSP7 -—=2 PICIGFSTTA

/* Define of PIN of IC74HC595 */

#define SHCP_PIN PIN CO

?define DS_ PIN PIN C1

#define STCP_PIN PIN C2

void IC_74hc595(int data)

Trang 10

Unit 2 = interface with 7-segment LED

UNIT OBJECTIVE

Students know how to:

SANK

1)

Create a project in Proteus

Students know how to use Proteus software to draw circuit

To use to simulate IN/OUT on microcontroller as PIC6F877A

Implement circuit on experimental kit

Related Knowledge

The control registers entry port

- Each port has three registers control main activities:

- The bit in the TRIS register: set foot respectively input (logic 1) or output (logic 0)

- The bit in the PORT registers: Read vacuum level from the corresponding logic

- The bit in the register LAT: write logic levels corresponding to the foot

Trang 11

// Program for display from 00 to 99

#include<16f877.h>

#fuses HS,NOWDT,NOPROTECT

#use delay(clock=4000000) // define crystal = 4MHz

Const char MA7D[10]=(0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x1 0}; void main()

Trang 12

#include <7 seg.h>

#define Data PIN BO //dinh nghĩa chan du lieu cho 595

#definesh PIN BI //dinh nghĩa chan SH cho 595

#define st PIN B2 /idinh nghĩa chan ST cho 595

//ma led 7 doan co dau cham nam o tren

unsigned char ma[10]={0x81 ,Oxed,Oxc2,0xc8,0xac,0x98,0x90,0xcd,0x80,0x88}; //ma led 7 doan co dau cham nam o duoi

unsigned char ma1[10]={0x18,0x7b,0x2c,0x29,0x4b,0x89,0x88,0x3b,0x08,0x09}; //mang chua cac so can hien thi len led 7 doan

unsigned char so[6]={0,1,2,3,4,5};

unsigned char sec, min1, hr,luu;

int1 en; //bien giup cho hieu ung chop tat dau :

//chuong trinh tach lay so de hien thi

void Transform_Number(int16 value)

{

so[1]=value/10000; //so hang van

//chuong trinh dich du lieu ra 595

void send_595(unsigned char da)

signed char i=0;

unsigned char temp;

Trang 14

Unit 3 — Interface with matrix led

UNIT OBJECTIVE

Students know how to:

Y Create a project in Proteus and experimental kit

¥ Write CCS program

¥Y Translation and load program into the PIC microcontroller

¥ Run and debug programs

Exercise 1: Students draw the circuit as shown below, write the program run string "MATRIX

8x16"

Q0

Qi Q2 Q4 Q8

Trang 16

Unit 4 — Interface with the LCD, LED

UNIT OBJECTIVE

Students know how to:

¥ Create a project about LCD, LED in Proteus and experimental kit

¥Y Translation and programs loaded into the PIC microcontroller

v¥ Write a program to Show LCD With CCS-C Language

Exercise 1:The students connect the circuit schematic as follows, it include DS1307, IC 74HC595

Write program to display hour, minute, second

#define Data PIN_BO //dinh nghia chan du lieu cho 595

#define sh PIN BI //dinh nghia chan SH cho 595

#define st PIN_B2 //dinh nghia chan ST cho 595

//ma led 7 doan co dau cham nam o tren

16

Trang 17

unsigned char ma[10]={0x81,0xed,0xc2,0xc8,0xac,0x98,0x90,0xcd,0x80,0x88 };

/fma led 7 doan co dau cham nam o duoi

unsigned char mal[10]={0x18,0x7b,0x2c,0x29,0x4b,0x89,0x88,0x3b,0x08,0x09 } ;

/mang chua cac so can hien thi len led 7 doan

unsigned char so[6]={0,1,2,3,4,5};

unsigned char sec, min1, hr,luu;

intl en; //bien giup cho hieu ung chop tat dau :

//chuong trinh tach lay so de hien thi

void Transform_Time(char *sec, char *min, char *hr)

{

so[0]=(*hr & 0x30) >> 4; //so chục gio

so[1]=*hr & OxOF; /Iso gio

so[2]=(*min & OxFQ) >> 4;//so chuc phut

so[3]J=*min & OxOF;

so[4]=(*sec & 0x70) >> 4;

so[5]=*sec & OxOF;

}

//chuong trinh dich du lieu ra 595

void send_595(unsigned char da)

signed char i=0;

unsigned char temp;

for=0;1<6;i++)

{

send_595(~(1<<(i+1)));

temp=((i%2)==0)? ma[so[i]]:mal[so[il]: //chon ma led 7 doan thích hop

if(==1)||ú==3))&&(en==L)) temp&=0xf7; /hien dau cham ngan cach

if((G==2)||(G==4))& & (en==1)) temp&=0x7f; /fhien dau cham ngan cach

Trang 19

Exercise 3: The students connect the scheme of circuit interface with LCD as follows:

ñ/AM5/ED- JANA EC1/T1OScC©P2 TP - RC2/CCP1|—LE - - - - ¬ cg 8

2/ANTICS Rc3/scl2scL | LÊ - - - - :.e®-

— RO4/GDUSDAA =“ :

LiwepEl RCSrTsgeLc —=z RC7/RS2DT|2E cà Ko R2 Ra RS

Coe LED phat -

Trang 20

Unit 5 — Interface with the ADC

UNIT OBJECTIVE

Students know how to:

Create a project in CCS

Translation and programs loaded into the PIC microcontroller

Survey operations A-D conversion blocks

Survey the operation control registers of block A-D conversion

Write a program to read the voltage value interface with ADC

VOUT —Ra:⁄^A: 2 RADIANO RB3/PGM |8 RB4 +

i RAVAN2VREF-ICVREF nes poe

RD1/PSP1 F>—————————

R02/PSP2 Sh RO3PSP3 |_—££

RD4'PSP4 |—S+

RDGIP: ae RDTIPSPT

Trang 21

ROSIPSPS ẤT RD7IPSP7 PIC1BF87TA

KTEXT>

Trang 22

Unit 6 — Interface with the keyboard

UNIT OBJECTIVE

Students know how to:

¥ Create a project in CCS

¥Y Translation and programs loaded into the PIC microcontroller

¥ Interface with the keyboard

The structure of the keyboard is as follows:

Trang 23

// Program for Exercise 1

#define ROW1 PIN_DO

#define ROW2 PIN_D1

#define ROW3 PIN D2

#define ROW4 PIN_D3

#define COL1 PIN D4

#define COL2 PIN D5

#define COL3 PIN D6

#define COL4 PIN D7

Trang 24

if(linput(COL1)) return KEY_4X4[3-i][0];

if(linput(COL2)) return KEY_4X4[3-i][1];

if(linput(COL3)) return KEY_4X4[3-i][2];

if(linput(COL4)) return KEY_4X4[3-i][3];

Trang 26

Unit 7 — Control DC motor

UNIT OBJECTIVE

Students know how to:

¥ Create a project in CCS

¥ Write program with c language

¥Y Translation and programs loaded into the PIC microcontroller

¥ Use module PWM in practical application

Exercise 1: The students connect the circuit as below figure, write program to control the DC motor:

press the up button to accelerate

Press the dw button to slow down

Press stop button to stop

Trang 28

Applicative Exercises:

Exercise 2: Write a DC motor control program in forward and reverse direction

Exercise 3: Write a Step motor control program in forward and reverse direction

Exercise 4: Connect the circuit as shown below, write the DC motor control program in combination with the keyboard and LCD screen

Trang 29

Unit 8 — Interface Buzzer

UNIT OBJECTIVE

Students know how to:

¥Y Translation and programs loaded into the PIC microcontroller

v¥ Write programs in speakers sound

The circuit diagram connected to speaker:

Exercise 1: The students connect the circuit according to the below circuit diagram to write

a music player with the following rules:

a RDO=0 play not DO, RE, MI

b RDI =0 play not RE, MI, FA

c RD2=0 play not MI, FA, SOL

d RDO =RDI1 = RD2 = | silent speaker

#include <16f877A.h>

#fuses NOWDT,PUT,HS,NOPROTECT,NOLVP

#use delay(clock=16000000) // defind crystal = 4MHz

#define option_1 PIN_ d0

#define option_2 PIN_d1

#define option_3 PIN_d2

Trang 31

Exercise 2: Write a program to play DO, MI, SOL and repeat

Exercise 3: Write a program to play the alarm buzzer

Exercise 4: Use the keyboard and buzzer to write the program so that when a key is pressed,

a corresponding note will be played

31

Trang 32

Unit 9= To review all part from 1-8

32

Trang 33

REFERENCE [1] Tim Wilmshurst, [2007], Designing Embedded Systems with PIC

Microcontrollers Principles and applications, Newnes is an imprint of Elsevier

[2] Nguyễn Trường Thịnh, [2013], Vi điều khiên PIC16F và ngôn ngữ lập trình

Hi-tech C, Nha xuat ban Dai hoc Quéc gia TPHCM

[3] Dogan Ibrahim, Advanced PIC microcontroller projects in C, Newnes [4] Muhammad Ali Mazidi, Janice Gillispie Mazidi, Rolin D McKinla, The 8051 Microcontroller and Embedded Systems Using Assembly and C, 2e

33

Ngày đăng: 04/10/2024, 14:58

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm