Maker Pro
Maker Pro

Spreadsheet as realtime viewer?

M

Martin Riddle

Jan 1, 1970
0
Joerg said:
Thanks, I let our SW guy know. However, Active-X gives me the goose
pimples (and nobody really uses IEEE 488 anymore in production...)

Know what you mean, It seems all the links are dead in that URL.
I dont have any rs232 devices here so I can t play. But you would need to
use the windows API Createfile etc to open the port. Or i've seen some
references to OpenComm (readcomm, writecomm...) in VB that does the same
thing.
Actually if it is USB then you might need more information on the device API
to get data from it. But RS232 should be a snap.

Had a good link for you, but can find it now.
Heres an example, it looks similar to a dll wrapper i created for the
windows API not too long ago, but the basics are the same.
original
here->http://groups.google.com/group/micr...b8d18feba7f/7143662bad84d61c#7143662bad84d61c

'*********************************************
'* LIBRARY FUNCTIONS *
'*********************************************


Declare Function opencomm Lib "USER" (ByVal LPCOMNAME$, ByVal WINQUEUE%,
ByVal woutqueue%) As Integer
Declare Function closecomm Lib "USER" (ByVal NCID%) As Integer
Declare Function readcomm Lib "USER" (ByVal NCID%, ByVal lpbuf$, ByVal
nsize%) As Integer
Declare Function buildcommdcb Lib "USER" (ByVal LPSZDEF$, WDCB As
tagDCB) As Integer
Declare Function setcommstate Lib "USER" (WDCB As tagDCB) As Integer
Declare Function getcommerror Lib "USER" (ByVal NCID%, LPSTAT As
tagCOMSTAT) As Integer


'*********************************************
'* TYPE DECLARATIONS *
'*********************************************


Type tagDCB
id As Integer
baudrate As Long
bytesize As Integer
parity As Integer
stopbits As Integer
rlstimeout As Long
ctstimeout As Long
dsrtimeout As Long
fbinary As Long
frtsdisable As Long
fparity As Long
outxctsflow As Long
foutxdsrflow As Long
fdummy As Long
fdtrdisable As Long
foutx As Long
finx As Long
fpechar As Long
fnull As Long
fchevt As Long
fdtrflow As Long
ftrsflow As Long
fdummy2 As Long
xonchar As Integer
xoffchar As Integer
xonlim As Long
xofflim As Long
pechar As Integer
eofchar As Integer
evtchar As Integer
txdelay As Long
End Type ' tagDCB


Type tagCOMSTAT
status As Integer
cbinq As Integer
cboutq As Integer
End Type ' tagCOMSTAT


The essential usage of the functions is:


To close an open com port:


Function close_port() As Integer
close_port = closecomm(Port_Num)
End Function ' close_port


To open a com port:


Sub open_port()
Dim dcbstr As String
outstr$ = "com2" + Chr(0)
Port_Num = opencomm(outstr$, 1024, 128)
Debug.Print Port_Num
dcbstr = "com2:1200,n,8,1" & Chr$(0) '<--- change to your protocol
Debug.Print buildcommdcb(dcbstr, mydcb)
Debug.Print setcommstate(mydcb)
End Sub ' open_port


'*********************************************
'* READ COMM PORT *
'*********************************************
Function read_port() As String


Dim outstr$
Dim port_str$
Dim qcl%


port_str$ = Space$(100)
outstr$ = ""
qcl% = 0


Do
qerr% = readcomm(Port_Num, port_str$, 1)
...
loop
End Function

Cheers
 
J

Joerg

Jan 1, 1970
0
Martin said:
Know what you mean, It seems all the links are dead in that URL.
I dont have any rs232 devices here so I can t play. But you would need to
use the windows API Createfile etc to open the port. Or i've seen some
references to OpenComm (readcomm, writecomm...) in VB that does the same
thing.
Actually if it is USB then you might need more information on the device API
to get data from it. But RS232 should be a snap.

Had a good link for you, but can find it now.
Heres an example, it looks similar to a dll wrapper i created for the
windows API not too long ago, but the basics are the same.
original
here->http://groups.google.com/group/micr...b8d18feba7f/7143662bad84d61c#7143662bad84d61c

'*********************************************
'* LIBRARY FUNCTIONS *
'*********************************************


Declare Function opencomm Lib "USER" (ByVal LPCOMNAME$, ByVal WINQUEUE%,
ByVal woutqueue%) As Integer
Declare Function closecomm Lib "USER" (ByVal NCID%) As Integer
Declare Function readcomm Lib "USER" (ByVal NCID%, ByVal lpbuf$, ByVal
nsize%) As Integer
Declare Function buildcommdcb Lib "USER" (ByVal LPSZDEF$, WDCB As
tagDCB) As Integer
Declare Function setcommstate Lib "USER" (WDCB As tagDCB) As Integer
Declare Function getcommerror Lib "USER" (ByVal NCID%, LPSTAT As
tagCOMSTAT) As Integer


'*********************************************
'* TYPE DECLARATIONS *
'*********************************************


Type tagDCB
id As Integer
baudrate As Long
bytesize As Integer
parity As Integer
stopbits As Integer
rlstimeout As Long
ctstimeout As Long
dsrtimeout As Long
fbinary As Long
frtsdisable As Long
fparity As Long
outxctsflow As Long
foutxdsrflow As Long
fdummy As Long
fdtrdisable As Long
foutx As Long
finx As Long
fpechar As Long
fnull As Long
fchevt As Long
fdtrflow As Long
ftrsflow As Long
fdummy2 As Long
xonchar As Integer
xoffchar As Integer
xonlim As Long
xofflim As Long
pechar As Integer
eofchar As Integer
evtchar As Integer
txdelay As Long
End Type ' tagDCB


Type tagCOMSTAT
status As Integer
cbinq As Integer
cboutq As Integer
End Type ' tagCOMSTAT


The essential usage of the functions is:


To close an open com port:


Function close_port() As Integer
close_port = closecomm(Port_Num)
End Function ' close_port


To open a com port:


Sub open_port()
Dim dcbstr As String
outstr$ = "com2" + Chr(0)
Port_Num = opencomm(outstr$, 1024, 128)
Debug.Print Port_Num
dcbstr = "com2:1200,n,8,1" & Chr$(0) '<--- change to your protocol
Debug.Print buildcommdcb(dcbstr, mydcb)
Debug.Print setcommstate(mydcb)
End Sub ' open_port


'*********************************************
'* READ COMM PORT *
'*********************************************
Function read_port() As String


Dim outstr$
Dim port_str$
Dim qcl%


port_str$ = Space$(100)
outstr$ = ""
qcl% = 0


Do
qerr% = readcomm(Port_Num, port_str$, 1)
...
loop
End Function

Cheers

Thanks, Martin. This gets quite complicated. I guess we'll check out the
Azeotech factory control package. They have a 25-day or so free trial
and it supposedly now supports SPI via the USB which is what we'll have
to do most of the time. If that works we'll by licenses.
 
Top