PPMAC - Invalid lookahead definition when switching CS Groups
Description
The redefineLookaheads method currently uses commands that are exclusive to TurboPMAC, making it ineffective for PowerPMAC. This difference can lead to incorrect or non-existent lookahead buffer allocation for coordinate systems, especially when switching between defined CsGroups.
Currently, the method performs the following operations:
strcpy(cmd, "DELETE ALL TEMPS");
This deletes all the temporary buffers: lookahead, gather, rotary and ccbuffer.
sprintf(cmd, "&%dDEFINE LOOKAHEAD 50,10", cs);
This sets:
- A lookahead buffer size of 50
- 10 synchronous assignments
In contrast, PowerPMAC expects:
strcpy(cmd, "delete all lookaheads");
sprintf(cmd, "&%d define lookahead 1024", cs);
Key differences between TurboPMAC and PowerPMAC relevant to this issue include:
- PowerPMAC does not require a specific order to define lookahead buffers for each coordinate system, whereas TurboPMAC requires definitions from high-numbered to low-numbered coordinate systems.
- PowerPMAC enforces a minimum lookahead buffer size of 1024.
- PowerPMAC only accepts the define lookahead command for coordinate systems that have at least one assigned motor. While it is technically possible to set Coord[x].LHSize directly, the Power PMAC Software Reference Manual (May 19, 2023, p.853) states:
“It is not possible to write to it directly in the Script environment.”
As a result, the current implementation is incompatible with PowerPMAC systems and may lead to incorrect or non-existent lookahead buffer allocation, particularly when switching between defined CsGroups or modifying the number of motors in a coordinate system.
Suggested solution
- Abstract the command string in
pmacHardwareInterfacethrough agetfunction. - Define the correct syntax for each hardware in:
-
pmacHardwareTurbo -
pmacHardwarePower.
-
In PB_Startup, PLC3 - Initialise uses the following code to define the lookahead buffers at power-up/restart:
// Delete all lookahead buffers before defining new ones
cmd "delete all lookahead"
// Define lookahead buffers for all coordinate systems which contain motors
local CoordNum = 0
while (CoordNum < Sys.MaxCoords) {
if (Coord[CoordNum].NumMotors > 0) {
cmd "&%f define lookahead 1024", CoordNum
}
CoordNum++
}
Hi @bmkemp910,
That's right. However the pmac driver is failing in following this:
If you wish to redefine the lookahead buffer for a coordinate system, either to change the number of segments it can store, or for a changed number of motors in the coordinate system, you must first eliminate the existing buffer with a delete lookahead or delete all lookahead command.
That fails because it's using the TurboPMAC syntax on both operations: delete and define. If the number of motor changes for a CS, by setting them in the CsGroups, then the buffer will not be redefined to comprehend the added motor.
I'll edit the issue description to include the snippet for deleting the buffers, which should also change.