Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Controlling Switches and Motors via Parallel Port

Status
Not open for further replies.
hi,
Attached pinout of port connector.

Pins 2 to 9 are output pins [ 8 in all] and ground [0v] pins 18 to 25.
These pins can be used to drive transistors/logic devices, they are TTL outputs, Low or High
[ 0v or +5v, you will find if you use your DC meter, that the voltage levels are around 0.4v and 4.5v]

As you want to drive outputs just consider these 8 pins at first, you can use the other input/output pins later on.

Use the VB program from yesterday to drive these 8 output lines. Sending a 0 or 255 will switch them all low/high.

To switch just 1 line, say pin2, send 0 or 1. to switch two lines,say 1 and 2 send 0 and 3. On address 378.

As you can now see its a 8 bit binary pattern, sending 0 and 15 [00001111] will switch pins 2,3,4,5 low/high. Got the idea?.

Buy a piece of copper strip board [PCB], the type that has a 0.1inch hole pattern and copper tracks on one side,
running the length of the PCB. Size say, 100mm *160mm.

A range of resistors, common values for LED's 330R. Transistor biasing 2K2, 4K7, 10K0. A range of capacitors, 1000nF, 0.1uF, 1uF.
Transistors about 4, general purpose 30V, 200mA, NPN and PNP types.
Motors, 2, small DC motors with a voltage rating to suit your DC power supply.

Signal diodes 4, 1N914 or equivalent, rectifier diodes 1N4001 100v 1A or equivalent.

When you have these parts, let me know, I'll post some circuits.

Eric
 
Last edited:
Hey!! thanx Eric!!!!!!!
Now i understand the idea behind the pins!!
thank you so much

but it take a lot of time for me to calculate and find out the data (converting from binary to numbers) !! otherwise i'm confident

ok ! i have a few PCBs already!

And bout the parts - i'l be getting them within another 4-5 hrs
 
Eric,
1 doubt- what does the pcb do?

why dont i just use a relay to activate a switch and work the motor using a 9V in a different circuit ?
is there any mistake?pls correct me if any!

Do u get a 5v relay? to get activated by the voltage from the parallel port ?
 
Last edited:
hi,

The pcb is the board that you will solder your components to.

If you get the 0.1inch hole pitch, copper stripboard, you will use a soldering iron to mount/solder the components to the board. [pcb]

Also the wires fron the end of your printer cable will be soldered to the board so that they connect with your components, OK?

Always make you circuits neat and tidy, dont cramp all the components in one corner of the board, it makes fault finding a nightmare.

I've already done a rough drawing for you.
You should try to do the 'layout' of the components yourself, Let me know.

Eric

EDIT: Dont connect a motor or relay to the port connector wires!. You could damage your PC's port.
ALWAYS use a transistor to drive a relay or motor
 
Last edited:
hi,
Added two parts to drawing.

One is an Input to your VB program, its Pin #13. 'select' line.[bit#4. 00010000] Address 379 when the VB prog reads.
PB#1 is a push button switch.

Be SURE to use the 6K8 and 10K0 resistor values, dont exceed +5v input to the port.

The second part is an optional +3v to +9v psu for other projects.

Eric
 
Last edited:
JobbinJP said:
hey man!! it Worked!! koool .

But doesn't it have enough ampere for a motor?

and how did you know that to activate pin# 2 it is port 378?
how can i know how to activate pin# 5 or any other pin?
If You have a Form in VB with a textbox to put the data that you want in the lpt output then just write a number .... for example...

If you want to turn on just the pin # D0 then just type 1 in the textbox.
if you want to turn on the pin # D1 type 2

Here is a table that may helps...

Text box nummer LPT Out(or binary)
1 = 10000000
2 = 01000000
3 = 1100000
4 = 00100000
5 = 10100000
And if you want the # D4 wich is the 5th pin then yust type:
16 = 00001000
 
hi gromikov,

Could you please explain this:

Here is a table that may helps...

Text box nummer LPT Out(or binary)
1 = 10000000
2 = 01000000
3 = 1100000
4 = 00100000
5 = 10100000
And if you want the # D4 wich is the 5th pin then yust type:
16 = 00001000


Eric
 
I made some projects working with VB and the LPT of the computer...
My VB Form contained a textbox where you could type a number (decimal) and that number was the output in the LPT in its (binary). That goes automatically, you don't need a special code for the conversion and that because of the machine language.

Due the explained above :

If you type the number 1 (for example), inside the textbox in your VB form, you will have in the LPT Output the binary code for "1" which is "10000000" or if you want to write it the other way "00000001"

The output pins are from
D0 to D7 or pin 2 to pin 9

**broken link removed**

You just need the right File.Dll for your Windows Version which can be inpout32.dll or IO.dll.
And A BV form with a button and a a textbox...... the button has to tell the form to write the data contained in the textbox to the LPT address.

I Hope this helps .
 
Last edited:
hi,

I have the inpout32.dll which I use for all my parallel port projects.

Ive tried the 'example' as you have posted it, it dosn't work for me!.

If you type the number 1 (for example), inside the textbox in your VB form, you will have in the LPT Output the binary code for "1" which is "10000000" or if you want to write it the other way "00000001"

What you are saying 11000000 is the same as 00000011, if its binary how can it select pin #2 and #3 in both cases?

As another forum member got this to work?

Eric
 
Last edited:
to convert binary to numerals - ( i learnt it from my computer text book )

the formula is sum of (0 or 1) * 2^(n-1) where n is the place of the digit from the right.

eg

01000000 = (0*2^7) + (1* 2^6) + (0*2^5) + (0*2^4) + ........ (0*2^0)
= 2^6
= 64
when you enter the data as 64 for port 378 then pin 8 will be activated.
 
Last edited:
Eric, my curiosity is killing me !

Won't the first circuit that u gave work?

How does the circuit u gave me work ?
why should i connect the circuit to pin#3 isn't just pin#2 and pin#25 enough?

what actually does the circuit do ?
why connect to pin#13 and
what is PB#1? is it a switch ?
 
Last edited:
hi john,
The circuit will work Ok for pin3 as planned.

Ive just drawn the pin2 part as the next step you are going to want to know as you learn.

Get pin3 working the transistor and LED, let me know, I can then explain pin2 function which can be used to drive a motor.

pin13 is for when you want your VB prog to read an external push button.

Does this explain it OK?

Eric

Remember: pins 2 thru 9 are ALL outputs you can call from your VB prog, use any pins from 2 to 9 that suits you.
Just call the correct pin from the VB prog. OK
 
Last edited:
john,

Yes right!.

Remember: pins 2 thru 9 are ALL outputs you can call from your VB prog, use any pins from 2 to 9 that suits you.
Just call the correct pin from the VB prog. OK

Use either pin 2 or 3, it dosn't matter, as long as you call the pin from VB.
If you call 0 and 255 you will switch ALL 8 output pins 2 to 9.

Eric

EDIT: If you prefer, email me on my Yahoo address, you should have that from my earlier email to you.
 
Last edited:
ok i get that ! what does the IC in the 2nd circuit for?

and what all do u have to connect in the first circuit ? the pin#3 and pin#25?
-( its taking me a while to find all the parts thats why i dint complete it yet!)

Do you have yahoo messenger account?
 
Last edited:
hi,

This thread is now being answered as a 'one on one' by email.

JobbinJB/Eric
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top