Logix5000 MID (Middle String)

Touge

Member
Join Date
May 2012
Location
UK
Posts
4
Hi
I am trying to manipulate the data coming in from an EthernetIP Barcode scanner. I now have the data as a String value
with
.LEN 18 Decimal
.DATA SINT [82] ASCII

When I try to use the MID Instruction to remove the first few characters that I do not require. No value is returned in the dest box.
However if I double click on the actual "source" string value and remove any single character (or multiple) close it again.
Then it processes the value and allows all my other code to work.
Any help greatly appreciated
 
Can we see a screenshot of your code? Do you have any conditions on your MID instruction? If you don't have any conditions the MID will be executing continuously and stripping a few characters out every scan until you have none left.
 
Aha!

I think you may have cracked it right away. I hadnt realised that the process would be executing continuously. Rather ike a counter I assume? Its the first time I have used this function.
I have attached a screenshot of my code. I assume I should be using a oneshot to execute only once.

screenshot barcode.jpg
 
Still have a problem

I have altered the code to update and trim the characters once every time the camera operates however the same issue. The Source updates fine. The old Dest value stays the same. If I go in and edit any character (add or remove) in the source with the string edit box. Then open the block on line 1 to stop it overwriting again. As soon as I close the edit window the edit updates to the correct value. Still baffling me.

MID Problem 1.jpg Mid Problem 2.jpg
 
I'm going to take another stab at this. Part of writing to a string tag requires that the ".LEN" field gets updated with the correct length of the string. For example, if you have 5 characters in your string tag, string.LEN must be equal to 5.

The proper method for copying a string tag to another string tag is to use COP StrTag1 StrTag2 with a length of 1. This will copy all characters and update ".LEN" automatically. When you go COP StrTag1.DATA[0] StrTag2 with a variable length, I don't think StrTag2.LEN is updated and you're not telling the COP command to write to StrTag2.DATA[0]. Using this method, I think you have to write the correct length to StrTag2.LEN. When you edit the string value using the edit box, it automatically updates the ".LEN" field.

You could also try this and you don't need the MID instruction: COP StrTag1.DATA[2] StrTag2.DATA[0] length is StrTag1.LEN-2. This copies character by character skipping the first two.
 
Thanks

Hi gmferg
I follow you. I think as you say this is a .LEN issue. Still can't get it to convert though. I have just managed to get round the issue by using the concat instruction 18 times. Not pretty but works. Then using the MID, FIND & DELETE command I am left with a Barcode String the correct length. FIND used as the barcode lengths vary.
Many thanks for your help!
 

Similar Topics

Hi! So my problem is a little funky, I had Studio 5000 v 24 and 30 installed, but forgot to install RSLogix (which I cannot go without). Is there...
Replies
2
Views
112
So I had an odd request from a customer for the above. I have written the logic and tested it all in one PLC with only using 7 outputs and 7...
Replies
15
Views
427
I'm a Siemens person, and this is one of my first AB programs. The customer wants everything programmed in Ladder. I have a lot of data (3...
Replies
14
Views
217
Good day everyone. if you have a logic for 3 pumps (lead/lag/off), would you please email it to me? I really appreciate it!
Replies
7
Views
215
Maybe this is just not possible, or maybe I am doing something wrong. Background; I have a data array of over 1500 products. For sorting I...
Replies
6
Views
757
Back
Top Bottom