![]() ![]() If you are unlucky, your PLC vendor will make you pay an extra license fee for the Modbus functionality. Hopefully, the information is right there in the help menu or manual. Setting up the variablesĮnabling the Modbus server and configuring which PLC program variables to make available through Modbus works differently for each brand of PLC. Numbers require more than one bit to store and I want to write it, not just read, so I will be using a register address in the 40,000 range.īefore we can write any values over the network, we’ll have to tell the PLC which piece of information to store in which of the Modbus register addresses. In the example below I am going to change a time interval, measured in hundredths, by sending a Modbus message from my laptop to the PLC. Since Modbus has no authentication or user agent headers or anything like that, your “first” PLC can’t tell if another PLC or a laptop is sending Modbus commands to it. When you use a Python library to make a laptop (or server or RaspberryPi or whatever other device you run your Python code on) send Modbus commands, you are basically emulating that “second” PLC. When using an existing Python library (like we do below), there is no need to know the details about those.īut if you’re curious, the Wikipedia page about Modbus has an absurd amount of detail on the command types.Īs I mentioned above, Modbus was invented to allow two or more PLCs to communicate with each other. The Modbus protocol defines a collection of message formats for reading and writing registers, either one-at-a-time or in groups. Address rangeĪll PLC programming software tools that I have seen guide you through this and won’t let you assign an incorrect address. The register address space is divided into four groups.Įach group is defined by the data type that can be stored in it and its read/write permissions. Instead of variable names, Modbus uses register addresses to identify the variables on the server. The client, or “master”, are those other entities which send network requests in order to read or write the values of variables stored in the server. The server, or “slave”, is the entity that maintains a list of variable values and allows other entities to change them through network requests. The protocol dates itself by using the “master/slave” terminology to refer to these roles. If you’re in a rush, you can step reading now.Įverything below are details on how to do this accessing of variables over Ethernet 3. The key point is: Modbus allows read-write access to PLC program variables 2 over Ethernet or Serial. It’s also an open standard and virtually universally supported in PLCs and with libraries in many programming languages including Python.Įnough reasons for me to use it when demonstrating the connection of Python and PLCs in my conference talks! Today, many other protocols exist to serve the same and similar purposes and I will cover some of them in the next post of this series.ĭespite, or maybe because of, being a rather primitive protocol, Modbus is still widely used today. (The name “Modbus” derives from the company name Modicon, the inventors of the PLC.) Modbus is a communication protocol to address this need that was invented soon after the first PLCs. To do this requires either PLCs talking with each other or to a central point of coordination. However, since the early days of PLCs, there has been a need to control larger systems such as HVAC in large buildings or long production lines. Just wire all the sensors and actuators to the PLC’s I/O terminals and put a program on the PLC. Modbus: Two PLCs talking to each otherĪ PLC by itself is great for controlling a single machine or even a small production line. If you find yourself working with PLCs in academia or for a hobby project, you might actually be the one doing these things yourself.Įither way, I assume that you somehow found yourself with a programmed PLC and now want to connect to it using Python. In industry, the Python developer is usually not involved in the purchasing, installing, and programming of a PLC. In the previous parts of this series, I covered what a PLC is, and how PLCs are programmed. ![]() This post is part 4 of a series covering material I presented in a talk at P圜on 2019.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |