Code Comments
Programming Forum and web based access to our favorite programming groups.I am trying to get data from a balance to my vb app using MSComm. I know th e balance is transmitting because I can pick it up in hyperterminal. I need t o get the value from the balance when the balance sends it so I believe I need the OnComm method but I don't know how. Any help greatly appreciated. Thanks Mike Here is what I have: Sub Form_Load() Dim strBalanceOutput As String MSComm1.CommPort = 2 ' 9600 baud, Odd parity, 7 data, and 1 stop bit. MSComm1.Settings = "9600,O,7,1" 'Open Com port MSComm1.PortOpen = True MSComm1.InputMode = comInputModeText Text1.Text = strBalanceOutput End Sub
Post Follow-up to this messageCheck out this previous thread.... http://groups-beta.google.com/group...d39aeb36e359f27 Most likely the balance is transmitting Binary not Text data... What kind of output are you seeing in Hyperterminal?
Post Follow-up to this messageHi, I answered this question elsewhere. You need to enable OnComm event handling (RThreshold = 1), and add code to the MSComm OnComm subroutine to capture the data. You also need the manufacturer's information about the structure of the data to be captured. Dick -- Richard Grier (Microsoft Visual Basic MVP) See www.hardandsoftware.net for contact information. Author of Visual Basic Programmer's Guide to Serial Communications, 4th Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See www.mabry.com/vbpgser4 to order.
Post Follow-up to this messageIn hyperterminal I am seeing the numbers from the balance so in hypertermina l I see N + 72.14 g So is the balance sending text or does hyperterminal convert? Mike "btpanek09@yahoo.com" wrote: > Check out this previous thread.... > http://groups-beta.google.com/group...d39aeb36e359f27 > Most likely the balance is transmitting Binary not Text data... > What kind of output are you seeing in Hyperterminal? > >
Post Follow-up to this messageThanks for the reply. The balance docs say there is a 23-byte transmit buffer and a 40-byte receive buffer. Mike "Dick Grier" wrote: > Hi, > > I answered this question elsewhere. > > You need to enable OnComm event handling (RThreshold = 1), and add code to > the MSComm OnComm subroutine to capture the data. You also need the > manufacturer's information about the structure of the data to be captured. > > Dick > > -- > Richard Grier (Microsoft Visual Basic MVP) > > See www.hardandsoftware.net for contact information. > > Author of Visual Basic Programmer's Guide to Serial Communications, 4th > Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See > www.mabry.com/vbpgser4 to order. > > >
Post Follow-up to this messageWhat you see s what youi're getting <g> Normally (with due exceptions I imagine) scales send ASCII. Saga "Mike D" <MikeD@discussions.microsoft.com> wrote in message news:4068EFAD-DE27-4790-AD4D-85686C32C6DC@microsoft.com... > In hyperterminal I am seeing the numbers from the balance so in > hyperterminal > I see > N + 72.14 g > > So is the balance sending text or does hyperterminal convert? > > Mike > > "btpanek09@yahoo.com" wrote: >
Post Follow-up to this messageOK. But... The details are critical. The statement, "a 23-byte transmit buffer and a 40-byte receive buffer," doesn't say anything about what the data that are sent by the scale represent, nor the data format. Dick -- Richard Grier (Microsoft Visual Basic MVP) See www.hardandsoftware.net for contact information. Author of Visual Basic Programmer's Guide to Serial Communications, 4th Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See www.mabry.com/vbpgser4 to order.
Post Follow-up to this messageDick,
Thanks so much for your time. I think I have found the details
Character Coding = 7-bit ASCII
Data output = 16 or 22 characters
Hardware handshake with 2 characters after CTS
I am stiil unable to get the ON_Comm to fire with this code
Sub Form_Load()
Dim strBalanceOutput As String
MSComm1.CommPort = 2
' 9600 baud, Odd parity, 7 data, and 1 stop bit.
MSComm1.Settings = "9600,O,7,1"
'Open Com port
MSComm1.PortOpen = True
MSComm1.InputMode = comInputModeText
MSComm1.RThreshold = 1
MSComm1.SThreshold = 1
End Sub
Sub MSComm1_OnComm()
MsgBox ("Boo")
End Sub
"Dick Grier" wrote:
> OK. But...
>
> The details are critical. The statement, "a 23-byte transmit
> buffer and a 40-byte receive buffer," doesn't say anything about what the
> data that are sent by the scale represent, nor the data format.
>
> Dick
>
> --
> Richard Grier (Microsoft Visual Basic MVP)
>
> See www.hardandsoftware.net for contact information.
>
> Author of Visual Basic Programmer's Guide to Serial Communications, 4th
> Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
> www.mabry.com/vbpgser4 to order.
>
>
>
Post Follow-up to this messageAdd RTSEnable = True You don't need SThreshold (in fact, it never is needed). -- Richard Grier (Microsoft Visual Basic MVP) See www.hardandsoftware.net for contact information. Author of Visual Basic Programmer's Guide to Serial Communications, 4th Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See www.mabry.com/vbpgser4 to order.
Post Follow-up to this messageI can't get the OnComm event to fire. My balance is sending data to
hyperterminal what am I missing?
Mike
Here is my code:
Dim MSComm1 As New MSComm
Sub Form_Load()
Dim strBalanceOutput As String
MSComm1.CommPort = 2
' 9600 baud, Odd parity, 7 data, and 1 stop bit.
MSComm1.Settings = "9600,O,7,1"
'Open Com port
MSComm1.PortOpen = True
MSComm1.RThreshold = 1
MSComm1.RTSEnable = True
MSComm1.InputMode = comInputModeText
End Sub
Sub MSComm1_OnComm()
MsgBox ("Boo")
End Sub
"Dick Grier" wrote:
> Add RTSEnable = True
>
> You don't need SThreshold (in fact, it never is needed).
> --
> Richard Grier (Microsoft Visual Basic MVP)
>
> See www.hardandsoftware.net for contact information.
>
> Author of Visual Basic Programmer's Guide to Serial Communications, 4th
> Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
> www.mabry.com/vbpgser4 to order.
>
>
>
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.