Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identifying which tags are multidimensional? #14

Open
jdingus opened this issue Apr 11, 2018 · 10 comments
Open

Identifying which tags are multidimensional? #14

jdingus opened this issue Apr 11, 2018 · 10 comments

Comments

@jdingus
Copy link

jdingus commented Apr 11, 2018

Just want to say thank you for this library!
I have a project which I will be going up to 6 or 7 plcs and doing some data monitoring.
Using your library is there a method for determining which tags have an array rather than a single variable? Working on a script which provide a live update of the variables as the machine is running. Thanks again for all your work on this library.

@dmroeder
Copy link
Owner

dmroeder commented Apr 12, 2018

There is not a way. I'm curious though... maybe I can come up with something.

Can you give me a bit of context on what you are planning on doing? Maybe with tag name examples and datatypes?

Are these tag names that you already know, but the same tag is an array in one PLC but not in another?
Or are you using GetTagList to get tag names, then trying to read them?

@jdingus
Copy link
Author

jdingus commented Apr 12, 2018

Envisioning connecting to a PLC and running and running GetTagList() and then from that maybe opening up a flask dev server which would serve up in a data table the tag lists generated along with their datatypes and the values.

I could refresh the data on the server side maybe every 5 seconds or whatever would be reasonable and thru ajax refresh the browser in real-time.
In order to serve up the data I would need to know if the tag is multidimensional and how large.
I'm not very familiar with PLC tags but I would think only certain datatypes can be multidimensional?

The dev PLC I'm doing some initial prototype work on is a CompactLogix.
All PLC's I"m working with will be completely different implemented by different people at different times making different parts

I do not know what the tag names are coming up to the machine and I'm trying to determine which tags I want to use for data collection.

My use case for this would be to connect to a machine while it is producing parts and use the tag names and the data values to quickly determine which data is relevant for my project.

Attached an example output of tags and data types.
TagList_csv.txt

Thanks again

@dmroeder
Copy link
Owner

dmroeder commented Apr 12, 2018

Ah I see. This will be much more difficult. It is not impossible, but not currently possible. On my list of things to work on, I have always thought it would be cool to do exactly what you are after, just connect to the PLC, get the tags, and start reading them.

You are correct, the PLC has arrays, and multi-dimensional arrays (up to 3 dimensions). Using more than one dimension is a bit uncommon though, but I suppose that doesn’t matter.

A Logix PLC has a few basic data types: STRING, SINT, INT, DINT, LINT, REAL, BOOL. Then there is the UDT. UDT is a user created data type, or a data type that is made up of the base data types. When requesting the tags, I get the tag name and basic data type. The problem that I need to solve is interrogating the UDT’s to get down to their basic data type.

Let’s say we have a UDT called “Person”, it’s made up of a “Name”(STRING) and an “Age” (SINT). So we create an instance of it and we have Bill.Name and Bill.Age. When you request the tag list, you will get Bill, and it will be identified as a UDT. A tag called MyTimer that is the TIMER data type also appears to be a UDT. What would need to happen is we would need to find out the makeup of “Person”. Then you add the possibility of nested UDT’s and arrays, it gets more complicated. And the process takes a bit longer.

This is something I hope to work out as time allows. One user shared a clever way of working with UDT’s which involved exporting the PLC program to a L5X file (which is essentially XML). You can fairly easily parse a L5X in python to get the tag names and structures, then read the tags that were in the L5X. This may be an option for you for now. I'll think about this some more...

@jdingus
Copy link
Author

jdingus commented Apr 15, 2018

Thanks for info on parsing the L5X export.

Would work just fine and already some good libraries developed.

@dmroeder
Copy link
Owner

Hopefully I'll sort out getting a more complete picture of the tags soon. I've been experimenting with some ideas. Stay tuned...

@su600
Copy link

su600 commented Sep 26, 2019

Thank you for this library too!
Is there any progress on this issue? Can we indentify the dimensional of Tags now ?

@TheFern2
Copy link
Collaborator

TheFern2 commented Mar 11, 2020

Could this be done by brute force?

try a tag[0], if it returns something, then try tag[0][0] , and just keep going until you get None. That's one way to find out the depth of a tag.

Thoughts?

@ottowayi
Copy link

You can get the dimensions of a tag by reading attribute 8 for the Symbol Object. Here is how I do it.

@dmroeder
Copy link
Owner

Thanks for the details @ottowayi, I'll check into it.

@th3dj
Copy link

th3dj commented Mar 31, 2020

I just used the l5x parsed it and read the Demention tag and then a
ref = comm.Read('tag', dementionvariable)

That way it just pulls the whole array. My first try used a while loop but it wasn't to my liking and lists are easier to work with plus i don't have to assemble all the output form the read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants