CX-Programmer: Get Length of String and Copy String to CHANNEL

khelza

Member
Join Date
Sep 2015
Location
Ontario
Posts
67
Hi guys,

I don't use CX-programmer often, and haven't been able to locate an answer on the web. Manuals aren't extremely helpful if you don't know exactly how to describe what you are looking for:

- Store "abc,xyz,000" in a string
- LEN$ command to get the length of that string
- output string to a CHANNEL datatype - what instruction would do that?
- output length to a different CHANNEL

I was trying MOV but was getting errors.. (n)
 
MOV$ should work.
Were you getting errors or warnings?? You will get a warning from CXP any time you move data from one data type to another. In most cases you can ignore warnings.
 
The error I'm getting right now is when trying to store the string values in the string.

I am using the MOV$ "abc,xyz,000" into String and get an error back about "memory area not valid"
 
A channel is a single 16-bit word, and any string longer than 2 symbols simply cannot fit into a single channel.
For the same reason, a string longer than 2 symbols cannot be copied into another string by a single MOV instruction.
 
A channel is a single 16-bit word, and any string longer than 2 symbols simply cannot fit into a single channel.
For the same reason, a string longer than 2 symbols cannot be copied into another string by a single MOV instruction.

NOT TRUE! MOV$(664) is a string move instruction for up to 4,095 characters.

Have used this on both on CJ2M and CP1L PLC's. WILL NOT WORK on CP1E models.

MOV$(664).jpg
 
Last edited:
In any case ... his problem is that the MOV$ instruction wants two addresses (Source and Destination) and it appears he is trying to use a quoted string as the source.
 
Attached is cxp file with example. Uses a Structured Text FB to manage the String.
Note that in ST variables in FB must be InOut to handle strings.
Note:- Uploaded file extension is pdf, change to cxp to view.
 
Hello I am new in this forum and i don't now where i can start the question.I have the servo drive LXM32M and i want to connect with the plc Modicon M221 with Modbus Rtu.

 
Attached is cxp file with example. Uses a Structured Text FB to manage the String.
Note that in ST variables in FB must be InOut to handle strings.
Note:- Uploaded file extension is pdf, change to cxp to view.

Example was written for CJ2M.
CP1L does not permit STRING variables within FB.

Since the OP still hasn't specified which model PLC he is using don't know if this will work for him?
 
Last edited:
[email protected],
You need to create a new thread.
No one will find your question, since it is inside an Omron thread.
You can start a new thread by going to the LIVE PLC Questions and Answers and click on start new thread at the top.
Hope this will help.
 
RESOLVED!

Not sure what the issue was before, but the MOV$ worked for me with the source as a D string, and the destination as the Channel address.

I later switched it to a RPLC$ so that I could modify the string a bit before sending it the the channel.

Thanks for everyones' help and input!
 

Similar Topics

bonjour je souhaiterais savoir si c'est possible de faire communiquer Cx-programmer ( logiciel de programmation des automates Omron ) avec...
Replies
2
Views
157
Dear All, I need a sample PLC program to count the output pulse of a mass flow meter so that a specific amount of mass (for example 100gm)can be...
Replies
2
Views
148
I need a good website or tutorial to learn plc programming Thank you
Replies
10
Views
509
Hello ! I am trying to use an omron cj2m-cpu33 with a CP1W-CIF01 plug in serial connector to talk to a zebra ZT610 printer. I am getting the data...
Replies
8
Views
375
Dear all, First of all thanks for letting me join this forum. I just need some help in one of my programming exercises. Being a beginner...
Replies
6
Views
610
Back
Top Bottom