YASKAWA MP920 User Manual page 288

Machine controller
Table of Contents

Advertisement

//Sets the serial number.
sbuf[1] = rbuf[1];
// Sets the destination channel number.
sbuf[2] = rbuf[3];
// Sets the source channel number.
sbuf[3] = 0x00;
sbuf[4] = 0x00;
sbuf[5] = 0x00;
// Sets all the number of data items (from the start of 218 header to the end of MEMOBUS data).
sbuf[6] = (char)((12 + 2 + memex_len) & 0x00FF);
//L (218 header (12 bytes) + MEMOBUS header length (2 bytes) + Extended MEMOBUS length
//(memex_len bytes)
sbuf[7] = (char)(((12 + 2 + memex_len) >> 8) & 0x00FF); // H
sbuf[8] = 0x00;
sbuf[9] = 0x00;
sbuf[10] = 0x00;// Reserved
sbuf[11] = 0x00;// Reserved
// Sets the send data length (218 header + Extended MEMOBUS data).
*slen = (int)(memex_len + 12 + 2);
}
/*****************************************************/
/* Extended MEMOBUS Command Check
/* Checks the header of the received data.
/*****************************************************/
int chk_cmd_data( int rlen )
{
int rc;
unsigned shortdata_len, memex_len;
rc = 0;
// Total data length
data_len = (unsigned short)((unsigned char)rbuf[7]) << 8;
data_len += (unsigned short)((unsigned char)rbuf[6]);
// Checks the total data length.
if ( rlen != (int)data_len )
{
rc = -1;
return( rc );
}
// Checks the packet type.
if ( rbuf[0] != 0x11 )// Commands other than MEMOBUS commands are not accepted.
{
rc = -2;
return( rc );
}
// Send a received data.
// Sets the PLC source channel number.
// Fixed to 0 since a personal computer has no channel number.
// Reserved
// Reserved
// Reserved
// Reserved
*/
*/
C-13
C.2 Sample Programs for Slave Station
C

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents