Scale Indicator Programming Code

M

Thread Starter

mustafa1990

Hello
I hope my message find you well.

I have problem with programming code by visual basic 2005 to make a program to read the data that come from the serial port of the scale indicator. Below you will find a picture for the code of the program and the data after running the program.

I want to read and appear only one in a textbox from the Instantaneous data. The picture shows you the data that I want to read and appear but I don't know how can I get this result. The code and the protocol of the indicator you will find below too.

Please help me if you can.

https://ibb.co/cBuX5v
https://ibb.co/ejodCa

This my code that I use it in Visual basic 2005:

Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived

receivedtext(SerialPort1.ReadExisting())

End Sub

Private Sub receivedtext(ByVal [text] As String)

If Me.screen.InvokeRequired Then

Dim x As New settextcallback(AddressOf receivedtext)

Me.Invoke(x, New Object() {(text)})

Else

Me.screen.Text &= [text]

End If

End Sub


please can you help me
this is my email
[email protected]
 
Hi,

From the data format you posted, it seems like CAS indicator you are trying to interface. My company used to be the dealer of CAS. I have never used VB to do programming for RS232, but it can be done.

For VB, you can use ActiveX called mscomm32.ocx to access data from serial port.

Once you install the activeX, you will have MSCOMM control in your VB.
Then in OnComm event, you can put your code to capture the data from the scale. They are just normal strings.

https://msdn.microsoft.com/en-us/library/aa259393(v=vs.60).aspx

It should be fairly easy to separate the weight data (eg. 100 kg) from the captured string.

Hope it helps.

Bronson Alex
https://www.pt-altraman.com
 
Top