Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Logic to Read Text String 1

Status
Not open for further replies.

spongebob17

Electrical
Oct 10, 2007
16
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!



 
Replies continue below

Recommended for you

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.
 


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.
 
Actually, I have a Tag that the OCR writes to:
tag name = OCR2LGX
data type = SINT[100]
style = ASCII

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

 
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.
 
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
 
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.
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor