Storing and Acessing Data in N7 Files


Thread Starter

Dan McReynolds

I am trying to write logic to store a tool name and an encoder value in corresponding integer files. Later, I need to search the tool name integer file and extract the corresponding integer and load it into the encoder presets. I also want to allow the operator to delete the tool name and corresponding value from the files. I am trying to use SQL and SQC instructions to step through the file and load the tool name and corresponding encoder count. I am having trouble getting the SQL and SQC to step through the file. When I enter successive integers, it will only put the integer into the first word of the specified N7 file. Is this the correct functions to use or is there an alternative to this approach?

Alejandro (Alex) Flores

I want to make sure of one thing. When you say to name are you wanting the N7(Integer) file to display ASCII. Or where you refering to a tool number? Where you desiring to have a PV button that increments thru the tool list? A PV button to clear the current displayed tool if desired?



Rather than using sequencer functions, look at the FFL and FFU functions. I would also recommend using 2 different integer files. ie:

N20 - Tool Number
N21 - Encoder value

Questions / caveats:

Do you need to delete from the middle of the 'stack'? Or are you just interested in removing the first or last item. Check the LFL/LFU functions as well.

If you do need to manipulate the data in the middle of the stack, you will need a way to close the gap afterward. This can be done with a carefully constructed COP command. Something like:

COP #N20:10 #N20:9 20

Will shift 20 words up by one, deleting the data in N20:9. It will leave "garbage" at the end of the file tho, so you may need to add a MOV 0
N20:30. In the example above, you would do this to N20 and N21 at the same time.

Post a bit more info about what your requirements are, and I can try to write up a short snippet of logic and post it at the plc archive(

--Joe Jansen
I would like the logic to automatically shift through the file and store the integer as the operator enters enters consecutive tool numbers from the Microview.
To add more detail, what I am trying to do is initially move from 1 to 20 4 digit integers representing a tool number into a file. The only purpose for the tool number is to give a common name for the operators to type in to reference the corresponding encoder position that the machine will advance to. I want to make the system universal, regardless of tool number or positions. It all has to be set by the operator.
At initial installation, the operator will manually advance the tooling head to home position and zero the encoder. They will then manually move the tooling head to the tool installation position. They will then install the tool. Then they will go to the Microview and go to the tool set-up menu. They will then enter the tool number on the microview. Press enter to send, and the PLC will search N20:0-20 for a value of zero. The first zero value that is found will be the selected position that that tool number will be stored in. Now the tool name is stored. The operator will bring up the Record Tool Position menu and enter the tool name. The PLC will then prompt the operator for OK to save the position. The operator will press a button to store the encoder position. The PLC will then search N20:0-20 for the tool name name that was entered, and capture the encoder position and move it to the corresponding word in the N7:21 file. Later, when that tool is to be run again, the operator will go to Auto Advance menu, type in the tool number and press go. The PLC will search N20:0-20 for the tool name and load the corresponding encoder position value from N21 into the encoder HSC presets. The machine will then automatically send the tooling head to the desired position for that tool. I also want the operator to be able to delete a tool number and position if desired. The operator would go to the Delete Tool menu, enter the tool number acknowledge deletion. The PLC will then search then search the N20 file for the tool number and move a 0 to that word and also to the corresponding N21 word to overwrite the encoder value, leaving zeros in both positions. I have tried to use SQC instruction in a loop to step through the N20 file to find either a zero or a tool number. I tried to use a SQL instruction in a loop to load the tool names into the first word with a 0 in the N20 file. Stepping through, searching and loading in the integer files is the key to this project. This is the first program I have not been able to find a solution for. I could send you a copy of the program if you would like to look at it. Thanks for your help. Dan Mc
It is late an I haven't completely read or studied the explanation of your exact application but it sounds like you may want to consider using indirect addressing. indirect addresing lets you use an integer value as a pointer to a stack. you can then increment the pointer to search. when what you want is found you can use the pointer number to determine where. For example an address of N7:[N9:0] (entered like that)will refer to N7:1 when N9:0 is 1 and N7:100 when N9:0 is 100. This could be used to step through the files. If the tool number was N9:0 the operator could press a button activating a move when ready of the constant he entered to N7:[tool number N9:0)] Just something to think about.