Delta Tau GEO BRICK LV User Manual

Page of 440
 
Turbo PMAC User Manual 
420 
Writing a Host Communications Program 
     mask = ~mask; 
memcpy(EthCmd.bData,&mask,len); 
// Send command request 
send(sock,(char *)&EthCmd,ETHERNETCMDSIZE+len,0); 
recv(sock,(char *)&errcode,1,0); 
VR_PMAC_SETBITS 
This packet causes the Ethernet connection to perform a write to DPRAM shared between the Turbo 
PMAC CPU and the Ethernet microcontroller that sets bits in a 32-bit word to a new value. The wValue 
field contains the byte offset to retrieve the data from.  The bData field of the Ethernet command packet 
must be stuffed with a mask indicating which bits to set in four bytes followed by four bytes that indicate 
the bits to clear in a 32-bit word. After sending the packet the programmer must wait to receive 1 byte via 
the recv function before continuing. The data received is irrelevant; its purpose is to insure the sender’s 
command was received. 
Example 
EthCmd.RequestType = VR_UPLOAD; 
EthCmd.Request     = VR_PMAC_SETBITS; 
EthCmd.wValue      = htons((WORD)offset); 
EthCmd.wIndex      = 0; 
EthCmd.wLength     = htons(2*sizeof(DWORD)); 
temp = 0xFF03FFFF ; 
memcpy(EthCmd.bData,&temp,sizeof(DWORD)); 
temp = 0x00030000 ; 
memcpy(EthCmd.bData + 4,&temp,sizeof(DWORD)); 
// Send command request 
send(sock,(char *)&EthCmd,ETHERNETCMDSIZE + 2*sizeof(DWORD),0); 
recv(sock,(char *)&errcode,1,0); 
Data Gathering 
Turbo PMAC has a general-purpose data gathering function for repetitive on-the-fly storage of real-time 
data.  In this function, Turbo PMAC can store the contents of up to 48 memory locations at specified 
intervals up to the servo interrupt frequency.  This data is stored in a buffer in open Turbo PMAC 
memory for later transmission to the host.  This feature is useful for filter tuning and motion problem 
solving.   
Executive Program Data Gathering 
Most users will utilize this feature in conjunction with the PMAC Executive Program on the PC, which 
handles its details automatically.  Refer to the manual of the Executive Program for details.  It is possible 
(although not trivial) to write a custom host program to utilize this feature. 
Gathering I-Variables 
Variable I5000 controls the location and mode of the data-gathering buffer.  Bit 1 of I5000 controls 
whether the gathered data is stored in Turbo PMAC’s main memory (bit 1 = 0), or whether it is stored in 
optional dual-ported RAM (bit 1 = 1).  The PMAC Executive program supports only the use of data 
gathered to Turbo PMAC’s main memory. 
Bit 0 of I5000 controls whether gathering will stop when the end of the buffer is reached, or whether it 
will wrap around and continue gathering at the beginning of the buffer, overwriting previously gathered 
data.  Setting bit 0 to 0 causes gathering to stop at the end.  This is the most common mode, used for 
gathering during a known sequence of operation.