Sign in to follow this  
Followers 0
Van

Moving Literals

10 posts in this topic

Is it possible to move literal text/string into memory? For example, to move a literal hex value one does this: MOV #41 H150 and that moves hex 0x41 ("A") into memory location H150. but I would like to do something like this: MOV$ "TEST" H150 How would one go about this? I am trying to avoid having to have four MOV commands using hex.

Share this post


Link to post
Share on other sites
Hi It depends which PLC you're using. A V4 CJ1/CS1 will allow string data types to store constant strings (in ST FBs) Fred:='Hello World'; CP1L and CP1H have V3 functionality, and don't allow this. It's a bit of a pain. I generally populate Data memory, and use the MOV$ instruction. Pp

Share this post


Link to post
Share on other sites
Assuming you are using a CJ/CS series CPU, have a look at the instruction reference manual: W340-E1-11 CS-CJ Instructions Reference Manual See section 3-12 for ASCII to HEX and reverse instructions and 3-33 for Text String Processing Instructions.

Share this post


Link to post
Share on other sites
I am using a CJ1M-CPU11 (and 12) Version 3.0. Does this present a problem? That is what I am trying to do: initially populate the data memory. Example: ON PLC Start do: set "MyTestSymbol" = "TextData"

Share this post


Link to post
Share on other sites
Each ASCII character requires 1 byte of memory, so you cannot store four characters in a single word. You don't need four MOV instructions, only two are required. In your example to load TEST into memory starting at H150":- MOV #5445 H150 MOV #5354 H151

Share this post


Link to post
Share on other sites
ASCII_to_MOVL_converter.xls You can use MOVL to cut the number of Move's in half. Attached is an Excel sheet that will create and comment the ladder (in statement list) so you can copy / paste into CXP. Change the rung view to "Statement List" and then paste the created rung.

Share this post


Link to post
Share on other sites
Very nice, PMCR! Consider that 'borrowed'! Upto now, I've just typed away...but this relies on saving a *.mem file, and downloading it. I've been after a way to hard-code ASCII. Change the display to ASCII, and it's simple to initially populate D memory. Edited by ParaffinPower

Share this post


Link to post
Share on other sites
I have done a couple of jobs recently that required a lot of stored ASCII (PLC as serial slave). They were for OEMs, and I did not want to rely on loading ASCII from the mem file, so I wrote that Excel file to auto generate the ladder.

Share this post


Link to post
Share on other sites
Awsome PMCR That's a great tool. It would be nice if Omron added the ability to write a string directly to memory. Ex. COP $Hello World D0 Thanks

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