EasyManua.ls Logo

Mitsubishi Electric Q12DCCPU-V - Sending Side Program for CPU No.1; Receiving Side Program for CPU No.2 (C Controller Module); Interlock Program Example

Mitsubishi Electric Q12DCCPU-V
618 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...
13 - 22
13.3 Data Communications Using CPU Shared Memory
13.3.2 Data communications using auto refresh
13
COMMUNICATIONS BETWEEN CPU MODULES
Sending side program for CPU No.1
(programmable controller CPU)
Receiving side program for CPU No.2 (C Controller module)
{
:
unsigned short usBuf; /* Data storage destination */
unsigned short pusData[128]; /* Data storage destination */
:
/***********************************************************************/
/* Confirm that 1 is set in the area corresponding to M0 in the CPU No.1 auto refresh area. */
/* (CPU No.1 data set completion bit turns ON.) */
/***********************************************************************/
while(1){
sRet = QBF_FromBuf(lPath, 0x3E0, 0x800, 1, &usBuf, 1);
if( sRet != 0) return(sRet);
if( (usBuf & 0x1) == 0x1 ) break; /* When 1 is set, processing gets out from the loop. */
taskDelay(2);
}
/****************************************************************/
/* Data are read from the area corresponding to D0 to D9 in the CPU No.1 auto refresh area. */
/****************************************************************/
sRet = QBF_FromBuf(lPath, 0x3E0, 0x802, 10, pusData, 128);
if( sRet != 0) return(sRet);
/*****************************************************************/
/* 1 is set in the host CPU's auto refresh area corresponding to M32 of CPU No.1. */
/* (CPU No.2 data processing completion bit turns ON.) */
/*****************************************************************/
usBuf = 1;
sRet = QBF_ToBuf(lPath, 0x3E1, 0x800, 1, &usBuf, 1);
if( sRet != 0) return(sRet);
/***********************************************************************/
/* Confirm that 0 is set in the area corresponding to M0 in the CPU No.1 auto refresh area. */
/* (CPU No.1 data set completion bit turns OFF.) */
/***********************************************************************/
while(1){
sRet = QBF_FromBuf(lPath, 0x3E0, 0x800, 1, &usBuf, 1);
if( sRet != 0) return(sRet);
if( (usBuf & 0x1) == 0x0 ) break; /* When 0 is set, processing gets out from the loop. */
taskDelay(2);
}
/*****************************************************************/
/* 0 is set in the host CPU's auto refresh area corresponding to M32 of CPU No.1. */
/* (CPU No.2 data processing completion bit turns OFF.) */
/*****************************************************************/
usBuf = 0;
sRet = QBF_ToBuf(lPath, 0x3E1, 0x800, 1, &usBuf, 1);
if( sRet != 0) return(sRet);
}
Figure 13.15 Interlock program example
Write
command
M100
1)
Set send data in
D0 to D9.
2)
6)
SET M0
RST M0
RST M100
M3M0
M3M0
3)
4)
5)
7)
8)

Table of Contents

Related product manuals