Aaron's Homepage Forum
Aaron's Homepage Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Projects/Inventions
 Computers/Electronics
 Need Programming Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pmlapl
Apprentece

6 Posts

Posted - May 07 2010 :  10:50:57 PM  Show Profile  Reply with Quote
Output to parallel
I used to use Qbasic alot but haven't for some years. I want to use Visual Basic to output data to a parallel port. Installed a PCI parallel card. Adresses are B800 - B807 and B000 - B007 listed in that order in the Resources window. I'm trying to use WIN95.DLL to address the port but I'm having difficulty in writing a program to do it since my lack of VB experience. I'm using VB 6.6 in Excel. Here's the code:

Private Declare Sub vbOut Lib "WIN95IO.DLL" (ByVal nPort As Integer, ByVal nData As Integer)
Private Sub cmdCompute_Click()
Dim intNum As Integer
intNum = txtOut
vbOut 46080, txtOut
End Sub

I get an overflow error 6 on the vbOut statment. If I use 888 for the port number, I get error 455 can't find entry point in WIN95.DLL since I can't read the DLL file, I don't know how to call it. Tried hex but got a sysntx error.

Could someone please help a neophyte?
Thanks much in advance.

codingplanet
Mad Scientist

United Kingdom
195 Posts

Posted - May 08 2010 :  05:33:23 AM  Show Profile  Visit codingplanet's Homepage  Reply with Quote
For a start, intNum & txtOut are null, so you aren't outputting any data to the port. Secondly, the address you are specifying is outside the addresses you listed in the first paragraph of your post. Third, to represent hex in VB, prefix the hex number with "&H".
Go to Top of Page

pmlapl
Apprentece

6 Posts

Posted - May 08 2010 :  2:58:48 PM  Show Profile  Reply with Quote
OK thanks. txtOut refers to a text box that I enter data so I don't believe it's null. Here are some changes to the code:

Private Declare Sub vbOut Lib "WIN95IO.DLL" (ByVal nPort As Integer, ByVal nData As Integer)
Private Declare Sub vbOutw Lib "WIN95IO.DLL" (ByVal nPort As Integer, ByVal nData As Integer)
Private Declare Function vbInp Lib "WIN95IO.DLL" (ByVal nPort As Integer) As Integer
Private Declare Function vbInpw Lib "WIN95IO.DLL" (ByVal nPort As Integer) As Integer


Private Sub cmdCompute_Click()

Dim intOut As Integer
intOut = txtOut.Text
vbOut &HB400, intOut
End Sub

Error statement now reads: "Can't find DLL entry point vbOut in WINIO95.DLL"
The declare statements were taken off a page called: Programming The Parallel Port In Visual Basic by Aaron on this site. So I'm confused why vbOut can't be called. Are the entry points labeled differently?

Thanks again for the help.
Go to Top of Page

Aaron Cake
Administrator

Canada
6718 Posts

Posted - May 09 2010 :  11:01:21 AM  Show Profile  Visit Aaron Cake's Homepage  Send Aaron Cake an ICQ Message  Send Aaron Cake a Yahoo! Message  Reply with Quote
Can you even all a DLL in Excel?

More to the point, have you downloaded the DLL and put it in the Windows\System directory?

I'm not sure that any of this works in any version of Windows past Windows 98.
Go to Top of Page

pmlapl
Apprentece

6 Posts

Posted - May 09 2010 :  12:01:39 PM  Show Profile  Reply with Quote
Yes it's in system32. I've since learned that the correct entry calls are WritePort and ReadPort and I need to use hex to address the port. I redid the program and it gave an error of a long string of numbers. I searched and found that perhaps Excel is looking for a cell value. I think you're right that it won't run in Excel. I've downloaded Visual Basic Express and I'm in the process of trying that.
Thanks for the reply.
Go to Top of Page

pmlapl
Apprentece

6 Posts

Posted - May 15 2010 :  6:29:52 PM  Show Profile  Reply with Quote
So I'm now using VB 2008 Express and am trying to use the following code:

Public Class Form1

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

WritePort(&HB400, TextBox1.Text)

End Sub
Private Declare Sub WritePort Lib "WIN95IO.DLL" (ByVal nPort As Integer, ByVal nData As Integer)
Private Declare Sub WritePortw Lib "WIN95IO.DLL" (ByVal nPort As Integer, ByVal nData As Integer)
Private Declare Function ReadPort Lib "WIN95IO.DLL" (ByVal nPort As Integer) As Integer
Private Declare Function ReadPortw Lib "WIN95IO.DLL" (ByVal nPort As Integer) As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class

I get an SEH error that says "External device has thrown an exception" whatever that means. I'm wondering if I the PCI card somehow needs to be addressed in the program.

Help is appreciated. Thoughts? Comments? Code?
Thanks in advance.
Pierre
Go to Top of Page

pmlapl
Apprentece

6 Posts

Posted - May 16 2010 :  4:31:21 PM  Show Profile  Reply with Quote
I tried using inpout32 and still get the exception error. After poking around the net, that error can mean a dozen things or more. Since I'm a novice, I don't have a chance in fixing it. @#$#%%$?@#$%!!!! It appears at this point in time there is no way I can program my parallel port.
I needed to vent.
Pierre
Go to Top of Page

jnewman
Apprentice

United Kingdom
126 Posts

Posted - May 16 2010 :  5:04:12 PM  Show Profile  Visit jnewman's Homepage  Reply with Quote
Sounds like you're using XP or above if you're using VB2008. Those DLLs don't work on anything other than Win9x, as they can't gain direct access to the parallel ports under NT due to security.

Read this, it has the solution: http://www.epanorama.net/circuits/parallel_output.html

>>> http://www.josephn.net <<<
>>> http://forum.josephn.net <<<
Go to Top of Page

codingplanet
Mad Scientist

United Kingdom
195 Posts

Posted - May 17 2010 :  11:23:07 AM  Show Profile  Visit codingplanet's Homepage  Reply with Quote
I've used input32 in XP before. In fact I wrote a program to display info on an LCD through the parallel port based on it using XP. It was written using VB.Net Express 2005 IIRC. I'll see if I can find the code.
Go to Top of Page

pmlapl
Apprentece

6 Posts

Posted - May 17 2010 :  7:37:11 PM  Show Profile  Reply with Quote
Thanks much for the comments. I've seen most of the info at site referenced. It's a little dated and some of the links don't work. I didn't find a different DLL. But I appreciate the advice.

I measured the ground pins on my parallel port and only three were low. The rest were high. I think I may have messed something up on my board and that could be the reason for the exception error.

This journey started with some old stepper motors I pulled out of a printer. I wanted to see if I could control them with my computer. There are lots of programs that work on XP systems and below. However now it seems that parallel ports are a bit obsolete. I now think I will try using a serial port instead. VB 2008 has a serial port component which should simplify some things but I will now need more interface circuitry.

Anyway, more head scratching awaits.
Go to Top of Page

jnewman
Apprentice

United Kingdom
126 Posts

Posted - May 19 2010 :  11:52:21 AM  Show Profile  Visit jnewman's Homepage  Reply with Quote
That's where microcontrollers come handy. They can do all the leg work with spinning the stepper motor, and the computer could just be a way of issuing commands, such as speed up, slow down, stop, etc.

>>> http://www.josephn.net <<<
>>> http://forum.josephn.net <<<
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Aaron's Homepage Forum © 1995-2020 AARONCAKE.NET Go To Top Of Page
This page was generated in 0.12 seconds. Snitz Forums 2000