Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dealing with parallel port reading and writing.

Status
Not open for further replies.

Leibnitz

Programmer
Apr 6, 2001
393
CA
what i need to know exactly is how i could read the bytes that reach the parallel port each 1ms (for example), and then use those data bytes to represent a sin wave on the coordinate system?
which means each byte will be read according to timer then the data will be converted to its decimal values which will be represented into the coordinate system as one point.
meanwhile we are still reading the coming bytes to the port then representing them on the coordinate...we will continue with this until some period of time then we will stop receiving data from the port and try to connect the drawn points together to get the sin wave display.

till now i wrote this code to read and write from the parllel port with a timer but still not sure of it, so please if some one could check this code for me and give me some hints of how to solve the problem above.

Code:
' this to read from the data port,
'and display it in a label,
'but u have to click on the button
Private Sub Command1_Click()
   Dim invalue As Byte
   invalue = PortIn(888)
   Label1.Caption = Val(invalue)
End Sub

'this to send zero
'to the first bit in the control port
Private Sub Command2_Click()
   Dim invalue, f1 As Byte
   invalue = PortIn(890)
   f1 = Val(invalue) Or (&H1)
   Call PortOut(890, Val(f1))
End Sub

'this to send one
'to the first bit in the control port
Private Sub Command3_Click()
    Dim invalue, o1 As Byte
    invalue = PortIn(890) 
    o1 = Val(invalue) And (&HFE)
   Call PortOut(890, Val(o1))
End Sub
 
'this code to read automatically,
'using a timer
     Private Sub Timer1_Timer() 
     Dim invalue As Byte
     invalue = PortIn(888)
     Label1.Caption = Val(invalue)
End Sub

ps: i used the io.Dll library as the followin defintions in the module
Public Declare Sub PortOut Lib "io.dll" (ByVal Port As Integer, ByVal Value As Byte)
Public Declare Function PortIn Lib "io.dll" (ByVal Port As Integer) As Byte

 
Double post, see thread222-829623.

See faq222-2244 for information on why double posts are frowned upon.

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top