4 - 33 4 - 33
MELSEC
4 FUNCTIONS
(5) Program example when the standby master function is used
The following shows a program example when the standby master function is
used.
void Change_StanbyMaster()
{
short
Counter;
// General counter
short
StNo;
//
Station
number
unsigned short
DevType;
// Device type
short
DevNo;
// Device number
short
Size;
// Sending data size
short
RecvBuf[10];
// Buffer for receiving
unsigned short
ret;
// Return value
//Turn on SB1 (switching request)
StNo = 0xFF;
//Set the station number
DevType = 5;
//Set the device type (SB: equivalent to special M)
DevNo = 0x1;
//Set the device number
ret = mdDevSet(path,StNo,DevType,DevNo);
if(ret!=0)
{
printf("SBI ON processing failed, error code:%x\n",ret);
printf("Press
any
key\n");
getch();
mdClose(path);
exit(0);
}
for(Counter = 0;Counter < 100;+){
// Confirm completion of switching
//Read SB (equivalent to special SM) 43)
Size = 2;
// Set the size of sending data
StNo = 0xFF;
// Set the station number
DevType = 5;
// Set the device type (SB: equivalent to special M)
DevNo = 0x20;
// Set the device number
ret = mdReceive(path,StNo,DevType,DevNo,&Size,&RecvBuf[0]);
if(ret!=0){
printf("mdReceive[SB43 read] processing failed, error code:%xYn";ret);
printf("Press
any
key\n");
getch();
mdClose(path);
exit(0);
}
if((RecvBuf[0] & 0x0800)!=0)
// Exit from the loop if SB43 is on
break;
Sleep(100);
// Wait for 100ms
}
// Confirm the time-out
if(Counter>=100){
printf("[SB43]ON conformation timed out \n");
Summary of Contents for Q80BD-J61BT11N
Page 2: ......
Page 34: ...1 10 1 10 MELSEC 1 OVERVIEW MEMO ...
Page 54: ...3 12 3 12 MELSEC 3 SPECIFICATIONS MEMO ...
Page 124: ...5 16 5 16 MELSEC 5 PROCEDURE BEFORE STARTING THE DATA LINK MEMO ...
Page 160: ...9 2 9 2 MELSEC 9 MELSEC DATA LINK LIBRARY MEMO 9 ...
Page 200: ...12 16 12 16 MELSEC 12 COMMUNICATION BETWEEN THE MASTER STATION AND LOCAL STATIONS MEMO ...
Page 355: ...App 93 App 93 MELSEC APPENDIX MEMO ...
Page 361: ......