(True) Indirect Addressing in Rockwell Logix

Ed_Pethick

Member
Join Date
Aug 2018
Location
Midlands
Posts
7
Hi

It may be that I'm calling it the wrong thing, but every time I search for indirect addressing I end up looking at indirect indexing (to my mind) instead.
So, apologies for the bluntness but to try and ensure we're on the same page

I'm not asking about: Array[DINT] stuff

I would like to be able to address the Array as a String (Or similar) as this would make my life vastly simpler (I am aware that I could create a large Array of these strings, look them up and use their position to reference a specific array but this would be very cumbersome and require a lot of manual programming)

What I'd like to do is something like:

Move [Dint] into (String)[0]


So at one point it could be "Move 334 into BiscuitArray[0]" and at another point it could be "Move 663 into "CheeseArray[0]" for e.g. Depending on the Value of the tag giving me the String.


Thanks for reading & in advance for any replies.
Even if the answer is not known if you know that actually I'm looking for something called "x" then that would be much appreciated.

Regards
Ed
 
You want to do WHAT ?!?!

Welcome to the forum!

What I'd like to do is something like:

Move [Dint] into (String)[0]

So at one point it could be "Move 334 into BiscuitArray[0]"

It appears that you are trying to find a PLC equivalent to the VB "Set" function, as in:

Code:
Set myTag = "BiscuitArray"
myTag[0] := 334


If so, then no. There is no way to programatically change a "pointer" ('alias' in RS5K parlance) to a different tag name.

PLCs aren't very good at error handling. They don't have time for it. Every msec counts in some applications. If BiscuitArray[x] is an array of numbers, but CheeseArray[x] was an array of UDTs, the data type mismatch would crash the PLC.

Needless to say, while this is acceptable for a PC with just electronic data to get mangled, it isn't acceptable in a PLC where people and machinery can get mangled.

So every tag is deterministic as to a specific memory location. You can index numerically to a different range, but not go so some wildly different place.

Sorry.
 
That's a bummer

Thanks for your speedy reply :)

I'd like to think that simply crashing the PLC shouldn't end up in anyone getting hurt, if it does my safety probably needs looking at too...

Whilst I was kind of expecting that it wouldn't be standard practice, I don't see why it's uniquely dangerous - after all you could copy between totally incompatible datatypes if you really fancied and it would compile just fine and only fault as you ran it - even something as simple as indexing above an arrays' size will math fault out the PLC and that's allowed.

In my particular case then the PLC is not actually controlling anything, merely parsing data at speed garnered from other PLCs, the loss of this PLC would not immediately stop production, it would just mean that transfers of product stopped happening and so after a period of time some processes would be starved.

Speaking to Rockwell tech support, they seemed to think this should be possible but weren't sure how to do it as it's not part of what they cover. I'm happy to do it in ST if Ladder isn't capable - but yes a dynamic Set instruction is sort of what I'm after.
 
First you can not copy or move a DINT to a STRING data Type
You need to use the DTOS Function (Dint to String)
All strings are stored as an ASCII array the length of the array is the number of char
the max length is 85
The DTOS function dos the conversion for you.
 
The way I read this, there is a need for a two dimensional array where one dimension is a food type and the other is an (undefined) integer index. One approach would be to create the two dimension integer array, and for every access there would need to be a translation of the food type string to an integer, based on a fixed convention (e.g., Biscuit = 0, Cheese = 1, etc.) Alternatively there could be a single dimension array of a user defined type (UDT) consisting of a string and an integer array. In this case the UDT array would need to be searched for the matching string in order to access the integer array.

If one "dimension" is truly coming from a string, there would need to be some kind of search required for each string-based element access. The number of possible strings, and data access needs would help determine an effective design, and whether additional complexity is warranted (e.g., hashing)
 
In my particular case then the PLC is not actually controlling anything, merely parsing data at speed garnered from other PLCs

Is a PLC the best choice of hardware for the job in that case?

For just collating and moving about data, would a PC and an OPC server be the better choice?
 
Per technote 54960 "Indirect Access to Tag Data addressing in ControlLogix":

"Operation is asynchronous to program scan, via system overhead time-slice."

While this message-based approach is clever, that qualification is a red flag that needs to be carefully considered.
 
Is a PLC the best choice of hardware for the job in that case?

For just collating and moving about data, would a PC and an OPC server be the better choice?

Must of the PLC's I install are only handling data and have very few IO's, the reason I use PLC's for this job is reliabilit.

I have worked many years as a Oracle DBA, installing systems where we collected all production data into the database and made all merges and data handling there before replying back to the production floor, you have so many layers in this setup that can go wrong.

Since I switched over to use PLC's as my DB's and data handling (dual PLC setup) my systems has become rock solid, never any downtime :)
 
To clarify your question, you're looking for a way to get the value of a process variable by way of a string of that process variable's name. Example, what is the value of "MyTag"?

JaxGTO has the only workable answer by using the MSG instruction and as Mispeld points out, that is processed acyclically, so you will need to monitor for completion before moving onto the next call.

For people looking to solve similar puzzles on other platforms, like Codesys or B&R, you would use a library that provides information on process variables. A function in that library will give you the address of the variable when given the name as a string. You then use a pointer to get the data in that address. In B&R land, that would be PV_xgetadr()
 
It is possible and very easy to do. Check my thread here:
http://www.plctalk.net/qanda/showthread.php?t=105602


You basically use a MSG instruction to yourself.


Jack.

Per technote 54960 "Indirect Access to Tag Data addressing in ControlLogix":

"Operation is asynchronous to program scan, via system overhead time-slice."

While this message-based approach is clever, that qualification is a red flag that needs to be carefully considered.

Absolutely perfect Jack, tested & fully working - thanks! That has saved me weeks of work.
& Also thanks for pointing out the qualification, that could easily have tripped me up but I've covered for it in the program now.


FYI, The reason this is being done in a PLC is exactly the same as Holmux but also political/security - in many enterprises IT control computers and Engineering PLCs, trying to keep both happy when sticking in a small server is excruciatingly painful so it's much easier to add a PLC and use existing connections to DBs rather than add remote computers.
 
Thought I'd just add this info for anyone else who is looking at a similar situation;

If the string used for the remote tag is completely incorrect (Tag doesn't exist) then the message will simply display an error but will not fault the PLC
If the string addresses an array that does exist but of a size that doesn't then it will fault the PLC as normal. I'd suggest putting in some LEQs to catch this before it happens.
 

Similar Topics

Software Ver. 22.00.00, After the 1st time of being true the EQL. instruction is still allowing the rung to be true even though the inputs are...
Replies
7
Views
186
Have a noob question regarding OTL/OTU bits. Can someone look at the attached photo and tell me why both the OTL/OTU bits are true? Then they both...
Replies
8
Views
1,916
Hello. I have struggled all my Saturday with this one issue, and it is clear that only someone far more knowledgeable than me on CoDeSys can...
Replies
5
Views
2,573
Has anyone ever successfully used one of the fleaBay laptops with what would appear to be thousands of dollars of software e.g...
Replies
28
Views
8,774
Hi all, I'm just starting out in the plc world. For school we had some introduction into codesys v3.5, basically we get given visualizations and...
Replies
9
Views
2,337
Back
Top Bottom