Read Weight from Mettler Toledo Scale via RS232

M

Thread Starter

Martin

Hi All,

How can i read a weight from a Mettler Toledo Scale via RS232

I have written the coding to read the data from serial port.

I am very new ..working to read the weight(mg) data from a mettler Toledo via RS232 using VB.Net

please help and pass me any coding or idea.

My mail id: [email protected]

Thanks in Advance


 
E

Earthed Solutions

Hi,

I understand that you want to capture Mettler Toledo RS232 port weight data in a VB.NET application. And you are after source code for VB.NET.

To query the scale, you need to send an ASCII command:

S<CR><LF>

To process the returned weight:
<?><LF>S S 0.000 lb
<?><LF>S S 0.000 g

It would be best to extract the value and the units and then implemenmt a switch statement on the units toi convert to a standard weight.

I would suggest reading the captured string into a string seperator using space " " as the delimiter such that
str[0] = "<?><LF>S"
str[1] = "S"
str[2] = "0.000"
str[3] = "lb|g|kg|..."

then process the result

Which version of VB are you using? - I might be able to supply VB.NET 2008 code.

www.earthed.net.au [email protected]
 
F

Fred Loveless

Ultimately what is your goal, i.e. what are you going to do with the data?

If you are using it in an automated process of some kind you might want to consider useing and OPC Server like Kepware's UCON Protocol Server. UCON stands for User Configurable. You can can create the request and response handling and then connect to the server via any SCADA Client or via VB.Net if you wish. the process is similar to the VB.Net code example that was presented.

Just another option to consider.

Fred Loveless
Senior Application Engineer
Kepware Technologies
http://www.kepware.com
 
L

Lee Munyaradzi

Hi,

> I understand that you want to capture Mettler Toledo RS232 port weight data in a VB.NET application. And you are after source code for VB.NET. <

I'm facing a similar problem. Could you please supply the vb .net code on how to read data from a scale via an RS232.
 
P

Praveen Gaddam

Hi

I am trying to do the same i.e., capture weights from mettler toledo Scale through RS232/USB.

Can you please provide the C# code sample for it?

Thank You,
Praveen
 
Hi,

I have the same problem, Can you supply the VB code. I have 2005 and 2008.

Thanks
donald [at] norpacexport.com
 
Y
> Did anyone solve this, if you have can you email me the code too pls, [email protected]

This will read the weight on the mettler scale on the serial port. Put this Function in and call it. <pre>
Private Function get_lbs() As String
Dim buffer As New StringBuilder()
Dim comPort As New SerialPort("COM1", 9600, Parity.None, 8, StopBits.One)

comPort.Open()
comPort.Write(STX)
mytimer(1)
comPort.Write("P")
mytimer(1)
comPort.Write(CR)
mytimer(1)
Dim line As String = comPort.ReadExisting
comPort.Close()
Return isnum(Trim(line))

End Function</pre>
 
Y
> This will read the weight on the mettler scale on the serial port. Put
> this Function in and call it. <pre>
> Private Function get_lbs() As String
> Dim buffer As New
>StringBuilder()
> Dim comPort As New
>SerialPort("COM1", 9600, Parity.None, 8,
>StopBits.One)
>
> comPort.Open()
> comPort.Write(STX)
> mytimer(1)
> comPort.Write("P")
> mytimer(1)
> comPort.Write(CR)
> mytimer(1)
> Dim line As String =
>comPort.ReadExisting
> comPort.Close()
> Return isnum(Trim(line))
>
> End Function</pre>
You will also need this in the class <pre>
Public Shared STX = Chr(2)' ascii start of text
Public Shared CR = Chr(13) 'ascii Carriage Return</pre>
 
Sorry, but I don't know, why use: comPort.Write("P")

>> This will read the weight on the mettler scale on the serial port.
>> Put this Function in and call it. <pre>
>> Private Function get_lbs() As String
>> Dim buffer As New
>>StringBuilder()
>> Dim comPort As New
>>SerialPort("COM1", 9600, Parity.None, 8,
>>StopBits.One)
>>
>> comPort.Open()
>> comPort.Write(STX)
>> mytimer(1)
>> comPort.Write("P")
>> mytimer(1)
>> comPort.Write(CR)
>> mytimer(1)
>> Dim line As String =
>>comPort.ReadExisting
>> comPort.Close()
>> Return isnum(Trim(line))
>>
>> End Function</pre>
 
Top