parallel port interfacing - 16f84


Closed Thread
Results 1 to 13 of 13
  1. #1
    Join Date
    Mar 2008
    Location
    Madhya Pradesh, India
    Posts
    9

    Default parallel port interfacing - 16f84

    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.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    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.
    Parallel port operation is well document throughout the Internet, literally millions of hits on a Google search as well as here.
    As far as using an 'F84, how many bits do you plan on transferring at a time?
    8 bits is going to be a bit difficult and still have enough pins left over to control....anything...
    How much other PIC programming have you done so far?

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    This might get you started on how to set it up.
    http://www.picbasic.co.uk/forum/showthread.php?t=218
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Mar 2008
    Location
    Madhya Pradesh, India
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Parallel port operation is well document throughout the Internet, literally millions of hits on a Google search as well as here.
    As far as using an 'F84, how many bits do you plan on transferring at a time?
    8 bits is going to be a bit difficult and still have enough pins left over to control....anything...
    How much other PIC programming have you done so far?
    I haven't used any other PIC.

    well, what I want to do is to store the incoming data from the parallel port into a variable. Now, let us suppose once the PORTA has been set to be input (trisa = %11111111), then how to read the value of all the pins in PORTA and store them in a variable?

    suppose if the incoming data is say "2" whose binary equivalent is 00000010, so now how to read this value on PORTA pins & store it in a variable?

    thanks

  5. #5
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    trisa = %11111111
    Variable var byte
    Variable = PORTA

    ... but that won't work on PORTA with 8-bit data. Read the datasheet.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by devil6600 View Post
    I haven't used any other PIC.[........suppose if the incoming data is say "2" whose binary equivalent is 00000010, so now how to read this value on PORTA pins & store it in a variable?
    At the risk of being wrong...'cause it's entirely possible...
    Before you go messing with a parallel port and blowing it up, I'd suggest you go for Mr. Blinky LED first, then throw a button or two into the mix, add an LCD, and so on.
    If you don't know how to assign a value from a port to a variable, then how do you expect to do any handshaking with a parallel port?

  7. #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

  8. #8
    Join Date
    Mar 2008
    Location
    Madhya Pradesh, India
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    Hello Sougata,

    thanks for the information. I'll try it out.

    Basically i want to do a PC->PIC communication.

    what i want is that:
    1) i'll send some string to the PIC via the Parallel port, ex: "mov-1-5"
    2) PIC will interpret it as "move motor number 1 for 5 seconds"
    3) Now PIC will make a particular pin high for 5 seconds.

    thanks.
    Last edited by devil6600; - 21st March 2008 at 15:45.

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


    Did you find this post helpful? Yes | No

    Default Any specific reason for using the parallel port

    Hi,

    I am just curious why the parallel port. Serial communication is easy to handle on the PC side. But for Parallel you need to have your own soft. I once developed a software for the parallel port using some third party dll. It was in VB.net 2005.

    All I can say is it is 100% possible as I have done it and one of my printer port interceptor is still in production.
    Regards

    Sougata

  10. #10
    Join Date
    Mar 2008
    Location
    Madhya Pradesh, India
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    Hi!

    actually i am already using my serial port for some other purposes. Now the only communication port i am left with is the parallel port.

    What ever you told I applied that and now I am able to read a character through the parallel port. I want to read a string (as i told earlier), so I require your help.

    Thanks

  11. #11
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Have you thought about a USB to SERIAL converter?
    Dave
    Always wear safety glasses while programming.

  12. #12
    Join Date
    Mar 2008
    Location
    Madhya Pradesh, India
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    yes...

    i will be working on DOS..

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


    Did you find this post helpful? Yes | No

    Default Great to know that

    Hi,

    I started my programming with Qbasic in DOS. And my first implementation of electronics was a Voltmeter using ADC0808 and Qbasic.
    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