Pelatihan Dasar Mikrokontroller
14-15 April 2007
Surabaya
Rp. 300.000
ย
Microcontroller Kits
Programmer and Target 89s51
Rp.100.000
(USD $10)
Simple Mikrokontroller 89s51 Trainer
Rp, 350.000
(USD $35)
Standart
Mikrokontroller 89s51 Trainer
Rp. 650.000
(USD $65)
Super Mikrokontroller Trainer 89s51
Rp.1.250.000
(USD $125)
ย
ย
Printing temperature data to dot matrix printer
( Download Assembly File : printer.zip )
( How to build an easy and cheap Programmer 89Sxxx, only $1 )
( More about LPT Pin Configuration )
;===================================================; Print out temperature data each 60 second; By: Triwiyanto; www.mytutorialcafe.com;===================================================;1.Use temperature sensor LM35 and
; convert analog to digital by ADC0804;2.Time generate by Timer 0 : mode timer 16 bit,
; with interrupt every0.05 second second;3.Each 60 second data will print out to Dot matrix printer. ; dispclr equ 00000001b funcset equ 00111000b entrmod equ 00000110b dispon equ 00001100b cursor equ 00001110b blink equ 00001101b shiftL equ 00011011b counter20 equ 60h counter60 equ 61h minute equ 62h hour equ 63h minute1 equ 64h minute10 equ 65h hour1 equ 66h hour10 equ 67h second equ 68h second1 equ 69h second10 equ 6ah tenP equ 6bh oneP equ 6ch fractionP equ 6dh ten equ 6eh one equ 6fh fraction equ 50h DataADC equ 51h Strobe bit p1.4 Busy bit p1.5 ; org 0h sjmp begin org 0bh ljmp timerinterrupt ;begin: acall init_lcd acall write1 acall write2start: jb p1.6, startbounch: jnb p1.6, bounch acall Init_timer acall init_lcd acall write3 acall write4 next: acall adc acall convert acall scandisplay sjmp next ;shift2left: mov R7,#37 again: mov R1,#shiftL acall write_inst acall delay djnz R7,again ; mov R6,#21again1: mov R1,#shiftL acall write_inst acall delay djnz R6,again1 ret ;Printout: call comment_report call enter call comment_hour call PrintDatahour call enter call comment_Temp call PrintData_Temp call enter call comment_name call enter call enter call enter ret ;printchar: mov P3,A jb busy,$ setb strobe clr strobe acall delay Setb strobe acall delay ret ;delay: mov R7,#100del1: mov R6,#100 DJNZ R6,$ DJNZ R7,del1 ret ;
comment_report: mov dptr,#Text_reportagainH: clr A movc a,@a+dptr cjne a,#'$',PrintH sjmp OutHPrintH: call Printchar inc dptr call delay sjmp againHOutH: ret ;comment_hour: mov dptr,#Text_houragainJ: clr A movc a,@a+dptr cjne a,#'$',PrintJ sjmp OutJPrintJ: call Printchar inc dptr call delay sjmp againJOutJ: ret ;comment_Temp: mov dptr,#Text_TempagainT: clr A movc a,@a+dptr cjne a,#'$',PrintT sjmp OutT PrintT: call printchar inc dptr call delay sjmp againTOutT: ret ;comment_name: mov dptr,#Text_nameagainN: clr A movc a,@a+dptr cjne a,#'$',PrintN sjmp OutNPrintN: call printchar inc dptr call delay sjmp againNOutN: ret ;PrintData_Temp: mov A,tenP call printchar mov A,oneP call printchar call printcoma mov A,fractionP call printchar call space call printpoint call printCelcius ret ;ADC: mov A,P2 mov dataadc,a ret ;convert: mov R1,#0c5h acall write_inst mov a,dataadc mov dptr,#data_ten movc a,@a+dptr MOV R5,A Add A,#30h mov R1,A acall write_data ; mov R1,#0c6h acall write_inst mov a,dataadc mov dptr,#data_one movc a,@a+dptr mov r6,a add A,#30h mov R1,A acall write_data ; mov R1,#0c8h acall write_inst mov a,dataadc mov dptr,#data_fraction movc a,@a+dptr mov r7,a add A,#30h mov R1,A acall write_data ret ;Print_DataConvert: call Convert_HextoBCD mov A,ten add A,#30h call printchar mov A,one add A,#30h call printchar mov A,fraction add A,#30h call printchar ret ;;This Subrutine is to convert hex to BCD ; for example: 125 will be convert to; hundred = 1, ten =2, one = 5; to get print out to printer dot matrixConvert_HextoBCD: mov B,#100 ; DIV AB ; mov ten,A ; mov A,B ; mov B,#10 ; DIV AB mov one,A mov fraction,B ret ;PrintDatahour: mov A,hour10 call printchar mov A,hour1 call Printchar call Printdoubledot mov A,minute10 call printchar mov A,minute1 call printchar call Printdoubledot mov A,second10 call printchar mov A,second1 call printchar call space call space ret ;scandisplay: mov r1,#08bh acall write_inst mov r1,second1 acall write_data ; mov r1,#08ah acall write_inst mov r1,second10 acall write_data ; mov r1,#088h acall write_inst mov r1,minute1 acall write_data ; mov r1,#087h acall write_inst mov r1,minute10 acall write_data ; mov r1,#085h acall write_inst mov r1,hour1 acall write_data ; mov r1,#084h acall write_inst mov r1,hour10 acall write_data sjmp scandisplay ;timerinterrupt: mov tl0,#0b0h mov th0,#03ch djnz counter20,endinterrupt mov counter20,#20 acall hourdigital endinterrupt: reti ;hourdigital: inc second mov a,#60 cjne a,second,updatedisplay acall printout mov second,#0 ;oneminute: inc minute mov A,#60 cjne A,minute,updatedisplay mov minute,#0 ;onehour: inc hour mov A,#24 cjne A,hour,updatedisplay mov hour,#0 ;updatedisplay: mov a,second mov b,#10 div ab mov second1,b mov second10,a mov a,minute mov b,#10 div ab mov minute1,b mov minute10,a mov a,hour mov b,#10 div ab mov hour1,b mov hour10,a ; mov a,#30h add a,second1 mov second1,a ; mov a,#30h add a,second10 mov second10,a ; mov a,#30h add a,minute1 mov minute1,a ; mov a,#30h add a,minute10 mov minute10,a ; mov a,#30h add a,hour1 mov hour1,a ; mov a,#30h add a,hour10 mov hour10,a ret ;Init_Timer: mov counter20,#20 mov counter60,#60 mov second,#0 mov hour,#0 mov minute,#0 mov TMOD,#00000001b mov tl0,#0b0h mov th0,#03ch setb ET0 setb EA setb TR0 ret ;Write_inst: Clr P1.0 Mov P0,R1 Setb P1.1 Acall delay Clr P1.1 ret ;Write_data: Setb P1.0 Mov P0,R1 Setb P1.1 Acall delay Clr p1.1 ret ;Printchar1: mov P2,A jb busy,$ setb strobe clr strobe acall delay setb strobe ret ;init_lcd: mov r1,#dispclr acall write_inst mov r1,#funcset acall write_inst mov r1,#dispon acall write_inst mov r1,#entrmod acall write_inst ret ;Enter: mov A,#0dh call printchar call delay mov A,#0ah call printchar ret ;Space: mov A,#' ' call printchar ret ;Printdoubledot: mov A,#':' call printchar ret ;Printcoma: mov A,#',' call printchar ret ;Printpoint: mov A,#'o' call printchar ret ;PrintCelcius: mov A,#'C' call printchar ret ;write1: mov dptr,#comment1 mov R3,#37 mov R1,#80h acall write_inst tls1: clr a movc a,@a+dptr mov R1,A inc dptr acall write_data djnz R3,tls1 ret ;write2: mov dptr,#comment2 mov R3,#21 mov R1,#0c0h acall write_inst tls2: clr a movc a,@a+dptr mov R1,A inc dptr acall write_data djnz R3,tls2 ret ;write3: mov dptr,#comment3 mov R3,#11 mov R1,#0c0h acall write_inst tls3: clr a movc a,@a+dptr mov R1,A inc dptr acall write_data djnz R3,tls3 ret ;write4: mov dptr,#comment4 mov r3,#4 mov r1,#080h acall write_inst tls4: clr a movc a,@a+dptr mov r1,a inc dptr acall write_data djnz r3,tls4 ;write5: mov dptr,#comment5 mov r3,#4 mov r1,#086h acall write_inst tls5: clr a movc a,@a+dptr mov r1,a inc dptr acall write_data djnz r3,tls5 ret ;comment1: db' Print Temp Data'comment2: db' Labcomputer 'comment3: db'Temp: , oC'comment4: db'hour:'comment5: db': :'Text_report: db'Temperature Measurement$'Text_hour: db'hour:$'Text_Temp: db'Temp:$'Text_name: db'Labcomputer$' ;data_ten: DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1 DB 1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2 DB 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3 DB 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 DB 3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 DB 4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5 DB 5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 DB 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7 DB 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 DB 7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 DB 8,8,8,8,8,8,8,8,8,8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,3,3,2,1,0,9,9,8,7,6,5,5,4 DB 3,2,2,1,0,9,8,8,7,6,5,5,4,3,2,1,1,0,9,8 DB 7,7,6,5,4,4,3,2,1,0,0,9,8,7,6,6,5,4,3,3 DB 2,1,0,9,9,8,7,6,5,5,4,3,2,2,1,0 end
Comments, questions and discussion about this topic
ย
ย
Programmer
ISP 89s
Free Software
a. Edsim 51
b. MIDE-51
c. ATMEL ISP
Lesson 1:
Architecture
1.1.Memory
1.2.SFR
1.3.Addressing
1.4.Instruction Set
1.5.Assignment
Lesson 2:
Input Output
2.1.LED
2.2.Swicht
2.3.7 Segmen
2.4.LCD Character
2.5.ADC
2.6.DAC
2.7.Motor Stepper
2.8.Keypad
2.9.Assignment
Lesson 3:
Timer Counter
3.1.Basic
3.2.Mode 0
3.3.Mode 1
3.4.Mode 2
3.5.Mode 3
3.5.Assignment
Lesson 4:
Serial Comm.
4.1.Basic
4.2.LED
4.3.Rotate LED
4.2 ADC
4.3.LCD
4.4.Assignment
Lesson 5:
Interuption
5.1.Basic
5.2.Timer
5.2.External
5.3.Assignment