s7 barcode

adamplc

Member
Join Date
Dec 2009
Location
usa
Posts
92
My problem is i'm scanning a barcode in and was originally comparing the string to all my other part types to determine what this part type is,
this seems to be a waste of time as there are over 35 strings to compare. Is it best to keep it as is or just add the bytes together to get a sum of the string and tell the machine it is a certain part type.o_O
Any input on this greatly appreciated
 
Every barcode system I've used reads a number in character format, the numbers usually being similar, usually just a few characters changed.

These characters I'd change to number format and compare the numbers as integers.
 
My problem is i'm scanning a barcode in and was originally comparing the string to all my other part types to determine what this part type is,
this seems to be a waste of time as there are over 35 strings to compare. Is it best to keep it as is or just add the bytes together to get a sum of the string and tell the machine it is a certain part type.o_O
Any input on this greatly appreciated

You cant do that, consider a+b=b+a. In numbers 4+5=5+4=9 so you have no way to know that those two are different parts.


Ps. char is already a number, its just number that is agreed to represent some character.
 
Is scan time a issue??
Or just trying to tweak the code to make it more smarter and effecient.

Ok if strings have commom parts then try to filter them out.

AAA2121rdf
AAA4533dds

then filter out AAA.
 
I had originally had a problem with the string it had squares at the end I tried to initalize it but still had the problem so I tried rather than store it as a sting I changed it to a array of char and it was then ok.
I don't seem to know the difference between a sting and a array of chars, should be the same but I need to convert this into a int for evaluation compares.
I tried to move the array to a string location and then use the iec string to int fc37 but it will not scan the block. That is why I wanted to just simply add the bytes together and determine what the barcode was. I would have thought that would be a better solution but maybe not as was pointed out by TurpoUrpo
 
You need to look at the string format and ensure you create the additional characters (max length, actual length, etc).

When you are in the program editor, go to HELP, CONTENTS and go to the appendix area, the string is explained.
 
If I want to change your Char Array to string I do the following:
Create a struct Eg:
UserNameIn_Container-as struct
in this struct I have:
UserNameIn_Container.MaxLength as byte
UserNameIn_Container.ActualLength as byte
UserNameIn_Container.Chars[1..20] as array of char

The MaxLength I write fixed to 20 as per example.
The ActualLength I use from the return value of FB RCV_ET200S
With a block move after read OK, I copy my read buffer into the UserNameIn_Container.Chars array.

I then copy the struct (UserNameIn_Container) with blockmove onto a string with the length of 20.
Then you could use your compare from the IEC library on the string.

I hope it makes sense, if not I could make you a sample FB.
 
Last edited:
If I want to change your Char Array to string I do the following:
Create a struct Eg:
UserNameIn_Container-as struct
in this struct I have:
UserNameIn_Container.MaxLength as byte
UserNameIn_Container.ActualLength as byte
UserNameIn_Container.Chars[1..20] as array of char

The MaxLength I write fixed to 20 as per example.
The ActualLength I use from the return value of FB RCV_ET200S
With a block move after read OK, I copy my read buffer into the UserNameIn_Container.Chars array.

I then copy the struct (UserNameIn_Container) with blockmove onto a string with the length of 20.
Then you could use your compare from the IEC library on the string.

I hope it makes sense, if not I could make you a sample FB.

this is kind of how I was doing it, but not using the structure within the db. I have never understood the struct of a db and see it all the time whats the point?
If you dont mind could you please write the fb for this as i'm about ready to start to drink myself into a coma
 

Similar Topics

Hi to everybody. I need to read the first 12 characters of the message that a barcode reader sends to the ascii card (1734-rs232 ascii) and I...
Replies
8
Views
725
I thought I was nearly finished on this TIA Portal/s7-1212C project (famous last words)... Up until now, I'd developed the PLC/HMI such that the...
Replies
10
Views
1,544
Does anyone know a way to dynamically generate a 2D barcode on a PanelView screen? An Activex Control maybe? If such a method is out there, it...
Replies
14
Views
2,985
I'm wondering if anyone has a solution where I can use a barcode scanner to input a string into a PLC tag. All AB hardware/software. I'm aware...
Replies
8
Views
17,965
Looking for some application advice with barcode scanners and Compactlogix PLC and a Panelview Plus. I assume Ethernet/IP is the way to go here...
Replies
1
Views
1,645
Back
Top Bottom