EasyManua.ls Logo

YASKAWA MP920 - Page 279

YASKAWA MP920
336 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Appendix C C Language Sample Programs
C.1.1 TCP (When Using Extended MEMOBUS Protocol (SFC = 09))
C-4
closesocket(sd);
printf( "Error: Recv !! -> %d\n", rlen );
exit(0);
}
// Checks the response data.
rc = chk_rsp_data( rlen );
if ( rc != 0 )
//Errors in received data
closesocket(sd);
exit(0);
}
sbuf[1] ++;
// Increments the serial number of 218 header.
printf( "Hit Any Key !!\n" );
}
}
// Prepares the extended MEMOBUS protocol command, Read Holding Register Contents (SFC = 09).
void mk_cmd_data(void)
{
// Prepares the 218 header.
// Sets the data type.
sbuf[0] = 0x11;
// Extended MEMOBUS (reference command)
// Sets the serial number (The serial number will be incremented every send data.)
sbuf[1] = 0x00;
// Sets the destination channel number.
sbuf[2] = 0x00;
// The channel number can be fixed to 0 as the channel of PLC is not specified.
// Sets the destination channel number.
sbuf[3] = 0x00;
// Always set to 0 because a personal computer has no channel number.
sbuf[4] = 0x00;
// Reserved
sbuf[5] = 0x00;
// Reserved
// Sets all the number of data items (from the starting of 218 header to the end of MEMOBUS data).
sbuf[6] = 0x16;
// L (22 bytes = 218 header (12 bytes) + MEMOBUS data (10 bytes)
sbuf[7] = 0x00;
// H
sbuf[8] = 0x00;
// Reserved
sbuf[9] = 0x00;
// Reserved
sbuf[10] = 0x00;
// Reserved
sbuf[11] = 0x00;
// Reserved
// Prepares the MEMOBUS data.
// Length: From MFC to the end of data
sbuf[12] = 0x08;
// MEMOBUS data length (L)
sbuf[13] = 0x00;
// MEMOBUS data length (H)
// MFC is fixed to 0
x20
sbuf[14] = 0x20;
// SFC is 0x09 (Read Holding Register Contents (extended))
sbuf[15] = 0x09;
// Sets the CPU number.
sbuf[16] = 0x10;
// Remote CPU No.: CPU1. Multi CPUs: 1 - 4. Local CPU No.: always 0.
sbuf[17] = 0x00;
// Always 0 for Spare.

Table of Contents

Related product manuals