Ethernet/IP AB Logix5000 PLC - Set bit with .exe

Anthony92

Member
Join Date
Aug 2019
Location
Sydney
Posts
6
What is the best way to set a bit over an ethernet/IP network on an Allen-Bradley ControlLogix Series PLC from a Windows PC.

We have a program running on a plant networked Windows PC that is able to run an executable or script when a measurement is recorded out of tolerance. But we want to be able to write a bit on the controller from the PC when this happens.

Is there a simple way/script to connect to the IP address of the PLC and write some data to a tag? Or will I have to write my own solution using Ethernet/IP drivers such as AdvancedHMI E/IP to accomplish this?
 
It's just a rough script using tkinter, there is a lot of room for improvement:

Code:
import pylogix
import tkinter as tk


class Pylogix_App():
    def __init__(self, driver):
        self.root = tk.Tk()
        self.root.geometry("350x100")

        self.driver = driver


        self.l1 = tk.Label(text="IP Address")
        self.address = tk.Entry(self.root)
        self.address.insert(0, "192.168.1.10")

        self.l2 = tk.Label(self.root, text="Slot")
        self.slot = tk.Entry(self.root, text="0")
        self.slot.insert(0, "0")


        self.read_button = tk.Button(self.root, text="Read Tag", command=self.read)
        self.read_tag = tk.Entry(self.root)
        self.value_text = "None"
        self.read_value = tk.Label(self.root, text=self.value_text)

        self.write_button = tk.Button(self.root,text="Write Value", command=self.write)
        self.write_tag = tk.Entry(self.root)
        self.write_value = tk.Entry(self.root)


        self.l1.grid(row=0, column=0, padx=0)
        self.address.grid(row=0, column=1, padx=0)
        self.l2.grid(row=0, column=2, padx=2)
        self.slot.grid(row=0, column=3, padx=2)

        self.read_button.grid(row=1, column=0, padx=2)
        self.read_tag.grid(row=1, column=1, padx=2)
        self.read_value.grid(row=1, column=2, padx=2)

        self.write_button.grid(row=2, column=0, padx=2)
        self.write_tag.grid(row=2, column=1, padx=2)
        self.write_value.grid(row=2, column=2, padx=2)

        self.root.mainloop()

    def read(self):
        self.driver.IPAddress = self.address.get()
        tag = self.read_tag.get()
        ret = self.driver.Read(tag)
        self.read_value.config(text=ret.Value)


    def write(self):
        self.driver.IPAddress = self.address.get()
        tag = self.write_tag.get()
        val = int(self.write_value.get())
        self.driver.Write(tag, val)
       
comm = pylogix.PLC()
app=Pylogix_App(comm)
 
I am getting this, trying to connect to my Micro820 at .160:
>>> import pylogix
>>> comm=pylogix.PLC("192.168.1.160")
>>> tl=comm.GetTagList()
>>> tl
Response(TagName=None, Value=None, Status=Forward open failed)
In WSL.

Can pylogix work from WSL? Or does WSL being behind a router (essentially) mess things up?

Do I have to configure a Micro820 in a special way for pylogix to connect to it?

I can ping 192.160.1.160 from WSL.
 

Similar Topics

I have a project a customer supplied an old version 5555 CPU (1756-L55) that I flashed to version 16.22 (the highest it would support) Using...
Replies
6
Views
2,315
Hi all, I'm trying to setup Ethernet messaging. The following describes it very well: http://www.plctalk.net/qanda/showthread.php?t=51059 I have...
Replies
8
Views
2,088
Hi Guys! I'm setting up a small DLR test system at my desk, consisting of one CompactLogix PLC and one FC102 (Danfoss drive). If I use the EDS...
Replies
5
Views
3,374
I've been searching for Ethernet Drivers so that I can view my PF70, 700,40 and 525 AB VFD's in Logix5000. They look *** if they are connected to...
Replies
15
Views
4,501
Hi, folks, how’s going? We just get one new production line with Logix5000 system. But I cannot understand why there are 4 Ethernet cards and 1...
Replies
17
Views
14,032
Back
Top Bottom