https://www.AutomationDirect.com/servos
(VID-SV-0073)
Learn how to communicate with the SureServo2 Servo System via EtherNet/IP Explicit messaging.
With EtherNet/IP’s explicit mode you directly read and write parameters to the drive using ladder instructions. Explicit mode can be used as connected or unconnected messaging. “Unconnected” means there is no permanent connection to the target. Each read and write operation, opens a connection, does its thing, and closes the connection to the drive. Unlike the implicit mode where the PLC always stays connected to the drive and uses that open connection to continuously pass information back and forth transparently in the background for you. Let’s do a quick example. I have this AutomationDirect Productivity PLC connected to this SureServo 2 drive’s EtherNet/IP module like this. This video assumes you have already connected the EtherNet/IP module to the drive, have the most recent firmware in the module, and have configured the module for your network. Check out these videos if you need help with any of that. I’m not connected to a network, so we’ll use the EtherNet/IP modules default addressing. To get that we just go to parameter 3.064 and set it to a 1 - that does a factory reset on the module. We need to get the Productivity PLC on the same network, so in the productivity suite software, we go to the hardware configuration, CPU tab, double click on the base group CPU, double click on the CPU, ethernet ports tab, and set the static IP address to something that is compatible with your network. Since my drive is at dot 10, I’ll put the CPU at dot 1. This subnet mask is good and we’re using a direct connection, so we don’t have a gateway. Hit OK. Now we go to the EtherNet/IP tab, grab a generic client, and give it a name. We know the default address of the drive is 192.168.1.10 – again you would put whatever your drive's address is here – and I like to use a structure for my status tags. We are going to use unconnected explicit messaging where the ladder instructions take care of connecting to the target device. But if we were using a “connected” explicit message, then we would set that up by clicking on this plus sign and selecting the explicit message type. We don’t need any of that, so I’ll hit OK. It’s asking me if I want it to create all of these tags for me. I do, but I like to increase the size of any strings just to be sure there is room for any message that might be sent. Now that we have created all of those tags, we can go back into the device and click the monitor button to automatically build a data view of all of this stuff for us. Ok, so this is the EtherNet/IP device we will be talking to via EtherNet/IP explicit messaging – the SureServo 2 drive. In our ladder code, let’s say on the rising edge of C0, we want to send an explicit EtherNet/IP message. To this device, using explicit unconnected messaging. Let’s read the firmware version in parameter zero dot triple zero. The first two options in the service drop-down are for targeting the get and set instances of the assembly object. We want to use the SureServo 2 drive specific object, so we choose the generic option which allows us to change these values to get us to the SureServo 2 Drive object. If we look in chapter 9 of the user manual, we see a chart that shows us all the available classes. Remember, a class is just a template. An object is that template – or class with numbers filled in so it can actually do something. In particular, we want to talk to the drive parameters which is class 300 hex. And if we scroll down to the description of that guy, we see Instance is the parameter group number and the attribute is the parameter member which is really the offset to the parameter. And since each parameter is two 16-bit words wide, the parameter member is just the parameter number times two. We also see the usual read and write service codes for that class. So, since we want to read parameter 0.0, We just tell EtherNet/IP to use the 300 hex class code – which is 768 decimal, then we put the parameter group number here, the parameter member – which is the parameter number times two - here, and we want to do a read operation which the table said was a zero E hex – or 14 decimal for that class. Of course, to do a read we need to enable explicit messaging from the drive target to the PLC or “originator” and we need to tell the PLC where to put the reply. Since all SureServo 2 parameters are 32 bits – really two 16-bit words, we could put the result in a 32-bit word or two 16-bit integers. Use whatever makes your programming easier. I think we’ll put our result in a 32-bit word and we just need one of those. We’re only requesting one element and we are not writing anything, so I’ll leave that unchecked. I’ll add a structure, so we can monitor the progress of this command. When I hit OK, the software asks me if I want to create all of these tags. I do but again, I prefer longer strings to make sure they can handle any status messages we get from the drive. Now that the tags have been created, I’ll go back into that instruction and click on the monitor button to create a data view for all of those guys. And let’s add a rung comment reminding us what this was. Make sure the rung comments are enabled by clicking this guy. I’ll transfer that to the PLC and bring up the data view. And of course, we need to add C0 so we can enable our EtherNet/IP instruction. Let’s click on that and write it to the PLC and sure enough, our status tells us the operation was completed, it was successful, there was no error, which gave us no exception string, and there was no time out. And most importantly, it retrieved the firmware version. When we did that explicit read, it opened an EtherNet/IP connection. So if we look at the EtherNet/IP data view, we see it gave us the vendor ID of the drive, the drive's EtherNet/IP name and there were no errors and the connection is no longer open. Perfect. That was a read operation. Let’s write some drive parameters to control the SureServo 2 drive. Let’s do this: We’ll disable non-volatile memory writes from coms by setting parameter 2.030 to a 5. That’s important –non-volatile memories have a limited number of writes which is in the millions so normally it isn’t an issue, But with coms, you can eat that up really quickly if you aren’t careful, so it’s a good idea to disable non-volatile memory writes from coms in general and only allow it when you are absolutely sure you want something stored permanently. You re-enable writes to non-volatile memory by writing a minus 5 to parameter 2.030. Once we’ve protected our non-volatile memory, we’ll set parameter 2.030 to a 1 to enable the servo, parameter 5.007 to a 1 to trigger a position register path that I already put in the drive starting at path 1 – see this video to learn how to do that – and then we’ll send a minus 1 to parameter 2.030 to disable the drive. Let’s add a rung comment to remind us that we are using this rung to disable non-volatile memory writes from coms. Let’s use the rising edge of C1 to enable an EtherNet/IP message. We want to talk to this drive device we created, using explicit or unconnected messaging, and again, we want the generic service, so we can modify these guys. We want the drive parameter access class. And we want to write to parameter group 2. We want to write to parameter 30, but remember we have to double that to get the parameter offset or parameter member as it’s called in the manual. And we see in the manual a write service for this class is 16. We are not doing a read, but we are doing a write to the target drive. We want to write a 5 which we will put in a tag called disable NV writes. I like to use all caps for constants to remind me that value should never change. Again, all SureServo drive parameters are 32 bits so we’ll use a 32-bit integer for that. You can use whatever format makes your programming easier. You just have to end up with 4 bytes here because that what the drive actually needs to see. And were only sending 1 of those. And let’s add a structure to capture the status from this instruction. Hit OK and the software asks if it can create all of those tags for us. Sure, but again let’s make sure the strings are big enough to handle any message sent. Now that we have created all of those tags, let’s go back into that instruction and tell it to create a data view for those guys. The next write will be very similar to the write we just did so I’m just going to copy this rung and paste it here. Change the comment to remind us we want to enable the servo by setting parameter 2.030 to a 1, change the trigger bit, and we want to write to the same parameter 2.030 – remember we double the parameter number to get the offset - but we want to send a 1 which we will put in a tag called servo_enable which again will use a 32-bit integer. And let’s create a structure for this status. And I’ll increase the size of that string. Now that we created those tags we can go back into the instruction and hit the monitor button to create a data view for that. We’re gonna do another write, so I’ll just copy that instruction and paste it here. Change the comment and change the trigger bit. We want to write to parameter 5 dot 007. So, we’ll double the 7 and put a 14 here. We want to send a 1 which we’ll put in a tag a called path_1. Another 32-bit integer. And let’s create a structure for its status. And I’ll Increase the size of that string. Go back in and create a data view for that guy. Finally, let’s disable the servo. That’s almost identical to enabling the servo, so we’ll copy that instruction and paste it here. Modify the comment. Change the trigger bit. The only difference is we need to send a minus 1 which we’ll put in a tag called servo_disable – which will be another 32-bit integer - and we’ll create a new structure for this guy. And go back in and create a data view for that. I’ll transfer all of that to the PLC and bring up the data views. Ok, we need to add the trigger bits for each data view. C1 triggers this guy, C2 for this guy, C3 for this guy, and C4 for this guy. And don’t forget, we need to fill in the values we want to send. We want to send a 5 to disable memory writes, a one to enable the servo, we want to trigger path 1, and we need to send a minus 1 to disable the servo. Ok, the PLC is running, so let’s disable non-volatile memory writes by toggling this trigger bit. And we see that was successful. If I reach over and try to move the disk, I can feel the servo is not enabled. So, I’ll toggle this bit to enable the servo. We see the command was successful, but more importantly, I can feel it is enabled. Let’s trigger the path I set up in the drive-by toggling this guy. We see the command was successful, and that the path is definitely running. And let’s go over here and disable the servo by toggling this guy. Again, we see it was successful and that the servo motor stopped and is definitely not enabled. Well, that ought to be enough to get you started with reading and writing parameters to the SureServo 2 drive via EtherNet/IP explicit – or unconnected messaging. Click here to learn more about SureServo 2 and to find more tutorial videos. Click here to subscribe to our YouTube channel so you’ll be notified when we publish more videos like this and click here to learn about AutomationDirect’s free award-winning support team.
Voted #1 mid-sized employer in Atlanta
Check out our
job openings