Solved

sending data out of computer...

Posted on 1998-12-17
20
260 Views
Last Modified: 2012-06-27
I would like to send data out of the computer some how. I think this is posible throught the printer port but I don't know how... Can any one point me twards the right place? Thanks!
0
Comment
Question by:testing38
  • 10
  • 4
  • 3
  • +3
20 Comments
 

Author Comment

by:testing38
ID: 1451068
to be more spicific... I would like to control say a L.E.D with the computer. Sorry about that.
0
 
LVL 3

Expert Comment

by:traygreen
ID: 1451069
Where do you want the data to "go"?
0
 
LVL 1

Expert Comment

by:cyber_bandit
ID: 1451070
There is an excellent book written by Paul Bergsman, called CONTROLLING THE WORLD WITH YOUR PC, has connections to your computer and schematics of various devices, and a ton of code....
Here is a sample of some of the code
100 REM   FILE = LED_SRCE.BAS
110 REM
120 REM  SOURCE CURRENT control LEDs connected to parallel printer port.
130 REM  LEDs are "lit" when data logic is HIGH.
140 REM  Written in QBASIC
150  T = 1
500 REM
510 REM  begin program
520 REM  REPEAT
530 GOSUB 1000
540 LPRINT CHR$(255);
550 IF INKEY$ = CHR$(27) THEN STOP
560 GOSUB 2000
570 IF INKEY$ = CHR$(27) THEN STOP
580 GOTO 510
590 stop
1000 REM
1010 REM -=[ subuoutine,   Output_All_Combinations_Of_Bits ]=-
1020 REM  just a check to be sure all LEDs are working
1030 REM
1040 FOR e = 0 TO 255
1050 PRINT e: LPRINT CHR$(e);
1060 IF INKEY$ <> "" THEN STOP
1070 NEXT e
1080 RETURN
2000 REM
2010 REM  -=[ subroutine,  Run_Up_And_Down_The_Bits }
2030 REM  turn each printer port data bit on, and then off.
2040 DIM Two(8)
2050 A = 0: e = 0
2060 REM
2090 Two(0) = 2^0:  Two(1) = 2^1:  Two(2) = 2^2:  Two(3) = 2^3:
2100 Two(4) = 2^4: Two(5) = 2^5: Two(6) = 2^6: Two(7) = 2^7:
2110 FOR A = 1 TO 10
2120 FOR e = 0 TO 7
2130 PRINT Two(e):  LPRINT CHR$(Two(e));
2135 SLEEP (T)
2140 IF INKEY$ <> "" THEN STOP
2150 NEXT e
2160 REM
2170 FOR e = 7 TO 0 STEP -1
2180 PRINT Two(e): LPRINT CHR$(Two(e));
2190 SLEEP (T)
2200 IF INKEY$ <> "" THEN STOP
2210 NEXT e
2220 NEXT A
2230 RETURN



0
 

Author Comment

by:testing38
ID: 1451071
I can't seem to get the  Lprint  command to work... In fact I have this book for when I used to program in Qbasic but... I now program in Visual Basic... I would like my program to control a led light with the parallel printer out put. I think that is how it is spelled... :) But in VB and not QB
0
 

Author Comment

by:testing38
ID: 1451072
Adjusted points to 110
0
 

Author Comment

by:testing38
ID: 1451073
traygreen- I would like the data to be sent to the parelle printer port. If you under stand QB at all read over the code cyber_bandit has given. This is exactley what I want to do only it is in Qb. I need code like this to run in VB. Thanks
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1451074
testing38,
Communicate with parallel port in VB is a little different.
You should find the infor. in the following:
http://www.doc.ic.ac.uk/~ih/doc/par/
http://www.senet.com.au/~cpeacock/parallel.htm      http://et.nmsu.edu/~etti/fall96/computer/printer/printer.html
Regards
Dalin
0
 
LVL 1

Expert Comment

by:cyber_bandit
ID: 1451075


How about this one?


Technical Details for Standard Printer Port
Parallel printer pin connections

output at portbase address
DB25 Connector
PINS 2-9 Data output and PINS 18-25 are GND
The following table is for the selected bit to be low all others high (unused ttl inputs float high)

portbase + 1 printer port input from control lines

                bit 7654 3210
pin 15 DB25 low=h70 0111 0000 D3
pin 13 DB25 low=h68 0110 1000 D4
pin 12 DB25 low=h58 0101 1000 D5
pin 11 DB25 low=hF8 1111 1000 INVERT D7
pin 10 DB25 low=h38 0011 1000 D6
all high h78 0111 1000
portbase addr + 2 printer port output control lines

pin 1 DB25 D0 INVERT
pin 14 DB25 D1 INVERT
pin 16 DB25 D2
pin 17 DB25 D3 INVERT

--------------------------------------------------------------------------------

Option Explicit
' Demonstration code for AVBUG
' by Roger Curtain
' the printer port address constants
' assume that the printer port
' is located at hex address 378,
' if you have problems with this routine,
' use the MSD diagnostic prog to find the
' printer port
' &H278 is the alterate or lpt2 value
Private Declare Function GetTickCount _
   Lib "kernel32" () As Long
  'port BYTE output
  Const portout% = &H378
  Const portin% = (portout% + 1)
  ' printer port input from control lines
  ' bit 7654 3210
  ' pin 15 DB25 low=h70 0111 0000 D3
  ' pin 13 DB25 low=h68 0110 1000 D4
  ' pin 12 DB25 low=h58 0101 1000 D5
  ' pin 11 DB25 low=hF8 1111 1000 INVERT D7
  ' pin 10 DB25 low=h38 0011 1000 D6
  ' all high h78 0111 1000
  ' printer port output control lines
  Const portctrl% = (portout% + 2)
  ' pin 1 DB25 D0 INVERT
  ' pin 14 DB25 D1 INVERT
  ' pin 16 DB25 D2
  ' pin 17 DB25 D3 INVERT
  ' Data read from port
  Dim port_read As Integer
  Dim stopped As Integer
  Private Sub Cmd_Take_click()
    stopped = False
    Do
      'calculate freq. from pulses per second
      frequency
      DoEvents
    Loop Until stopped = True
  End Sub
  Private Sub Cmd_Stop_Click()
    stopped = True
  End Sub
  Private Sub Form_Load()
    'supply power using data byte
    'all high level to the outputs
    agOutp portout%, &HFF
  End Sub
  Private Sub frequency()
    Dim prev_read As Integer
    Dim count As Integer
    Dim start As Long
    Dim elapsed As Long
    start = Timer
    count = -1
    'API call to system timer
    start = GetTickCount()
    Do
      ' retrieve data from port control lines
      port_read = agInp(portin%)
      If port_read <> prev_read Then
        count = count + 1
      End If
      prev_read = port_read
      elapsed = GetTickCount() - start
    Loop Until elapsed >= 3000
    Lbl_Count.Caption = count
    ProgressBar1.value = count / 5
    Lbl_freq.Caption = "Freq " + _
           Format$(3000 / elapsed * count / 6, _
           "standard")
  End Sub
 

Option Explicit
' -----------------------------------------
'
' APIGID32.BAS --
' APIGID32.DLL API Declarations
'   for Visual Basic
'
' Copyright (C) 1992-1996 Desaware
'
' You have a royalty-free right to use,
' modify, reproduce and distribute
' this file (and/or any modified version)
' in any way you find useful,
' provided that you agree that Desaware and
' Ziff-Davis Press has no warranty,
' obligation or liability for its contents.
' Refer to the Ziff-Davis Visual Basic
' Programmer's Guide to the
' Win32 API for further information.
'
' -----------------------------------------
Type POINTS
  x As Integer
  y As Integer
End Type
Private Type FILETIME
  dwLowDateTime As Long
  dwHighDateTime As Long
End Type
Declare Function agGetInstance& Lib "apigid32.dll" ()
Declare Function agInp% _
    Lib "apigid32.dll" _
        (ByVal portid%)
Declare Sub agOutp _
    Lib "apigid32.dll" _
        (ByVal portid%, ByVal outval%)

0
 
LVL 1

Expert Comment

by:cyber_bandit
ID: 1451076
oh yeah... here is the URL I got that from:
http://www.ozemail.com.au/~avbug/jun97/frart5a.htm

0
 

Author Comment

by:testing38
ID: 1451077
I'm sorry Dalin and every body else. I am just not "smart" enough to look at those information packets Dalin sujested and get code out of it. If any one could write a sample program and send it to me. And cyber_bandit I thought for sure I could get your code to work but nope I could not. Sorry I have to hand fed all this info... I added a few points for this one. I hope some one can help. Thanks
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:testing38
ID: 1451078
Sorry I have to be hand fed all this info...  is what I mean to say :)
0
 

Expert Comment

by:stingray
ID: 1451079
Try using the file inpout32.dll  (somewhere on the net) works with win9x not NT.

then add the following code

Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Byte

Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Byte)

const lpt1=&h378

to send data to the port
out lpt1,value

or to get the value
value = inp(lpt1)

Hope it helps
Adam
0
 

Author Comment

by:testing38
ID: 1451080
Stingray- I'm going to go with this answer. But before I give you the points I have a weird question to ask you: Who is Adam? Thanks a lot. Apon answering this Question I will give you 200 points. (raised 40)
0
 

Expert Comment

by:stingray
ID: 1451081
I am Adam.
Stingray is just a handle.
0
 

Author Comment

by:testing38
ID: 1451082
Sorry... I thought you some how found out my name with out me telling you and I was wondering how you you did so. My name is Adam also. :) Well anyway Answer and I'll give you the points. Thanks again!!!!
0
 

Expert Comment

by:stingray
ID: 1451083
Adam,

Send me your e-mail address.  I have found my copy of the dll I was talking about, and I can e-mail it to you.

stingray@canada.com

0
 

Author Comment

by:testing38
ID: 1451084
My address is testing38@hotmail.com           But I have already downloaded the dll and I'm using it. Since you have told me about it I have designed and built a printed circuit bord to work with my project. It works great! I already got big plans for automating my room at home :) I just have one more but to work out... How do get data into the computer. The page I got the dll off of game me a little halp And I am sure I will visit it again for more. Thanks again for the great help.
0
 
LVL 1

Expert Comment

by:xer_soft
ID: 1451085
.
0
 

Author Comment

by:testing38
ID: 1451086
stingray: you still need to answer this question. I will then give you the points! Thanks for the help!
0
 

Accepted Solution

by:
stingray earned 200 total points
ID: 1451087
Try using the file inpout32.dll  (somewhere on the net) works with win9x not NT.

then add the following code

Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Byte

Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Byte)

const lpt1=&h378

to send data to the port
out lpt1,value

or to get the value
value = inp(lpt1)

Hope it helps
Adam

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now