# Barcode Scanner Data Compiling

## Recommended Posts

Hey all...

Probably a simple question that I am overlooking.

We have a barcode scanner hooked up to our 570, and it is scanning and putting data where we need it. We are converting the ASCII characters to numbers and putting each number in an MI. How do I connect the 6 MI's with a single digit in them, to make 1 MI with a 6 digit number.

Basically:

MI 10= 5

MI 11=6

MI 12=9

MI 13=9

MI 14=6

MI 15=0

and I would like MI 16 to read 569960.

I have been racking my brain for about 5 hours on this, and can't seem to get it quite right.

##### Share on other sites

Hi,

First, you cannot put number 569960 in MI for thhe same reasons you cannot put elefant family in a small car. MI is 16 bit signed register. The range there is from -32768 to +32767. Maybe you need ot use ML or DW...?

Then - why not to use ASCII ot NUM function to convert the whole ASCII string to number in one cut?

If you still want to work the way you offer:

Store the fist number in a buffer;

Multiply the second number by 10 and add it to buffer;

Multiply the second number by 100 and add it to buffer;

...

##### Share on other sites

This is more simple than you think. When I first looked at this I was going down the hard road too till the EE accross the hall set me straight. As long as you bar code reads are always the same general positions just multiply the numbers by there relative position then add them together to come up with the final number. So for your example of:

5

6

9

9

6

0

is (0*1) + (6*10) +(9*100) + (9*1000) + ....... Ect.

However, in this example it will not fit in an MI. I have asked the question about using a standard MI without reserving the negative sign so that you can show the number you have in your example. The answer was that you can not, you can only show MIs as -32768 to 32767. So in your example even if you are able to functionally do what you want you will have to save the value in an ML and not an MI.

A general question to anyone else is there an SB82 long integer function like there is for M90/91 and JAZZ models to act on the the next two MIs as a pair? (or some other way to not use MLs since there just are not that many MLs available).

Thanks

Keith

##### Share on other sites

Thank you for the tips!

@Keith- your way worked well! I got it to put together a full number, but not to display that in a text box, it shows up as an equation and not the number Any tips?

@Emil I am working on getting your way to work. Am I thinking right that I need to scan the bar code, Save it to an ML, convert that ML ASCII to a number?

Thanks again!

Nick

##### Share on other sites

The easiest way is to define in FB Protocol variable "Numeric" and to get the number from bar code direct a number.

Other option - if you already have the ASCIII string, you can use ASCII to NUM function (Strings menu) to convert the number with one function.

Both these ways seem to me very elegant.

##### Share on other sites

I can get it to directly output to an ML now as a number. When I go to display this number in a Text Box it shows up as h2*. What else am I doing wrong? Sorry...I'm a PLC newbie, and we are trying to complete someone else half finished project!

##### Share on other sites

• MVP 2023

Is your display object set up as a numeric variable or a string variable? If you're loading it to an ML the display object needs to be a properly sized numeric.

Joe T.

##### Share on other sites

Joe,

Thanks for the heads up...one of my colleagues had pointed out I had an ASCII box instead of a Numeric Value box...thankfully an easy fix.

Next issue...now that I have the 6 digit number scanning into an ML, I am having troubles getting this to Compare to a value in a data table. We have it setup now so you can manually enter a lot number and from the data table it will pulll a part number and rev. I am trying to make it so you can scan the barcode of the item number, and it will query the Data table, match the value, and pull the rest of the row in. I feel like I am close, but just can't quite get it!

Thanks again!

Nick

##### Share on other sites

• MVP 2023

Have you looked at the "Data Tables-Find Row" function block?

Joe T.

##### Share on other sites

We had a conference call with our Unitronics distributor, and got that all figured out.

Next question...probably more simple... I have a number box that the scanned number goes into just fine now. I have keypad entry turned on. Is there anyway to make that box so I can enter numbers via keypad or have them come in through the scanner?

Nick

##### Share on other sites

Hi Nick,

The way you asked your question I am not 100% sure I understand what you are asking. It sounds like you all ready have the ability to populate a memory location with either information from the barcode scanner or a user putting in a number. If you do not then it is just a mater of direct soring your barcode information into the same memory location as the referenced MI in your keypad entry. If however you were asking if you can make a keypad entry and disable it (or not) you can do this as well by making a disable bit for the number entry box an d whenever the bit was true the ability to make keypad entries would be turned off.

Keith

## Create an account

Register a new account

×