Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need a little bit of help. I'm working on a project where I have to create a scheme which controls 16 Leds using LPT Port. For that, I'm using two 74HC595 shift registers. I also need to write a program in C/C++ which lights up a certain led, makes all ON and/or all OFF. I'm in need of help regarding how to connect the parts together.
Thanks!

What I have tried:

I've tried connecting the two registers parallel but it seems it doesn't get any information from the LPT port itself.
Posted
Updated 13-Sep-23 4:05am
v2

How old is this machine you're on? I haven't seen a PC come with a parallel port in maybe 20 years.

If the port in on the motherboard, you would be much better off NOT using it. You can easily blow up the port if you're not sure of what you're doing and replacing a motherboard that old is impossible today.

A better solution would be to use a microcontroller, like an Arduino or Pi or similar, or something like a Phidgets controller. If you blow these up on accident, they are far easier to replace, and much easier to write code for.

It won't stop at LEDs. Once you get that working, you'll try to move up to motors and such, which give you a much greater chance of destroying your parallel port.

There are plenty of articles on the web that show how to do this. All you have to do is Google for "c code parallel port led".
 
Share this answer
 
v2
Comments
Dave Kreskowiak 31-Aug-23 16:24pm    
It's possible, but there are no standards for this. You would have to come up with your own signaling scheme and write the software on both ends to get something like that to work. Face it, parallel ports are just not used today.

An Arduino has a serial interface you could use to make things much easier, but I suspect you have to use the parallel port for some assignment that's ridiculously outdated.

As it is, to connect shift registers to the parallel port, you would need 4 or 5 pins on the port (I think!). From memory, power and ground, and another pair for data and clock. You'll also need a kernel driver to get around the hardware abstraction layer in Windows and be very careful in what you're wiring up where. Granted, you're only dealing with 5 volts, but if you drop a screwdriver on the project and short stuff out, you can do damage.

There are articles here on CodeProject for LED's and parallel ports, but I seriously doubt you'll find anything on shift registers on a parallel port. But if you can get an LED wired up and code to work with it, you've just built the starting point for signaling a shift register.
 
Share this answer
 
Comments
Member 15974219 31-Aug-23 12:24pm    
Awesome article, but it's based on Arduino usage, how to connect an lpt port to that and is it even possible?
Richard MacCutchan 31-Aug-23 12:44pm    
You need to read the technical documentation for the device that you want to connect. That is the only way to find the answer to the question. As far as I can see these items are chips that need to connet to a board. So I cannot see how you would connect them direct to any port.
This article I/O Ports Programming (Parallel port) Reading / Writing + Surveillance System using VB.NET[^] provides a LOT of information. The code is in VB.net but it should be adaptable and I'm fairly certain you can find similar code in C++. If nothing else, the article is very good reference on the parallel port and how it works.

For your purposes, it appears the port has eight output data bits along with four other outputs - the C bits. It seems to me you could hook the data bits to both of the shift registers and then use the C bits to select which chip latches the data inputs. This means it would be a form of multiplexing. I have never done this kind of thing but hopefully that is enough information to get you started.
 
Share this answer
 
Comments
merano99 1-Sep-23 9:08am    
If you multiplex the 8 output data bits with the 4 outputs of the control register two simple latches would be enough. The circumstance with the shift register seems to be due to the the special task. Technically this does not seem to make sense for the time being.

With two simple latches, like e.g. 74HCT573, the programming would be much easier.
Nowadays using a parallel port under Windows (or DOS) is rather uncommon. Since Win95 the registers are no longer easy to use. On newer operating systems you need either root privileges or a kernel driver.
First a few questions that would be important:

1. With which operating system should the port be accessed?
2. Under which base address is the port to be accessed (in former times: 0x278, 0x378 or 0x3BC).

About the circuit:

A parallel port consists of 3 registers. The 8-bit data register usually only works as an output with 8 data lines. So you can connect here up to 8 ICs of the type 74HCT595 each with pin 14.
Then there are status and control registers with 4 pins each.
To the outputs 15,1,2,3,4,5,6,7 you can connect LEDs with one resistor each. Better would be an additional MOS-FET.
The two clock inputs for storage and shift must each be connected with a line to a pin of the control register. The reset pins (10) must be connected to +5V, the enable pins (13) to ground, later they can also be controlled with one bit each of the control register.

If you have more than one 74HCT595, you can connect all reset, enable and clock lines to one pin each.

The 74HCT595 needs its own power supply with 5V at pin 16 and GND at pin 8. Here you could tap the voltage at a USB port, because the parallel port usually offers nothing here.

There are also old projects that you can use as a base with C++. E.G.
Parallel Port Pin Control Library (PaPiC)
https://www.codeproject.com/Articles/19402/Parallel-Port-Pin-Control-Library-PaPiC

I would also like to point out that using an HC type will probably require many pull-up resistors.I would therefore rather use an HCT.
 
Share this answer
 
v2
Programming for serial port is cumbersome, so be aware that you need to have patience and better understand the basics to find some solution.

Beside the Microsoft documentation you may find a bunch of resources. I would recommend that you read and try out the code of the article Serial library for C++.

Most common problems are that you need some threading (with wait times of 100 ms) and you really must take care to close all opened ports or get errors. Sometime only helps a reboot.
 
Share this answer
 
Comments
Richard MacCutchan 1-Sep-23 4:53am    
OP wants to use the parallel port.
I want to delete my question
@Sandeep-MewaraWatch
 
Share this answer
 
Comments
Richard MacCutchan 10-Sep-23 7:32am    
Feel free, no one is stopping you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900