Skip to Content
Technical Articles
Author's profile photo Kevin Hunter

Integrating Mettler Toledo Weigh Scales to SAP Digital Manufacturing Cloud Part 2

In the first part of this blog series I discussed the various hardware options to connect the scales, after releasing the blog a colleague contacted me to let me know that they had tried to connect to a real Mettler Toledo ACI400 and due to it exposing the weight data as an OPCUA property called “EURange” they couldn’t subscribe to it and use it in DMC. I have modified the original blog to highlight that this means its not currently supported by DMC but also added it here incase you had already read part 1. I have also contacted the appropriate product owners in SAP and support will be added to the development back log so watch this space.

So, as mentioned in part 1 I am going to use a RS232 to USB convertor

First step is to connect the RS232 convertor into the scales and connect it to your computer (Im using a windows based PC but this will work on a Mac or Linux machine as well).

Now configure the scales so that the interface is in “Dialog” mode and not “Print” mode, this allows the scale communicate using the RS232 interface rather than only sending data when the print button is pressed. Please refer to the operators manual for your specific scales to find out how to do this.

Now configure the Baud rate (Speed) of the RS232 to be as fast as possible (19200 in my case) – Please note that the length of the RS232 cable effects the reliable speed of communication. For example at 19200 bits/s the maximum cable length is 15M, at 9600 bits/s its 30M.

Now that its configured and connected you can use any terminal program you have access to, for example “Hyperterminal”. I happen to experiment with ESP8266 boards using the Arduino IDE which has a “Serial Monitor” function so I used that.

According to the MT-SICS documentation you send the character “@” to reset the scales and it should respond with the serial number of the scales.

The scales correctly responded with a serial number of 2422747, all good so far.

Next we want to issue a command that reads the weight, so after referring to the MT-SICS document we find that the command is “S” so I placed something on the scales that weighs 7.66 grams according to its display so this is the value I expect to receive.

 

The scales respond with a message that has the correct value and unit of measure in it.

So we have now proven that the hardware is working and that we can communicate with the scales and receive responses.

Now we need to create an application that converts the MT-SICS commands and responses into an OPC UA server.

 

My personal set of requirements for this software are as follows:

  • The OPC UA SDK must be open source as I have no budget to buy a commercial one. For productive use I would always consider using a commercially available SDK as this will include support or use an open source project that has a support option available.
  • Must be simple to program as I’m not a developer.
  • Must be executable on multiple operating systems with low hardware requirements as ultimately I would like it to use a low cost Raspberry PI.

Because of these requirements I selected an open source javascript library called Node-OPCUA that is executed using NodeJS  and used Visual Studio Code as my development environment. I tested the OPC UA server using UAExpert from Unified Automation.

If you want to follow along with this blog then install NodeJS, Visual Studio Code and UAExpert onto your local machine.

Create a directory on your local machine called “MTServer”.

Open Visual Studio Code.

Select File –> Add Folder To Workspace and select the folder you just created.

Select Terminal –> New Terminal and this should open a terminal window inside Visual Studio Code.

 

Type git clone https://github.com/KevinHunter12/MettlerToledoOPCUA.git into the terminal window. This will download the finished server from my github repository into your directory.

Change directory to the MettlerToldeoOPCUA directory that was created during the cloning.

Now type npm install this will download and install all the required NodeJS packages into your directory.

 

Finally type node mtserver <PORT> <BAUD> replacing PORT and BAUD with your values. In my case it was node mtserver com5 19200 as my serial port was com5 and the baud I set the scales to was 19200.

 

This should start the server and display the following:

Now open UAExpert and press the “+” icon in the tool bar to add a new server

 

 

Now double click the Add server text and enter localhost:4335

 

This should add the new server to the list of available servers, expand the node and select “None” as the security settings by double clicking it.

 

You should now see the server in the list of servers in the top left hand side of the screen, now click the connect Icon to connect to the server.

 

Once connected to the server it should display the OPCUA address space on the lower left hand side of the screen.

 

Now highlight all of the tags exposed by the server and drag them into the middle of the screen (this is the Data Access View)

Note that if everything is OK then the serial number of your scales should be shown in the SerialNumber Tag.

 

Now to explain what all the tags are and how to use them , the list of tags available are:

  1. DecodedResponse – Read Only – String
  2. RawResponse – Read Only – String
  3. ReadStableWeight – Read Write – Boolean
  4. ReadWeightImmediate – Read Write – Boolean
  5. ReadWeightImmidiateRepeat – Read Write – Boolean
  6. Reset – Read Write – Boolean
  7. SerialNumber – Read Only – String
  8. SerialPortConnected – Read Only – Boolean
  9. SoftwareVersion – Read Only – String
  10. Tare – Read Write – Boolean
  11. TareWeight – Read Only – Float
  12. TareWeightUOM – Read Only – String
  13. Weight – Read Only – Float
  14. WeightStable – Read Only – Boolean
  15. WeightUOM – Read Only – String
  16. Zero – Read Write – Boolean

DecodedResponse

When you send a message to the scales it responds with a coded series of characters eg. S S 7.66 g. The software decodes these message into a more human friendly format. In the example, the first “S” means that its a weight and the second “S” means that it is stable.

RawResponse

This value is the raw character string returned by the scales

ReadStableWeight

Writing a 1 (or true) to this tag will send a command to the scales to read the Stable Weight, this means that the scales will wait until the weight has stabilized before sending the data. The tag is automatically reset to 0 (false) by the software.

ReadWeightImmediate

Writing a 1 (or true) to this tag will send a command to the scales to read the Immediate weight regardless if it is stable or not. The tag is automatically reset to 0 (false) by the software.

ReadWeightImmidiateRepeat

Writing a 1 (or true) to this tag will send a command to the scales to continuously read the Immediate weight regardless if it is stable or not. The tag is automatically reset to 0 (false) by the software and the data will be streamed until you send another command such as ReadStableWeight or Reset to stop it.

Reset

Writing a 1 (or true) to this tag will send a command to the scales to reset the scales, the scales will reply with the serial number of the scales. The tag is automatically reset to 0 (false) by the software.

SerialNumber

This is the serial number of the connected scales.

SerialPortConnected

This is supposed to tell you if the serial port is connected or not but doesn’t appear to function as it should. I am still investigating why.

SoftwareVersion

This is the software version installed in the scales

Tare

Writing a 1 (or true) to this tag will send a command to the scales to Tare the scales. The tag is automatically reset to 0 (false) by the software.

TareWeight

When the scales are Tared this tag will display the Tare Weight.

TareWeightUOM

This tag shows the unit of measure for the Tare Weight.

Weight

This tag displays the weight send by the scales (Stable or Dynamic).

WeightStable

This tag will display 1 (True) when the weight measurement is stable.

WeightUOM

This tag displays the unit of measure for the Weight.

Zero

Writing a 1 (or true) to this tag will send a command to the scales to Zero the scales. The tag is automatically reset to 0 (false) by the software.

 

Finally time for a quick test.

Lets send a zero command to the scales then I want to see a constant read out of the weight.

We firstly need to write a 1 (true) to the Zero tag and then write a 1 (true) to the ReadWeightImmediateRepeat tag.

We do this by double clicking on the word false in the Zero tag display in UAExpert

This will display a check box that you tick, this will write a true to the tag and you should see your scales reset. Repeat this for the ReadWeightImmediateRepeat tag and place something onto your scales and you will see the Weight tag increase in value.

 

In the next blog we will configure DMC to connect to the scales and create some production processes that allow us to display the data in a dashboard and send commands from a POD.

 

Thanks for reading this blog, the next one will be released soon.

Assigned tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.