RSLogix 500 N register into ST

jimtech67

Member
Join Date
Jun 2002
Location
New Jersey
Posts
505
I would like to copy register N61:131 thru N61:147 into ST252:0
I keep failing
What happens is I copy into ST252:0,1, 2 etc.

What am i missing ???

thanks

NICE UPDATE BY THE WAY!!!!!!!!!!!!!!
 
ST252:0 is an instance of string data type

It has two attributes:
  • ST252:0.LEN - the length of the string data, in characters
  • ST252:0.DATA - the string data, as an array of 41 words (16-bit signed integers) i.e.
    • ST252:0.DATA[0] contains the first character (char 0) in the upper byte, and the second character (char 1) in the lower byte
Either COP or CPW may be able to copy data from an N-file to a string's .DATA array (e.g. see here); I can't get it to work. The MOV command can move a single value from an N-file to one element of a string .DATA array (e.g. MOV N7:1 ST9:2.DATA[3].
 
Would the values need to be within the ascii set? is there validation that takes place during a COP to ensure that? after all not much point in putting 65534 into a string.
 
As far as I know, the COP instruction doesn't do any data validation, just a bit-by-bit copy based on the number of destination registers indicated in the COP's length parameter. I would think you'd be able to COPy from N7 into the DATA array of a string type, but...it wouldn't look pretty unless the data was packed into the N7 array properly. Each element of the DATA array is only 8 bits, right? I can't open the software right now to confirm.
The "MOV" is "smarter" in that it does the type conversion so the value is as intact as possible after the transfer.
 
using a SLC 500 5/03

drbitboy... thanks forgot about those designations.
The COP instruction does not work.
you have to move the data one word at time using he the MOV instruction.
Rung 49 works rung 50 throws an error.

1708442665508.png

found this that spells it out (a link to Rockwell)
https: //rockwellautomation.custhelp.com/app/answers/answer_view/a_id/22714
Converting data from an Integer (N) file to a String (ST) file

Side note
all my data in the N registers is in ASCII being sent to a printer (has been working for years)
I want to display a small amount of this data in the AdvancedHMI software.
And to display the text in AdvancedHMI it must read as a ST file.
the C-More software allows you to designate a N register as any data type..

Thanks to All !!!!!!
 
...

Side note
all my data in the N registers is in ASCII being sent to a printer (has been working for years)
I want to display a small amount of this data in the AdvancedHMI software.
And to display the text in AdvancedHMI it must read as a ST file.

If I had the data in Integers in the SLC-5/03, then it would probably be easier to do the transfer to a string in Visual Basic or C# in AdvancedHMI than doing it in ladder in the SLC.

But that's me.

Sidebar: It seems odd that, even though STNNN.Y.DATA an array of 16-bit integers, it is not allowed to CPW those data from an N-file of 16-bit integers. I thought I found an old post where someone did it with CPW (see link in Post #2 above); my assumption was that in that old case using the fully-featured RSLogix 500, and I am using the freebie RSLogix Micro Starter Lite. It might be possible to overwrite to an indirect address to get around the file boundary.
 
Heh. Apparently, it can be done; even in Micro Starter Lite.

The "trick" is to use indirect addressing in the Destination file address parameter passed to the COPy instruction, so the compiler does not know that COPy is writing past the boundary of the N-file (N9 in the example below) and actually writing into the ST-file (ST10 in the example below.

"It's just zeros and ones, it cannot be hard" - Jouni Rynö

00.png
N.B. N7:0 value is 3 in the image below, which is the indirect address in N9 of the start of string ST10:0.

01.png
 
where does the copy or move to the ST10:0.DATA[0] registers happen?
or am I missing something?????

Concept

Memory is a sequence of bits. What memory is accessed by the program, and how the program treats any subset of those bits* depends on the syntax of the "variable names" used.

* e.g. bit, 16-bit signed Integer word; 32-bit REAL; 82-character "string," etc.


Details

String memory

The "variable name" ST10:0 is actually an address reference that points to the memory address a structure comprising forty-two 16-bit words that compose an instance of a "string" data type.​
  • The first word in ST10:0 memory is the length of the string, ST10:0.LEN, for which valid values range from 0 to 82
  • The next 41 words in memory are reserved to hold the 82 characters of string data, and compose the array ST10:0.DATA[0..41], (even if ST10:0.LEN is less than 82)
    • Each of those 41 words comprise two of the characters of the string
      • the high 8 bit (byte) of each word is the ASCII code (range [0:255]) of the first of those two characters
      • the low 8 bit (byte) of each word is the ASCII code of the second of those two characters

Integer memory

The file N9 has only three elements: N9:0; N9:1; N9:2. So any elements N9:y, where y > 2, does not actually exist in the N9 file.

The Magic

However, the address reference N9:[N7:0], where N7:0 > 2, will map beyond the N9 file boundaries and into ST10, the STring-file that follows the N-file N9 in memory.
  • N9:[N7:0], when the value of N7:0 is 3, is an address reference that maps to the same register as ST10:0.LEN.
  • The next memory address, N9:[N7:0 + 1] if you will, maps to ST10:0.DATA[0]
  • The next memory address, N9:[N7:0 + 2], maps to ST10:0.DATA[1]
 
However, the address reference N9:[N7:0], where N7:0 > 2, will map beyond the N9 file boundaries and into ST10, the STring-file that follows the N-file N9 in memory.
...just so long as nobody ever adds any more elements to N9
 
COP uses the destination data type to set the length of the copy, not the source. I tested this with some random number data and it copied the N file into the string file. You will need to stage the string length as part of your data as it did copy N7:0 into ST19:2.LEN.
 

Attachments

  • Screenshot 2024-02-21 071705.png
    Screenshot 2024-02-21 071705.png
    2.3 KB · Views: 0
...just so long as nobody ever adds any more elements to N9
Yeah, I didn't mention that wrinkle.

Also as long as nobody ever changes the Length parameter to the COP command or the offline value of N7:0, because, while in offline mode, if N9 has fewer elements than that [length plus the offline value of N7:0], RSLogix resizes N9 to that length.

Perhaps the best thing would be to resize N9 to 256 elements.
 
COP uses the destination data type to set the length of the copy, not the source. I tested this with some random number data and it copied the N file into the string file. You will need to stage the string length as part of your data as it did copy N7:0 into ST19:2.LEN.
Yes. Note that, when I am using the previous N-file (N9) as the proxy for the ST-file (ST10), not only is the Dest starting indirect address ([N7:0]) interpreted as an offset from N9:0, but also the Length parameter to the COP instruction is interpreted the number of Dest N9 elements (i.e. words) to be copied, even though the destination is actually a string data type.

Or use CPW, so the Length parameter is the number of words copied, and the Source and Dest data types can be different.

What version of RSLogix 500 is that? Because I cannot get anything like that to verify successfully.

Untitled.png
 
Yes. Note that, when I am using the previous N-file (N9) as the proxy for the ST-file (ST10), not only is the Dest starting indirect address ([N7:0]) interpreted as an offset from N9:0, but also the Length parameter to the COP instruction is interpreted the number of Dest N9 elements (i.e. words) to be copied, even though the destination is actually a string data type.

Or use CPW, so the Length parameter is the number of words copied, and the Source and Dest data types can be different.

What version of RSLogix 500 is that? Because I cannot get anything like that to verify successfully.

View attachment 68193
I've running v12. I had to test that on a SLC 5/04, as I didn't have a 5/03 to try it on. That could be the difference.

If your N7 file at least 43 words long? That may impact it as well.
 

Similar Topics

What's happening is, when running the lid picker is coming up one short and while the rest of the machine is functioning in sequence as normal...
Replies
5
Views
4,083
Hi, I have a line where I need my shift register to vary in size depending on the type of product being run. I am using ffu and ffl instructions...
Replies
1
Views
5,165
Hi Everyone, I am not proficient in RSLogix 500 so I have a question regarding the evaluation of N7:0 data as an input. So as I understand in...
Replies
1
Views
87
I have a little bit of experience with Allen-Bradley. I have a Micrologix 1500 (RSLogix 500) and a PanelView Plus 7 (FactoryTalk View Studio ME)...
Replies
3
Views
168
buen dia. tengo una falla al pasar los tags de mi plc SLC 5 0/4 a mi panel me aparece un error Problem writing value " " to item <tag name>...
Replies
1
Views
83
Back
Top Bottom