Peter Nachtwey
Member
Designing a COPY or COP command should be easy, but there are so many things to consider. We have decided to add a COPY command even though it is not part of the IEC specification. This should make it easier and faster to copy data around within the controller. The IEC specification doesn't have a COPY or similar command by another name. The IECE specifications requires using a FOR or WHILE loop which isn't very efficient and by now you should know we count time in nanoseconds.
We have the internal part of the COPY command done and it works but now we need to decide how it looks to the user.
We have decided the format will look something like this
COPY(src,dst,count); // duh
Examples:
1. COPY(src,dst,count); // src and dst may or may not be an array
2. COPY(src,dst,count); // dst is an array and i can be index to copy the next block
3. COPY(src,dst,count); // src is an array and i can be index to copy the next block
4. COPY(src,dst,count); // both src and dst are arrays.
We think the first 3 options will be used most to copy data from Ethernet/IP I/O or Profibus DP I/O to other locations.
The most common will be the example 1 where Profibus or Ethernet I/O has just updated a command in the first register of the I/O block. Based on a command a program will be started and that program will copy the data to some variables where they will be used.
The second most common version will be example 2. In this case the cam table will be downloaded over multiple transfers. A new command will indicate that data is ready in the other 31 data registers to be copied. ( Profibus DP can only have consistent data transfers of 32 32 bit value ). The Profibus DP and Ethernet/IP IO locations are fixed and is just a small window through which all the data must be passed. There needs to be a away to transfer cam tables of any size through the small Profibus DP window.
The third most common version will be shifting the data like example 4 but the source and the destination are the same array:
COPY(array[0],array[1],count);
The problem is how does one specify the source is an address and not a value? If we document that the source and destination are address and not values this is inconsistent with the normal way of expressing values. Should we use
COPY(#array[0],#array[1],count); or
COPY(@array[0],@array[1],count);
Is it important to indicate that the src and dst parameters of the COPY command are address and not values.
If so would you use a symbol @,#, & or a function such as ADDR(src) and ADDR(dst) to indicate the parameter are addresses?
COPY(ADDR(array[0]),ADDR(array[1]),count); // too much typing but the intentions are clear.
What if the source and destination are variables and not arrays? Should we allow the user to index off the variable and treat it like and array? If so should we allow COPY(src,dst,count) even though src and dst are just simple 1 register variables. If you think we should allow indexing of a single variable is using the array format misleading or should there be a separate function that makes it clear that the variable is being indexed like an array. For instance COPY(ADDR(src,i),ADDR(dst,i),count) where i can be any expression that evaluates to a DINT and is added to the address of src or dst.
What about the count? Should that be in terms of data type or just total number of registers. I don't like the way Rockwell implemented their COP where it depends of the destination type.
I prefer using number of registers regardless if the UDT or data type is many registers. One can always make count equal to the number of elements time the element size. This is very flexible.
BTW, our COPY command will copy over lapping data up or down. I think the way Rockwell blew it. I have read too many threads about how to shift data up one location. This should be easy an natural.
COPY(#array[0],#array[1],count);
Will shift data up not not fill. We can make a FILL command for that if we need to.
One thing we want to do is to avoid pointer or address arithmetic as much as possible. The IEC specification avoids the use of pointers for good reason and we want to also.
Opinions wanted.
We have the internal part of the COPY command done and it works but now we need to decide how it looks to the user.
We have decided the format will look something like this
COPY(src,dst,count); // duh
Examples:
1. COPY(src,dst,count); // src and dst may or may not be an array
2. COPY(src,dst,count); // dst is an array and i can be index to copy the next block
3. COPY(src,dst,count); // src is an array and i can be index to copy the next block
4. COPY(src,dst,count); // both src and dst are arrays.
We think the first 3 options will be used most to copy data from Ethernet/IP I/O or Profibus DP I/O to other locations.
The most common will be the example 1 where Profibus or Ethernet I/O has just updated a command in the first register of the I/O block. Based on a command a program will be started and that program will copy the data to some variables where they will be used.
The second most common version will be example 2. In this case the cam table will be downloaded over multiple transfers. A new command will indicate that data is ready in the other 31 data registers to be copied. ( Profibus DP can only have consistent data transfers of 32 32 bit value ). The Profibus DP and Ethernet/IP IO locations are fixed and is just a small window through which all the data must be passed. There needs to be a away to transfer cam tables of any size through the small Profibus DP window.
The third most common version will be shifting the data like example 4 but the source and the destination are the same array:
COPY(array[0],array[1],count);
The problem is how does one specify the source is an address and not a value? If we document that the source and destination are address and not values this is inconsistent with the normal way of expressing values. Should we use
COPY(#array[0],#array[1],count); or
COPY(@array[0],@array[1],count);
Is it important to indicate that the src and dst parameters of the COPY command are address and not values.
If so would you use a symbol @,#, & or a function such as ADDR(src) and ADDR(dst) to indicate the parameter are addresses?
COPY(ADDR(array[0]),ADDR(array[1]),count); // too much typing but the intentions are clear.
What if the source and destination are variables and not arrays? Should we allow the user to index off the variable and treat it like and array? If so should we allow COPY(src,dst,count) even though src and dst are just simple 1 register variables. If you think we should allow indexing of a single variable is using the array format misleading or should there be a separate function that makes it clear that the variable is being indexed like an array. For instance COPY(ADDR(src,i),ADDR(dst,i),count) where i can be any expression that evaluates to a DINT and is added to the address of src or dst.
What about the count? Should that be in terms of data type or just total number of registers. I don't like the way Rockwell implemented their COP where it depends of the destination type.
I prefer using number of registers regardless if the UDT or data type is many registers. One can always make count equal to the number of elements time the element size. This is very flexible.
BTW, our COPY command will copy over lapping data up or down. I think the way Rockwell blew it. I have read too many threads about how to shift data up one location. This should be easy an natural.
COPY(#array[0],#array[1],count);
Will shift data up not not fill. We can make a FILL command for that if we need to.
One thing we want to do is to avoid pointer or address arithmetic as much as possible. The IEC specification avoids the use of pointers for good reason and we want to also.
Opinions wanted.