How to Use the Omron ZW 7000 Series to do a Thickness Measurement Using an Omron NX1P PLC

Hello this is Ray Marquiss from Valin Corporation, and today I'm going to show how to use the Omron, ZW-7000 series laser measurement sensor to do a thickness measurement using Ethercat and an Omron NX1P PLC.

This is the setup that we're going to use. You can see my auto-store feeler gauge is there on the table for calibrating and measuring.  These are the two ZW-7000 amplifiers that can communicate to the PLC over Ethernet, Ethercat or Ethernet IP. Only one of those protocols can be used at a time. These are connected over Ethercat to the Ethercat port on the NX1P2 PLC. And then I have the sensor heads connected to the amplifiers using the built-in cables, and there's a calibration chip attached to that cable. I'm using the ZW-7020, even though it's a little out of focus here. That gives me 20 millimeter target range plus or minus, I think, it's 2 millimeters. And so this ledge that you can see this feeler gauge on, that is 20 millimeters away from each sensor, so that puts it right in the middle between the two sensors and that white dot is the laser beam that you can see.

Next, we're going to create the project, and you should already be experienced with starting Sysmac Studio. But once were started, just give it a name so we'll just call this the “ZW” and we'll make it famous and say it's “for movies”. You can add your comments and so on in here. It's a standard project for a controller, and since I'm using the NX1P2, I'm going to select that one from the list. And I know that this model is correct: the 1040-DT, and I also know that my firmware version is very old, so I'm going to select the old firmware version for this. You can select a newer one if that's what you have.  Then I'll just create it.

Once we're here, what we want to do is go to the configuration. And I'll double click on the Ethercat icon here. And I could go over to the Toolbox, select measurement sensors, and then drag over The ZW-7000. But if I already have them powered up and connected to my Ethercat network then the easiest thing to do is go online. If you're PLC is set at the default settings from the factory, going online will just involve clicking this icon after you've changed your network card to match the network address of the PLC. That's normal Ethernet stuff, so you should know how to do it. If not, you can contact us, and we can help you through that. It's going to go online. And this is a message that's pretty common for a new one, and I could say no to this, and I'd still go online, but I'm just going to say yes, so it doesn't keep asking me to name the PLC. So I'll just say yes to that. Once I'm here, I can right click on the master, and then select “compare” and “compare and merge with actual network” by clicking on it. And you can see that it went out and it scanned the network and the hardware on it, and it found my two sensors, more specifically, the two sensor amplifiers. And then I just click on “apply actual network configuration” and that will bring this network over to the project.

This step gets confusing for people because they think now that they've done this, and now the network configuration is complete. But it's actually not complete. All we've done is created a configuration in our project. And we actually need to let the PLC know that we want to use this configuration, so we'll go offline. And we have to build the project. So will select the project menu and then click on build. Or if you like shortcuts, you can use the F8 key just to save a few mouse clicks. The build is generally pretty fast, and if there are any problems you'll see them down here in this window at the bottom. And if you haven't opened that window, it'll open automatically after the build is completed.

The next thing that I like to do before we go back online is go into the sensor settings. So now that the sensors have been brought into our Ethercat network, I can go in here to the system data for the sensors, the ZW-7000s.  I'll double click on that system data. You see how I got to it, by expanding the Ethercat and then expanding the node one, ZW 7000, and then expanding the system icon there. So I'll double click on system data. And the very first thing that pops up in this window is the measurement mode. And since we're using Ethercat, and we want these two sensors to be synchronized together,  we're going to click on this measurement mode and change it to “PDO synchronized mode”. Now that's going to change some other settings that we're going to in a minute, but it's not important to worry about those. Then we'll do the same thing for node 2. Click on system data, and change this to “PDO synchronized mode”. That means that the measurements between the two sensors are going to be synchronized with each other based on a clock pulse over the Ethercat network.

Now the other thing that we want to do is go to the banks, and we're going to use bank one. In this case, we're only going to use bank one for this example. Double click on that, and everything in here is fine. But later on when you start playing with the data that you want to get, you can play with the measurement cycle. Shortening this will give you data that you can average faster, but it could be less precise. I'm not going to say it will be, but it could be.  Increasing this number will take more time for the measurement cycle and it'll slow down the sensor, but you'll get more precise, or could get, more precise measurements. In addition to that, you can change the average time by default when you change the measurement mode to PDO, cyclic PDO synchronization mode. The average is set to one time. So what I like to do is usually set this to about 8 just to start out with. You can play with that also to increase your measurement accuracy or smooth out your measurements depending on which way you go with it. Of course, more averaging is going to be slower. It's approximately 200 microseconds per. Average, I believe.  We’ll do the same thing for. Sensor two click on bank one and sensor 2 and will change this average to about 8. Should be the same for both sensors.
OK, we could go online and synchronize this, but instead what we're going to do is we're going to flesh this out. Assuming all this is going to go OK, we're just going to flesh this out by adding the variables in the program that we want to use to use these two sensors together to calculate the thickness. So I'm going to go down to the data icon in my project tree and expand that. And then double click on global variables and bring those in. You can see that there's none there. So the first thing I want to do is create the variables for the sensors that we put into the Ethercat network.
The sensor amplifiers they have data that they exchange through variables. And we can do that by going to the IO map. By double clicking on IO map here, and then I'll click on the arrow next to the first ZW7000. And you can see there's all of this data that gets exchanged with the PLC over Ethercat, so I'm going to select the first one in the list, and then I'll click and shift and click the last one in the list. Right-click anywhere in that area and say create device variable with prefix by clicking this option here. The prefix by default is going to be “E001_”.  That's a normal prefix for an Ethercat node 1, or any other  node. It'll be “E” and then the node number following it. And when you read any of the documentation, the references will be similar to this with the E001 prefix on there. But I'm going to make this more readable to people and more user friendly, so I'm going to say “Sensor1_”. And that's going to add “Sensor1_” to all of the variable data here. So click on OK, and you can see all of these variables now have that prefix on it. I'm going to do the same thing with the second sensor head, so I'll click on the 1st entry, then I'll shift+click on the last one, right+click, click on create device variable with prefix, and change this to “Sensor2” with an underscore. OK, now when I go back to the global variables. You can see there's a whole list of variables that are assigned to those two sensors. We need additional ones for our program, so I'm going to click on the last variable in the data table. I'm going to right click and select “Create new” and you can see that I could also tap the insert key, which I'm going to do from now on, 'cause I'm a quick learner. In that space I'm going to create a variable. I want to be able to calculate or do a routine to calculate a value, an offset value, for these two sensors because they're never mounted exactly the same on any two applications you can be microns off and you want to account for that error, so I'm going to create a variable called “CalcK”. The K is going to be offset value amount, and it's going to be a Boolean just because this is the bit I'm going to use to execute that routine to calculate the value. Next I'll push the insert button on my keyboard and that gives me space for a new variable. And now that I've got the variable that will start the calculation, I want to actually come up with the variable that I'm going to calculate, so I'll call this one “Kvalue”. Only it's not going to be a bool, it's going to be a real. And then I also don't want to have to do this every time I power cycle the system, so I'm going to check the box under the “retained” field. So that once we calculate this K value, it will be retained. I'm going to create a few more of these.  The next one I want to create is the sensor one measurement value only in a real format, So I'll call it “S1measureReal”.  Then insert one more. I'll make that “S2MeasureReal”. I'm going to need a couple more. We need to know the thickness.  That's going to be a value that we're trying to get with all this, so I'll say we're going to come up with the calculated thickness. Type really loud. And that should be about all we need for our program now.

So the next step would be to create a program that we can use these variables in and all this data. So I'm going to look over in the tree view again. If I right click on the programs icon here I can select “add” and I'm going to add a structured text program because it's easier to type these equations in structured text than it is to do in ladder. I could also create a function block that would do this automatically. It would just be one function block that would encompass all this structured text that I'm going to write, but I'll just do it longhand here and say create or click on structured text program. So it added it in there. A good practice is that once you've added a program into the list here and you know you're going to use it in the PLC,  you want to add that into the task list.  So we’ll go to the task settings, click on the program assignment settings icon.  It looks like a sheet of paper. And I'm going to select program one from the list and it's going to automatically deselect program 0.  So if I wanted to use both of those, I would have to click on the plus sign to add a new space for program one.  And I'm adding it into the primary task as we want this to run as fast as possible.
OK, so I'm done with that. I can close it. I'm going to go back to my program. And I'll just put a comment in here and say “this is calculating the K value”. The structure we use is an IF-THEN, so “IF CalcKvalue,” which was our Boolean, “Equals true, Then Kvalue equals the Cal target” - which we did not add to our global table.  So we'll have to put that in in a second – “minus Sensor1MeasurementReal plus Sensor2MeasurementReal”. One other thing we want to do is, once we're done doing that calculation we want to turn off the CalcKvalue bit, so we’ll go “CalcKValueEquals false”. And then end that structure.

Now we've made this variable in the program here, but it's not a real variable, and so we're getting an alarm here. It says it's “undefined identifier”, so we might be able to click on this and register it in the variable table. And we can make it a global variable. And we’ll make it a real data type. If your software did not pop up the option to select whether it's a global or local variable like mine did, then you should go to our website and look for our tips page on Omron Sysmac Studio software.

The next thing I'd like to do in my program is to get the value from the sensors and turn it into a real number. It's a double integer by default, so we want to convert that double integer to a value that's more easily understood, which is a real number.  We use the “Senosr1_MeasureReal” and we're going to convert it to equal to “DINT_To_REAL” function on “Sensor1_OutputData”.  Sensor1_OutputData is the value that's going to be output to tell us what the sensor is reading. We’ll take that and multiply it by a factor to get the decimal point in the right place, so it's a real number: Real#1e-6.  We need that because we're going to have 6 decimal places. And I like to use spaces in here. I didn't put them in when I was typing, so it looks a little neater.  We're going to do the same thing to sensor 2.  So now what thos two lines do is just take the output values, the measurement values of each sensor, and convert them to a real number instead of a double integer.

OK, and then we need to get the thickness so the calculated thickness is going to be equal to the K value. For us let's Sensor1_MeasurementReal plus Sensor2_MeasurementReal. And since we already converted these from the double integer value that comes from the sensor, then all of our calculations are done in real values instead of double integers and then converted at the end.

And that's the whole program. So now that we've done it, we can build it.  We’ll go to the project menu and we’ll select build. Or we could press the F8 key as I mentioned before. And down in the bottom right hand corner you may see a little blue scrollbar. Sometimes it takes a little while to do the build. Sometimes the build goes really, really fast. And when you're done, you'll see some messages at the bottom here if there are any mistakes. OK, the build's done. So now we're going to go online. By clicking the online button there. And we'll synchronize. So we're going to synchronize everything now instead of doing it in steps.  We've set the Ethercat network correctly; we've set the sensor settings; we've created the program and the variables.  Now we're just going to transfer all that over to the controller.
Notice that I'm using synchronize here. I like to use synchronize. There is a “transfer to” and a “transfer from”, but I like to use “synchronize”. Mostly it's just a habit on my part, because when the software was first released with version 1.01, there was no transfer to; there was only synchronize, and so I've just gotten used to it. 

The synchronization process successfully finished. Some guys will re-compare, but once I see that the process is successfully finished. I just assumed that everything is OK. And click on “close” here. We can see some values coming in from the sensors already right here, and that's the measured values of each sensor coming in over the Ethercat network. Now there's zeros in these other numbers, but it seems like this should not be 0, because this is an algorithm or a calculation that converts this number into a real number. So the problem is that my PLC is not running. It's not in run mode, so I'll set it and run mode. More than likely you won't have this issue. I was fooling around with the PLC before and had to put it in program mode and just never took it back out of program mode. So once I put it into Run mode now you can see I'm getting the values converted from the double integer to the real.

So the next step is that we need to figure out what the K value is and the way that we do that is we’ll put a target in in between the two sensors of a known thickness, and in this case my known thickness on this caliper or this feeler gauge that I'm using is 0.63 millimeters, so make sure that that's in there between the two sensors and I'm going to set the cal target (calibration target) to .63 and then trigger this structure here to do the calculation. And so now there's our K value or offset value. And you can see the calculated thickness now measures at 0.63. And so if I take another feeler gauge and put it in here, a 0.5 mm feeler gauge, that's measuring 0.496.  So we're about four microns short there. If we found this to be a consistent measurement that we were always about four microns short, we could do an offset added to our calculation there.  That's the beauty of using the PLC for doing these measurements is that you have the flexibility to do any of the math that you want, control any IO points that you want, be able to read data from the sensor that could be useful. It's just everything is wide open over that Ethercat connection.

That's all for now. I hope you find this helpful. If you have questions you can call us at (855) 737-4716 or fill out our online form.