swish_jr
Aug 1 2002, 10:24 AM
My eventual goal is to write control strings to an RS232 keypad which requires using lower ASCII control characters as part of the string. I've found that a hex ASCII value can be entered into the data file manually, but is there a way to hard-code a string in the ladder logic, similar to a simple MOV that could be done for an integer?
Ken Roach
Aug 1 2002, 03:49 PM
There is; use the COP (File Copy) instruction.
Here's how it works: A String element in the SLC-5/03,4,5 controllers consists of one Length word and 41 data words (each contains two characters).
To COPy an Integer file into a String file, you need to reserve 42 Integer data words, even if you only need to use a few.
The trick is that you need to specify the Length of the COP instruction as 1. Even though the String element is 42 words long, it's just one data element.
When you execute the COP instruction, all 42 words will get moved into the String element. Again, you need all 42 words available to be moved, even if the String instructions in ladder logic will ignore all bytes beyond those specified by the Length word.
If you have, for example:
Address Decimal Value ASCII Value
N7:0 7 ^G (this is the length)
N7:1 260 ^A^D (two cntrl-char)
N7:2 18533 He (actual text)
N7:3 27756 ll
N7:4 28449 o/00
You would get as a result:
ST12:0.LEN = 7
ST12:0.DATA = ^A^DHello
Using this to just move the unprintable characters into your String data files will let you then concatenate the actual text onto them to make the final string that will be sent out the serial port. Remember that you can set up prefix or appended characters to be sent out the SLC serial port along with a string !