T O P I C R E V I E W |
pmlapl |
Posted - May 07 2010 : 10:50:57 PM 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. |
10 L A T E S T R E P L I E S (Newest First) |
jnewman |
Posted - May 19 2010 : 11:52:21 AM 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. |
pmlapl |
Posted - May 17 2010 : 7:37:11 PM 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. |
codingplanet |
Posted - May 17 2010 : 11:23:07 AM 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. |
jnewman |
Posted - May 16 2010 : 5:04:12 PM 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 |
pmlapl |
Posted - May 16 2010 : 4:31:21 PM 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 |
pmlapl |
Posted - May 15 2010 : 6:29:52 PM 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 |
pmlapl |
Posted - May 09 2010 : 12:01:39 PM 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. |
Aaron Cake |
Posted - May 09 2010 : 11:01:21 AM 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. |
pmlapl |
Posted - May 08 2010 : 2:58:48 PM 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.
|
codingplanet |
Posted - May 08 2010 : 05:33:23 AM 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". |