free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes :: Forums :: Project Development :: Project Help
 
<< Previous thread | Next thread >>
interfacing dotmatrix parallel port printer to 8051
Go to page  [1] 2
Moderators: Ajay, Junied , abbas1707, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph
Author Post
irish
Tue May 27 2008, 06:54AM
 User Offline
Registered Member #8091
Joined: Tue May 27 2008, 06:41AM

Posts: 7
Thanked 0 times in 0 posts
i want to interface microcontroller to dotmatrix printer, actually the project is to pass to printer the data for printing in run time through keyboard but in the initial phase i just want to print the data that i have provided in the asm code. here are my schematics and code but its not working. i dont know whether there is a problem in circuitry or the code.
plz help



CODE:
;;;;;CODE;;;;
busy     bit P1.5
strobe   bit P1.4
portData equ P2  
;
        org 0h
start: 
        call word_Welcome ; to print ' Welcome To '
        call enter        ; new line feed       
        call word_Lab     ; to print ' Computer Laboratory '
        call enter        ; new line feed
        ;
quit:   sjmp Quit         ; Hang Forever until reset pressed
;
;===========================================================
;This subroutine is used to print single character
;trough Port Data
;before printing a character,a busy signal must be detected
;till a low logic received, than a strobe ( --__-- ) pulse
;must be generate to starts printing a character.
;==========================================================
Printchar:
        mov portData,A
        jb busy,$
        setb strobe
        clr strobe
        acall delay
        Setb strobe
        acall delay
        ret
;
delay:  mov R7,#2
del1:   mov R6,#20
        DJNZ R6,$
        DJNZ R7,del1
        ret
;===========================================================
;This subroutine is used to print a text ' Welcome To'
;this subroutine will print character by character till '$'
;character is detected, when this character is detected then
;It's indicated that a text has finished
;===========================================================
word_welcome:
        mov DPTR,#Text_welcome
lagi1:  clr A
        movc A,@A+DPTR
        cjne A,#'$',Print1
        sjmp Out1
Print1: call Printchar
        inc dptr
        call delay
        sjmp lagi1
Out1:   ret                    
;
;================================================================
;This subroutine is used to print a text ' Computer Laboratorium'
;this subroutine will print character by character till '$'
;character is detected, when this character is detected then
;It's indicated that a text has finished
;===============================================================
word_Lab:
        mov DPTR,#Text_lab
lagi2:  clr A
        movc A,@A+DPTR
        cjne A,#'$',Print2
        sjmp Out2
Print2: call Printchar
        inc dptr
        call delay
        sjmp lagi2
Out2:   ret                    
;
Enter:
        mov A,#0dh
        call printchar
        call delay
        mov A,#0ah
        call printchar
        ret
;
Text_welcome:   DB ' Welcome To           $'
Text_Lab:       DB ' Computer Laboratory  $'
 

end
printer_circuitry.pdf



[ Edited Thu May 29 2008, 12:42AM ]
Back to top


pdi33
Tue May 27 2008, 02:53PM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 770
Thanked 185 times in 180 posts
hi irish,
ur code looks perfect to me.
the problem is with ur hardware connection of the busy line . just connect the p1.5 line to the pin 11 of the printer connector instead of the pin 16 . pin 16 is the reset (as u have already mentioned and is the input to the printer to reset it and will always remain high unless ur microcontroller pulls it low. So ur uC goes into a infinite loop at the instructin
jb busy,$
as it doesnot receive a low from the printer.

* inspired to develop,developing to inspire *
Back to top


pdi33
Tue May 27 2008, 03:13PM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 770
Thanked 185 times in 180 posts
and yes, do not forget to turn off the printer while progrmming through ISP as the MOSI pin of programmer (an active output pin of the programmer) is shorted to the busy pin (also an active output pin from the printer) which is not recommended. Still better shift the busy line to some other port pin say p1.3 to avoid conflict.
good luck .
If u still do not get any output by connecting the busy line from pin11, try removing it from the printer connector and shorting the busy line of ur uC to ground. Do not worry about data overflow as the modern parallel printers have an inbuilt buffer memory which can store ur small testing data atleast at present for checking purpose.

* inspired to develop,developing to inspire *
Back to top


irish
Wed May 28 2008, 01:15AM
 User Offline
Registered Member #8091
Joined: Tue May 27 2008, 06:41AM

Posts: 7
Thanked 0 times in 0 posts
actually i m not using the programmer part of the circuit. i have got a burner so i just dump my code onto the uc.
even after making the changes the printer is not printing anything.

also i want to connect a 20x2 lcd with the microcontroller so that what ever is going to the printer for printing also goes to lcd and is visible there.
plz if some 1 can help in this regard, where to connect the lcd in the circuitry and changes in the code.
Back to top


pdi33
Wed May 28 2008, 04:23AM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 770
Thanked 185 times in 180 posts
remove the instruction
jb busy,$
and try again.
as for the LCD interfacing check the download and tutorial section with the following link
http://www.8051projects.net/downloads5.html
for the code and the link
http://www.8051projects.net/lcd-interfacing/
for the working principle. U can easily extend it with minor modifications once u understand the logic.

* inspired to develop,developing to inspire *
Back to top


irish
Wed May 28 2008, 08:41PM
 User Offline
Registered Member #8091
Joined: Tue May 27 2008, 06:41AM

Posts: 7
Thanked 0 times in 0 posts
at last the printer has started printing. thanks to pdi33. now there is a slight problem and that is the printer prints each character twice. example: " wweellccoommee ttoo llaabb"
guidance required in this regard.
Back to top


pdi33
Wed May 28 2008, 10:46PM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 770
Thanked 185 times in 180 posts
Hi irish,
well, at last it did work .
Now, about ur secondary problem about double character printing, still ur code seems alright. Try adding pullup resistors to the port1. i.e. a 9 pin resistor SIP (8+1) having a value of 4.7k or 10kohms with the common tied to VCC and the 8 other lines to the port pins. This is because the internal pullups of 89s51 are only weakly pulled high and if the strobe pin of the printer is consuming a little larger current, then ur high level of uC @ port pin may not be reaching the volatge level +5. this may be causing the problem.Just try it out and give feedback.
Sill i feel u have to modify ur hardware as the software looks good to me.

* inspired to develop,developing to inspire *
Back to top


irish
Thu May 29 2008, 06:08AM
 User Offline
Registered Member #8091
Joined: Tue May 27 2008, 06:41AM

Posts: 7
Thanked 0 times in 0 posts
you mean to tie pull up resistors to the pins of the microcontroller(those 8 pins which i have used for sending data) or to the 8 data lines of the parallel port???and by the common did you mean the common ground of the entire circuit??
also if this 9 pin pull up resistor is not available than what should i do. is there any alternate way???????????
Back to top


sashijoseph
Thu May 29 2008, 03:33PM

 User Online
Registered Member #5870
Joined: Mon Feb 04 2008, 06:26PM

Posts: 647
Thanked 137 times in 130 posts
irish wrote ...

you mean to tie pull up resistors to the pins of the microcontroller(those 8 pins which i have used for sending data)

Yes.....

and by the common did you mean the common ground of the entire circuit??
also if this 9 pin pull up resistor is not available than what should i do. is there any alternate way???????????

Common is the common pin of the SIP resistor.One end of each of the 8 resistors is tied together to form the 9th common pin.This should be tied to Vcc.
If a sip resistor is unavailable,use 8 normal resistors between Vcc and port pins.

btw which change got it working?...... removing the busy check or grounding P1.5 ?

Let there be music........
Back to top


irish
Thu May 29 2008, 08:32PM
 User Offline
Registered Member #8091
Joined: Tue May 27 2008, 06:41AM

Posts: 7
Thanked 0 times in 0 posts
no i havnt removed the busy check, i just connected pin 1.5 to pin 11 instead of pin 16. at first it was not working bcz there were some wires short circuited. whn i removed those short circuits it started printing but with that double character prob. i ll check this resistor method to see if it works.
Back to top


Go to page  [1] 2  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems