Scanner input to CP1L

3 posts in this topic

I can only guess how much you guys hate rookies and dumb questions….. But here it goes..

I have played with PLCs years ago. I understand ladder inputs and outputs 

I find the omron manual extremely confusing with samples that are not complete ect..

I have a scanner connected to the plc. Serial port 1 option board

i can scan a upc 12 code and store it in D0 (this is just testing as I have a QR code reader coming)

when I look in the memory area for DM 0 With the display set to TEXT I see the complete bar code just as it appears on the upc label 

When I use D0 in a counter it shows a no. that makes no sense.

This scanner is meant to be a P.C. keyboard wedge.

Does this mean the scanner is sending ascii characters to the PLC?

The plan is to use a QR code scanner with numbers that I want to use to turn on conveyors then set a value in a counter that will count pcs and turn off

I have the code working for the conveyors and the counter. Just need to get the numbers from the DM area into the counter with a decimal number.

the QR code will scan a number like this

1,4 2,2 3,7 4,1 

1,4 conveyor 1 count 4 pcs

2,2 conveyor 2 count 2 pcs

3,7 conveyor 3 count 7 pcs

4,1 conveyor 4 count 1 pcs 

ect ect

I don’t need to use a comma it can be anything

This would be so easy if I could use the (text data) directly into the counter.

Is there anywhere a guy can find sample code…. Working sample code for each of the commands



Edited by Robafe

Share this post

Link to post
Share on other sites

Put the data into a data memory and use the data memory as the number reference in the counter - or timer. They will only accept numbers though - BCD on the old ones and decimal on the new ones.

Share this post

Link to post
Share on other sites

I don't have time to make an example but hopefully lead you in the right direction.

You are most likely reading ASCII characters. The PLC cannot count ASCII. Well, it will but it won't make sense. :-)

You said you can see it in text like:


But as a number:


You'll need to remove your commas (2C) and spaces (20) and get the numbers (all preceded by a "3") all by themselves. Then you can use the NUM4 instruction to convert them to a Hexadecimal number. From here you can do BCD math and counting. If you choose to use decimal then use the BIN instruction on the hexadecimal number.

If you choose, the old school method to convert is to subtract BCD 30 from all the numeric ASCII characters.


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