+ Reply to Thread
Page 1 of 3 1 2 ... LastLast
Results 1 to 10 of 27

PC Tutorial: Parallel Port Interfacing Techniques - Part 2

This is a discussion on PC Tutorial: Parallel Port Interfacing Techniques - Part 2 within the Computer Science & IT Engineering forums, part of the CE : Technical Discussions category; PC Parallel Port Interfacing Techniques - Part 2 16 October 2006 v1.0 Elec: 3.5 Comp: 2 Mech: 0 Introduction In ...

  1. #1
    CE - Editor xheavenlyx's Avatar
    Join Date
    2nd October 2006
    I'm a crazy: Electronics Hacker & engineer

    Location
    Dubai, UAE
    Posts
    617

    Lightbulb Tutorial: Parallel Port Interfacing Techniques - Part 2

    PC Parallel Port Interfacing Techniques - Part 2

    16 October 2006 v1.0
    Elec: 3.5 Comp: 2 Mech: 0

    Introduction


    In this tutorial we will flash a LED (Light Emitting Diode) connected to your printer port socket. Reading the first part is recommended to get a general idea what you are upto.

    Connections


    To connect a LED to your port first you have to know what it looks like. Here are the two most common connectors that you can have.

    D-Type 25 Pin connector



    Pin Layout:


    36 Pin Parallel Centronics



    Pin Layout:




    The LED


    Shown below is a very common LED found anywhere from toys to computers. To connect, insert the positive pin into Pin number 2 of your port. And the negative to any ground of your connector. Pin 19 is an easy reach.



    In the above image the longer pin is positive and the shorter one is negative (ground). If you have a LED looking like the left one then you have to find out yourself which one is +/- by connecting it to a battery. I would recommend a 220ohm or 470ohm resistor in series with the LED. Mine worked without the resistor but I cannot promise anyone!

    Ok after you finish this setup, it is now time to test the light! See if you have really found out the correct address by following the first tutorial then download this( http://www.beyondlogic.org/pardebug/spp20.zip)** to have real-time control over your Port to test the light.



    Open the executable; you should see a blue screen with port addresses, pins and their description. Choose the address where you have connected the port wire, and click on PIN 2 (Data 0) (there should be a cross on it now). Look at the LED, it must glow. If it does not glow then try different Port addresses, LPT1, LPT2 etc.

    Programming the Parallel Port in C, C++, VB or Java with ‘Windows the great XP’ is not easy since it does not allow you to access the Ports directly. All hardware is virtualised. I somehow have a feeling programming in VB is easier. Very basic LED flashing is also easy through Assembly Language. I’ll look into this problem and post a tutorial soon.

    Dont hesitate, ask me if you have trouble with anything!!! Writing a tutorial from scratch is not easy so please don’t mind random grammar mistakes


    Some Useful links:

    http://www.epanorama.net/circuits/parallel_output.html : A very detailed look into the Port basics and programming.

    http://www.logix4u.net/ : Excellent for explanation on Win NT/XP programming.

    ** http://www.beyondlogic.org/pardebug/pdebug.htm : The Debug program to test your parallel port with LED

  2. #2
    Good Administrator The_Big_K's Avatar
    Join Date
    26th November 2005
    I'm a crazy: Electrical engineer

    Location
    Terra-Firma
    Posts
    12,889

    Thumbs up Re: PC Tutorial: Parallel Port Interfacing Techniques - Part 2

    Great going, xHx !

    We plan to make pdfs of the articles posted on CE forums and make them available for download* along with the poster's name/id & contact. How about coming up with your own diagrams?

    -The Big K-
    p.s: * You can already guess we have many things planned along with the forum restructure . Keep doing a good job, buddy!
    Founder & Administrator | CrazyEngineers® | admin{@}crazyengineers{dawt}com
    About CE | Small Talk | Official Blog 'VoiCE' | Advertise On CE
    The Big K's SuperBlogmt | Join CE! | Guide: How to post on CE

  3. #3
    CE - Editor xheavenlyx's Avatar
    Join Date
    2nd October 2006
    I'm a crazy: Electronics Hacker & engineer

    Location
    Dubai, UAE
    Posts
    617

    Lightbulb Re: PC Tutorial: Parallel Port Interfacing Techniques - Part 2

    Hay thanks biggie. I too am waiting for the upgrades and some attachment ability (if you all think its necessary). In this perticular tutorial, I took the working pics in the bottom, the remaining are from the linked sites, and since this was a very simple one it did not need any major schematics. I will be writing a tutorial to program in some languge for more flexability, there I will be clear on the diagrams and pictures.

    I want ot see people get interested by reading this tutorial, and I hope I did that. If there can be any changes to improve it, anyones views are welcome!


    This is just the begining, we can in a year come up with a full home automation tutorial and project :P

    Thanks a lot again!
    Have fun.

  4. #4
    Good Administrator The_Big_K's Avatar
    Join Date
    26th November 2005
    I'm a crazy: Electrical engineer

    Location
    Terra-Firma
    Posts
    12,889

    Thumbs up Re: PC Tutorial: Parallel Port Interfacing Techniques - Part 2

    No promises for the attachment ability. The simpler way is to create an id on http://www.flickr.com ( a Yahoo! Company ) and link the images. Let the Flickr guys do the image hosting job

    This is just the begining, we can in a year come up with a full home automation tutorial and project :P
    Of course! To speed up the process, our editor-in-chief & I had chat with professors from Engineering colleges & they seemed to be excited about us. Probably we'll see better stuff in coming days.

    Good initiative, xHx! Very soon, we will try to have a separate place for all the good articles

    -The Big K-
    Founder & Administrator | CrazyEngineers® | admin{@}crazyengineers{dawt}com
    About CE | Small Talk | Official Blog 'VoiCE' | Advertise On CE
    The Big K's SuperBlogmt | Join CE! | Guide: How to post on CE

  5. #5
    CEan - Techie
    Join Date
    16th November 2006
    I'm a crazy: Computer Science engineer

    Posts
    136

    Default Re: PC Tutorial: Parallel Port Interfacing Techniques - Part 2

    i hope you guys don't mind me digging up this post from under the grave, but i was just going throught it and kinda got curious.

    xheavenly, would it be possible for you to make a brief post about USB interfacing if you have time. Just the basics!!. Just like your posts about parallel port interfacing would be good.

    And probably turning on and off an LED using the USB port if thats possible

    and few other things...

    is there any difference between RS232, the parallel port and the serial port?
    Enjoy Life; Everyday above ground is a good day.
    - Anon

  6. #6
    CE - Editor xheavenlyx's Avatar
    Join Date
    2nd October 2006
    I'm a crazy: Electronics Hacker & engineer

    Location
    Dubai, UAE
    Posts
    617

    Default Re: PC Tutorial: Parallel Port Interfacing Techniques - Part 2

    Quote Originally Posted by desijays View Post
    xheavenly, would it be possible for you to make a brief post about USB interfacing if you have time. Just the basics!!. Just like your posts about parallel port interfacing would be good.

    And probably turning on and off an LED using the USB port if thats possible

    and few other things...

    is there any difference between RS232, the parallel port and the serial port?
    1. Well USB is a bit difficult than parallel or serial port. And moreover I have never worked with USB. Their programming in windows is shrouded with crappy permition protocols and timing stuff. wind00z XP/Vista is really the worst OS you can possibly use for programing hardware. Its all virtualised.

    Take a look at http://beyondlogic.org/

    2.
    • RS-232 IS serial port. It has serial communication. That is, one bit after the other in a single wire. It has a longer range too, meaning long wires will not spoil the data. Check this page for Interfacing the Serial Port - Parts 1 and 2.
    • The USB is a whole other story. Here is line from Beyondlogic.org.
    • " Starting out new with USB can be quite daunting. With the USB 2.0 specification at 650 pages one could easily be put off just by the sheer size of the standard. This is only the beginning of a long list of associated standards for USB. There are USB Class Standards such as the HID Class Specification which details the common operation of devices (keyboards, mice etc) falling under the HID (Human Interface Devices) Class - only another 97 pages. If you are designing a USB Host, then you have three Host Controller Interface Standards to choose from. None of these are detailed in the USB 2.0 Spec."
    • Anyway, if you really want to interface a USB device then have a look at the whole tutorial here USB in a Nutshell - Making sense of the USB standard
    Good luck! Its really fun though
    Contact: varun(att)crazyengineers(d0t)com.
    CLICK HERE FOR MY BLOG ( Robotics, Hardware Hacks and more)

  7. #7
    CEan - Techie
    Join Date
    16th November 2006
    I'm a crazy: Computer Science engineer

    Posts
    136

    Default Re: PC Tutorial: Parallel Port Interfacing Techniques - Part 2

    Link galore. Thanks for the links mate. I'll look into it.

    Hopefully I should get something going
    Enjoy Life; Everyday above ground is a good day.
    - Anon

  8. #8
    ash
    ash is offline
    Moderator ash's Avatar
    Join Date
    12th July 2007
    I'm a crazy: Comms & Network engineer

    Location
    Cyberjaya, Malaysia
    Posts
    4,205

    Default Re: PC Tutorial: Parallel Port Interfacing Techniques - Part 2

    Oh, I should have posted here instead of Part 1 of the tutorial great work xheavenlyx. Wanted to ask a few things:
    • Is it safe to use the parallel port on a laptop for experiments? eg, lighting LED's.
    • Can you give a sample C code on how to light an LED on and off? Like what libraries to use. At least I know it involves a while loop and a delay I believe you have to use this file called Inpout32.dll, am I right?
    • Can you also recommend me a program to use for Assembly Language programming?
    Thanks a lot dude!

  9. #9
    CE - Editor xheavenlyx's Avatar
    Join Date
    2nd October 2006
    I'm a crazy: Electronics Hacker & engineer

    Location
    Dubai, UAE
    Posts
    617

    Default Re: PC Tutorial: Parallel Port Interfacing Techniques - Part 2

    1. No its not really safe to directly use a parallel port of a laptop. You CAN try an LED or something, because the grounds can sink that much current from your port. However, dont try using motors directly. The links I have provided are VERY useful and have many circuits too. Read carefully. I cant cover that here, since everyone has their own design.

    2. god, forgive me, I actually stoped programming PP in newer PC because of that problem (Windooz..input32.dll) but if you search you will get a LOT of info. As for the libraries, not many are needed. In win98 it were stdio.h and io.h or something. Very few. Here is a sample code I wrote 4 years ago (!):

    Code:
    //This example code shows how to switch a LED on/off in Visual C++.
    //We use two variables N and L explained below.
    
    //I am assuming you have some knowledge in C++. Instruction to connect the LED is given in the Tutorial.
    
    
    
    
    
    
    
    #include <iostream.h>  //The most important include to display data on screen.
    #include <conio.h>     //Include for outp and inp functions for the printer port.
    #include <windows.h>   //For _sleep functions for our time delay.
    
    #define addr 0x3BC     //IMPORTANT: Normaly 378 is the most common address, 
                           //if not then insert your address instead of 378
    
    int main()
    {
        int freq; //Variable for time delay.
        int L; //Variable for counts of Blinking LED.
        
        
        cout<<"\t\t XheavenlyX WELCOMES YOU!!! \n\n";         //How can I forget this ^_^
        
        cout<<"How many times to blink?? Enter 0 to exit: ";  //Ask user how many times to blink the LED
        cin>>L;                                               //And exit if zero is entered.  
        
        
        if (L==0)
        {
            cout<<endl<<"Exiting application..."<<endl;             //Code to exit if L = 0. 
            for (int i=0;i<=5;i++) {_sleep(500);}                   //A lame pause before exit!
            exit(0);
        }
    
        cout<<"Frequency (in mS): ";                          //Ask user to enter the frequency at which the LED will blink.
        cin>>freq;                                              //Store that value in freq.
        
    //Bottom code is the Juice! This will blink your LED the number of times you put in L.
    //The speed of blinks will depend on freq. As an example if you entered 500milliseconds. The LED
    //will blink twice every second since 500ms is half of 1000ms (1000millisecondss = 1sec)
    
        for (int i=1;i<=L;i++)        //The loop. L times to blink.
        {
        _outp(addr,1);             //Output is high in the first 'Data bit' of port(*), i.e Pin number 2 where you have connected the LED.
        _sleep(freq);               //freq mS delay between the high and low of LED.
        _outp(addr,0);             //Output is low now
        _sleep(freq);               //Pause again between the high,
        }
        return 0;                   //main returns nothing to you. ^_^
    }                               // For an indepth look at 
    
    
    //(*)NOTE: There are some simple calculations to turn on/off the other PINs on the printer port.
    
    //links
    // http://msdn2.microsoft.com/en-us/library/733szwah.aspx _outp, _inp etc.
    
    How input32.dll works:
    http://logix4u.net/Parallel_Port/How...ll_works_.html

    3. Assembly learning is somewhat a smooth ride if you stick with it. And it can be very very helpful. Speacially if you are planning on optimizing complex control instructions. It can be for Microcontrollers or your PP programming. That too, youll have to search...
    Contact: varun(att)crazyengineers(d0t)com.
    CLICK HERE FOR MY BLOG ( Robotics, Hardware Hacks and more)

  10. #10
    ash
    ash is offline
    Moderator ash's Avatar
    Join Date
    12th July 2007
    I'm a crazy: Comms & Network engineer

    Location
    Cyberjaya, Malaysia
    Posts
    4,205

    Default Re: PC Tutorial: Parallel Port Interfacing Techniques - Part 2

    Cool, thanks a lot bro! Really appreciate it

+ Reply to Thread
Page 1 of 3 1 2 ... LastLast

Posting Permissions

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