Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need help for wireless printer using infra red

Status
Not open for further replies.

kfwpw

Newbie level 1
Joined
Jul 20, 2007
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,312
need help to analysing my project. i make a wireless printer through infra red using AT89S51.

this is the program:

a. Take the data from the PC and send it through infra red

$MOD51
ROM equ 0000H

kodepapererror equ 01H
kodepaperready equ 02H

stb equ P3.2
Busy equ P3.3
ack equ P3.4
pe equ P3.5

org ROM ; reset vektor
Ajmp Mulai
org ROM + 3H ; vektor interrupt eksternal 0

reti
org ROM + 0bH ; vektor interrupt timer 0

reti
org ROM + 13H ; vektor interrupt eksternal 1

reti
org ROM + 1bH ; vektor interrupt timer 1

reti
org ROM + 23H ; vektor interrupt serial
ajmp serial_int
reti

serial_int: ; serial interrupt service routine
; feedback
clr es ; matikan interupsi serial
push psw ; simpan pointer di stack
;
acall data_serial_masuk ; aktifkan penerimaan
;
cjne a, #kodepapererror, bukanpapererror ; periksa data
setb pe ; set paper error


tunggu_ready:
acall data_serial_masuk
cjne a, #kodepaperready, tunggu_ready

bukanpapererror:
clr busy ;
clr ack ; memberikan acknowledge sekejap ke PC
nop ; jeda sekejap
setb ack ; stop acknowledge
pop psw ; keluarkan pointer dari stack
setb es ; aktifkan kembali interupsi serial
reti

data_serial_masuk:
jnb ri, $ ; tunggu flag interupsi penerimaan
mov a, sbuf ; ambil data serial
clr ri ;
ret

Mulai:
acall initial
mov p1, #ffH ; port 1 sebagai input
setb stb ; belum ada strobe
clr busy ; printer tidak sibuk
clr pe ; tidak ada paper error
setb ack ; belum ada acknowledge
setb ea ;
setb es ; aktifkan interupsi serial

loop:
jb stb, $ ; tunggu sinyal strobe dari PC
mov a, p1 ; ambil data paralel dari port 1
setb busy ;
nop ; jeda sebentar
acall data_keluar ; kirim data ke port serial
clr ack ;
clr busy ;
nop ;
setb ack ;
ajmp loop ;


initial:
mov pcon, #00H
mov scon, #50H ; mode 1 & aktifkan penerimaan
mov tcon, #40H ; timer 1 on, timer 0 off
mov tmod, #20H ; timer 1 mode 2, timer 0 mode 0
mov th1, #d0H ; generate 600 baudrate
ret

data_keluar:
clr es ; matikan interupsi serial
clr ti
mov sbuf, a ;
jnb ti, $ ; tunggu interupsi flag pengiriman
clr ti
setb es ; aktifkan kembali interupsi serial
ret

END




b. Sending data to the printer

$MOD51
ROM EQU 2000H

KodePaperError EQU 01H
KodePaperReady EQU 02H

Busy Bit INT1
STB Bit INT0
PE Bit T0
ACK Bit T1

Buffer EQU 50H

Org ROM ;Reset Vector
Ajmp Start ;
Org ROM+3H ;External Interrupt 0 Vector
Reti ;
Org ROM+0BH ;Timer 0 Interrupt Vector
Reti ;
Org ROM+13H ;External Interrupt 1 Vector
Reti ;
Org ROM+1BH ;Timer 1 Interrupt Vector
Reti ;
Org ROM+23H ;Serial Interrupt Vector
Ajmp Serial_Interrupt
Start:
Mov DPTR,#3000H
Acall Init_Serial ;Inisial Serial Port
; Setb EA ;Enable Serial Interrupt
; Setb ES ;
Mov P1,#0FFH ;Set Port 1 sebagai input data printer
Setb STB ;Set STB sebagai input
Clr Busy ;Printer sedang tidak sibuk
Clr PE ;Tidak ada Paper Error
Setb ACK ;Acknowledge high
Clr ES
Loop:
Clr Busy
Jb STB,* ;Tunggu Sinyal Strobe dari PC
Setb Busy
Mov A,P1 ;Ambil data Parallel dari P1
Acall Serial_Out ;Kirim ke Serial Port
Ajmp Loop ;

Init_Serial:
MOV SCON,#52H ; Mode 1 Ren
MOV TMOD,#20H ; T0 Mode 2, T1 Mode 2
MOV TH1,#0FDH ; 600 Baudrate
MOV TCON,#040H ; T1 On, T0 Off
MOV PCON,#00H ;
Clr RI ; Hapus Flag Receive
Clr TI ; Hapus Flag Transmit
RET

Serial_Out:
Clr ES ;Matikan Serial Interrupt
CLR TI
MOV SBUF,A
JNB TI,*
Clr TI
Setb ES ;Aktifkan kembali Serial Interrupt
RET

Serial_In:
CLR RI
JNB RI,*
MOV A,SBUF
Clr RI
RET


Serial_Interrupt:
Clr ES
Push PSW
Mov A,SBUF ;Ambil Data Serial
Cjne A,#KodePaperError,BukanPaperError
Setb PE ;Set Paper Error, PC menunggu

TungguReady:
Acall Serial_In
Cjne A,#KodePaperReady,TungguReady
Clr PE
BukanPaperError:
Pop PSW
Setb ES
Reti

END


Thank you for your help.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top