OCR checking string correct message and no extra characters in RSLogix5000

kloc5

Member
Join Date
Apr 2014
Location
St Louis
Posts
25
Hello,

I have a question on an OCR application I am doing.

I am reading in 16 characters that come from a camera into the plc in its input words (Camera:I.Data[38] thru [45]). I copy them into a string and then want to compare them to a "golden" 13 character string to see if they match and that there aren't any extra characters.

I am having trouble finding out if there are any extra characters. I could use FIND and look for the location of the first null character ($00), delete from there on using DEL, and compare the resulting string (whatever its length) to the "golden" string using EQU, but then if all 16 characters are full (not null) the FIND will return a zero and through things off.

I also was thinking I could copy everything after 13 characters to a "remainder" string using MID and then compare the first 13 characters string to the "golden" string and "remainder" to a string of nulls ($00), but then I guess I would have to make that "null string" is the correct number of null characters. Would I just hard code a 3 character null string? This seemed like the wrong way to do this.

Any suggestions on checking that I have the correct message with nothing extra?
 
First MOV 13 into Compare String.LEN Then COP Camera:I.Data[n] into Compare String.Data[0] For length of 13 then the EQU instruction will work just fine test Compare String = Golden String.

To find extra characters you could COP Camera:I.Data[n] Into Test String.Data[0] for length of 16. Then use the FSC instruction to check Test String.Data[FSC.POS] = 0. Then position found will determine length of Test String. If position is greater than 13 then string is longer than 13 characters. Or use 3 NEQ 0 on Test string.Data[13],[14] and [15]. I would probably go with 3 NEQ 0 just to simplify the code.
 
Last edited:
Or append the nulls to the "golden string" i.e. "golden string$00$00$00" and compare that to the 16 characters in the string from the camera.
 
If the strings are different lengths then there is no way they could be compared and get a accurate result
Adding empty characters or ant characters will invalidate that string.
And yes a space is actually an ASCII character, HEX 20, Dec 32
So adding characters to any received string or any comparator string would make you comparison invalid.
You need to work out exactly witch characters of the string you need to compare
You said that you are reading 16 characters of what appears to be a 45 character string are you sure you are parsing out correct characters. Check you manuals carefully
Keep in mind that ASCII has 256 distinct characters 00-255
 

Similar Topics

Hi everyone, Does anyone here use any kind of OCR software for electrical diagrams? What is your experience? Even better, is there a service...
Replies
16
Views
5,866
Hello, can someone share/explain How to check comms between PC and PLC via TeamViewer? TIA
Replies
14
Views
391
I have some questions about MSG Type checking Does a MSG instruction care if the name of the UDT type are different on each PLC as long as...
Replies
6
Views
3,463
I just finished making my 3rd service call to a large machine shop, troubleshooting PLC issues. I can see that none of the PLC or HMI programs are...
Replies
11
Views
3,072
All of these processes are taking all day to run. When doing the same operation in a stand alone intouch application it only take a few minutes to...
Replies
0
Views
1,611
Back
Top Bottom