Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 31st, 2005, 6:20 AM   #1
bigbondfan
Newbie
 
bigbondfan's Avatar
 
Join Date: May 2005
Posts: 7
Rep Power: 0 bigbondfan is on a distinguished road
[solved] Controlling the parallel port

is there any way to control the parallel port in VB6. I need to individualy change what each pin does (on, off or earth).

Last edited by bigbondfan; Jun 1st, 2005 at 7:56 AM. Reason: solved
bigbondfan is offline   Reply With Quote
Old May 31st, 2005, 7:35 AM   #2
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
http://computer.howstuffworks.com/parallel-port2.htm that will help in figuring out what it does, and i doubt you could have that much control over the port using VB6 you will have to go down to assembly i think.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein
Berto is offline   Reply With Quote
Old May 31st, 2005, 12:27 PM   #3
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
You can communicate with any device as in any other language:
Open "COM1" For Output As #1
Print #1, "AT" 'Sends the Attention directive
Close #1
Though this requires intimate knowledge of the PnP device protocol, etc. Theoretically you can therefore do this:
Open "LPT1" For Output As #1
Print #1, Chr(65) 'Sends the letter A
Close #1
Sending A would set the port to 65 which in binary is 01000001 so it should set pins 1 and 7 high and the others to low. However, in practice, the drivers may impose an abstraction layer, and handle the start, stop and parity bits at a lower level: you'll just have to experiment! (This is more or less a total guess: this is what happened in gwbasic, but there are probably die hard 1970s enthusiasts that'll gut me for saying this).

However, parallel ports only have a shared earth "pin" (the metal cladding): the rest can only be "on" or "off": if you're seeking to connect to an external circuit, you should buy a purpose built device as used in schools: directly connecting the motherboard to a 9v battery would destroy it.

If you are using a serial device such as a modem or the serial port, VB wraps this functionality in the MSCOMM object:
' Use COM1
MSComm1.CommPort = 1
' 2400 baud, no parity, 8 data bits, 1 stop bit
MSComm1.Settings = "19200,N,8,1"
MSComm1.DTREnable = False
MSComm1.PortOpen = True
and LPT1 should work, though you'd be best to check the MSDN archives. Again, if you set the communication settings correctly (no parity, no stop bits) you should be able to control each pin individually.

Last edited by Rory; Jun 1st, 2005 at 2:09 AM.
Rory is offline   Reply With Quote
Old Jun 1st, 2005, 7:55 AM   #4
bigbondfan
Newbie
 
bigbondfan's Avatar
 
Join Date: May 2005
Posts: 7
Rep Power: 0 bigbondfan is on a distinguished road
Thanks, I will continue to experiment with VB. I do have the whole of Visual Studio, I've just never programmed in any other language before.

Last edited by bigbondfan; Jun 1st, 2005 at 8:50 AM.
bigbondfan is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:15 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC