Timbercub

Barcode string parsing

5 posts in this topic

Hi all, long time reader first time poster.
I am an AB programmer through and through. Recently working on more and more omron gear and need a bit of a steer in the right direction.
I have a sick barcode reader communicating to a omron CP1LE PLC over serial. Problem is the value from the barcode reader is not value, it is sometimes multiple values separated by commas (,). I really wish to only have the first value before the comma in this long string stored in D200. 
I take it i'll have to move this string into individual container registries which i can easily go from there and pick which one I want to use. But how do I initially go about parsing the string in CX programmer?
Attached is a screenshot of what I have so far>
Cheers
Dave

Capture.PNG

Share this post


Link to post
Share on other sites

Hi Dave,
Can you change the  sick barcode reader  to produce a start character sequence? This way you may be able to eliminate some the information that you need to search for in the PLC.
http://www.edata.omron.com.au/eData/PLCs/CP1/W451-E1-03.pdf
Look in the above manual for  '3-31 Text String Processing Instructions'
This will have several instructions that you can use to search, move or compare.

Regards,
Garry

 

 

 

Share this post


Link to post
Share on other sites

Is there also a terminator?  If it is always sending just values separated with commas and a comma at the end, set your end code up to be a comma.  I would guess that this is probably not the case, that the end code is a CR + LF or something, but I thought that I would throw the suggestion out there.

Share this post


Link to post
Share on other sites

The basics are:

1) Use the FIND$(660) command to return the position of the first comma in the string in hex

2) Use the LEFT$(652) command to extract the characters to the left of the comma to another string

You will probably want to subtract 1 from the hex value returned by the FIND$ command so that you don't get the trailing comma when you use the LEFT$ command. You may also want to use the DEL$ command to clean up the data left in the receive buffer.

1 person likes this

Share this post


Link to post
Share on other sites

Hi All, Thanks for your suggested points.
Sorry about the late reply, I had an ill spell and ended up in the hospital>
Back at it again. Attached is what I think maybe the way to go, does it look right to you guys? 
Say for the find raw comma 'comma' variable, do I just set this once online to a comma?
Cheers Guys

Untitled.png

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