Help with Indirect Addressing on RSLogix 5000

Join Date
Nov 2021
Location
United States
Posts
37
I’m working with indirect addressing and trying to make an HMI where each Rectangle Object has a tag of “A[0-127]” with a correlating Push Button with a tag of “PB[0-127]”. How would I make it to where I could say if PB[35] is turned true, put a value of 1 at A[35] without having a separate rung for each PB. To reiterate, how do I connect the DINTs specifically with indirect addressing?
 
Last edited:
Could you put all those bits in two arrays, PB and A, of four LINTs, and COP/CPS PB to A on each scan?

Or maybe PB is still an array of BOOLs, and it is COP/CPSed to A which is also an array of BOOLs?
 
To little info to help. We need PLC make/model, HMI software system, method of communication. Is this classwork or work work? either way we'll help guide you to your answer as best we can.
 
Just for some more insight, I’m trying to program a battleship game. If you click a Push Button, the corresponding Rectangle turns grey.

You will need to investigate and learn about 2D arrays, X/Y. Don't bother with a 3D array, that would be for a more advanced and wildly cooler space battleshit.
 
Sorry, I will provide more information. The PLC is an Allen Bradley L71. The HMI software is kind of irrelevant I have that figured out, but I’m using RSLogix 5000 Revision 32. This is also class work work.
 
Okay, well first you need to figure out how to address a 2D array for this I would suggest. Also many of the functions of instructions can either take a direct value or a tag name. The function will read either the direct value or the value of the tag and use it.
Add/Sub/Cop/Mov/TON/TOF/etc. Using a tag is nice as you can modify the value at will. Wheres a direct one you cannot and must edit the rung, change the value, and submit/finalize the online edit.
 
Are PB[0] through PB[127] in the PLC? Or perhaps in the HMI? If neither, where are they?

Are A[0] through A[127] in the PLC? Or perhaps in the HMI? If not, where are they?

Wherever they are, what are PB[0] through PB[127] used for?


Wherever they are, what are A[0] through A[127] used for?
 
A 2D BOOL array would nicely match to representing a 2D grid of rectangles with 2 possible colors.

Unfortunately, RSLogix does not support 2D BOOL arrays so that's a non-starter for this particular assignment.

One thing I think may be being overlooked -- what is the data type of the PB[0-127] and A[0-127] tags? Does the assignment specify? Pushbuttons and rectangle objects would normally deal in bools and the [] format suggests an array in which case drbitboy's suggestion of COP/CPS should be sufficient, no indirection necessary (even if his signature suggests otherwise).

On the other hand the OP asked "how do I connect the DINTs specifically" -- where do DINTs come into it at all?

EDIT: Since OP has stated this is for a game of battleship, it seems clear to me that the original post led some of us a little astray. From the sounds of it, the player will push a button (somehow mapped to PB[...]) and the corresponding tile A[...] will change color -- "turn grey" -- to indicate it was fired at (or perhaps turn a different color to indicate a hit, but that's an issue to deal with later). In Battleship you want the tiles fired upon to stay marked until the end of the game, so a COP/CPS is not sufficient, instead a loop using latches will be necessary.
 
Last edited:
...In Battleship you want the tiles fired upon to stay marked until the end of the game, so a COP/CPS is not sufficient, instead a loop using latches will be necessary.


If the HMI only writes a 1 to A[iPB] and/or PB[iPB] when pushbutton iPB (=0 to 127) is pressed, and some other pushbutton resets the game which causes the PLC to fill (FLL, IIRC?) the array with 0s, then the COP/CPS would work, and for that matter, the PB[0..127] array is not needed at all.

I.e. the rectangle PB action from the HMI is "set and forget."

Also, I would not bother with a 2D array: MOD/SUB(or AND)/DIV/MUL/ADD would be good enough to map the 1D array to the 2D array, and vice versa.


Also, at first I though that 127 is a strange number of buttons as it is not a square, I suppose it represents both opponents' grids and buttons, two by 64.

Hmm, this is interesting, because in the ship placement phase of the game buttons PB[0..63] for player A represents grid locations 0-63 of player A, but in the firing phase of the game they represent grid locations 64-127 of player B; looks like we'll need a rung to execute an XOR of bit 6 of the grid location.
 
Last edited:
If the HMI only writes a 1 to A[iPB] and/or PB[iPB] when pushbutton iPB (=0 to 127) is pressed, and some other pushbutton resets the game which causes the PLC to fill (FLL, IIRC?) the array with 0s, then the COP/CPS would work, and for that matter, the PB[0..127] array is not needed at all.

Of course if the latching logic is done prior it does not need to be done here, but that just pushes the problem elsewhere. The existence of two separate arrays suggests that there is expected to be some difference in their values -- as you note, one of them would be redundant otherwise.

But perhaps the assignment specifies that such arrays shall be used in such a manner? If the purpose of the exercise is to teach indirection it may be designed with constraints to make simple copying insufficient. We don't know the details, so all we can do is provide suggestions as to how to make the game work.

Also, at first I though that 127 is a strange number of buttons as it is not a square, I suppose it represents both opponents' grids and buttons, two by 64.
A good thought, I had wondered that myself. 8x8 seems a small grid to me, but I suppose it's plenty large to teach the principles.
 
Last edited:
A 2D BOOL array would nicely match to representing a 2D grid of rectangles with 2 possible colors.

Unfortunately, RSLogix does not support 2D BOOL arrays so that's a non-starter for this particular assignment.

One thing I think may be being overlooked -- what is the data type of the PB[0-127] and A[0-127] tags? Does the assignment specify? Pushbuttons and rectangle objects would normally deal in bools and the [] format suggests an array in which case drbitboy's suggestion of COP/CPS should be sufficient, no indirection necessary (even if his signature suggests otherwise).

On the other hand the OP asked "how do I connect the DINTs specifically" -- where do DINTs come into it at all?

EDIT: Since OP has stated this is for a game of battleship, it seems clear to me that the original post led some of us a little astray. From the sounds of it, the player will push a button (somehow mapped to PB[...]) and the corresponding tile A[...] will change color -- "turn grey" -- to indicate it was fired at (or perhaps turn a different color to indicate a hit, but that's an issue to deal with later). In Battleship you want the tiles fired upon to stay marked until the end of the game, so a COP/CPS is not sufficient, instead a loop using latches will be necessary.

IF its using actual outputs yes latching would be needed. But if using bools, dints, or something else. the value wont generally change until updated by the logic or hmi again.

I would think the turning grey is to mark where the player is placing a ship to be hit by the other. But thats kinda a minor variant at this moment. placed/hit/miss doesn't seem to be a concern here yet.
 

Similar Topics

Hi guys, New to indirect addressing is anyone able to help me with the attached file. I have tried the pen and paper method and first I put the...
Replies
11
Views
2,489
🙃 I have been scratching my head for a couple of days on this issue. I am in the process of converting a program from rs500 to Studio 5000...
Replies
7
Views
5,636
Hello PLC gurus, i would like to ask you for your help. I have a little problem with indirect addressing, also with ST language. My problem. I...
Replies
7
Views
2,799
Some of you guys may remember I was getting some help on a roller door project a few months.. Lets say learning the ropes of what can be done...
Replies
2
Views
4,274
I have an oven that can contain a rack. I have two racks, "1" and "2", each of which can hold up to 6 parts. I load one rack via a robot that...
Replies
0
Views
1,255
Back
Top Bottom