Sign in to follow this  
Followers 0
Patriot

PLC-5 to ControlLogic Conversion Issues

6 posts in this topic

I am working on code that has been converted from a PLC-5 to ControlLogix. The old PLC-5 code was very heavy in its use of indirect addressing. Where bit indirect addressing was used, the RSLogix5000 code has replaced the indirect but address with long expressions. For example in the PLC-5 B3/[N7:0] would convert to something close to B3[N7_0 / 16].[N7_0 AND 15]. I understand why this was done, but it looks ugly. Since I am not to rewrite the whole program from scratch, I think I will have to live with these Boolean expresisons, since i cannot think of any way to clean it up. If I create a new tag to replace B3[N7_0 / 16].[N7_0 AND 15], then I will break the relationship with other parts of code that accesses data directly. For example, the new ControlLogix code has contacts and coils with direct addressing of bits within bit file B60. B60[15].2 If I also have indirect addressing of bit file B60 that looks like this: B60[(N7_15 AND 16#fffffff0) / 16].[N7_15 AND 15] I don't dare change the expressions to a new tag, because it won't be related to the parts of code that use direct addressing. Now, please.... before I get all of the responses that recommend rewriting the code for ControlLogix... I am a programmer, not someone who calls the shots. I would prefer to have it redone also, since I don't like the meaningless B60, N7_25, etc. type tags in the ControlLogix that I have now. If someone has some advice about how to make this new code look cleaner and keep it looking "somewhat" like its old PLC-5 self, I would welcome the comments. The goal would be to replace the expressions with a cleaner looking tag, but also not break the relationship that the data has with converted code that used direct addressing. If I can determine that there is no clean way to do it, I am fine living with the Boolean expressions as they are. I anticipate unhappiness with these expressions from the customer, but if I can convince them that I have exhausted other ways to work around it short of rewriting code.... Well, you get the idea. UPDATE: I am trying to locate a demo ControlLogix processor to test a few ideas. I will let you know how this works out. I also see I misspelled ControlLogix in the title. Edited by Patriot

Share this post


Link to post
Share on other sites
Just a couple of thoughts. Controllogix does have a global search and replace function when you are working with offline code. If you save as an L5K file and open the L5K with Excel or Notepad you also can replace tag references this way. it is even possible to have an excel macro generate an L5K file.

Share this post


Link to post
Share on other sites
I have done some further testing and I have found that B60[(N7_15 AND 16#fffffff0) / 16].[N7_15 AND 15] can be reduced to B60[(N7_15) / 16].[N7_15 AND 15] to make it look a little better. The expressions solve when I test them online. My only concern now is trying to comment a contact or a coil that has an expression like this. Since this is not a tag, I cannot put a comment right above the expression. I could comment the rung with info about the indirect addressing expression, but that would look messy also. Is there any way to comment an expression like the above for a contact or a coil?

Share this post


Link to post
Share on other sites
While still remaining "messy", you can alias the tags to something else; the new tag will work fine, and if you miss an old one it will work fine as well. The goal would be to alias something like "B60[(N7_15) / 16].[N7_15 AND 15]" to "MonkeyStatus[MS_index].[bitbit]" or whatever floats your boat. Just make sure the new addresses have the same array structure and you will be fine. Any math to be done can be done in one place, instead of every instruction. You will still have the mess, but you can hide it from your normal ladder logic. ...of course, it would be easier and cleaner if...

Share this post


Link to post
Share on other sites
I've been dealing with a similar mess. In addition, I used to have the program broken out into ladders and used rung titles extensively to break the individual ladders into logical blocks. With the "integrated diagnostics" mode, it was easy to browse a PLC-5 program. CLX uses programs and routines instead. The individual ladders became single routines. The rung titles were merged into the rung comments, leaving me with a huge mess and pretty much unrecognizable code again. The only way out of this is to make the ladders into programs and then break it up into individual routines. It will take some time. In addition, the addresses are readable but that's about as far as I'd go to call it. And they all got dumped into the controller address space. I thought about aliasing but in the end, I've pretty much concluded that the only good thing to do is to take an hour per day or so and carefully create all new data structures and do large search/replace options to use those new data structures.

Share this post


Link to post
Share on other sites
I am not sure how aliasing would be used in this case (as far as using the controller tag table). If I go to the controller tag table, I can alias one tag for another, but see no possible way to alias an expression. One way I simplified, was to add two CPT statements. One solves for the word value, and the second solves for the bit. I guess that could be considered a form of aliasing. We are probably talking about the same thing. Basically, I moved the expression away from the coil or contact to two CPTs, and then the coil or contact references B60[Word].[bit], where Word and Bit are the destination tags of the two CPT statements. Edited by Patriot

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0