You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old August 16th, 2022, 12:45 PM   #1
mylespetro
Supporting Member
Canada

mylespetro is offline
 
mylespetro's Avatar
 
Join Date: Dec 2015
Location: NS
Posts: 686
PLC5 to Logix conversion - Double indirect addressing

Hey everyone,

Just used the PLC5/Logix migration utility to convert a program, and while addressing the PCEs, I noticed a lot of errors for "XIC (or XIO), Operand 0: Invalid expression or tag." When I clicked on it, it brought me to a section of the program where there are about a dozen instances of double indirect addressing (not sure if that's the right term or not, but it's the best I can think of ). For instance, in the original PLC5 program, one instance is addressed as N[N377:1]:[N377:36].14, while in the converted Logix program it's addressed as N[N377_1][N377_36].14, which understandably doesn't work. For reference, the values evaluate to N[21]:[49].14 in the PLC5 and N[21][49].14 in the Logix program.

I understand why this doesn't work on the Logix side, and have found a couple really good threads of people having the same (or similar) issue, and gather that the solution is probably to utilize two-dimensional arrays, but I'm having a little trouble wrapping my head around the actual implementation of it. I'm assuming that if I set it up correctly, instead of N[N377_1][N377_36].14 or N[21][49].14, I would have N[21,49].14, but there was mention of setting up intermediate DINT tags as two-dimensional arrays and using MOV instructions and I was just looking for a bit of clarification on the actual procedure of utilizing dimensional arrays to properly convert the PLC5 addressing to Logix addressing. I'll try to get some screenshots of both programs and post them here.

Thanks in advance
  Reply With Quote
Old August 16th, 2022, 12:50 PM   #2
mylespetro
Supporting Member
Canada

mylespetro is offline
 
mylespetro's Avatar
 
Join Date: Dec 2015
Location: NS
Posts: 686
Screenshots of the same rungs in both programs attached
Attached Images
File Type: png PLC5 Indirect Addressing.PNG (46.6 KB, 20 views)
File Type: png Logix Indirect Addressing.PNG (33.1 KB, 20 views)
  Reply With Quote
Old August 16th, 2022, 01:40 PM   #3
drbitboy
Lifetime Supporting Member
United States

drbitboy is online now
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,587
the first thing I would do is export the Logix version to .L5X, open that .L5X with a text editor (Notepad or Notepad++), and to a find-and-replace of all occurrences of ][ with , (comma).


Also, the branches in the middle of Rung 0004 can be simplified, with the common [XIO N[N377:27][4].0] instructions removed from the branches and inserted onto the main rung, although there is nothing wrong with how it is, and it might be easier to read and understand.


Anyway, to get to the main question, both PLC-5 and Logix programs are using two-dimensional arrays.

However, since PLC-5 does not have 2D arrays per se, or even 1D arrays for that matter, they are implemented using intra-Data-File element numbers as one dimension, and contiguous Data Files and file numbers as the additional dimension.

The key steps will be determining
  • How many different types of 2D arrays there are e.g. does element 4 always contain the same bits with the same meaning for that row?
  • What are the ranges for the file numbers (rows or data structures; BLK_I1=N377:0=N377_0, BLK_I2=N377:1=N377_1, N377:27=N377_27)?
    • If the file numbers are too large and/or start at a large number, there may not be enough memory, and the lower rows of the 2D array will be unused empty space.
    • The fix for that is to use a negative offset to reduce the lowest file number to 0
      • Which offset will be applied to the values of the "Data File Numbers| N377_0, N377_1, and N377_27.
      • I suspect that offset is already present in the PLC-5 program's calculation of those data file numbers
  • What are the ranges for the data elements (columns within a row or data structure; PMT_ID=N377:27=N377_27)?
Because what this kind of 2D-hackery in PLC-5 is probably trying to do is implement a form of the Object Oriented Programming approach by treating each of a contiguous range of N (Integer) Data Files as a structure that models some entity, with each entity comprising several attributes (binary states and values) that can be represented by the Integers, and bits within integers, of the elements in that structure (structure = array of Integers; element = one Integer in the array; state = one bit in an Integer).
__________________
_
Brian T. Carcich
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
iii) Measurement is hard.
iv) I solemnly swear that I am up to no good

Last edited by drbitboy; August 16th, 2022 at 01:43 PM.
  Reply With Quote
Old August 16th, 2022, 01:47 PM   #4
drbitboy
Lifetime Supporting Member
United States

drbitboy is online now
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,587
Simply put, this task boils down to bookkeeping.
__________________
_
Brian T. Carcich
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
iii) Measurement is hard.
iv) I solemnly swear that I am up to no good
  Reply With Quote
Old August 16th, 2022, 02:00 PM   #5
mylespetro
Supporting Member
Canada

mylespetro is offline
 
mylespetro's Avatar
 
Join Date: Dec 2015
Location: NS
Posts: 686
Quote:
Originally Posted by drbitboy View Post
the first thing I would do is export the Logix version to .L5X, open that .L5X with a text editor (Notepad or Notepad++), and to a find-and-replace of all occurrences of ][ with , (comma).


Also, the branches in the middle of Rung 0004 can be simplified, with the common [XIO N[N377:27][4].0] instructions removed from the branches and inserted onto the main rung, although there is nothing wrong with how it is, and it might be easier to read and understand.


Anyway, to get to the main question, both PLC-5 and Logix programs are using two-dimensional arrays.

However, since PLC-5 does not have 2D arrays per se, or even 1D arrays for that matter, they are implemented using intra-Data-File element numbers as one dimension, and contiguous Data Files and file numbers as the additional dimension.

The key steps will be determining
  • How many different types of 2D arrays there are e.g. does element 4 always contain the same bits with the same meaning for that row?
  • What are the ranges for the file numbers (rows or data structures; BLK_I1=N377:0=N377_0, BLK_I2=N377:1=N377_1, N377:27=N377_27)?
    • If the file numbers are too large and/or start at a large number, there may not be enough memory, and the lower rows of the 2D array will be unused empty space.
    • The fix for that is to use a negative offset to reduce the lowest file number to 0
      • Which offset will be applied to the values of the "Data File Numbers| N377_0, N377_1, and N377_27.
      • I suspect that offset is already present in the PLC-5 program's calculation of those data file numbers
  • What are the ranges for the data elements (columns within a row or data structure; PMT_ID=N377:27=N377_27)?
Because what this kind of 2D-hackery in PLC-5 is probably trying to do is implement a form of the Object Oriented Programming approach by treating each of a contiguous range of N (Integer) Data Files as a structure that models some entity, with each entity comprising several attributes (binary states and values) that can be represented by the Integers, and bits within integers, of the elements in that structure (structure = array of Integers; element = one Integer in the array; state = one bit in an Integer).
I'm not exactly positive on the answers to your questions, as this is only my second time working with indirect addressing in general, and my first time working with indirect addressing requiring two-dimensional arrays. I've attached another screenshot of the start of the subroutine with some good information for context in the description for rung 0000. The subroutine is being called in the previous subroutine, with some parameters being passed into it. I'm also going to attach the program itself, the subroutine in question is LAD 20.
Attached Images
File Type: png PLC5 Parameter Passing.PNG (54.5 KB, 11 views)
Attached Files
File Type: zip LINWTP 5 30_APR16.zip (11.6 KB, 4 views)
  Reply With Quote
Old August 16th, 2022, 03:39 PM   #6
drbitboy
Lifetime Supporting Member
United States

drbitboy is online now
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,587
Quote:
Originally Posted by mylespetro View Post
...I'm also going to attach the program itself, the subroutine in question is LAD 20.

PDF would be easier, as not everyone has RSLogix 5.
__________________
_
Brian T. Carcich
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
iii) Measurement is hard.
iv) I solemnly swear that I am up to no good
  Reply With Quote
Old August 16th, 2022, 03:45 PM   #7
drbitboy
Lifetime Supporting Member
United States

drbitboy is online now
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,587
Do the Data File numbers (BLK_I1=N377:0=N377_0, BLK_I2=N377:1=N377_1, N377:27=N377_27) change their values while the program is running?

Or perhaps, and I am guessing here, BLK_I1, BLK_I2, and N377:27 were at one time fixed (maybe hard-coded) at 20, 21, and 25, and they were change to N377 Data File Elements so the subroutine could be inserted into different existing programs if Data Files 20, 21, and 25, were already allocated?
__________________
_
Brian T. Carcich
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
iii) Measurement is hard.
iv) I solemnly swear that I am up to no good
  Reply With Quote
Old August 17th, 2022, 08:35 AM   #8
mylespetro
Supporting Member
Canada

mylespetro is offline
 
mylespetro's Avatar
 
Join Date: Dec 2015
Location: NS
Posts: 686
You’re totally right, I’m used to posting programs (ML1100/1400 or Logix) that most people on here would be able to open, but not as many people would be able to open a Logix5 program. I’ll make a PDF of the program when I get a chance and post it.

I haven’t actually seen the program running, I’d have to dig in and cross reference the addresses to see if they change at any point.
  Reply With Quote
Old August 17th, 2022, 09:51 AM   #9
mylespetro
Supporting Member
Canada

mylespetro is offline
 
mylespetro's Avatar
 
Join Date: Dec 2015
Location: NS
Posts: 686
PDF of the PLC5 program attached. I was working on the converted Logix program and realized that for some reason, the conversion didn't actually create an "N" tag, only "N377[X]"/"N377_X" etc.

I created a two-dimensional DINT[100,100] "N" tag, and essentially did what drbitboy said, replacing every instance of "][" with "," which caused all of the errors to go away. Of course, all of the values of those new two-dimensional tags (e.g. N[N377_5,N377_36] which is N[25,49]) are 0, so I still have to go through the program and see if the values of those tags are dynamic or if they're initialized somewhere.
  Reply With Quote
Old August 17th, 2022, 11:46 AM   #10
drbitboy
Lifetime Supporting Member
United States

drbitboy is online now
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,587
Quote:
Originally Posted by mylespetro View Post
PDF of the PLC5 program attached.

...

Um, maybe you forgot to click the [Upload] button?



Quote:
Originally Posted by mylespetro View Post
I ... replacing every instance of "][" with "," which caused all of the errors to go away.

sweet hack!


The rest is bookkeeping, looks like you are on your way.
__________________
_
Brian T. Carcich
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
iii) Measurement is hard.
iv) I solemnly swear that I am up to no good
  Reply With Quote
Old August 17th, 2022, 12:25 PM   #11
mylespetro
Supporting Member
Canada

mylespetro is offline
 
mylespetro's Avatar
 
Join Date: Dec 2015
Location: NS
Posts: 686
Quote:
Originally Posted by drbitboy View Post
Um, maybe you forgot to click the [Upload] button?
I sure did
Attached Files
File Type: pdf LINWTP 5 30_APR16.pdf (2.17 MB, 7 views)
  Reply With Quote
Old August 17th, 2022, 03:29 PM   #12
drbitboy
Lifetime Supporting Member
United States

drbitboy is online now
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,587
Hah!

The use of ...blah].[blah... is confined to Program File LAD 20, the Permit Window Subroutine, which has 10 rungs. And there are 46 calls (JSR U:20), just over half of which are all called with all constants.

So almost certainly that routine can be replaced by an AOI.


The Data File numbers in Data File N377 are all fixed numbers and never changed that I can detect. E.g. N377:27 is 54, so N[N377:27]: is N54:, which appears to contain global values, never changes.
__________________
_
Brian T. Carcich
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
iii) Measurement is hard.
iv) I solemnly swear that I am up to no good
  Reply With Quote
Old August 18th, 2022, 07:40 AM   #13
mylespetro
Supporting Member
Canada

mylespetro is offline
 
mylespetro's Avatar
 
Join Date: Dec 2015
Location: NS
Posts: 686
Quote:
Originally Posted by drbitboy View Post
Hah!

The use of ...blah].[blah... is confined to Program File LAD 20, the Permit Window Subroutine, which has 10 rungs. And there are 46 calls (JSR U:20), just over half of which are all called with all constants.

So almost certainly that routine can be replaced by an AOI.


The Data File numbers in Data File N377 are all fixed numbers and never changed that I can detect. E.g. N377:27 is 54, so N[N377:27]: is N54:, which appears to contain global values, never changes.
Yeah, I managed to scrounge up a spare ControlLogix chassis with a processor and downloaded the program onto it and it seems to be running fine. The existing system is attached to a custom DCS system (the precursor to VTScada) so there is the possibility that the DCS does write different values to those tags (N377:27 for example), but I haven't gotten to poke around that end of it yet.

If I had a bit more time (and leeway) to do so, I would try to roll my own AOI and have one AOI replace each JSR in subroutine 17, but I think we'll try this the way it is now. It's on a water treatment plant that has a lot of downtime, so we should be able to disconnect the current PLC-5 from the network and plop the ControlLogix in as a test to see if the program functions properly without actually running any equipment.

As usual, thanks for your insights and help, always appreciated!
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
4 threads on RS5000 indirect addressing not enough... NotaHippie LIVE PLC Questions And Answers 8 May 1st, 2019 11:11 AM
Help With Indirect Addressing In Studio 5000 Conversion From Rs500 kentuckytech LIVE PLC Questions And Answers 7 January 21st, 2015 12:03 PM
PLC5 Conversion to Logix - PID Question robbo LIVE PLC Questions And Answers 0 May 29th, 2013 12:10 AM
PLC5 and Indirect Addressing kdcui LIVE PLC Questions And Answers 3 October 23rd, 2008 10:46 AM
Ab Rs Logix Indirect Addressing PERSPOLIS LIVE PLC Questions And Answers 4 December 23rd, 2002 03:33 PM


All times are GMT -4. The time now is 03:33 PM.


.