Sign in to follow this  
Followers 0
Datman

Integer File Manipulation

9 posts in this topic

Hi guys, another easy one for you, i really am struggling with the easy stuff! I have an integer file which is storing information about parts that are moving along a conveyor system. eg: 1 2 3 Length Width Grade N7:0 300 50 A ... N7:10 250 45 B ... N7:20 150 40 A ... When a condition is true i simply want to increment the position of each part information, so it becomes: 1 2 3 Length Width Grade N7:0 0 0 0 ... N7:10 300 50 A ... N7:20 250 45 B ... N7:30 150 40 A ... And this will happen several times. What i want to know is the easiest way to do this, I have tried using a file copy to a temporary file, then copying back into the current file in the desired postion. It works but i figure there must be an easier way, something similar to a bit shift? Hope this makes some sort of sense... Thanks guys (sorry the format is a little screwed up, spaces didnt work) Edited by Datman

Share this post


Link to post
Share on other sites
For my response I'll make some assumptions and a couple of suggestions. Suggestion #1 - Do not shift of move your entire data if not necessary. The more data you move the more room for error. Suggestion #2 - Think about using pointers and identifiers. I'll explain as follows: I'll assume your system never has more than 25 parts at any one time. If you use N7 to store data about parts then you'll begin entries at N7:0, N7:10, N7:20 ... N7:220, N7:230 and N7:240. Next we'll use N17 as a scratchpad file. N17:0 will point to the next location to load data into. It will contain the numbers such as 0, 10, 20 ... 230, 240. If it is at 240 and needs to increment it will wrap to 0. N17:0 will point to length, N17:1 to Width and N17:2 to Grade. We'll also use N17:20 thru N17:44 as a FIFO of length 25. It will store part ID's. R16:0 will be the control for this FIFO. So lets run thru a few parts being processed. 1. Part number 1 arrives N17:0 = 0 so the Length is put in N7:[N17:0] == N7:0 ; Width is put in N7:[N17:1] == N7:1 and grade into N7:[N17:2] == N7:2. Then we'll FFL N17:0 or "0" into our FIFO R16:0. Housekeeping math will increase N17:0, N17:1 & N17:2 by 10 each. 2. Part Number 2 arrives N17:0 = 10 so the length is put in N7:[N17:0] == N7:10 ; Width is put in N7:[N17:1] == N7:11 and grade into N7:[N17:2] == N7:12. Then we'll FFL N17:0 or "10" into our FIFO R16:0. Housekeeping math will increase N17:0, N17:1 & N17:2 by 10 each. 3. Part Number 3 arrives N17:0 = 20 so the length is put in N7:[N17:0] == N7:20 ; Width is put in N7:[N17:1] == N7:21 and grade into N7:[N17:2] == N7:22. Then we'll FFL N17:0 or "20" into our FIFO R16:0. Housekeeping math will increase N17:0, N17:1 & N17:2 by 10 each. This sequence continues until Part Number 1 needs to be removed from tracking. To remove the lead part from Tracking we use an FFU unstruciton and copy from the FIFO to N17:10 our storage location for unloading. We add 1 to N17:10 and get N17:11 and then add 2 to N17:10 and put it in N17:12. Now we move N7:[N17:10] into the register for printing or displaying length. Next we move N7:[N17:11] into the register for printing or displaying Width and finally we move N7:[N17:12] into the register for printing or displaying grade. Just don't forget that if you get 250, 251 or 252 during housekeeping additions to use 0,1, & 2. Hope this is clear. If not let us know what Platform SLC, PLC CLGX and I can mock it up. Edited by BobLfoot

Share this post


Link to post
Share on other sites
So here is the program I described in SLC 5/05 format. datman_0.RSS

Share this post


Link to post
Share on other sites
excellent, thanks very much!!! I was having trouble working it out until you posted that sample code. All clear now, much appreciated!!!

Share this post


Link to post
Share on other sites
The way you do it is good enough if you fit the file length limitation and do not care about execution time of such copying.

Share this post


Link to post
Share on other sites
Yes what he was doing initially was good enough but what is wrong with Bobs method?

Share this post


Link to post
Share on other sites
The advantage of my method is more evident when used on the CLGX platform and the SoftLogix Platforms where larger arrays of data can be created. If you want to edit a piece of data as the data is shifting it gets real hairy if it is all shifting. The "static" table approach with a single shifting pointer is most efficient for scan time. Once a Machine Code programmer always an MC Programmer.

Share this post


Link to post
Share on other sites
It is maybe ten times longer code which is also ten times less obvious for one reading it for first time. I did not say it's wrong or useless but it is overkill for the application. Edited by Sergei Troizky

Share this post


Link to post
Share on other sites
Very good point, that's why your the (Math) Wizard

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
Sign in to follow this  
Followers 0