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");
Содержание Q80BD-J61BT11N
Страница 2: ......
Страница 34: ...1 10 1 10 MELSEC 1 OVERVIEW MEMO ...
Страница 54: ...3 12 3 12 MELSEC 3 SPECIFICATIONS MEMO ...
Страница 124: ...5 16 5 16 MELSEC 5 PROCEDURE BEFORE STARTING THE DATA LINK MEMO ...
Страница 160: ...9 2 9 2 MELSEC 9 MELSEC DATA LINK LIBRARY MEMO 9 ...
Страница 200: ...12 16 12 16 MELSEC 12 COMMUNICATION BETWEEN THE MASTER STATION AND LOCAL STATIONS MEMO ...
Страница 212: ...13 12 13 12 MELSEC 13 COMMUNICATION BETWEEN THE MASTER STATION AND INTELLIGENT DEVICE STATION AJ65BT R2 MEMO ...
Страница 228: ...14 16 14 16 MELSEC 14 COMMUNICATION BETWEEN THE MASTER STATION AND INTELLIGENT DEVICE STATION AJ65BT D75P2 S3 MEMO ...
Страница 354: ...App 92 App 92 MELSEC APPENDIX Appendix 19 2 Q81BD J61BT11 121 141 147 153 19 158 103 5 91 Unit mm ...
Страница 355: ...App 93 App 93 MELSEC APPENDIX MEMO ...
Страница 361: ......