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

402066 tn vđk eng

33 0 0
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
Người hướng dẫn Division Of Electronics-Telecommunication
Trường học Ton Duc Thang University
Chuyên ngành Electrical-Electronics Engineering
Thể loại Laboratory Manual
Định dạng
Số trang 33
Dung lượng 781,3 KB
File đính kèm hydraulic pump 98 snapshot 1.zip (4 MB)

Nội dung

CDACDACIUDVHDBIAUVBNAXMV X CLXLCKALCSA;CSACSSCCJNALCDDDDDDDDDDDDDDDDDDDDDDDDĐNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN

Trang 1

TON DUC THANG UNIVERSITY

FACULTY OF ELECTRICAL-ELECTRONICS ENGINEERING

Trang 2

2

Unit 1 – Get familiar with the Proteus software

UNIT OBJECTIVE

 Students know how to use Proteus software to draw circuit

 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

Component Name

Pictures of components

The circuit diagram

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 icon P on interface

Terminals (Contains resources and Gnd)

Trang 4

4

The interface appears as follows when we choose:

Step 2: Get the parts and arranged in principle diagram:

Name of device

Name of components

Trang 5

Step 3: Connect wires

Step 4: For running the application circuit

Exercise 1: Insert the following circuit in Protues

To run the applicative circuit

Trang 6

6

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

instrumentation see the previous section)

Exercise 3: Draw microcontroller circuit as follows, Programming for leds Light up

RA0/AN0 2 RA1/AN1 3 RA2/AN2/VREF-/CVREF 4

RA4/T0CKI/C1OUT 6

RA5/AN4/SS/C2OUT 7

RE0/AN5/RD 8

RE1/AN6/WR 9

RE2/AN7/CS 10

OSC1/CLKIN 13

OSC2/CLKOUT 14

RC1/T1OSI/CCP2 16RC2/CCP1 17RC3/SCK/SCL 18

RD0/PSP0 19RD1/PSP1 20

RB7/PGD 40RB6/PGC 39RB5 38RB4 37RB3/PGM 36RB2 35RB1 34RB0/INT 33

RD7/PSP7 30RD6/PSP6 29RD5/PSP5 28RD4/PSP4 27RD3/PSP3 22RD2/PSP2 21

RC7/RX/DT 26RC6/TX/CK 25RC5/SDO 24RC4/SDI/SDA 23

RA3/AN3/VREF+

5

RC0/T1OSO/T1CKI 15

MCLR/Vpp/THV 1

Trang 7

// code for above circuit

case 0: output_c(0); break;

case 1: output_c(0b00000001); break;

case 2: output_c(0b00000011); break;

case 3: output_c(0b00000111); break;

case 4: output_c(0b00001111); break;

case 5: output_c(0b00011111); break;

case 6: output_c(0b00111111); break;

case 7: output_c(0b01111111); break;

case 8: output_c(0b11111111); break;

Trang 8

/* Define of PIN of IC74HC595 */

#define SHCP_PIN PIN_C0

#define DS_PIN PIN_C1

#define STCP_PIN PIN_C2

void IC_74hc595(int data)

Trang 10

10

Unit 2 – interface with 7-segment LED

UNIT OBJECTIVE

Students know how to:

 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

1) 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

2) Practice

Exercise 1: LED display is connected as follows, program to display the numbers from 00 to 99:

Trang 11

// Program for display from 00 to 99

int chuc,dv,i,z;

set_tris_d(0x00);

set_tris_b(0x00);

while(true) {

for (i=0; i< 100; i++) {

Exercise 2: The students Students connect the circuit as shown below, writing program number

65535

Trang 12

12

#include <7_seg.h>

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

#define sh PIN_B1 //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 unsigned char ma[10]={0x81,0xed,0xc2,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 so[2]=(value-so[1]*10000)/1000;//so ngan so[3]=(value-so[1]*10000-so[2]*1000)/100;

signed char i;

for(i=7;i>=0;i ) {

output_bit(Data,(da>>i)&0x01);

output_bit(sh,0);

output_bit(sh,1);

} }

//chuong trinh hien thi gia tri ra led 7 doan void display()

{ signed char i=0;

unsigned char temp;

for(i=0;i<6;i++) {

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

temp=((i%2)==0)? ma[so[i]]:ma1[so[i]]; //chon ma led 7 doan thich hop if(((i==1)||(i==3))&&(en==1)) temp&=0xf7; //hien dau cham ngan cach if(((i==2)||(i==4))&&(en==1)) temp&=0x7f; //hien dau cham ngan cach send_595(temp);

output_bit(st,0);

output_bit(st,1);

delay_ms(1);

Trang 13

send_595(0xff);

void main() {

signed char i;

// TODO: USER CODE!!

set_tris_b(0x00);

while(true) {

} }

Application exercises :

Exercise 3: Also the circuit above, write programs display numbers from 000000-99999

Exercise 4: With the circuit above, write programs display the even numbers from 000000-

99998

Trang 14

14

Unit 3 – Interface with matrix led

UNIT OBJECTIVE

Students know how to:

 Create a project in Proteus and experimental kit

 Write CCS program

 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

Trang 15

Exercise 2: Write a program that runs the string "LOP VIDIEUKHIEN" from right to left

Exercise 3: Write a program that runs the string "DH TON DUC THANG" from left to right

Trang 16

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

 Translation and programs loaded into the PIC microcontroller

 Write a program to Show LCD With CCS-C Language

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

c dp g f a

l6 l4 l2

data sh st

SH_CP 11 ST_CP 12 DS 14

MR 10 OE 13

U7

74LS595

Q0 15Q1 1Q2 2Q3 3Q4 4Q5 5Q6 6Q7 7Q7' 9

SH_CP 11 ST_CP 12 DS 14

MR 10 OE 13

U8

74LS595

RA0/AN0 2 RA1/AN1 3 RA2/AN2/VREF-/CVREF 4

RA4/T0CKI/C1OUT 6

RA5/AN4/SS/C2OUT 7

RE0/AN5/RD 8 RE1/AN6/WR 9 RE2/AN7/CS 10

OSC1/CLKIN 13 OSC2/CLKOUT 14

RC1/T1OSI/CCP2 16RC2/CCP1 17RC3/SCK/SCL 18

RD0/PSP0 19RD1/PSP1 20

RB7/PGD 40RB6/PGC 39RB5 38RB4 37RB3/PGM 36RB2 35RB1 34RB0/INT 33

RD7/PSP7 30RD6/PSP6 29RD5/PSP5 28RD4/PSP4 27RD3/PSP3 22RD2/PSP2 21

RC7/RX/DT 26RC6/TX/CK 25RC5/SDO 24RC4/SDI/SDA 23

RA3/AN3/VREF+

5

RC0/T1OSO/T1CKI 15MCLR/Vpp/THV

1

U9

PIC16F877A

VBAT 3 X1 1

X2 2

SCL 6 SDA 5 SOUT 7

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

#define sh PIN_B1 //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

Trang 17

unsigned char ma[10]={0x81,0xed,0xc2,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_Time(char *sec, char *min, char *hr)

{

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

so[1]=*hr & 0x0F; //so gio

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

so[3]=*min & 0x0F;

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

so[5]=*sec & 0x0F;

}

//chuong trinh dich du lieu ra 595

void send_595(unsigned char da)

signed char i=0;

unsigned char temp;

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

{

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

temp=((i%2)==0)? ma[so[i]]:ma1[so[i]]; //chon ma led 7 doan thich hop

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

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

send_595(temp);

output_bit(st,0);

output_bit(st,1);

delay_ms(1);

Trang 18

Exercise 2: Write the program read the date, month and year data from the DS1307 and then

display on the 7 segment Leds

Trang 19

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

Write a program to read date, month and year data from DS1307 and then display on LCD

Trang 20

 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

Trang 21

Exercise 3: Use of PIC ADC module to measure the temperature in the room, use the LCD to

display temperature value with LCD-mode of 8 bits as follows:

Trang 22

 Translation and programs loaded into the PIC microcontroller

 Interface with the keyboard

The structure of the keyboard is as follows:

Exercise 1: Write a program to retrieve data from a keypress and then displays the binary

value of the key press on the single LED

Trang 23

// Program for Exercise 1

// I/O KEY PAD 4x4

#define ROW1 PIN_D0

#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(!input(COL1)) return KEY_4X4[3-i][0];

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

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

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

}

Trang 26

 Write program with c language

 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

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:

 Translation and programs loaded into the PIC microcontroller

 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 RD0 = 0 play not DO, RE, MI

b RD1 = 0 play not RE, MI, FA

c RD2 = 0 play not MI, FA, SOL

d RD0 = RD1 = RD2 = 1 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

Trang 32

32

Unit 9 – To review all part from 1-8

Trang 33

REFERENCE

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

Microcontrollers Principles and applications, Newnes is an imprint of Elsevier

Hi-tech C, Nhà xuất bản Đại học Quốc gia TP.HCM

[3] Dogan lbrahim, 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

Ngày đăng: 09/05/2024, 00:44

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

TÀI LIỆU LIÊN QUAN

w