Integrating Mitutoyo Calipers with Ignition

Mitutoyo calipers are a common tool to find in a lot of QA/QC labs. Many of their models have the capability of being integrated with SCADA systems using the RS-232 protocol and a USB cable plugged into the caliper and a computer. For companies using Ignition integrating the current measurement from Mitutoyo calipers is a relative breeze.

You will need the Serial Module in Ignition to use the code in this post as written. If you don’t have the Serial Module it is possible to accomplish the same result using Python libraries to interact with the serial port, however that is out of the scope of this post.

First you will want to install the USB-INT drivers on your computer and plug the Mitutoyo calipers into your computer. It will then show up as a Virtual Com Port. You will want to open the Device Manager on your computer to get the com port number, in the case below it is COM9.

Next you will want to open an Ignition Designer on the machine your calipers are plugged into.

If you are using a client machine instead of the server we would take a slightly different approach to connect to the calipers from the client machine where the COM port is set up, but for this example we are assuming we are on the gateway machine.

We will set up a folder in the tag provider called “Calipers” and add 3 Memory Tags to the folder. Ultimately you will only need 2 of these, but having the 3rd helps for formatting the data. These tags are called COM Port, RawText, and Reading.

In a system with more than one set of calipers it would make sense to set up a Caliper UDT, an exercise left for the reader for now.

Setting the value of COM Port will allow us to change the COM port easily should it ever show up as a different port after a restart of the machine.

Raw text will show us the raw data coming back from the calipers when we request data, and reading will store the current measurement on the calipers themselves.

You will need to set the value of the COM Port tag based on your machine, and you should see null values for RawText and Reading at the moment.

Next we will set up a Timer Script in the Gateway Event Scripts to trigger Ignition to read data from the calipers:

#get the com port to interact with
comPort = system.tag.read("[Ignition]Calipers/COM Port").value

#open the serial port and write the command to trigger the calipers to send their measurement
system.serial.openSerialPort(comPort)
system.serial.write(comPort, "1\r")

#read the line from the calipers, replacing 01A with an empty string
readingRaw = system.serial.readLine(comPort).replace("01A","")
reading = 0

#look for a negative sign in the reading and return a negative value
if "-" in readingRaw:
	reading = -1*float(readingRaw.split("-")[1])

#otherwise look for a positive value and return it
elif "+" in readingRaw:
	reading = float(readingRaw.split("+")[1])
	
#write the value of the reading from the calipers to the tag
system.tag.write("[Ignition]Calipers/Reading", reading)

This code is set to run every 5 seconds on a timer, and will grab the current value from the calipers and write it to the reading tag each time it is run.

To troubleshoot or dig deeper into the caliper data you can write the value of readingRaw to the RawText tag to see exactly what the calipers are returning. You may also find it helpful to take out the .replace(“01A”,””) when doing this.

Wrapping Up

Beyond a timer script you could trigger reading data from the calipers based on tag change scripts or a user clicking on a button, you would simply put the script in the relevant location.

You can also use the data button, or a footswitch to trigger a write to the USB port on the calipers and use the calipers as a Human Interface Device without installing the USB-INT driver, but these methods require operator intervention and may not be preferable to an automated collection solution.

Using Mitutoyo calipers in this way can make them an integral part of your QA/QC process, and can even be integrated into an SPC solution if you are using caliper measurements as part of your SPC process.

Previous
Previous

Automation Direct Modbus Addressing in Ignition

Next
Next

Ignition Edge Remote Tag Provider