EasyManua.ls Logo

YASKAWA MP920 - Page 280

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...
C.1 Sample Programs for Master Station
C-5
C
// Sets the reference number.
sbuf[18] = 0x00;
// Adr(L) leading address: MW0
sbuf[19] = 0x00;
// Adr(H)
// Sets the number of registers.
sbuf[20] = 0x0A;
// Reads 10 words from the DataNum(L) leading address.
sbuf[21] = 0x00;
// DataNum(H)
}
// Checks the response data.
int chk_rsp_data( int rlen )
{
int rc;
rc = 0;
// Checks the total length of data.
if ( rlen != 40 )
// 40-byte response for 10-word read out
// ((218 header (12 bytes) + MEMOBUS data (28 bytes))
{
rc = -1;
return( rc );
}
// Checks the packet type.
if ( rbuf[0] != 0x19 )
// Not the MEMOBUS response
{
rc = -2;
return( rc );
}
// Checks the serial number.
if ( sbuf[1] != rbuf[1] )
// Does not agree with the command serial number.
{
rc = -3;
return( rc );
}
// Checks the length of the total data in the message.
if (( rbuf[6] != 0x28 ) && (rbuf[7] !=0x00))
// 40 bytes = 218 header (12 bytes) + MEMOBUS data (28 bytes)
{
rc = -4;
return( rc );
}
// Checks the MEMOBUS data length.
if (( rbuf[12] != 0x1A ) || (rbuf[13] != 0x00))
// 26 bytes
{
rc = -5;
return( rc );
}
// Checks the MFC.
if ( rbuf[14] != 0x20 )
// MFC is fixed to 0x20.
{
rc = -6;
return( rc );
}
// Checks the SFC.
if ( rbuf[15] != 0x09 )
// SFC is 0x09 (Read Holding Register Contents).
{
rc = -7;
return( rc );
}

Table of Contents

Related product manuals