Sign in to follow this  
Followers 0
Joao Manuel

String compare in CPM2A

7 posts in this topic

Hi everyone, My name is Joao and i'm new with PLC programming, but i accepted a job to program a Omron CPM2A, since my job is to program in C,C#, Delphi etc. i had to dig alot to understand how PLC's work and how LADDER programming is done, this Forum and Download section had been my principal source of information, BUT now i'm stuck in a string compare and dont know how to start with it, for ex. i have a string_1 stored (starting) in DM0100 and has for example 10 bytes, and i have a string_2 in DM0200 and has 10 bytes to, now the goal is to compare the entire strings and see if they match ... Can someone giveme some help ? Joao Manuel

Share this post


Link to post
Share on other sites
Joao, Welcome to the forum! With the CPM2, you will need to use multiple CMP or CMPL instructions. The CMP instruction will allow you to compare one "word" (2 bytes) at a time. The CMPL will allow two words (4 bytes). You will need to evaluate the comparison "flags" immediately after the instruction. Take a look at the information in the manual. CPM Programming manual @ MrPLC.com It is a bit of work to do string comparison in the CPM units. The CJ1 processors offer a single instruction for string compare. Hope this will help.

Share this post


Link to post
Share on other sites
Hi gtsuport, Thank you for your quick reply. The answer that you gaveme was what i was afraid, i will have alote to write ...

Share this post


Link to post
Share on other sites
Do you have to use that particular PLC? If you can get ome with the CJ instruction set it has a compare string function built in. I believe the shoebox style for the CJ instruction set is the CP1H? (please correct me if I am wrong experts!)

Share this post


Link to post
Share on other sites
Chris does have a good suggestion, but I kind of thought the CPM2 was existing. It will mean some extra programming, but have done this many times in the past. Chris, FYI, we are having problems getting CP1H units here in the US, You may want to check with your distributor.

Share this post


Link to post
Share on other sites
Hmm.. I will have to check. I typically use the CJ's because the projects I tend to work on need more than a shoebox.

Share this post


Link to post
Share on other sites
Hi Chris ! Thank you for your reply, but in fact i have to use the CPM2A, because it already exists. But thank you anyway. Joao Manuel

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