6.11 Assign G37 and G31 Sensor Input


G37 and G31 input signals were plc.vto0.bit.orobe and plc.vto2.bit.skp31, and these physical inputs were defined by PLC. Two new NC commands (NC_COMMAND_SET_G37_PROBE_PORT, NC_COMMAND_SET_G31_SKIP_PORT) can speed up respond time.


The plc.ncCommand.data.x was to assign input port, the data of plc.ncCommand.data.x must larg than 0 and less than 256.


For example: plc.ncCommand.data.x = 21, and that was to assign plc.gdi[1].bit.bit04 as input port.


If the data of plc.ncCommand.data.x not in reasonable range, for example was –1, the system would detecting plc.vto0.bit.probe and plc.vto2.bit.skp31.


At boot time, the original plc.vto0.bit.probe and plc.vto2.bit.skp31 are used as the detection input points of the G37 and G31.


The following is the program fragment of PLC. The detection input point of G37 is specified by M66,Hxx:

void plcRun(Status &sts, PlcBlock &plc)


{


....


if( plc.mCode.flag ) {

 switch( plc.mCode.data ) {

  case 66: // to set G37 probe port

   if( plc.ncCommand.flag == NC_COMMAND_SET_G37_PROBE_PORT &&

  plc.ncCommand.finish ) {

   plc.ncCommand.flag = 0;

   plc.mCode.finish = 1;

  } else if( plc.ncCommand.flag == 0 && plc.mhAttr&PLC_MH_ATTR_0 ) {

   plc.ncCommand.flag = NC_COMMAND_SET_G37_PROBE_PORT;

   plc.ncCommand.data.x = plc.mhCode0;

  } else

   plc.mCode.finish = 1;

  break;


 }

}


....


}