RX3i Decompose a variable in the PLC program

Ozpeter

Member
Join Date
Aug 2014
Location
Virginia
Posts
124
Hi all,
Given a variable VAR1 at an address of %R101 is it possible within the PLC program to decompose this so that you can say the address is of type "R" and that the offset is "101"?

The reason I want this is that I am dealing with code that will use a lot of Comm_Req blocks and that in order to use them you have to explicitly define the memory type and offset of a variable - which requires a lot of manual intervention in order to correctly configure it.

I would love to simply say to some code "Here's the variable, you work out the memory type and offset"
 
GFK-2224 details comreq command block values (section 9.2.2). Each address type is defined by a value (%R is an decimal 8, %AI is a decimal 10, etc etc). Also, 9.2.2 details that the CRS word address offset is a zero offest, meaning if you want %R101, word four of the comreq commend block should be a decimal value 100


GFK-2224 download:

https://digitalsupport.ge.com/en_US...munications-User-Manual-GFK-2224D-DO2008-enUS
 
GFK-2224 details comreq command block values (section 9.2.2). Each address type is defined by a value (%R is an decimal 8, %AI is a decimal 10, etc etc). Also, 9.2.2 details that the CRS word address offset is a zero offest, meaning if you want %R101, word four of the comreq commend block should be a decimal value 100


GFK-2224 download:

https://digitalsupport.ge.com/en_US...munications-User-Manual-GFK-2224D-DO2008-enUS

I am aware of this, but it requires manual intervention in multiply places in order to make a simple program change EG if my status register is at %R101 and want to change it to be %201 then I both have to know whether or not I am using it in a Comm Req block and if I am, I have to know to manual set the constants as required (and that the offset is Base 0)

This reliance on manual intervention for program correctness would have gotten you laughed at in any other programming field and would be seen as a major code smell.

What I am striving for is a technique where I can feed some code a reference to %R101 and have it pop out 8 and 100, so that I can then remove the most flawed part of coding a PLC from the software process - the person programming it.
 
Just speculating here, but would you be able to do what you want if you use default variable names? When you create a new variable addressed to %R101 it will have the default name R00101.
Also, COMMREQ instructions support indirect addressing. That won't help you with discrete memory types though.
 
Last edited:
Just speculating here, but would you be able to do what you want if you use default variable names? When you create a new variable addressed to %R101 it will have the default name R00101.
Also, COMMREQ instructions support indirect addressing. That won't help you with discrete memory types though.
Aside from default names being evil, do you mean aliased variables?
 
Since I don't fully understand what you're trying to accomplish, all I'm doing is to throw out ideas which you may or may not have already tried.
I've never created one myself, but I know the Rx3i supports user-created function blocks written in C. I expect you could decompose the default variable name. The first character of the name could be used to set an integer to the appropriate memory type identification. The remaining characters in the name converted to an integer representing the offset.
Is the designation of which memory location you're trying to access coming from an HMI? If so, it shouldn't be too difficult to prompt an operator for a string data entry like "R101" and write a script to break that string into memory type and offset.
 
Last edited:
Since I don't fully understand what you're trying to accomplish, all I'm doing is to throw out ideas which you may or may not have already tried.
To explain it explicitly:

For a Comm Req command you supply a Status Register that will receive the status of the Comm Req operation. EG A variable StatusReg at %R101

To convey to the Comm Req that you wish to use StatusReg for a command, you have to look the address of StatusReg, decompose it (in your mind) to the memory type (%R) and address (101)

Those values are then inserted into the Comm Req command block definition registers, with a value of 8 being used to indicate %R, and the base 0 offset of the address, 100.

Thus there is only a coincidental link between what you as a programmer thinks of as the Status Register and what the Comm Req block thinks of the status register. A change in either location will break that tenuous link.

EG if after the fact I decide that I want my StatusReg at %W123, I can edit the variable definition and now all my tests of the StatusReg will refer to the data stored in %W123. However the Comm Req block will continue to write the actual status information to to %R101 - unless I manually change it there as well (which in the heat of the moment can be easily overlooked)

What I am looking for is method to take the variable StatusReg at %R101 and programmatically determine 8 and 100 (or 0xC4, 122 in the case of %W123), so that it can be automatically inserted into the CommReq command block definition. In that way there will be an explicit link between both mine and the Comm Req's understanding of the status register.
 
Your best bet may be to create a C function block.
As I see it the advantage to your method is that you only have to change one thing, the address of the variable you want to use for the COMMREQ status word. What actually has to change is two addresses, the values in the third and fourth word of the COMMREQ command block. Are you always using the same address for the COMMREQ command block?
From your description I assume you want to go online with PME and change the address of a variable and then use that information to change the values in the third and fourth words of the COMMREQ command block. Here's a possible way to automate the process using a script in an HMI target.
If you don't already have a View target as part of your project, create a windows PC View target that talks to the PLC. Put a string data entry object on a screen of the HMI and use it to enter the address where you want the COMMREQ status to appear in the form. Using the (admittedly limited) string handling functions in Proficy Viewscript or VBScript to break apart the string and write the appropriate values to the addresses of the third and fourth words of the COMMREQ command block.
If you have to create a new View target because the project doesn't already have one, you can run the HMI target on the same PC that you're using to monitor the PLC by using the demo mode. That lets you download the HMI to the host PC. You have to make sure to enable I/O when you do the download. It defaults to disabled.
 
If you want to do it all in the PLC, (or if your you don't have a Proficy View development license) create a 6-character STRING variable in the PLC and write the address to that variable such as R00101. That will take up three consecutive words with two ASCII characters per word. Using AND and DIV instructions in ladder logic you can isolate each character and perform the necessary arithmetic to construct an address offset and select the appropriate value for the memory type the COMMREQ instruction needs.
 
Last edited:
Your best bet may be to create a C function block.
...
I just read 2012 C function block manual and it looks like you can't even do it there. All you get passed in are raw C pointers. Well maybe you could plot the memory layout of a system and use that to guess where in memory space the reference comes from .. but argh.

As for the Rube Goldberg methods .. I think they are as bad or worse than the problem itself :D

The answer is looking like NO.
 
Suit yourself. You asked if there was a way to do it.

I gave you a couple of possibilities.
I understand what you are suggesting, but to me it appears that you have haven't actually solved my issue - merely shifted it. There is still no explicit connection between the Status Register variable and the address. The only way that could occur is if the string variable gets automatically populated with the full address of the Status Register. Otherwise it is still a manual intervention in two locations - the address of the Status Register and the contents of the string variable.
 
Given the nature of the way the engineers at GE built the COMMREQ function, there is no way around the need to enter data into two locations, namely words three and four of the COMMREQ command block. Those two pieces of information specify the location in PLC memory where the status code of a particular instance of the COMMREQ function is located.
As to why they didn't specifically define one of the words of the command block as the status word, I don't know.
 

Similar Topics

Hi there, I'm doing some extensive testing and commissioning with a slew of new Emerson PACSystems RX3i PLCs. It would be convenient to...
Replies
5
Views
80
Hi there, Trying to get some ascii serial communications working via RS485 (COMMREQ functions). I have attached our wiring for the COM2...
Replies
1
Views
947
Hello all, First time poster, long time viewer of these forums. Could not find my solution on here. We have had issues with a Comm Fail on an...
Replies
2
Views
339
Spoke to a few outlets including Emerson and some distributors. Apparently updating firmware on subsequent modules past the CPU still uses...
Replies
1
Views
349
Hi I am a beginner to the GE PLC. I am working on a project to install two new viewmarq display. Has anyone ever connected or worked with this...
Replies
4
Views
358
Back
Top Bottom