ScottB Posted September 22, 2015 Share Posted September 22, 2015 I am trying to set up and use a rotary buffer for a motion program and I'm having trouble determining when the buffer is empty. The "ROTFREE" command in the SRM says that it will "Report number of unexecuted lines in rotary buffer". If I type: define rotary 10000 rotfree I get 9988, so I guess this is really returning the number of bytes free, not the number of lines remaining as the manual states. Now if I type the following: open rotary N100 x10y10f100 N110 x20y20f100 n120 x30y30f200 Close rotfree I get 9877, which makes sense, the amount of free memory decreased. The problem is that if I issue the Run command so the program starts, the rotfree command always returns 9877, it doesn't increase as the lines are executed. If I do a "list rotary" command, the lines are gone, but the rotfree command doesn't reflect this. The only way I've found to get Rotfree to increase again is to delete the rotary buffer and define a new one (not very useful). If the ROTFREE command doesn't work, how can you determine when the rotary buffer is getting empty? I noticed through Intellisense that there are Coord [].RotLine, RotFill, RotEnd status variables but these aren't mentioned in the manual at all. Is there any documentation for these? Link to comment Share on other sites More sharing options...
steve.milici Posted September 23, 2015 Share Posted September 23, 2015 A better method than the usage of the “rotfree” command would be to use the “N” synchronous program line labels (without the colon) in the rotary programs and monitor Coord[x].Ncalc and/or Coord[x].Nsync to decide when more program lines need to be downloaded. Using your program: open rotary N100 x10y10f100 N110 x20y20f100 N120 x30y30f200 N130 x40y40f200 Close Coord[x].Nsync contains the value of the line label most closely preceding the presently executing or most recently executed move. A value of 110 would indicate two lines or less are left in the buffer to execute. Link to comment Share on other sites More sharing options...
ScottB Posted September 24, 2015 Author Share Posted September 24, 2015 A better method than the usage of the “rotfree” command would be to use the “N” synchronous program line labels (without the colon) in the rotary programs and monitor Coord[x].Ncalc and/or Coord[x].Nsync to decide when more program lines need to be downloaded. Using your program: open rotary N100 x10y10f100 N110 x20y20f100 N120 x30y30f200 N130 x40y40f200 Close Coord[x].Nsync contains the value of the line label most closely preceding the presently executing or most recently executed move. A value of 110 would indicate two lines or less are left in the buffer to execute. Steve, Thanks for responding. I ended up calculating the free memory by using the Coord[].RotStore and Coord[].RotExec values, but I am going to change my logic to use Nsync instead. Scott Link to comment Share on other sites More sharing options...
curtwilson Posted September 28, 2015 Share Posted September 28, 2015 A clarification on the response to the "rotfree" query: Power PMAC responds with the size of the largest continuous block of open memory in the buffer, as there can be a block before the executing point and a block after. The reason that this value is reported is that a single program line cannot wrap around from the end of the buffer to the beginning. So the response to "rotfree" is the size of the longest program line that can be accepted. (If the space at the end of the rotary buffer is less than the length of the program line, the entire program line will be placed at the beginning of the buffer, presuming there is room there.) So in your test, the block of 9977 bytes open toward the end of the buffer is a far larger space than the ~40 bytes per line opened up by the executed program lines. Link to comment Share on other sites More sharing options...
sdefisher Posted September 29, 2015 Share Posted September 29, 2015 Here is how I solved the issue You can check Coord[1].RotStore and Coord[1].RotExec (Coord[1].RotStore - Coord[1].RotExec) will tell you how much information is buffered. Then set a threshold to begin downloading new lines Link to comment Share on other sites More sharing options...
curtwilson Posted September 30, 2015 Share Posted September 30, 2015 That will work until the storage pointer wraps around to the beginning of the rotary buffer. Then your expression will report a negative number. To make it more robust, you could do the following: BufferUsed = (Coord[x].RotStore - Coord[x].RotExec) modulo (Coord[x].RotEnd - Coord[x].RotStart) Using the modulo operation with the size of the buffer would turn a -4000 value into a +6000 value for a 10000-byte buffer. Link to comment Share on other sites More sharing options...
sdefisher Posted September 30, 2015 Share Posted September 30, 2015 That will work until the storage pointer wraps around to the beginning of the rotary buffer. Then your expression will report a negative number. To make it more robust, you could do the following: BufferUsed = (Coord[x].RotStore - Coord[x].RotExec) modulo (Coord[x].RotEnd - Coord[x].RotStart) Using the modulo operation with the size of the buffer would turn a -4000 value into a +6000 value for a 10000-byte buffer. Good catch! Link to comment Share on other sites More sharing options...
Recommended Posts