gshort Posted May 9, 2011 Share Posted May 9, 2011 I am attempting to use buffer lookahead but need to change the CS to add or remove motors from it. I am following the example in the "Power PMAC Move Mode Trajectories 2011-01.pdf" manual on Page 65 which shows the following: dwell 10 // Stop lookahead execution cmd "&1 delete lookahead" // Delete buffer cmd "&1 #4->100C" // Assign new motor to C. S. 1 cmd "&1 define lookahead 10000" // Redefine buffer dwell 10 I've enhanced this to wait for the command to complete and check the return status: open subprog disableLookahead if (LOOKAHEAD_BUFFERSIZE != 0) { Coord[PARTPROG_CS].LHDistance = 0; dwell 10; Ldata.CmdStatus=1; cmd "&%d delete lookahead", PARTPROG_CS; sendallcmds; while (Ldata.CmdStatus > 0) {dwell 0;} if (Ldata.CmdStatus != 0) { send 2 "disableLookahead: delete lookahead failed, Ldata.CmdStatus=%d\n", Ldata.CmdStatus; } dwell 10; } close What I've found that this will from time-to-time fail with error 33 (buffer in use). When the failure occurs there has been a move before it but there has since been a dwell so I would have thought that the buffer was no longer in use. When the failure occurred I tried "holding" the motion script with a while loop on a P variable. I then tried manually deleting the lookahead buffer from a terminal window and I continued to get the buffer-in-use error: &1 delete lookahead; stdin:4:17: error #33: BUFFER IN USE: delete lookahead; delete lookahead; stdin:5:17: error #33: BUFFER IN USE: delete lookahead; delete lookahead; stdin:6:17: error #33: BUFFER IN USE: delete lookahead; delete lookahead; stdin:7:17: error #33: BUFFER IN USE: delete lookahead; delete lookahead; stdin:8:17: error #33: BUFFER IN USE: delete lookahead; Can you give me some ideas as to how to proceed with this ? Link to comment Share on other sites More sharing options...
bradp Posted May 9, 2011 Share Posted May 9, 2011 I am not in a place to test this but an idea is that perhaps the line Coord[PARTPROG_CS].LHDistance = 0 is causing the problem. Since it is getting set at calculation time you might need a dwell before this line so I would try this and see if it helps. open subprog disableLookahead if (LOOKAHEAD_BUFFERSIZE != 0) { dwell10 Coord[PARTPROG_CS].LHDistance = 0; dwell 10; Ldata.CmdStatus=1; cmd "&%d delete lookahead", PARTPROG_CS; sendallcmds; while (Ldata.CmdStatus > 0) {dwell 0;} if (Ldata.CmdStatus != 0) { send 2 "disableLookahead: delete lookahead failed, Ldata.CmdStatus=%d\n", Ldata.CmdStatus; } dwell 10; } close Link to comment Share on other sites More sharing options...
gshort Posted May 9, 2011 Author Share Posted May 9, 2011 I just tried adding the extra dwell, but I'm afraid it didn't make any difference. Link to comment Share on other sites More sharing options...
bradp Posted June 10, 2011 Share Posted June 10, 2011 We have implemented a new feature to make changing from an axis to a spindle work without having to manipulate the lookahead buffer. In general it is not a good idea to manipulate the lookahead buffer while a program is executing because there are several potential pitfalls with timing that make it hard to handle correctly. Here is how it works. We have made three new axis definitions &m#n->s motor is a spindle in CS m and uses the CS m feedpot &m#n->s0 motor is a spindle in CS m and uses the CS 0 feedpot &m#n->s1 motor is a spindle in CS m and always uses 100% feedpot When the motor is defined as s it will respond to jog commands even though a program in that CS is executing. It will not respond to axis commands. Changing from axis mode to spindle mode is as follows dwell0 // must have something that stops LH buffer Ldata.CmdStatus=1 // so know when cmd is executed cmd"&1#2->s1" // change axis to spindel with fixed 100% feedpot SendAllCmds // purge buffer do { dwell0 // never have empty while() loop and want dwell0 executed at least once } while(Ldata.CmdStatus = 1) // could also check for an error Changing from spindle mode to axis mode is as follows dwell0 // must have something that stops LH buffer Ldata.CmdStatus=1 // so know when cmd is executed cmd"&1#2->y" // change axis to spindel SendAllCmds // purge buffer do { dwell0 // never have empty while() loop and want dwell0 executed at least once } while(Ldata.CmdStatus = 1) // could also check for an error firmware dated June 9th 2011 or newer has this feature. Link to comment Share on other sites More sharing options...
Recommended Posts