parallel port interfacing - 16f84


Results 1 to 13 of 13

Threaded View

  1. #7
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Thumbs up

    Quote Originally Posted by devil6600 View Post
    hello all,

    I want to read some data from the parallel port of my PC, the data would be in the from of strings. After some research I came to know that parallel port sends data bitwise (set of 8 bits). Now I do not know how to read each bit. Would it require the use of buffer IC's?
    I don't know how to do it. Any help is solicited.

    My target uC is 16f84

    Thanks.
    Hi,

    Forgive me for not understanding your requirement (actually not reading in details other posts) properly. So I would try to cover both PC --> PIC and PIC --> PC (within my limited knowledge though)

    Please note that PC parallel ports have evolved (and possibily dead by this time) from the SPP to Bi-Dir to ECP/EPP. To keep everything simple and under the scope of a 16F PIC and PBP you should use the SPP (Standard Parallel Port) mode. This can be set from your PC's BIOS.
    In a SPP the data from the PC is presented at a time to the 8bit wide dataout pins. That's why it is called a parallel port. Handshaking is done through Strobe/Busy signals on the port. Since it was basically made to drive printers it also takes inputs in the form of Online (detects whether a printer is connected and ready to accept data), PaperOut (detects the printer is out of paper and stop sending data prompting user) and Error. There are other bits also.
    When the port is in online mode without any errors (easy to hardwire so that the PC side software finds it okay to send the data) the data is first presented on the port itself folllowed by a strobe signal. You need to detect (thorugh interrupt to make sure that a byte is not lost) this strobe signal to detect a fresh new valid data to initiate your read/process routine. You should then pull-down the busy line to indicate that your PIC is busy to prevent any further data flow from the PC. When you finish reading the byte then you should release your busy signal and send an acknowledge pulse through the acknowledge pin. (In newer BIOSes I have found that the PC doesn't care for the ack signal rather dumps another byte when you release strobe) . And it goes on like this. If you are short on a 8bit wide port then you may map any bit to any discrete pin.
    For example
    Code:
    Data_byte var byte ' byte read from the PC
    
    Busy var portb.7
    busy = 0
    TRISB.7 = 0
    
    ; parallel read
    read_data:
    busy           =   1         ' put a busy on the pc port till grabbed
    Data_byte   =  PORTD   ' PC parallel port data connected here
    busy = 0                     ' data grabbed end busy
    
    ; discrete read
    busy = 1
    data_byte.0 = porta.0
    data_byte.1 = porta.1
    ...
    ...
    ...
    data_byte.6  = portc.4
    data_byte.7  = portc.5
    
    busy = 0
    So it is important to grab the strobe signal. The signal is about 0.5uS wide. You can use a inverter pulse stretcher with its ouput ored to the PIC busy out pin to rule out any missing pulse or working at low Fosc

    Thus grabbing (reading from the PC is easy to accomplish). I have done in on a PIC18F452 @ 40Mhz but then it intercepts data going to printer and parses on the fly.

    For storing sequential data you can use an array.

    However to send a byte from the pic to the PC under SPP mode is bit tricky. You need to send them in nibbles (only 4/5 pins work as input) and assemble it into a byte in your PC side soft. You definately need handshaking though through the strobe or the data port itself.

    If you could elaborate me with some more details stating practical usage I would try to cooperate.
    Last edited by sougata; - 21st March 2008 at 06:56. Reason: typos
    Regards

    Sougata

Similar Threads

  1. port config.
    By tamertokgoz in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th July 2008, 12:25
  2. interfacing to the pc serial port
    By kelangfei in forum General
    Replies: 4
    Last Post: - 7th October 2007, 22:35
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. parallel port multi pic programmer?
    By SuB-ZeRo in forum Schematics
    Replies: 8
    Last Post: - 25th June 2005, 10:20
  5. STATUS re-curtain W
    By zugvogel1 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th February 2005, 15:21

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts