×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Creating Logic to Read Text String

Creating Logic to Read Text String

Creating Logic to Read Text String

(OP)
Hello everyone,

I have a PLC controllogix that an OCR system will write to through an ethernet gateway module.

I'm trying to figure out how to write a logic that will read 8 text string messages within 1 long text string message seperated by delimiters ";" and place them into 8 tag string.

I know that I would have to use the FIND instruction but how will I seperate them and mov them into 8 different tag strings in the Result operand?

example: '$123;45678;9;$' delimiter = ";"

1st scan: reads 123; then moves it to Result operand.
2nd scan: reads 45678; then moves it to Result operand.
3rd scan: reads 9; then moves it to Result operand.

Thanks in advance!



 

RE: Creating Logic to Read Text String

NO

stay away from string functions, they are a pain.

When you receive the data put it into SINT (byte) data type array, then create a for loop and some statements to search and act on the ";".  

Put the results in other SINT arrays.

It would be a lot easier for you.  

RE: Creating Logic to Read Text String

(OP)


I'm not sure what you mean, can you give an example if you dont mind. I'm sorry I'm kinda new in PLC. I've only made 2programs with supervision and this text string stuff is new to me.

RE: Creating Logic to Read Text String

(OP)
Actually, I have a Tag that the OCR writes to:
tag name = OCR2LGX
data type = SINT[100]
style = ASCII

 

RE: Creating Logic to Read Text String

(OP)
...Or should I make the Tag:
data type = STRING, instead of SINT[100]?

 

RE: Creating Logic to Read Text String

tag name = OCR2LGX
data type = SINT[100]
style = ASCII

Then when you use any function remember most functions will look at the decimal value and perform the function.

example:
ascII ; = decimal 59 = hex 3B
the equal function
EQU OCR2LGX[10] 59

It would be wise to get a copy of the ASC2 table.  I know AB has it in there basic programming functions PDF.

The equal statement is looking for your ; at position 10 in the array.

Now take it one step further use a For Loop and use the index.  For Loop is in another file, when you call the For Loop the below statement will be in the file that the for loop is calling.  Get IT?

EQU OCR2LGX[index] 59

Now that you know that during this index through the for loop that position 10 is where the ; is you just simply use the copy statement to move  the data to another data area that is a SINT array.

The statement below will copy the data from the index 10 to 19 of OCR2LGX.  Get it?
COP OCR2LGX[index] OCR_DEST[0] 10


Now that you know how to do this and what is happening, just add other statements accordingly.
 

RE: Creating Logic to Read Text String

(OP)
One last question. How do you clear out all the text strings in the data TAG string? ex: MYTAG.DATA.
Would I have to just zero out the the first Word of MYDATA? ex: MYTAG.LEN

RE: Creating Logic to Read Text String

two ways

FLL 0 MYTAG.DATA
Also have to zero out the LEN
mov 0 MYTAG.DATA.LEN
OR

Create another string its a blank string then just do this

COP blank.data MYTAG.DATA

Just remember there is a feature when you copy a string where the 1st word is the LEN

I thought you were not going to use string types, it will just make it more painful.

RE: Creating Logic to Read Text String

(OP)
Yeah...I had started the prog couple days before your last reply...so I had just stucked with it...and I was actually finish and everything was fine except for the .data part having to clear.

I actually had notice that if a new message string comes in, it writes over the old string...but thats ok coz, since I'm looking for a certain delimiter to end a string, then I wont have to worry about the excess string beyond the delimiter.

Anyway, I will try zero-ing the .data as how you showed it and or redo my program without using the string type instructions just to get familiarize with this. I just needed to have a working program yesterday....thank you for your time.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources